Skip to content

Commit

Permalink
Add tostring.py improvements from Chameleon
Browse files Browse the repository at this point in the history
  • Loading branch information
per-mathisen-arm committed Apr 8, 2024
1 parent 188d21e commit 686f750
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/tostring.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,36 @@
if pos and not name in added_case:
print('\t\tcase %s: result += "%s"; break;' % (name, name), file=source)
added_case.append(name)

# Find and add post-1.0 variants
for feat in spec.root.findall('feature'):
api = feat.attrib.get('api', '').split(',')
if api and not 'vulkan' in api: continue
for bit in feat.findall('require/enum'):
extends = bit.attrib.get('extends')
if extends == rname:
name = bit.attrib.get('name')
pos = bit.attrib.get('bitpos')
if pos and not name in added_case:
print('\t\tcase %s: result += "%s"; break;' % (name, name), file=source)
added_case.append(name)

# Find and add extensions enums
for ext in spec.root.findall('extensions/extension'):
supported = ext.attrib.get('supported')
if supported in ['disabled', 'vulkansc']: continue
supported = ext.attrib.get('supported', '').split(',')
if supported and not 'vulkan' in supported: continue
for vv in ext.findall('require'):
for bit in vv.findall('enum'):
extends = bit.attrib.get('extends')
if extends == ename:
name = bit.attrib.get('name')
pos = bit.attrib.get('bitpos')
prot = bit.attrib.get('protect')
if pos and not name in added_case:
if prot: print('#ifdef %s' % prot, file=source)
print('\t\tcase %s: result += "%s"; break;' % (name, name), file=source)
added_case.append(name)
if prot: print('#endif', file=source)
print('\t\tdefault: result += "Bad bitfield value"; break;', file=source)
print('\t\t}', file=source)
print('\t\tflags &= ~(1 << bit); // remove bit', file=source)
Expand Down

0 comments on commit 686f750

Please sign in to comment.