From 56bbc2e3cbc55b1be00a49af1386112783b05317 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 7 Oct 2003 13:14:53 +0000 Subject: [PATCH] don't copy methods from a grandparent that are already inherited from a parent. --- direct/src/ffi/FFITypes.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index 49f7cc79bf..e512e275d9 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -411,6 +411,18 @@ class ClassTypeDescriptor(BaseTypeDescriptor): self.copyParentMethodsRecursively(parentList, file, nesting) + def inheritsMethodNamed(self, parentList, methodName): + """ + returns true if the named method is a method on this class, or + on any parent class except the last one in the list. + """ + if self.hasMethodNamed(methodName): + return 1 + for pi in range(len(parentList) - 1): + if parentList[pi].hasMethodNamed(methodName): + return 1 + return 0 + def copyParentMethodsRecursively(self, parentList, file, nesting): """ Copy all the parents instance methods @@ -427,20 +439,20 @@ class ClassTypeDescriptor(BaseTypeDescriptor): recurse = 0 for method in parent.instanceMethods: - if not self.hasMethodNamed(method.name): + if not self.inheritsMethodNamed(parentList, method.name): # with downcast for all instance methods that are not themselves upcasts method.generateInheritedMethodCode(self, parentList, file, nesting, 1) # Also duplicate the overloaded method dispatch functions, if # we don't already have any matching methods by this name. for methodSpecList in parent.overloadedInstanceMethods.values(): - if not self.hasMethodNamed(methodSpecList[0].name): + if not self.inheritsMethodNamed(parentList, methodSpecList[0].name): treeColl = FFIOverload.FFIMethodArgumentTreeCollection(self, methodSpecList) treeColl.generateCode(file, nesting) # Copy all the parents upcast methods so we transitively pick them up for method in parent.upcastMethods: - if not self.hasMethodNamed(method.name): + if not self.inheritsMethodNamed(parentList, method.name): # no downcast for all instance methods that are themselves upcasts # that would cause an infinite loop method.generateInheritedMethodCode(self, parentList, file, nesting, 0)