From c09f4a4ee47174117e4cad075ae59ce25612fe45 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Thu, 27 Oct 2022 14:11:10 -0600 Subject: 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. --- scripts/vulkaninfo_generator.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'scripts/vulkaninfo_generator.py') 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(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' -- cgit v1.2.3