Skip to content

Commit f3143c7

Browse files
authored
Merge pull request godotengine#1320 from mihe/bit-field-size
Change bit field enums to use `uint64_t` as underlying type
2 parents 588d869 + 943d1c8 commit f3143c7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

binding_generator.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,11 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
13291329

13301330
if "enums" in class_api:
13311331
for enum_api in class_api["enums"]:
1332-
result.append(f'\tenum {enum_api["name"]} {{')
1332+
if enum_api["is_bitfield"]:
1333+
result.append(f'\tenum {enum_api["name"]} : uint64_t {{')
1334+
else:
1335+
result.append(f'\tenum {enum_api["name"]} {{')
1336+
13331337
for value in enum_api["values"]:
13341338
result.append(f'\t\t{value["name"]} = {value["value"]},')
13351339
result.append("\t};")
@@ -1686,6 +1690,8 @@ def generate_global_constants(api, output_dir):
16861690
header.append(f"#ifndef {header_guard}")
16871691
header.append(f"#define {header_guard}")
16881692
header.append("")
1693+
header.append("#include <cstdint>")
1694+
header.append("")
16891695
header.append("namespace godot {")
16901696
header.append("")
16911697

@@ -1698,7 +1704,11 @@ def generate_global_constants(api, output_dir):
16981704
if enum_def["name"].startswith("Variant."):
16991705
continue
17001706

1701-
header.append(f'\tenum {enum_def["name"]} {{')
1707+
if enum_def["is_bitfield"]:
1708+
header.append(f'\tenum {enum_def["name"]} : uint64_t {{')
1709+
else:
1710+
header.append(f'\tenum {enum_def["name"]} {{')
1711+
17021712
for value in enum_def["values"]:
17031713
header.append(f'\t\t{value["name"]} = {value["value"]},')
17041714
header.append("\t};")

0 commit comments

Comments
 (0)