diff --git a/tools/spec.py b/tools/spec.py index df3f921..2e1954f 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -524,18 +524,9 @@ class Require(object): # ----------------------------------------------------------------------------- class Feature(Type): - def __init__(self, root): - assert root.tag == 'feature' - - name = root.attrib['name'] + def __init__(self, name: str, requires: List[Require] = []): super().__init__(name) - - self.requires = [] - for node in root: - if 'require' == node.tag: - self.requires.append(Require(node)) - else: - raise RuntimeError("Unhandled feature node") + self.requires = requires def define(self, reg: Registry): return "#define %s" % self.name @@ -701,7 +692,14 @@ def parse_feature(reg: Registry, root): name = root.attrib['name'] assert name not in reg.features - reg.features[name] = Feature(root) + requires = [] + for node in root: + if 'require' == node.tag: + requires.append(Require(node)) + else: + raise RuntimeError("Unhandled feature node") + + reg.features[name] = Feature(name, requires) reg.types[name] = reg.features[name] @@ -915,8 +913,8 @@ def main(): reg.types['VK_NULL_HANDLE'] = AliasValue("VK_NULL_HANDLE", "nullptr") # Request serialisation of all features - features = [Feature(n) for n in root.findall('./feature')] - features = dict((f.name,f) for f in features) + #features = [Feature(n) for n in root.findall('./feature')] + #features = dict((f.name,f) for f in features) #reg.extensions['VK_KHR_surface'].apply(reg, platform='xcb')