tools/spec: Don't construct Feature directly from XML

This commit is contained in:
Danny Robson 2019-03-02 16:01:04 +11:00
parent c3d51883cb
commit 6e813ecc5e

View File

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