From 6e813ecc5e681bcb324352f19be62e9f9b89741c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sat, 2 Mar 2019 16:01:04 +1100 Subject: [PATCH] tools/spec: Don't construct Feature directly from XML --- tools/spec.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) 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')