diff --git a/direct/src/ffi/FFISpecs.py b/direct/src/ffi/FFISpecs.py index e5f0e1ffb5..f969fa323b 100644 --- a/direct/src/ffi/FFISpecs.py +++ b/direct/src/ffi/FFISpecs.py @@ -428,6 +428,7 @@ class MethodSpecification(FunctionSpecification): argTypes = self.typeDescriptor.argumentTypes thislessArgTypes = self.typeDescriptor.thislessArgTypes() self.outputTypeChecking(methodClass, thislessArgTypes, file, nesting+2) + indent(file, nesting+2, 'upcastSelf = self\n') for i in range(len(parentList)): # Only output the upcast call if that parent class defines it parentClass = parentList[i] @@ -435,10 +436,10 @@ class MethodSpecification(FunctionSpecification): if (i != 0): childClass = parentList[i-1] if childClass.hasMethodNamed(methodName): - indent(file, nesting+2, 'upcastSelf = self.' + methodName + '()\n') + indent(file, nesting+2, 'upcastSelf = upcastSelf.' + methodName + '()\n') else: if methodClass.hasMethodNamed(methodName): - indent(file, nesting+2, 'upcastSelf = self.' + methodName + '()\n') + indent(file, nesting+2, 'upcastSelf = upcastSelf.' + methodName + '()\n') indent(file, nesting+2, 'returnValue = ' + self.typeDescriptor.moduleName + '.' + self.typeDescriptor.wrapperName + '(upcastSelf.this') if (len(thislessArgTypes) > 0): diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index 93ab24502f..58b794ccde 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -228,6 +228,18 @@ class ClassTypeDescriptor(BaseTypeDescriptor): """ return self.foreignTypeName + '-extensions.py' + def getCModulesRecursively(self, parent): + # Now look at all the methods that we might inherit if we are at + # a multiple inheritance node and get their C modules + for parentType in parent.parentTypes: + for method in parentType.instanceMethods: + if (not (method.typeDescriptor.moduleName in self.CModules)): + self.CModules.append(method.typeDescriptor.moduleName) + for method in parentType.upcastMethods: + if (not (method.typeDescriptor.moduleName in self.CModules)): + self.CModules.append(method.typeDescriptor.moduleName) + self.getCModulesRecursively(parentType) + def getCModules(self): """ Return a list of all the C modules this class references @@ -244,16 +256,8 @@ class ClassTypeDescriptor(BaseTypeDescriptor): if method: if (not (method.typeDescriptor.moduleName in self.CModules)): self.CModules.append(method.typeDescriptor.moduleName) - # Now look at all the methods that we might inherit if we are at - # a multiple inheritance node and get their C modules - if (len(self.parentTypes) >= 2): - for parentType in self.parentTypes: - for method in parentType.instanceMethods: - if (not (method.typeDescriptor.moduleName in self.CModules)): - self.CModules.append(method.typeDescriptor.moduleName) - for method in parentType.upcastMethods: - if (not (method.typeDescriptor.moduleName in self.CModules)): - self.CModules.append(method.typeDescriptor.moduleName) + self.getCModulesRecursively(self) + return self.CModules