本文整理汇总了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)
示例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)
示例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)