mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
79dc9d7d6c
commit
70465a2aa7
@ -369,13 +369,13 @@ class FFIInterrogateDatabase:
|
||||
descriptor = FFITypes.ClassTypeDescriptor()
|
||||
self.typeIndexMap[typeIndex] = descriptor
|
||||
#descriptor.environment = self.environment
|
||||
descriptor.foreignTypeName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
|
||||
descriptor.isNested = interrogate_type_is_nested(typeIndex)
|
||||
if descriptor.isNested:
|
||||
outerTypeIndex = interrogate_type_outer_class(typeIndex)
|
||||
descriptor.outerType = self.constructDescriptor(outerTypeIndex)
|
||||
if interrogate_type_has_module_name(typeIndex):
|
||||
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
|
||||
descriptor.foreignTypeName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
|
||||
if FFIConstants.wantComments:
|
||||
if interrogate_type_has_comment(typeIndex):
|
||||
descriptor.comment = interrogate_type_comment(typeIndex)
|
||||
|
@ -89,17 +89,35 @@ def getTypeName(classTypeDesc, typeDesc):
|
||||
# bit trickier because we output different things depending on the
|
||||
# scoping of the type.
|
||||
else:
|
||||
# Assuming the class and the module are the same name, return
|
||||
# typeName.typeName (ie Node.Node)
|
||||
# Unless we are in the same module. For instance, in Node.py,
|
||||
# Node.Node is not defined, so just return Node.
|
||||
nestedTypes = string.split(typeName, '.')
|
||||
if (classTypeDesc and (classTypeDesc.foreignTypeName in nestedTypes)):
|
||||
# Return the last type (SubClass) in the nested types
|
||||
return nestedTypes[-1]
|
||||
|
||||
# classTypeDesc typeDesc fullNestedName Resulting TypeName
|
||||
# 1 Outer Other Other Other.Other
|
||||
# 2 Outer Outer Outer Outer
|
||||
# 3 Outer Inner Outer.Inner Outer.Inner
|
||||
# 4 Inner Other Other Other.Other
|
||||
# 5 Inner Outer Outer Outer
|
||||
# 6 Inner Inner Outer.Inner Outer.Inner
|
||||
# 7 None Other Other Other.Other
|
||||
|
||||
# CASES 1,4, and 7 are the only ones that are different from the full
|
||||
# nested name, returning Other.Other
|
||||
|
||||
returnNestedTypeNames = string.split(typeName, '.')
|
||||
returnModuleName = returnNestedTypeNames[0]
|
||||
|
||||
if classTypeDesc:
|
||||
classTypeName = classTypeDesc.getFullNestedName()
|
||||
classNestedTypeNames = string.split(classTypeName, '.')
|
||||
# If there is no nesting, return typeName.typeName
|
||||
if ((not (classTypeDesc.foreignTypeName in returnNestedTypeNames)) and
|
||||
(not (typeDesc.foreignTypeName in classNestedTypeNames))):
|
||||
return (returnModuleName + '.' + typeName)
|
||||
# All other cases, we just need typeName
|
||||
else:
|
||||
return typeName
|
||||
else:
|
||||
# Return the full Module.Class.SubClass
|
||||
return (nestedTypes[0] + '.' + typeName)
|
||||
# If you had no class, you need to specify module plus typename
|
||||
return (returnModuleName + '.' + typeName)
|
||||
|
||||
|
||||
def inheritsFrom(type1, type2):
|
||||
|
@ -179,7 +179,9 @@ class GlobalFunctionSpecification(FunctionSpecification):
|
||||
file.write(', ')
|
||||
file.write(')\n')
|
||||
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
|
||||
returnType.generateReturnValueWrapper(file, self.typeDescriptor.userManagesMemory, needsDowncast, 1)
|
||||
returnType.generateReturnValueWrapper(None, file,
|
||||
self.typeDescriptor.userManagesMemory,
|
||||
needsDowncast, 1)
|
||||
|
||||
def outputFooter(self, file):
|
||||
indent(file, 0, '\n')
|
||||
@ -220,7 +222,9 @@ class GlobalFunctionSpecification(FunctionSpecification):
|
||||
file.write(', ')
|
||||
file.write(')\n')
|
||||
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
|
||||
returnType.generateReturnValueWrapper(file, self.typeDescriptor.userManagesMemory, 1, nesting+2)
|
||||
returnType.generateReturnValueWrapper(methodClass, file,
|
||||
self.typeDescriptor.userManagesMemory,
|
||||
1, nesting+2)
|
||||
|
||||
def outputMethodFooter(self, methodClass, file, nesting):
|
||||
indent(file, nesting+1, '\n')
|
||||
@ -378,7 +382,8 @@ class MethodSpecification(FunctionSpecification):
|
||||
indent(file, nesting+2, 'return self\n')
|
||||
else:
|
||||
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
|
||||
returnType.generateReturnValueWrapper(file, self.typeDescriptor.userManagesMemory,
|
||||
returnType.generateReturnValueWrapper(methodClass, file,
|
||||
self.typeDescriptor.userManagesMemory,
|
||||
needsDowncast, nesting+2)
|
||||
|
||||
def outputMethodFooter(self, methodClass, file, nesting):
|
||||
@ -416,7 +421,8 @@ class MethodSpecification(FunctionSpecification):
|
||||
file.write(', ')
|
||||
file.write(')\n')
|
||||
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
|
||||
returnType.generateReturnValueWrapper(file, self.typeDescriptor.userManagesMemory,
|
||||
returnType.generateReturnValueWrapper(methodClass, file,
|
||||
self.typeDescriptor.userManagesMemory,
|
||||
1, nesting+2)
|
||||
|
||||
def outputStaticFooter(self, methodClass, file, nesting):
|
||||
@ -473,7 +479,8 @@ class MethodSpecification(FunctionSpecification):
|
||||
file.write(')\n')
|
||||
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
|
||||
# Generate the return value code with no downcast instructions
|
||||
returnType.generateReturnValueWrapper(file, self.typeDescriptor.userManagesMemory,
|
||||
returnType.generateReturnValueWrapper(methodClass, file,
|
||||
self.typeDescriptor.userManagesMemory,
|
||||
needsDowncast, nesting+2)
|
||||
|
||||
def outputInheritedMethodFooter(self, methodClass, parentList, file, nesting, needsDowncast):
|
||||
|
@ -74,7 +74,7 @@ class BaseTypeDescriptor:
|
||||
def recordOverloadedMethods(self):
|
||||
# By default do nothing
|
||||
pass
|
||||
def generateReturnValueWrapper(self, file, userManagesMemory,
|
||||
def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
|
||||
needsDowncast, nesting):
|
||||
# By default do nothing
|
||||
pass
|
||||
@ -97,7 +97,7 @@ class PrimitiveTypeDescriptor(BaseTypeDescriptor):
|
||||
def __init__(self):
|
||||
BaseTypeDescriptor.__init__(self)
|
||||
|
||||
def generateReturnValueWrapper(self, file, userManagesMemory,
|
||||
def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
|
||||
needsDowncast, nesting):
|
||||
"""
|
||||
Write code to the file that will return a primitive to the caller.
|
||||
@ -767,7 +767,8 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
|
||||
indent(file, nesting+2, "raise RuntimeError, 'No C++ destructor defined for class: ' + self.__class__.__name__\n")
|
||||
|
||||
|
||||
def generateReturnValueWrapper(self, file, userManagesMemory, needsDowncast, nesting):
|
||||
def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
|
||||
needsDowncast, nesting):
|
||||
"""
|
||||
Generate code that creates a shadow object of this type
|
||||
then sets the this pointer and returns the object. We call the
|
||||
@ -776,10 +777,9 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
|
||||
"""
|
||||
indent(file, nesting, 'returnObject = ')
|
||||
# Do not put Class.Class if this file is the file that defines Class
|
||||
if (os.path.basename(file.name)[:-3] == self.foreignTypeName):
|
||||
file.write(self.foreignTypeName)
|
||||
else:
|
||||
file.write(self.foreignTypeName + '.' + self.foreignTypeName)
|
||||
# Also check for nested classes. They do not need the module name either
|
||||
typeName = FFIOverload.getTypeName(classTypeDesc, self)
|
||||
file.write(typeName)
|
||||
file.write('(None)\n')
|
||||
indent(file, nesting, 'returnObject.this = returnValue\n')
|
||||
if userManagesMemory:
|
||||
|
Loading…
x
Reference in New Issue
Block a user