當前位置: 首頁>>代碼示例>>Python>>正文


Python FFIRename類代碼示例

本文整理匯總了Python中FFIRename的典型用法代碼示例。如果您正苦於以下問題:Python FFIRename類的具體用法?Python FFIRename怎麽用?Python FFIRename使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FFIRename類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: constructEnumTypeDescriptor

    def constructEnumTypeDescriptor(self, typeIndex):
        if self.isDefinedType(typeIndex):
            return self.typeIndexMap[typeIndex]
        else:
            descriptor = FFITypes.EnumTypeDescriptor()
            #descriptor.environment = self.environment
            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)

            # Enums are ints in C++ but we do not want to redefine the int type
            # So we will just call them enums
            descriptor.enumName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
            descriptor.foreignTypeName = '__enum__' + descriptor.enumName
            numValues = interrogate_type_number_of_enum_values(typeIndex)

            # Store the names and values of the enum in a dictionary
            for i in range(numValues):
                value = interrogate_type_enum_value(typeIndex, i)
                name = FFIRename.classNameFromCppName(
                    interrogate_type_enum_value_name(typeIndex, i))
                scopedName = FFIRename.classNameFromCppName(
                    interrogate_type_enum_value_scoped_name(typeIndex, i))
                descriptor.values[name] = value
            
            descriptor.typeIndex = typeIndex
            self.typeIndexMap[typeIndex] = descriptor
            return descriptor
開發者ID:kralf,項目名稱:panda3d,代碼行數:31,代碼來源:FFIInterrogateDatabase.py

示例2: constructManifest

    def constructManifest(self, manifestIndex):
        descriptor = None
        intValue = None
        getter = None

        if interrogate_manifest_has_type(manifestIndex):
            typeIndex = interrogate_manifest_get_type(manifestIndex)
            descriptor = self.constructDescriptor(typeIndex)

        definition = interrogate_manifest_definition(manifestIndex)

        # See if this manifest is an int. There are shortcuts if it is.
        # If it does have an int value, there will be no getter, we will
        # just output the value in the generated code
        if interrogate_manifest_has_int_value(manifestIndex):
            intValue = interrogate_manifest_get_int_value(manifestIndex)
        else:
            # See if this manifest has a getter
            if interrogate_manifest_has_getter(manifestIndex):
                getterIndex = interrogate_manifest_getter(manifestIndex)
                getter = self.constructGlobalFunction(getterIndex)

        manifestSpec = FFISpecs.ManifestSpecification()
        manifestSpec.typeDescriptor = descriptor
        manifestSpec.definition = definition
        manifestSpec.intValue = intValue
        manifestSpec.getter = getter
        cppName = interrogate_manifest_name(manifestIndex)
        manifestSpec.name = FFIRename.classNameFromCppName(cppName)
        return manifestSpec
開發者ID:kralf,項目名稱:panda3d,代碼行數:30,代碼來源:FFIInterrogateDatabase.py

示例3: constructGlobal

    def constructGlobal(self, globalIndex, CModuleName):
        # We really do not need the descriptor for the value, just
        # the getter and setter
        # typeIndex = interrogate_element_type(globalIndex)
        # descriptor = self.constructDescriptor(typeIndex)
        
        if interrogate_element_has_getter(globalIndex):
            getterIndex = interrogate_element_getter(globalIndex)
            # If this function is not in this Cmodule just return
            if not self.functionInCModule(getterIndex, CModuleName):
                return None
            getter = self.constructGlobalFunction(getterIndex)
        else:
            getter = None

        if interrogate_element_has_setter(globalIndex):
            setterIndex = interrogate_element_setter(globalIndex)
            # If this function is not in this Cmodule just return
            if not self.functionInCModule(setterIndex, CModuleName):
                return None
            setter = self.constructGlobalFunction(setterIndex)
        else:
            setter = None
        globalSpec = FFISpecs.GlobalValueSpecification()
        globalSpec.getter = getter
        globalSpec.setter = setter
        # globalSpec.typeDescriptor = descriptor
        cppName = interrogate_element_name(globalIndex)
        globalSpec.name = FFIRename.classNameFromCppName(cppName)
        return globalSpec
開發者ID:kralf,項目名稱:panda3d,代碼行數:30,代碼來源:FFIInterrogateDatabase.py

示例4: constructGlobalFunction

 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
開發者ID:Wilee999,項目名稱:TTRInjector,代碼行數:12,代碼來源:FFIInterrogateDatabase.py

示例5: constructPrimitiveTypeDescriptor

 def constructPrimitiveTypeDescriptor(self, typeIndex):
     if self.isDefinedType(typeIndex):
         return self.typeIndexMap[typeIndex]
     else:
         descriptor = FFITypes.PrimitiveTypeDescriptor()
         # descriptor.environment = self.environment
         descriptor.atomicType = interrogate_type_atomic_token(typeIndex)
         if interrogate_type_has_module_name(typeIndex):
             descriptor.moduleName = "lib" + interrogate_type_module_name(typeIndex)
         descriptor.foreignTypeName = FFIRename.nonClassNameFromCppName(getTypeName(typeIndex))
         descriptor.typeIndex = typeIndex
         self.typeIndexMap[typeIndex] = descriptor
         return descriptor
開發者ID:Wilee999,項目名稱:TTRInjector,代碼行數:13,代碼來源:FFIInterrogateDatabase.py

示例6: constructMemberFunctionSpecifications

 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
開發者ID:kralf,項目名稱:panda3d,代碼行數:15,代碼來源:FFIInterrogateDatabase.py

示例7: constructFunctionArgumentTypes

    def constructFunctionArgumentTypes(self, functionIndex):
        numArgs = interrogate_wrapper_number_of_parameters(functionIndex)
        arguments = []
        for argIndex in range(numArgs):
            if interrogate_wrapper_parameter_has_name(functionIndex, argIndex):
                name = FFIRename.nonClassNameFromCppName(interrogate_wrapper_parameter_name(functionIndex, argIndex))
            else:
                name = "parameter" + ` argIndex `
            descriptor = self.constructDescriptor(interrogate_wrapper_parameter_type(functionIndex, argIndex))

            argSpec = FFISpecs.MethodArgumentSpecification()
            if interrogate_wrapper_parameter_is_this(functionIndex, argIndex):
                argSpec.isThis = 1
            argSpec.name = name
            argSpec.typeDescriptor = descriptor
            arguments.append(argSpec)
        return arguments
開發者ID:Wilee999,項目名稱:TTRInjector,代碼行數:17,代碼來源:FFIInterrogateDatabase.py

示例8: constructConstTypeDescriptor

 def constructConstTypeDescriptor(self, typeIndex):
     if self.isDefinedType(typeIndex):
         return self.typeIndexMap[typeIndex]
     descriptor = FFITypes.ConstTypeDescriptor()
     # descriptor.environment = self.environment
     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.nonClassNameFromCppName(getTypeName(typeIndex))
     descriptor.typeIndex = typeIndex
     wrappedTypeIndex = interrogate_type_wrapped_type(typeIndex)
     wrappedTypeDescriptor = self.constructDescriptor(wrappedTypeIndex)
     descriptor.typeDescriptor = wrappedTypeDescriptor
     self.typeIndexMap[typeIndex] = descriptor
     return descriptor
開發者ID:Wilee999,項目名稱:TTRInjector,代碼行數:18,代碼來源:FFIInterrogateDatabase.py

示例9: constructClassTypeDescriptor

    def constructClassTypeDescriptor(self, typeIndex):
        if self.isDefinedType(typeIndex):
            return self.typeIndexMap[typeIndex]
        typeName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
        if typeName == "PyObject":
            # A special case: the PyObject type is really a native
            # Python object, not to be molested--it's not really an
            # FFI class object.
            descriptor = FFITypes.PyObjectTypeDescriptor()
            self.typeIndexMap[typeIndex] = descriptor
            return descriptor
            
        descriptor = FFITypes.ClassTypeDescriptor()
        self.typeIndexMap[typeIndex] = descriptor
        #descriptor.environment = self.environment
        descriptor.foreignTypeName = typeName

        if (typeName == "TypedObject"):
            FFITypes.TypedObjectDescriptor = descriptor
        
        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)
        if FFIConstants.wantComments:
            if interrogate_type_has_comment(typeIndex):
                descriptor.comment = interrogate_type_comment(typeIndex)
        descriptor.typeIndex = typeIndex
        descriptor.instanceMethods = self.constructMemberFunctionSpecifications(typeIndex)
        descriptor.upcastMethods = self.constructUpcastFunctionSpecifications(typeIndex)
        # Constructing downcasts does not return the functions, it just puts them in the class
        # See the comment in that function
        self.constructDowncastFunctionSpecifications(typeIndex)
        descriptor.filterOutStaticMethods()
        descriptor.constructors = self.constructConstructorSpecifications(typeIndex)
        descriptor.destructor = self.constructDestructorSpecification(typeIndex)
        descriptor.parentTypes = self.constructParentTypeDescriptors(typeIndex)
        descriptor.nestedTypes = self.constructNestedTypeDescriptors(typeIndex)
        return descriptor
開發者ID:kralf,項目名稱:panda3d,代碼行數:41,代碼來源:FFIInterrogateDatabase.py

示例10: constructDowncastFunctionSpecifications

    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)
開發者ID:kralf,項目名稱:panda3d,代碼行數:36,代碼來源:FFIInterrogateDatabase.py


注:本文中的FFIRename類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。