aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2021-11-29 22:16:33 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-02-02 16:22:12 -0700
commit7a132ba4df38473423a2e1c0d212df2134bebc77 (patch)
treeb29a98aafc25d30d206feabd3cf68cd2b031210f /scripts
parent8070a7b77bdb4f13ffde1ef566421bf20cd9f9b2 (diff)
downloadusermoji-7a132ba4df38473423a2e1c0d212df2134bebc77.tar.xz
vulkaninfo: Use enum names in switches
Replace numeric values with the textual version, this makes it easier to read the code and verify that it is correct.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vulkaninfo_generator.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py
index 44eb238a..50bfcfb0 100644
--- a/scripts/vulkaninfo_generator.py
+++ b/scripts/vulkaninfo_generator.py
@@ -408,7 +408,7 @@ def PrintEnumToString(enum, gen):
out += f"std::string {enum.name}String({enum.name} value) {{\n"
out += f" switch (value) {{\n"
for v in enum.options:
- out += f" case ({str(v.value)}): return \"{v.name[3:]}\";\n"
+ out += f" case ({v.name}): return \"{v.name[3:]}\";\n"
out += f" default: return std::string(\"UNKNOWN_{enum.name}_value\") + std::to_string(value);\n"
out += f" }}\n}}\n"
out += AddGuardFooter(GetExtension(enum.name, gen))
@@ -434,8 +434,7 @@ def PrintGetFlagStrings(name, bitmask):
out += f" std::vector<const char *> strings;\n"
out += f" if (value == 0) {{ strings.push_back(\"None\"); return strings; }}\n"
for v in bitmask.options:
- val = v.value if isinstance(v.value, str) else str(hex(v.value))
- out += f" if ({val} & value) strings.push_back(\"{str(v.name[3:])}\");\n"
+ out += f" if ({v.name} & value) strings.push_back(\"{str(v.name[3:])}\");\n"
out += f" return strings;\n}}\n"
return out
@@ -482,7 +481,7 @@ def PrintBitMaskToString(bitmask, name, gen):
out += f" std::string out;\n"
out += f" bool is_first = true;\n"
for v in bitmask.options:
- out += f" if ({str(v.value)} & value) {{\n"
+ out += f" if ({v.name} & value) {{\n"
out += f" if (is_first) {{ is_first = false; }} else {{ out += \" | \"; }}\n"
out += f" out += \"{str(v.name).strip('VK_').strip('_BIT')}\";\n"
out += f" }}\n"