diff --git a/pyste/src/ClassExporter.py b/pyste/src/ClassExporter.py index 275b5cbd..c5536f6a 100644 --- a/pyste/src/ClassExporter.py +++ b/pyste/src/ClassExporter.py @@ -747,13 +747,14 @@ class _VirtualWrapperGenerator(object): This method creates the instance variable self.virtual_methods. ''' def IsVirtual(m): - return m.virtual and m.visibility != Scope.private + return isinstance(m, Method) and m.virtual and m.visibility != Scope.private - all_members = self.class_.members[:] + all_methods = [x for x in self.class_.members if IsVirtual(x)] for base in self.bases: - for base_member in base.members: - base_member.class_ = self.class_.FullName() - all_members.append(base_member) + base_methods = [x.Copy() for x in self.bases.members if IsVirtual(x)] + for base_method in base_methods: + base_method.class_ = self.class_.FullName() + all_methods.append(base_method) # extract the virtual methods, avoiding duplications. The duplication # must take in account the full signature without the class name, so @@ -771,10 +772,9 @@ class _VirtualWrapperGenerator(object): params = ', '.join([x.FullName() for x in method.parameters]) return '%s %s(%s) %s' % (result, method.name, params, const) - all_members = [x for x in all_members if type(x) == Method] self.virtual_methods = [] already_added = {} - for member in all_members: + for member in all_methods: sig = MethodSig(member) if IsVirtual(member) and not sig in already_added: self.virtual_methods.append(member) diff --git a/pyste/src/HeaderExporter.py b/pyste/src/HeaderExporter.py index 40d184e8..1d5fda1b 100644 --- a/pyste/src/HeaderExporter.py +++ b/pyste/src/HeaderExporter.py @@ -25,7 +25,7 @@ class HeaderExporter(Exporter): def IsInternalName(name): '''Returns true if the given name looks like a internal compiler structure''' - return name.startswith('__') + return name.startswith('_') Exporter.SetDeclarations(self, declarations) header = os.path.normpath(self.parser_header) diff --git a/pyste/src/declarations.py b/pyste/src/declarations.py index d32b376a..a037c04d 100644 --- a/pyste/src/declarations.py +++ b/pyste/src/declarations.py @@ -186,7 +186,11 @@ class Function(Declaration): return len(self.parameters) maxArgs = property(_MaxArgs) + + def Copy(self): + return self.__class__( + self.name, self.namespace, self.result, self.params[:]) class Operator(Function): @@ -199,7 +203,6 @@ class Operator(Function): return namespace + 'operator' + self.name - class Method(Function): 'The declaration of a method.' @@ -234,6 +237,19 @@ class Method(Function): return '(%s (%s::*)(%s) %s)&%s' %\ (result, self.class_, params, const, self.FullName()) + + def Copy(self): + return self.__class__( + self.name, + self.class_, + self.result, + self.params[:], + self.visib, + self.virtual, + self.abstract, + self.static, + self.const) + class Constructor(Method): 'A constructor of a class.' diff --git a/pyste/src/pyste.py b/pyste/src/pyste.py index f083601f..62cf3439 100644 --- a/pyste/src/pyste.py +++ b/pyste/src/pyste.py @@ -34,7 +34,7 @@ from policies import * from CppParser import CppParser, CppParserError import time -__VERSION__ = '0.7.7' +__VERSION__ = '0.7.9' def RecursiveIncludes(include): 'Return a list containg the include dir and all its subdirectories'