aboutsummaryrefslogtreecommitdiffstats
path: root/src/vulkan/util
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-06-26 13:35:54 -0500
committerJason Ekstrand <[email protected]>2019-11-26 02:48:42 +0000
commit121551bfdb07786c8e26b712d87c8564bda556b4 (patch)
treee72322ceb1dc809fc6acd8d2a72e692e2efa6cf4 /src/vulkan/util
parentf6aa51103b134b2cfdc4517cf251a180bd71cebc (diff)
vulkan/enum_to_str: Handle out-of-order aliases
The current code can only handle enum aliases if the original enum is declared first followed by the alias as we walk the XML in a linear fashion. This commit allows us to handle aliases where the alias declaration comes before the thing it's aliasing. Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/vulkan/util')
-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: