Skip to content

Commit 0f94325

Browse files
committed
Allow using unions and structs in the native structure definition.
1 parent 6a87094 commit 0f94325

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

binding_generator.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
15241524
expanded_format = native_struct["format"].replace("(", " ").replace(")", ";").replace(",", ";")
15251525
for field in expanded_format.split(";"):
15261526
field_type = field.strip().split(" ")[0].split("::")[0]
1527-
if field_type != "" and not is_included_type(field_type) and not is_pod_type(field_type):
1527+
if field_type != "" and field_type != "{" and field_type != "}" and field_type != "union" and field_type != "struct" and not is_included_type(field_type) and not is_pod_type(field_type):
15281528
if field_type not in used_classes:
15291529
used_classes.append(field_type)
15301530

@@ -1548,9 +1548,18 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
15481548
result.append("")
15491549

15501550
result.append(f"struct {struct_name} {{")
1551+
indent = 1
15511552
for field in native_struct["format"].split(";"):
15521553
if field != "":
1553-
result.append(f"\t{field};")
1554+
if "}" in field:
1555+
indent -= 1
1556+
if "{" in field:
1557+
parts = field.split("{")
1558+
result.append(f"{'\t' * indent}{parts[0]}{{")
1559+
indent += 1
1560+
result.append(f"{'\t' * indent}{parts[1]};")
1561+
else:
1562+
result.append(f"{'\t' * indent}{field};")
15541563
result.append("};")
15551564

15561565
result.append("")

0 commit comments

Comments
 (0)