@@ -113,6 +113,9 @@ def InheritMethods(self, exported_names):
113113 valid_members = (Method , ClassVariable , NestedClass , ClassEnumeration )
114114 # these don't work INVESTIGATE!: (ClassOperator, ConverterOperator)
115115 fullnames = [x .FullName () for x in self .class_ ]
116+ pointers = [x .PointerDeclaration (True ) for x in self .class_ if isinstance (x , Method )]
117+ fullnames = dict ([(x , None ) for x in fullnames ])
118+ pointers = dict ([(x , None ) for x in pointers ])
116119 for level in self .class_ .hierarchy :
117120 level_exported = False
118121 for base in level :
@@ -122,7 +125,12 @@ def InheritMethods(self, exported_names):
122125 if type (member ) in valid_members :
123126 member_copy = copy .deepcopy (member )
124127 member_copy .class_ = self .class_ .FullName ()
125- if member_copy .FullName () not in fullnames :
128+ if isinstance (member_copy , Method ):
129+ pointer = member_copy .PointerDeclaration (True )
130+ if pointer not in pointers :
131+ self .class_ .AddMember (member )
132+ pointers [pointer ] = None
133+ elif member_copy .FullName () not in fullnames :
126134 self .class_ .AddMember (member )
127135 else :
128136 level_exported = True
@@ -646,7 +654,7 @@ class _VirtualWrapperGenerator(object):
646654 'Generates code to export the virtual methods of the given class'
647655
648656 def __init__ (self , class_ , bases , info ):
649- self .class_ = class_
657+ self .class_ = copy . deepcopy ( class_ )
650658 self .bases = bases [:]
651659 self .info = info
652660 self .wrapper_name = makeid (class_ .FullName ()) + '_Wrapper'
@@ -703,7 +711,7 @@ def DefaultImpl(method, param_names):
703711 if not wrapper :
704712 # return the default implementation of the class
705713 if method .abstract :
706- s = indent2 + 'PyErr_SetString(PyExc_RuntimeError, "abstract function called");\n ' + \
714+ s = indent2 + 'PyErr_SetString(PyExc_RuntimeError, "pure virtual function called");\n ' + \
707715 indent2 + 'throw_error_already_set();\n '
708716 if method .result .FullName () != 'void' :
709717 s += indent2 + 'return %s();\n ' % method .result .FullName ()
@@ -789,14 +797,7 @@ def IsVirtual(m):
789797 return type (m ) is Method and \
790798 m .virtual and \
791799 m .visibility != Scope .private
792-
793- all_methods = [x for x in self .class_ if IsVirtual (x )]
794- for base in self .bases :
795- base_methods = [copy .deepcopy (x ) for x in base if IsVirtual (x )]
796- for base_method in base_methods :
797- base_method .class_ = self .class_ .FullName ()
798- all_methods .append (base_method )
799-
800+
800801 # extract the virtual methods, avoiding duplications. The duplication
801802 # must take in account the full signature without the class name, so
802803 # that inherited members are correctly excluded if the subclass overrides
@@ -811,10 +812,22 @@ def MethodSig(method):
811812 else :
812813 result = ''
813814 params = ', ' .join ([x .FullName () for x in method .parameters ])
814- return '%s %s(%s) %s' % (result , method .name , params , const )
815-
816- self .virtual_methods = []
815+ return '%s %s(%s) %s' % (result , method .name , params , const )
816+
817817 already_added = {}
818+ self .virtual_methods = []
819+ for member in self .class_ :
820+ if IsVirtual (member ):
821+ already_added [MethodSig (member )] = None
822+ self .virtual_methods .append (member )
823+
824+ for base in self .bases :
825+ base_methods = [copy .deepcopy (x ) for x in base if IsVirtual (x )]
826+ for base_method in base_methods :
827+ self .class_ .AddMember (base_method )
828+
829+ all_methods = [x for x in self .class_ if IsVirtual (x )]
830+
818831 for member in all_methods :
819832 sig = MethodSig (member )
820833 if IsVirtual (member ) and not sig in already_added :
0 commit comments