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


Python OutputGenerator.genStruct方法代碼示例

本文整理匯總了Python中generator.OutputGenerator.genStruct方法的典型用法代碼示例。如果您正苦於以下問題:Python OutputGenerator.genStruct方法的具體用法?Python OutputGenerator.genStruct怎麽用?Python OutputGenerator.genStruct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在generator.OutputGenerator的用法示例。


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

示例1: genStruct

# 需要導入模塊: from generator import OutputGenerator [as 別名]
# 或者: from generator.OutputGenerator import genStruct [as 別名]
    def genStruct(self, typeinfo, typeName, alias):
        OutputGenerator.genStruct(self, typeinfo, typeName, alias)

        typeElem = typeinfo.elem

        if alias:
            body = 'typedef ' + alias + ' ' + typeName + ';\n'
        else:
            body = ''
            (protect_begin, protect_end) = self.genProtectString(typeElem.get('protect'))
            if protect_begin:
                body += protect_begin
            body += 'typedef ' + typeElem.get('category')

            # This is an OpenXR-specific alternative where aliasing refers
            # to an inheritance hierarchy of types rather than C-level type
            # aliases.
            if self.genOpts.genAliasMacro and self.typeMayAlias(typeName):
                body += ' ' + self.genOpts.aliasMacro

            body += ' ' + typeName + ' {\n'

            targetLen = 0
            for member in typeElem.findall('.//member'):
                targetLen = max(targetLen, self.getCParamTypeLength(member))
            for member in typeElem.findall('.//member'):
                body += self.makeCParamDecl(member, targetLen + 4)
                body += ';\n'
            body += '} ' + typeName + ';\n'
            if protect_end:
                body += protect_end

        self.appendSection('struct', body)
開發者ID:krOoze,項目名稱:Vulkan-Docs,代碼行數:35,代碼來源:cgenerator.py

示例2: genStruct

# 需要導入模塊: from generator import OutputGenerator [as 別名]
# 或者: from generator.OutputGenerator import genStruct [as 別名]
    def genStruct(self, typeinfo, typeName, alias):
        OutputGenerator.genStruct(self, typeinfo, typeName, alias)

        if alias:
            # Add name -> alias mapping
            self.addName(self.alias, typeName, alias)
        else:
            # May want to only emit definition on this branch
            True

        members = [member.text for member in typeinfo.elem.findall('.//member/name')]
        self.structs[typeName] = members
        memberTypes = [member.text for member in typeinfo.elem.findall('.//member/type')]
        for member_type in memberTypes:
            self.addMapping(typeName, member_type)
開發者ID:krOoze,項目名稱:Vulkan-Docs,代碼行數:17,代碼來源:pygenerator.py

示例3: genStruct

# 需要導入模塊: from generator import OutputGenerator [as 別名]
# 或者: from generator.OutputGenerator import genStruct [as 別名]
    def genStruct(self, typeinfo, typeName, alias):
        OutputGenerator.genStruct(self, typeinfo, typeName, alias)

        typeElem = typeinfo.elem

        if alias:
            body = 'typedef ' + alias + ' ' + typeName + ';\n'
        else:
            body = 'typedef ' + typeElem.get('category') + ' ' + typeName + ' {\n'

            targetLen = 0
            for member in typeElem.findall('.//member'):
                targetLen = max(targetLen, self.getCParamTypeLength(member))
            for member in typeElem.findall('.//member'):
                body += self.makeCParamDecl(member, targetLen + 4)
                body += ';\n'
            body += '} ' + typeName + ';'

        self.writeInclude('structs', typeName, body)
開發者ID:krOoze,項目名稱:Vulkan-Docs,代碼行數:21,代碼來源:docgenerator.py


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