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

Method parseTree

scripts/reg.py:695–1039  ·  view source on GitHub ↗

Parse the registry Element, once created

(self)

Source from the content-addressed store, hash-verified

693 self.enumvaluedict[value] = type_name
694
695 def parseTree(self):
696 """Parse the registry Element, once created"""
697 # This must be the Element for the root <registry>
698 if self.tree is None:
699 raise RuntimeError("Tree not initialized!")
700 self.reg = self.tree.getroot()
701
702 # Preprocess the tree in one of the following ways:
703 # - either merge a set of APIs to another API based on their 'api' attributes
704 # - or remove all elements with non-matching 'api' attributes
705 # The preprocessing happens through a breath-first tree traversal.
706 # This is a blunt hammer, but eliminates the need to track and test
707 # the apis deeper in processing to select the correct elements and
708 # avoid duplicates.
709 # Schema validation should prevent duplicate elements with
710 # overlapping api attributes, or where one element has an api
711 # attribute and the other does not.
712
713 if self.genOpts.mergeApiNames:
714 mergeAPIs(self.reg, self.genOpts.mergeApiNames.split(','), self.genOpts.apiname)
715 else:
716 stripNonmatchingAPIs(self.reg, self.genOpts.apiname, actuallyDelete = True)
717
718 # Merge internal features (apitype="internal") into their public dependents
719 # This happens after API merging/stripping so we work with the correct API
720 if self.mergeInternalApis:
721 mergeInternalFeatures(self.reg, self.genOpts.apiname)
722
723 self.aliasdict = {}
724 self.enumvaluedict = {}
725
726 # Get vendor tags
727 vendors = []
728 for tag in self.reg.findall('tags/tag'):
729 vendors.append(tag.get('name'))
730
731 # Function to check which (if any) vendor suffix is present on
732 # an API name
733 def getApiVendorTag(name):
734 for vendor in vendors:
735 n = len(vendor)
736 if name[-n:] == vendor:
737 return vendor
738 return None
739
740 # Create dictionary of registry types from toplevel <types> tags
741 # and add 'name' attribute to each <type> tag (where missing)
742 # based on its <name> element.
743 #
744 # There is usually one <types> block; more are OK
745 # Required <type> attributes: 'name' or nested <name> tag contents
746 self.typedict = {}
747 for type_elem in self.reg.findall('types/type'):
748 # If the <type> does not already have a 'name' attribute, set
749 # it from contents of its <name> tag, or from the contents of
750 # its <proto><name> tag for funcpointer types.
751 name = type_elem.get('name')
752 if name is None:

Callers 2

loadElementTreeMethod · 0.95
loadFileMethod · 0.95

Calls 15

addElementInfoMethod · 0.95
addEnumValueMethod · 0.95
noneStrFunction · 0.90
mergeAPIsFunction · 0.85
stripNonmatchingAPIsFunction · 0.85
mergeInternalFeaturesFunction · 0.85
TypeInfoClass · 0.85
GroupInfoClass · 0.85
EnumInfoClass · 0.85
CmdInfoClass · 0.85
FeatureInfoClass · 0.85
SpirvInfoClass · 0.85

Tested by

no test coverage detected