tools/spec: bump spec.xml
This commit is contained in:
parent
863cdf4a35
commit
116ed2044d
@ -102,12 +102,15 @@ class bitflag(type):
|
||||
self.values = []
|
||||
for v in node.findall("./enum"):
|
||||
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:
|
||||
self.values.append({'name': v.attrib['name'], 'value': '1 << %s' % v.attrib['bitpos']})
|
||||
self.add(v.attrib['name'], '1 << %s' % v.attrib['bitpos'])
|
||||
else:
|
||||
assert False, "unhandled bitmask type"
|
||||
|
||||
def add(self, name, value=None):
|
||||
self.values.append({'name': name, 'value': value})
|
||||
|
||||
def depends(self):
|
||||
if self._depends:
|
||||
return [self._depends]
|
||||
@ -118,7 +121,13 @@ class bitflag(type):
|
||||
return ""
|
||||
|
||||
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))
|
||||
|
||||
|
||||
@ -130,19 +139,27 @@ class enum(type):
|
||||
name = node.attrib['name']
|
||||
super().__init__(name)
|
||||
|
||||
self.values = map(
|
||||
self.values = list(map(
|
||||
lambda x: {
|
||||
'name' : x.attrib['name'],
|
||||
'value': x.attrib['value']
|
||||
},
|
||||
node.findall('./enum')
|
||||
)
|
||||
))
|
||||
|
||||
def add(self,name,value=None):
|
||||
self.values.append({'name': name, 'value': value})
|
||||
|
||||
def declare(self):
|
||||
return ""
|
||||
|
||||
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 };" % (
|
||||
self.name,
|
||||
@ -304,6 +321,18 @@ def parse_commands(nodes):
|
||||
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):
|
||||
logging.info("writing: %s", t.name)
|
||||
@ -328,6 +357,8 @@ def write_types(dst, types):
|
||||
write_type(dst, types, types[k])
|
||||
|
||||
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
def write_root(dst, node):
|
||||
dst.write ("""
|
||||
@ -372,6 +403,9 @@ def write_root(dst, node):
|
||||
// extract the value for VK_NULL_HANDLE from the XML we'll just
|
||||
// hard code it here.
|
||||
#define VK_NULL_HANDLE uintptr_t(0)
|
||||
|
||||
// TODO: make this correspond to a required version
|
||||
#define VK_VERSION_1_0
|
||||
""")
|
||||
|
||||
types = []
|
||||
@ -381,6 +415,9 @@ def write_root(dst, node):
|
||||
|
||||
types = dict((t.name,t) for t in types)
|
||||
|
||||
for n in node.findall('./extensions/extension'):
|
||||
parse_extension(types, n)
|
||||
|
||||
write_types(dst, types)
|
||||
|
||||
#dst.writelines("\n".join(map(lambda x: x.declare(), types)))
|
||||
|
Loading…
Reference in New Issue
Block a user