diff --git a/pyste/src/Pyste/ClassExporter.py b/pyste/src/Pyste/ClassExporter.py index 79445d69..34b55805 100644 --- a/pyste/src/Pyste/ClassExporter.py +++ b/pyste/src/Pyste/ClassExporter.py @@ -39,7 +39,6 @@ class ClassExporter(Exporter): self.sections['include'] = [] # a list of Constructor instances self.constructors = [] - self.wrapper_generator = None # a list of code units, generated by nested declarations self.nested_codeunits = [] @@ -92,7 +91,7 @@ class ClassExporter(Exporter): self.ExportBases(exported_names) self.ExportConstructors() self.ExportVariables() - self.ExportVirtualMethods() + self.ExportVirtualMethods(codeunit) self.ExportMethods() self.ExportOperators() self.ExportNestedClasses(exported_names) @@ -111,7 +110,6 @@ class ClassExporter(Exporter): base classes. ''' valid_members = (Method, ClassVariable, NestedClass, ClassEnumeration) - # these don't work INVESTIGATE!: (ClassOperator, ConverterOperator) fullnames = [x.FullName() for x in self.class_] pointers = [x.PointerDeclaration(True) for x in self.class_ if isinstance(x, Method)] fullnames = dict([(x, None) for x in fullnames]) @@ -387,7 +385,7 @@ class ClassExporter(Exporter): # add wrapper code if this method has one wrapper = method_info.wrapper if wrapper and wrapper.code: - self.Add('declaration', wrapper.code) + self.Add('declaration-outside', wrapper.code) # export staticmethod statements for name in staticmethods: @@ -404,7 +402,7 @@ class ClassExporter(Exporter): member.virtual = not self.info[member.name].no_override - def ExportVirtualMethods(self): + def ExportVirtualMethods(self, codeunit): # check if this class has any virtual methods has_virtual_methods = False for member in self.class_: @@ -414,7 +412,7 @@ class ClassExporter(Exporter): holder = self.info.holder if has_virtual_methods: - generator = _VirtualWrapperGenerator(self.class_, self.ClassBases(), self.info) + generator = _VirtualWrapperGenerator(self.class_, self.ClassBases(), self.info, codeunit) if holder: self.Add('template', holder(generator.FullName())) else: @@ -505,7 +503,7 @@ class ClassExporter(Exporter): if wrapper: pointer = '&' + wrapper.FullName() if wrapper.code: - self.Add('declaration', wrapper.code) + self.Add('declaration-outside', wrapper.code) else: pointer = operator.PointerDeclaration() rename = self.info['operator'][operator.name].rename @@ -655,13 +653,14 @@ def _ParamsInfo(m, count=None): class _VirtualWrapperGenerator(object): 'Generates code to export the virtual methods of the given class' - def __init__(self, class_, bases, info): + def __init__(self, class_, bases, info, codeunit): self.class_ = copy.deepcopy(class_) self.bases = bases[:] self.info = info self.wrapper_name = makeid(class_.FullName()) + '_Wrapper' self.virtual_methods = None self._method_count = {} + self.codeunit = codeunit self.GenerateVirtualMethods() @@ -723,6 +722,8 @@ class _VirtualWrapperGenerator(object): return indent2 + '%s%s(%s);\n' % \ (return_str, method.FullName(), ', '.join(param_names)) else: + if wrapper.code: + self.codeunit.Write('declaration-outside', wrapper.code) # return a call for the wrapper params = ', '.join(['this'] + param_names) return indent2 + '%s%s(%s);\n' % (return_str, wrapper.FullName(), params) diff --git a/pyste/src/Pyste/pyste.py b/pyste/src/Pyste/pyste.py index 9d3fce79..cf1e5222 100644 --- a/pyste/src/Pyste/pyste.py +++ b/pyste/src/Pyste/pyste.py @@ -43,7 +43,7 @@ from CppParser import CppParser, CppParserError import time import declarations -__version__ = '0.9.20' +__version__ = '0.9.21' def RecursiveIncludes(include): 'Return a list containg the include dir and all its subdirectories'