tools/spec: bump spec.xml

This commit is contained in:
Danny Robson 2017-09-05 17:19:51 +10:00
parent 863cdf4a35
commit 116ed2044d
2 changed files with 1624 additions and 2984 deletions

View File

@ -102,12 +102,15 @@ class bitflag(type):
self.values = [] self.values = []
for v in node.findall("./enum"): for v in node.findall("./enum"):
if 'value' in v.attrib: if 'value' in v.attrib:
self.values.append({'name': v.attrib['name'], 'value': v.attrib['value']}) self.add(v.attrib['name'], v.attrib['value'])
elif 'bitpos' in v.attrib: elif 'bitpos' in v.attrib:
self.values.append({'name': v.attrib['name'], 'value': '1 << %s' % v.attrib['bitpos']}) self.add(v.attrib['name'], '1 << %s' % v.attrib['bitpos'])
else: else:
assert False, "unhandled bitmask type" assert False, "unhandled bitmask type"
def add(self, name, value=None):
self.values.append({'name': name, 'value': value})
def depends(self): def depends(self):
if self._depends: if self._depends:
return [self._depends] return [self._depends]
@ -118,7 +121,13 @@ class bitflag(type):
return "" return ""
def define(self): def define(self):
values = map(lambda x: "%(name)s = %(value)s" % x, self.values) values = []
for v in self.values:
if 'value' in v:
values.append("%(name)s = %(value)s" % v)
else:
values.append(v['name'])
return "enum %s { %s };" % (self.name, ", ".join(values)) return "enum %s { %s };" % (self.name, ", ".join(values))
@ -130,19 +139,27 @@ class enum(type):
name = node.attrib['name'] name = node.attrib['name']
super().__init__(name) super().__init__(name)
self.values = map( self.values = list(map(
lambda x: { lambda x: {
'name' : x.attrib['name'], 'name' : x.attrib['name'],
'value': x.attrib['value'] 'value': x.attrib['value']
}, },
node.findall('./enum') node.findall('./enum')
) ))
def add(self,name,value=None):
self.values.append({'name': name, 'value': value})
def declare(self): def declare(self):
return "" return ""
def define(self): def define(self):
values = map(lambda x: "%(name)s = %(value)s" % x, self.values) values = []
for v in self.values:
if v['value']:
values.append("%(name)s = %(value)s" % v)
else:
values.append(v['name'])
return "enum %s { %s };" % ( return "enum %s { %s };" % (
self.name, self.name,
@ -304,6 +321,18 @@ def parse_commands(nodes):
return commands return commands
###############################################################################
def parse_extension(types, node):
r = node.find('require')
for enum in r.findall('./enum'):
if 'extends' in enum.attrib:
types[enum.attrib['extends']].add(name=enum.attrib['name'])
for command in r.findall('./command'):
if not command.attrib['name'] in types:
raise "unknown command"
############################################################################### ###############################################################################
def write_type(dst, types, t): def write_type(dst, types, t):
logging.info("writing: %s", t.name) logging.info("writing: %s", t.name)
@ -328,6 +357,8 @@ def write_types(dst, types):
write_type(dst, types, types[k]) write_type(dst, types, types[k])
##----------------------------------------------------------------------------- ##-----------------------------------------------------------------------------
def write_root(dst, node): def write_root(dst, node):
dst.write (""" dst.write ("""
@ -372,6 +403,9 @@ def write_root(dst, node):
// extract the value for VK_NULL_HANDLE from the XML we'll just // extract the value for VK_NULL_HANDLE from the XML we'll just
// hard code it here. // hard code it here.
#define VK_NULL_HANDLE uintptr_t(0) #define VK_NULL_HANDLE uintptr_t(0)
// TODO: make this correspond to a required version
#define VK_VERSION_1_0
""") """)
types = [] types = []
@ -381,6 +415,9 @@ def write_root(dst, node):
types = dict((t.name,t) for t in types) types = dict((t.name,t) for t in types)
for n in node.findall('./extensions/extension'):
parse_extension(types, n)
write_types(dst, types) write_types(dst, types)
#dst.writelines("\n".join(map(lambda x: x.declare(), types))) #dst.writelines("\n".join(map(lambda x: x.declare(), types)))

4505
vk.xml

File diff suppressed because it is too large Load Diff