diff options
| author | NoahR02 <noahreppert95@protonmail.com> | 2023-05-20 18:40:38 -0400 |
|---|---|---|
| committer | NoahR02 <noahreppert95@protonmail.com> | 2023-05-20 18:42:49 -0400 |
| commit | c5c723b80ca6705b4234c6fac01a41356e1982ee (patch) | |
| tree | e85d3eb51d502adc45c9ef5435fdb986a49ac6b2 | |
| parent | 66461c9dbc2baae8d4ed4f8585713f8649cee2d2 (diff) | |
Parse C bit fields in parse_structs
| -rw-r--r-- | vendor/vulkan/_gen/create_vulkan_odin_wrapper.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py index e90c32659..79962ada9 100644 --- a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py +++ b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py @@ -64,6 +64,7 @@ def convert_type(t, prev_name, curr_name): 'int64_t': 'i64', 'int': 'c.int', 'uint8_t': 'u8', + 'int8_t': 'i8', "uint16_t": 'u16', "char": "byte", "void": "void", @@ -430,6 +431,18 @@ def parse_structs(f): prev_name = "" ffields = [] for type_, fname in fields: + + # If the typename has a colon in it, then it is a C bit field. + if ":" in type_: + bit_field = type_.split(' ') + # Get rid of empty spaces + bit_field = list(filter(bool, bit_field)) + # [type, typename, :] + assert len(bit_field) == 3, "Failed to parse the bit field!" + bit_field_type = do_type(bit_field[0], prev_name, fname) + f.write("\tbit_field: {},{}\n".format(bit_field_type, comment or "")) + break + if '[' in fname: fname, type_ = parse_array(fname, type_) comment = None @@ -443,7 +456,7 @@ def parse_structs(f): ffields.append(tuple([n, t, comment])) prev_name = fname - max_len = max(len(n) for n, _, _ in ffields) + max_len = max([len(n) for n, _, _ in ffields], default=0) for n, t, comment in ffields: k = max_len-len(n)+len(t) |