当前位置: 首页>>代码示例>>Python>>正文


Python generator.OutputGenerator类代码示例

本文整理汇总了Python中generator.OutputGenerator的典型用法代码示例。如果您正苦于以下问题:Python OutputGenerator类的具体用法?Python OutputGenerator怎么用?Python OutputGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OutputGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: beginFeature

    def beginFeature(self, interface, emit):
        # Start processing in superclass
        OutputGenerator.beginFeature(self, interface, emit)

        if interface.tag != 'extension':
            self.logMsg('diag', 'beginFeature: ignoring non-extension feature', self.featureName)
            return

        # These attributes must exist
        name = self.featureName
        number = self.getAttrib(interface, 'number')
        ext_type = self.getAttrib(interface, 'type')
        revision = self.getSpecVersion(interface, name)

        # These attributes are optional
        OPTIONAL = False
        requires = self.getAttrib(interface, 'requires', OPTIONAL)
        requiresCore = self.getAttrib(interface, 'requiresCore', OPTIONAL, '1.0')
        contact = self.getAttrib(interface, 'contact', OPTIONAL)
        promotedTo = self.getAttrib(interface, 'promotedto', OPTIONAL)
        deprecatedBy = self.getAttrib(interface, 'deprecatedby', OPTIONAL)
        obsoletedBy = self.getAttrib(interface, 'obsoletedby', OPTIONAL)
        provisional = self.getAttrib(interface, 'provisional', OPTIONAL, 'false')

        filename = self.directory + '/' + name + self.file_suffix

        self.extensions.append( Extension(self, filename, name, number, ext_type, requires, requiresCore, contact, promotedTo, deprecatedBy, obsoletedBy, provisional, revision) )
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:27,代码来源:extensionmetadocgenerator.py

示例2: genStruct

    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,代码行数:33,代码来源:cgenerator.py

示例3: __init__

 def __init__(self,
              errFile = sys.stderr,
              warnFile = sys.stderr,
              diagFile = sys.stdout):
     OutputGenerator.__init__(self, errFile, warnFile, diagFile)
     # Keep track of all extension numbers
     self.extension_numbers = set()
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:7,代码来源:docgenerator.py

示例4: beginFile

 def beginFile(self, genOpts):
     OutputGenerator.beginFile(self, genOpts)
     #
     # Dictionaries are keyed by the name of the entity (e.g.
     # self.structs is keyed by structure names). Values are
     # the names of related entities (e.g. structs contain
     # a list of type names of members, enums contain a list
     # of enumerants belong to the enumerated type, etc.), or
     # just None if there are no directly related entities.
     #
     # Collect the mappings, then emit the Python script in endFile
     self.basetypes = {}
     self.consts = {}
     self.enums = {}
     self.flags = {}
     self.funcpointers = {}
     self.protos = {}
     self.structs = {}
     self.handles = {}
     self.defines = {}
     self.alias = {}
     # Dictionary containing the type of a type name
     # (e.g. the string name of the dictionary with its contents).
     self.typeCategory = {}
     self.mapDict = {}
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:25,代码来源:pygenerator.py

示例5: endFile

    def endFile(self):
        # Print out all the dictionaries as Python strings.
        # Could just print(dict) but that's not human-readable
        dicts = [ [ self.basetypes,     'basetypes' ],
                  [ self.consts,        'consts' ],
                  [ self.enums,         'enums' ],
                  [ self.flags,         'flags' ],
                  [ self.funcpointers,  'funcpointers' ],
                  [ self.protos,        'protos' ],
                  [ self.structs,       'structs' ],
                  [ self.handles,       'handles' ],
                  [ self.defines,       'defines' ],
                  [ self.typeCategory,  'typeCategory' ],
                  [ self.alias,         'alias' ],
                ]
        for (entry_dict, name) in dicts:
            write(name + ' = {}', file=self.outFile)
            for key in sorted(entry_dict.keys()):
                write(name + '[' + enquote(key) + '] = ', entry_dict[key],
                      file=self.outFile)

        # Dictionary containing the relationships of a type
        # (e.g. a dictionary with each related type as keys).
        write('mapDict = {}', file=self.outFile)

        # Could just print(self.mapDict), but prefer something
        # human-readable and stable-ordered
        for baseType in sorted(self.mapDict.keys()):
            write('mapDict[' + enquote(baseType) + '] = ', file=self.outFile, end='')
            pprint(self.mapDict[baseType], self.outFile)

        OutputGenerator.endFile(self)
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:32,代码来源:pygenerator.py

示例6: genEnum

    def genEnum(self, enuminfo, name, alias):
        OutputGenerator.genEnum(self, enuminfo, name, alias)

        # Add a typeCategory{} entry for the category of this type.
        self.addName(self.typeCategory, name, 'consts')

        self.consts[name] = None
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:7,代码来源:pygenerator.py

示例7: genType

    def genType(self, typeinfo, name, alias):
        OutputGenerator.genType(self, typeinfo, name, alias)
        typeElem = typeinfo.elem
        # If the type is a struct type, traverse the embedded <member> tags
        # generating a structure. Otherwise, emit the tag text.
        category = typeElem.get('category')

        # Add a typeCategory{} entry for the category of this type.
        self.addName(self.typeCategory, name, category)

        if category in ('struct', 'union'):
            self.genStruct(typeinfo, name, alias)
        else:
            if alias:
                # Add name -> alias mapping
                self.addName(self.alias, name, alias)

                # Always emit an alias (?!)
                count = 1

                # May want to only emit full type definition when not an alias?
            else:
                # Extract the type name
                # (from self.genOpts). Copy other text through unchanged.
                # If the resulting text is an empty string, don't emit it.
                count = len(noneStr(typeElem.text))
                for elem in typeElem:
                    count += len(noneStr(elem.text)) + len(noneStr(elem.tail))

            if count > 0:
                if category == 'bitmask':
                    requiredEnum = typeElem.get('requires')
                    self.addName(self.flags, name, requiredEnum)

                    # This happens when the Flags type is defined, but no
                    # FlagBits are defined yet.
                    if requiredEnum is not None:
                        self.addMapping(name, requiredEnum)
                elif category == 'enum':
                    # This case does not seem to come up. It nominally would
                    # result from
                    #   <type name="Something" category="enum"/>,
                    # but the output generator doesn't emit them directly.
                    self.logMsg('warn', 'PyOutputGenerator::genType: invalid \'enum\' category for name:', name)
                elif category == 'funcpointer':
                    self.funcpointers[name] = None
                elif category == 'handle':
                    self.handles[name] = None
                elif category == 'define':
                    self.defines[name] = None
                elif category == 'basetype':
                    # Don't add an entry for base types that are not API types
                    # e.g. an API Bool type gets an entry, uint32_t does not
                    if self.apiName(name):
                        self.basetypes[name] = None
                        self.addName(self.typeCategory, name, 'basetype')
                    else:
                        self.logMsg('diag', 'PyOutputGenerator::genType: unprocessed type:', name, 'category:', category)
            else:
                self.logMsg('diag', 'PyOutputGenerator::genType: unprocessed type:', name)
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:60,代码来源:pygenerator.py

示例8: genCmd

    def genCmd(self, cmdinfo, name, alias):
        OutputGenerator.genCmd(self, cmdinfo, name, alias)

        # @@@ (Jon) something needs to be done here to handle aliases, probably

        self.makeThreadSafetyBlocks(cmdinfo.elem, 'param')

        self.writeInclude()
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:8,代码来源:hostsyncgenerator.py

示例9: __init__

 def __init__(self,
              errFile = sys.stderr,
              warnFile = sys.stderr,
              diagFile = sys.stdout):
     OutputGenerator.__init__(self, errFile, warnFile, diagFile)
     self.extensions = []
     # List of strings containing all vendor tags
     self.vendor_tags = []
     self.file_suffix = ''
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:9,代码来源:extensionmetadocgenerator.py

示例10: beginFeature

	def beginFeature(self, interface, emit):
		OutputGenerator.beginFeature(self, interface, emit)
		self.currentFeature = "// {0}".format(interface.attrib['name'])
		self.sections = dict([(section, []) for section in self.ALL_SECTIONS])
		self.opaqueStruct.clear()
		self.surfaceExtensionVersionIndent = ""
		self.isSurfaceExtension = self.currentFeature in self.surfaceExtensions
		if self.isSurfaceExtension:
			self.surfaceExtensionVersionIndent = "\t"
开发者ID:MaikKlein,项目名称:ErupteD,代码行数:9,代码来源:erupt.py

示例11: beginFeature

 def beginFeature(self, interface, emit):
     # Start processing in superclass
     OutputGenerator.beginFeature(self, interface, emit)
     # C-specific
     # Accumulate includes, defines, types, enums, function pointer typedefs,
     # end function prototypes separately for this feature. They're only
     # printed in endFeature().
     self.sections = {section: [] for section in self.ALL_SECTIONS}
     self.feature_not_empty = False
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:9,代码来源:cgenerator.py

示例12: __init__

 def __init__(self,
              errFile = sys.stderr,
              warnFile = sys.stderr,
              diagFile = sys.stdout):
     OutputGenerator.__init__(self, errFile, warnFile, diagFile)
     # Internal state - accumulators for different inner block text
     self.sections = {section: [] for section in self.ALL_SECTIONS}
     self.feature_not_empty = False
     self.need_platform_include = False
     self.may_alias = None
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:10,代码来源:cgenerator.py

示例13: beginFeature

	def beginFeature( self, interface, emit ):
		OutputGenerator.beginFeature( self, interface, emit )
		#if interface.attrib.get( 'protect' ):
			#write( interface.attrib[ 'name' ], file = self.testsFile )
		self.currentFeature = "// {0}".format( interface.attrib[ 'name' ] )
		self.sections = dict( [ ( section, [] ) for section in self.ALL_SECTIONS ] )
		self.opaqueStruct.clear()
		self.platformExtensionVersionIndent = ""
		self.isPlatformExtension = self.currentFeature in self.platformExtensions
		if self.isPlatformExtension:
			self.platformExtensionVersionIndent = "\t"
开发者ID:ParticlePeter,项目名称:ErupteD,代码行数:11,代码来源:erupt.py

示例14: beginFeature

 def beginFeature(self, interface, emit):
     # Start processing in superclass
     OutputGenerator.beginFeature(self, interface, emit)
     # Verify that each extension has a unique number during doc generation
     extension_number = interface.get('number')
     if extension_number is not None and extension_number != "0":
         if extension_number in self.extension_numbers:
             self.logMsg('error', 'Duplicate extension number ', extension_number, ' detected in feature ', interface.get('name'), '\n')
             exit(1)
         else:
             self.extension_numbers.add(extension_number)
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:11,代码来源:docgenerator.py

示例15: genGroup

    def genGroup(self, groupinfo, groupName, alias):
        OutputGenerator.genGroup(self, groupinfo, groupName, alias)

        if alias:
            # If the group name is aliased, just emit a typedef declaration
            # for the alias.
            body = 'typedef ' + alias + ' ' + groupName + ';\n'
        else:
            expand = self.genOpts.expandEnumerants
            (_, body) = self.buildEnumCDecl(expand, groupinfo, groupName)

        self.writeInclude('enums', groupName, body)
开发者ID:krOoze,项目名称:Vulkan-Docs,代码行数:12,代码来源:docgenerator.py


注:本文中的generator.OutputGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。