summaryrefslogtreecommitdiffstats
path: root/src/vulkan/util
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2017-09-15 15:10:56 +0100
committerJason Ekstrand <[email protected]>2017-09-22 07:47:34 -0700
commit7e90fc54e5807f45d9a4655aa592ab8b8225c4a8 (patch)
tree585acb531bb85f502900c4de16a947d3a3f77bf9 /src/vulkan/util
parent935b42d9bc92db11a1b0d471c6de368b49a1604c (diff)
vulkan: enum generator: make registry more flexible
It will be used to store extension numbers as well. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/vulkan/util')
-rw-r--r--src/vulkan/util/gen_enum_to_str.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index c615ed08c48..3c9f260595b 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -115,18 +115,18 @@ FOREIGN_ENUM_VALUES = [
]
-class EnumFactory(object):
+class NamedFactory(object):
"""Factory for creating enums."""
def __init__(self, type_):
self.registry = {}
self.type = type_
- def __call__(self, name):
+ def __call__(self, name, **kwargs):
try:
return self.registry[name]
except KeyError:
- n = self.registry[name] = self.type(name)
+ n = self.registry[name] = self.type(name, **kwargs)
return n
@@ -138,7 +138,7 @@ class VkEnum(object):
self.values = values or []
-def parse_xml(efactory, filename):
+def parse_xml(enum_factory, filename):
"""Parse the XML file. Accumulate results into the efactory.
This parser is a memory efficient iterative XML parser that returns a list
@@ -157,14 +157,14 @@ def parse_xml(efactory, filename):
if event == 'end' and elem.tag == 'enums':
type_ = elem.attrib.get('type')
if type_ == 'enum':
- enum = efactory(elem.attrib['name'])
+ enum = enum_factory(elem.attrib['name'])
enum.values.extend([e.attrib['name'] for e in elem
if e.tag == 'enum'])
elif event == 'end' and elem.tag == 'extension':
if elem.attrib['supported'] != 'vulkan':
continue
for e in elem.findall('.//enum[@extends][@offset]'):
- enum = efactory(e.attrib['extends'])
+ enum = enum_factory(e.attrib['extends'])
enum.values.append(e.attrib['name'])
root.clear()
@@ -182,10 +182,10 @@ def main():
args = parser.parse_args()
- efactory = EnumFactory(VkEnum)
+ enum_factory = NamedFactory(VkEnum)
for filename in args.xml_files:
- parse_xml(efactory, filename)
- enums = sorted(efactory.registry.values(), key=lambda e: e.name)
+ parse_xml(enum_factory, filename)
+ enums = sorted(enum_factory.registry.values(), key=lambda e: e.name)
for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
(H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h'))]: