aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vulkan/util/gen_enum_to_str.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index b65bc7f7ef6..035aa02a172 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -258,10 +258,23 @@ class VkEnum(object):
self.values = values or dict()
self.name_to_value = dict()
self.guard = None
+ self.name_to_alias_list = {}
def add_value(self, name, value=None,
- extnum=None, offset=None,
+ extnum=None, offset=None, alias=None,
error=False):
+ if alias is not None:
+ assert value is None and offset is None
+ if alias not in self.name_to_value:
+ # We don't have this alias yet. Just record the alias and
+ # we'll deal with it later.
+ alias_list = self.name_to_alias_list.get(alias, [])
+ alias_list.append(name);
+ return
+
+ # Use the value from the alias
+ value = self.name_to_value[alias]
+
assert value is not None or extnum is not None
if value is None:
value = 1000000000 + (extnum - 1) * 1000 + offset
@@ -274,14 +287,19 @@ class VkEnum(object):
elif len(self.values[value]) > len(name):
self.values[value] = name
+ # Now that the value has been fully added, resolve aliases, if any.
+ if name in self.name_to_alias_list:
+ for alias in self.name_to_alias_list[name]:
+ add_value(alias, value)
+ del self.name_to_alias_list[name]
+
def add_value_from_xml(self, elem, extension=None):
self.extension = extension
if 'value' in elem.attrib:
self.add_value(elem.attrib['name'],
value=int(elem.attrib['value'], base=0))
elif 'alias' in elem.attrib:
- self.add_value(elem.attrib['name'],
- value=self.name_to_value[elem.attrib['alias']])
+ self.add_value(elem.attrib['name'], alias=elem.attrib['alias'])
else:
error = 'dir' in elem.attrib and elem.attrib['dir'] == '-'
if 'extnumber' in elem.attrib: