def constructGlobalFunction(self, globalIndex): descriptors = self.constructFunctionTypeDescriptors(globalIndex) if len(descriptors) == 0: return None funcSpecs = [] for descriptor in descriptors: funcSpec = FFISpecs.GlobalFunctionSpecification() funcSpec.typeDescriptor = descriptor funcSpec.name = FFIRename.methodNameFromCppName(funcSpec.typeDescriptor.foreignTypeName) funcSpec.index = globalIndex funcSpecs.append(funcSpec) return funcSpecs
def constructGlobalFunction(self, globalIndex): descriptors = self.constructFunctionTypeDescriptors(globalIndex) if (len(descriptors) == 0): return None funcSpecs = [] for descriptor in descriptors: funcSpec = FFISpecs.GlobalFunctionSpecification() funcSpec.typeDescriptor = descriptor funcSpec.name = FFIRename.methodNameFromCppName( funcSpec.typeDescriptor.foreignTypeName) funcSpec.index = globalIndex funcSpecs.append(funcSpec) return funcSpecs
def constructMemberFunctionSpecifications(self, typeIndex): funcSpecs = [] numFuncs = interrogate_type_number_of_methods(typeIndex) for i in range(numFuncs): funcIndex = interrogate_type_get_method(typeIndex, i) typeDescs = self.constructFunctionTypeDescriptors(funcIndex) for typeDesc in typeDescs: funcSpec = FFISpecs.MethodSpecification() funcSpec.name = FFIRename.methodNameFromCppName( interrogate_function_name(funcIndex), getTypeName(typeIndex)) funcSpec.typeDescriptor = typeDesc funcSpec.index = funcIndex funcSpecs.append(funcSpec) return funcSpecs
def constructDowncastFunctionSpecifications(self, typeIndex): """ The strange thing about downcast functions is that they appear in the class they are being downcast TO, not downcast FROM. But they should be built into the class they are being downcast from. For instance, a method downcastToNode(ptrBoundedObject) will appear in Node's list of methods but should be compiled into BoundedObject's class UPDATE: These are no longer compiled into the from-class. That was preventing the libraries from being independent since the from class now had knowledge of the to class which is potentially in a library downstream. Now these functions are just global functions """ numFuncs = interrogate_type_number_of_derivations(typeIndex) for i in range(numFuncs): # Make sure this downcast is possible if (not interrogate_type_derivation_downcast_is_impossible( typeIndex, i)): if interrogate_type_derivation_has_downcast(typeIndex, i): funcIndex = interrogate_type_get_downcast(typeIndex, i) typeDescs = self.constructFunctionTypeDescriptors( funcIndex) for typeDesc in typeDescs: funcSpec = FFISpecs.GlobalFunctionSpecification() funcSpec.name = FFIRename.methodNameFromCppName( interrogate_function_name(funcIndex), getTypeName(typeIndex)) funcSpec.typeDescriptor = typeDesc funcSpec.index = funcIndex # Here we look for the class in the first argument fromClass = typeDesc.argumentTypes[ 0].typeDescriptor.recursiveTypeDescriptor() # Append the from class name on the method to uniquify it now # that these are global methods funcSpec.name = funcSpec.name + 'From' + fromClass.foreignTypeName # Append this funcSpec to that class's downcast methods # fromClass.downcastMethods.append(funcSpec) self.environment.addDowncastFunction(funcSpec)
def constructDowncastFunctionSpecifications(self, typeIndex): """ The strange thing about downcast functions is that they appear in the class they are being downcast TO, not downcast FROM. But they should be built into the class they are being downcast from. For instance, a method downcastToNode(ptrBoundedObject) will appear in Node's list of methods but should be compiled into BoundedObject's class UPDATE: These are no longer compiled into the from-class. That was preventing the libraries from being independent since the from class now had knowledge of the to class which is potentially in a library downstream. Now these functions are just global functions """ numFuncs = interrogate_type_number_of_derivations(typeIndex) for i in range(numFuncs): # Make sure this downcast is possible if (not interrogate_type_derivation_downcast_is_impossible(typeIndex, i)): if interrogate_type_derivation_has_downcast(typeIndex, i): funcIndex = interrogate_type_get_downcast(typeIndex, i) typeDescs = self.constructFunctionTypeDescriptors(funcIndex) for typeDesc in typeDescs: funcSpec = FFISpecs.GlobalFunctionSpecification() funcSpec.name = FFIRename.methodNameFromCppName( interrogate_function_name(funcIndex), getTypeName(typeIndex)) funcSpec.typeDescriptor = typeDesc funcSpec.index = funcIndex # Here we look for the class in the first argument fromClass = typeDesc.argumentTypes[0].typeDescriptor.recursiveTypeDescriptor() # Append the from class name on the method to uniquify it now # that these are global methods funcSpec.name = funcSpec.name + 'From' + fromClass.foreignTypeName # Append this funcSpec to that class's downcast methods # fromClass.downcastMethods.append(funcSpec) self.environment.addDowncastFunction(funcSpec)