diff options
| author | Charles Giessen <charles@lunarg.com> | 2022-10-27 14:11:10 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2022-10-28 17:43:29 -0600 |
| commit | c09f4a4ee47174117e4cad075ae59ce25612fe45 (patch) | |
| tree | 9b0ee83139b048a41ce004889006dea29d20c9a6 /scripts | |
| parent | 25fc297edb10221e321f51addc5fff40023b0dcc (diff) | |
| download | usermoji-c09f4a4ee47174117e4cad075ae59ce25612fe45.tar.xz | |
vulkaninfo: Improve array printing
Make the autogen use for loops instead of outputing printers for each
array element, since its needlessly verbose.
Make UUID and LUID printers use operator<< instead of to_string. This
simplifies the logic and makes sure that the array is printed correctly
everywhere, rather than requiring calling code to use to_string_XX()
where needed.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/vulkaninfo_generator.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index 1eba3e11..4fac2cfa 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -545,11 +545,7 @@ def PrintStructure(struct, types_to_gen, structure_names, aliases): elif v.typeID == "uint8_t" and (v.arrayLength == '8' or v.arrayLength == '16'): # VK_UUID_SIZE if v.arrayLength == '8': out += ' if (obj.deviceLUIDValid) { // special case\n' - out += f''' if (p.Type() == OutputType::json) {{ - ArrayWrapper arr(p, "{v.name}"); - for (uint32_t i = 0; i < {v.arrayLength}; i++) p.PrintElement(static_cast<uint32_t>(obj.{v.name}[i])); - }} else - p.PrintKeyString("{v.name}", to_string_{v.arrayLength}(obj.{v.name}));\n''' + out += f' p.PrintKeyValue("{v.name}", obj.{v.name});\n' if v.arrayLength == '8': out += ' }\n' elif struct.name == "VkQueueFamilyGlobalPriorityPropertiesKHR" and v.name == "priorities": @@ -561,9 +557,8 @@ def PrintStructure(struct, types_to_gen, structure_names, aliases): out += f' p.PrintString(VkQueueGlobalPriorityKHRString(obj.priorities[i]));\n' out += f" }}\n" elif v.arrayLength.isdigit(): - out += f' {{ ArrayWrapper arr(p,"{v.name}", ' + v.arrayLength + ');\n' - for i in range(0, int(v.arrayLength)): - out += f" p.PrintElement(obj.{v.name}[{str(i)}]);\n" + out += f' {{\n ArrayWrapper arr(p,"{v.name}", ' + v.arrayLength + ');\n' + out += f' for (uint32_t i = 0; i < {v.arrayLength}; i++) {{ p.PrintElement(obj.{v.name}[i]); }}\n' out += f" }}\n" else: # dynamic array length based on other member out += f' ArrayWrapper arr(p,"{v.name}", obj.' + v.arrayLength + ');\n' |
