summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-01-23 19:43:00 -0800
committerJason Ekstrand <[email protected]>2018-03-07 12:13:47 -0800
commit539a0aec451583fdb53abb9f3c45c722ab2e4a17 (patch)
treea42cd0a8fa64d94b71a1e6439faa00e41b7a92eb /src
parenteb23ca069fa15bb2c0527a741e49ea47c4ab2fae (diff)
vulkan/enum_to_str: Add a add_value_from_xml helper to VkEnum
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/util/gen_enum_to_str.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index b19d6de9f2f..6182055442f 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -165,6 +165,18 @@ class VkEnum(object):
if value not in self.values:
self.values[value] = name
+ def add_value_from_xml(self, elem, extension=None):
+ if 'value' in elem.attrib:
+ self.add_value(elem.attrib['name'],
+ value=int(elem.attrib['value']))
+ else:
+ error = 'dir' in elem.attrib and elem.attrib['dir'] == '-'
+ print(elem.attrib['name'])
+ self.add_value(elem.attrib['name'],
+ extension=extension,
+ offset=int(elem.attrib['offset']),
+ error=error)
+
def parse_xml(enum_factory, ext_factory, filename):
"""Parse the XML file. Accumulate results into the factories.
@@ -178,8 +190,7 @@ def parse_xml(enum_factory, ext_factory, filename):
for enum_type in xml.findall('./enums[@type="enum"]'):
enum = enum_factory(enum_type.attrib['name'])
for value in enum_type.findall('./enum'):
- enum.add_value(value.attrib['name'],
- value=int(value.attrib['value']))
+ enum.add_value_from_xml(value)
for ext_elem in xml.findall('./extensions/extension[@supported="vulkan"]'):
extension = ext_factory(ext_elem.attrib['name'],
@@ -187,17 +198,8 @@ def parse_xml(enum_factory, ext_factory, filename):
for value in ext_elem.findall('./require/enum[@extends]'):
enum = enum_factory.get(value.attrib['extends'])
- if enum is None:
- continue
- if 'value' in value.attrib:
- enum.add_value(value.attrib['name'],
- value=int(value.attrib['value']))
- else:
- error = 'dir' in value.attrib and value.attrib['dir'] == '-'
- enum.add_value(value.attrib['name'],
- extension=extension,
- offset=int(value.attrib['offset']),
- error=error)
+ if enum is not None:
+ enum.add_value_from_xml(value, extension)
def main():