MCPcopy
hub / github.com/KhronosGroup/Vulkan-Docs / genType

Method genType

scripts/docgenerator.py:401–451  ·  view source on GitHub ↗

Generate type.

(self, typeinfo, name, alias)

Source from the content-addressed store, hash-verified

399 for data in values))
400
401 def genType(self, typeinfo, name, alias):
402 """Generate type."""
403 OutputGenerator.genType(self, typeinfo, name, alias)
404 typeElem = typeinfo.elem
405 # If the type is a struct type, traverse the embedded <member> tags
406 # generating a structure. Otherwise, emit the tag text.
407 category = typeElem.get('category')
408
409 if category in ('struct', 'union'):
410 # If the type is a struct type, generate it using the
411 # special-purpose generator.
412 self.genStruct(typeinfo, name, alias)
413 elif category not in OutputGenerator.categoryToPath:
414 # If there is no path, do not write output
415 self.logMsg('diag', f'NOT writing include for {name} category {category}')
416 else:
417 body = self.genRequirements(name)
418 body += self.deprecationComment(typeElem)
419 # This is not appropriate for Vulkan
420 # if category in ('define',):
421 # body = body.strip()
422 if alias:
423 # If the type is an alias, just emit a typedef declaration
424 body += f'// Equivalent to {alias}\n'
425 body += f"typedef {alias} {name};\n"
426 self.writeInclude(OutputGenerator.categoryToPath[category],
427 name, body, None, None, None)
428 return
429 elif category == 'funcpointer':
430 # Only include the typedef
431 decls = self.makeCDecls(typeElem)
432 body += decls[1]
433 else:
434 # Replace <apientry /> tags with an APIENTRY-style string
435 # (from self.genOpts). Copy other text through unchanged.
436 # If the resulting text is an empty string, do not emit it.
437 body += noneStr(typeElem.text).lstrip()
438 for elem in typeElem:
439 if elem.tag == 'apientry':
440 body += self.genOpts.apientry + noneStr(elem.tail)
441 else:
442 body += noneStr(elem.text) + noneStr(elem.tail)
443
444 if body:
445 self.writeInclude(OutputGenerator.categoryToPath[category],
446 name, body + '\n',
447 self.deprecatedBy(typeinfo),
448 typeinfo.deprecatedlink,
449 typeinfo.supersededby)
450 else:
451 self.logMsg('diag', 'NOT writing empty include file for type', name)
452
453 def genStructBody(self, typeinfo, typeName):
454 """

Callers

nothing calls this directly

Calls 9

genStructMethod · 0.95
genRequirementsMethod · 0.95
writeIncludeMethod · 0.95
deprecatedByMethod · 0.95
noneStrFunction · 0.90
logMsgMethod · 0.80
deprecationCommentMethod · 0.80
makeCDeclsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected