* Use all_raise_py_exception=True in the %Module directive.

* remove pyRaisesException (May want to add it back later with different meaning...)
* Fix use of const for CppMethods
* Make flattenNode optionally not rstrip the string segments

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69906 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-12-02 01:10:49 +00:00
parent 5d9f463534
commit a236ea1867
2 changed files with 15 additions and 15 deletions

View File

@@ -231,7 +231,6 @@ class FunctionDef(BaseDef):
self.deprecated = False # is the function deprecated
self.factory = False # a factory function that creates a new instance of the return value
self.pyReleaseGIL = False # release the Python GIL for this function call
self.pyRaisesException = True # function may raise a Python exception
self.noCopy = False # don't make a copy of the return value, just wrap the original
self.pyInt = False # treat char types as integers
self.transfer = False # transfer ownership of return value to C++?
@@ -536,7 +535,9 @@ class ClassDef(BaseDef):
for node in element.findall('includes'):
self.includes.append(node.text)
for node in element.findall('templateparamlist/param'):
self.templateParams.append(node.find('type').text)
txt = node.find('type').text
txt = txt.replace('class ', '')
self.templateParams.append(txt)
for node in element.findall('innerclass'):
if node.get('prot') == 'private':
@@ -1217,7 +1218,7 @@ class ModuleDef(BaseDef):
# Some helper functions and such
#---------------------------------------------------------------------------
def flattenNode(node):
def flattenNode(node, rstrip=True):
"""
Extract just the text from a node and its children, tossing out any child
node tags and attributes.
@@ -1230,8 +1231,12 @@ def flattenNode(node):
for n in node:
text += flattenNode(n)
if node.tail:
text += node.tail.rstrip()
return text.rstrip()
text += node.tail
if rstrip:
text = text.rstrip()
if rstrip:
text = text.rstrip()
return text
class ExtractorError(RuntimeError):

View File

@@ -65,6 +65,7 @@ class SipWrapperGenerator(generators.WrapperGeneratorBase):
%%Module( name=%s.%s,
keyword_arguments="All",
use_argument_names=True,
all_raise_py_exception=True,
language="C++")
{
%%AutoPyName(remove_leading="wx")
@@ -598,7 +599,10 @@ from %s import *
else:
if fargs:
fargs = ', ' + fargs
fargs = '(%s* self%s)' % (klass.name, fargs)
selfConst = ''
if method.isConst:
selfConst = 'const '
fargs = '(%s%s* self%s)' % (selfConst, klass.name, fargs)
fstream.write('%s%%TypeCode\n' % indent)
else:
fname = '_%s_function' % method.name
@@ -767,15 +771,6 @@ from %s import *
annotations.append('ReleaseGIL')
if item.noCopy:
annotations.append('NoCopy')
if item.pyRaisesException:
# is it a class method?
if isinstance(item, extractors.MethodDef):
if not item.isCtor and not item.isDtor:
annotations.append('RaisesPyException')
# otherwise it's a plain function so no additional conditions
# need to be checked
else:
annotations.append('RaisesPyException')
if isinstance(item, extractors.MethodDef):
if item.defaultCtor: