Merge pull request #1320 from mihe/bit-field-size

Change bit field enums to use `uint64_t` as underlying type
pull/1321/head
Rémi Verschelde 2023-11-28 15:05:41 +01:00 committed by GitHub
commit f3143c7a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -1329,7 +1329,11 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
if "enums" in class_api: if "enums" in class_api:
for enum_api in class_api["enums"]: for enum_api in class_api["enums"]:
if enum_api["is_bitfield"]:
result.append(f'\tenum {enum_api["name"]} : uint64_t {{')
else:
result.append(f'\tenum {enum_api["name"]} {{') result.append(f'\tenum {enum_api["name"]} {{')
for value in enum_api["values"]: for value in enum_api["values"]:
result.append(f'\t\t{value["name"]} = {value["value"]},') result.append(f'\t\t{value["name"]} = {value["value"]},')
result.append("\t};") result.append("\t};")
@ -1686,6 +1690,8 @@ def generate_global_constants(api, output_dir):
header.append(f"#ifndef {header_guard}") header.append(f"#ifndef {header_guard}")
header.append(f"#define {header_guard}") header.append(f"#define {header_guard}")
header.append("") header.append("")
header.append("#include <cstdint>")
header.append("")
header.append("namespace godot {") header.append("namespace godot {")
header.append("") header.append("")
@ -1698,7 +1704,11 @@ def generate_global_constants(api, output_dir):
if enum_def["name"].startswith("Variant."): if enum_def["name"].startswith("Variant."):
continue continue
if enum_def["is_bitfield"]:
header.append(f'\tenum {enum_def["name"]} : uint64_t {{')
else:
header.append(f'\tenum {enum_def["name"]} {{') header.append(f'\tenum {enum_def["name"]} {{')
for value in enum_def["values"]: for value in enum_def["values"]:
header.append(f'\t\t{value["name"]} = {value["value"]},') header.append(f'\t\t{value["name"]} = {value["value"]},')
header.append("\t};") header.append("\t};")