Native structures forward declaration fix
parent
9bc489eb2a
commit
309db943e9
|
@ -72,6 +72,9 @@ builtin_classes = []
|
||||||
# Key is class name, value is boolean where True means the class is refcounted.
|
# Key is class name, value is boolean where True means the class is refcounted.
|
||||||
engine_classes = {}
|
engine_classes = {}
|
||||||
|
|
||||||
|
# Type names of native structures
|
||||||
|
native_structures = []
|
||||||
|
|
||||||
singletons = []
|
singletons = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,7 +240,10 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
result.append("")
|
result.append("")
|
||||||
|
|
||||||
for type_name in used_classes:
|
for type_name in used_classes:
|
||||||
result.append(f"class {type_name};")
|
if is_native_struct(type_name):
|
||||||
|
result.append(f"struct {type_name};")
|
||||||
|
else:
|
||||||
|
result.append(f"class {type_name};")
|
||||||
|
|
||||||
if len(used_classes) > 0:
|
if len(used_classes) > 0:
|
||||||
result.append("")
|
result.append("")
|
||||||
|
@ -753,6 +759,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||||
def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||||
global engine_classes
|
global engine_classes
|
||||||
global singletons
|
global singletons
|
||||||
|
global native_structures
|
||||||
|
|
||||||
include_gen_folder = Path(output_dir) / "include" / "godot_cpp" / "classes"
|
include_gen_folder = Path(output_dir) / "include" / "godot_cpp" / "classes"
|
||||||
source_gen_folder = Path(output_dir) / "src" / "classes"
|
source_gen_folder = Path(output_dir) / "src" / "classes"
|
||||||
|
@ -768,6 +775,8 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||||
engine_classes[class_api["name"]] = class_api["is_refcounted"]
|
engine_classes[class_api["name"]] = class_api["is_refcounted"]
|
||||||
for native_struct in api["native_structures"]:
|
for native_struct in api["native_structures"]:
|
||||||
engine_classes[native_struct["name"]] = False
|
engine_classes[native_struct["name"]] = False
|
||||||
|
native_structures.append(native_struct["name"])
|
||||||
|
|
||||||
for singleton in api["singletons"]:
|
for singleton in api["singletons"]:
|
||||||
singletons.append(singleton["name"])
|
singletons.append(singleton["name"])
|
||||||
|
|
||||||
|
@ -910,7 +919,10 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
result.append("")
|
result.append("")
|
||||||
|
|
||||||
for type_name in used_classes:
|
for type_name in used_classes:
|
||||||
result.append(f"class {type_name};")
|
if is_native_struct(type_name):
|
||||||
|
result.append(f"struct {type_name};")
|
||||||
|
else:
|
||||||
|
result.append(f"class {type_name};")
|
||||||
|
|
||||||
if len(used_classes) > 0:
|
if len(used_classes) > 0:
|
||||||
result.append("")
|
result.append("")
|
||||||
|
@ -1607,6 +1619,11 @@ def is_engine_class(type_name):
|
||||||
return type_name == "Object" or type_name in engine_classes
|
return type_name == "Object" or type_name in engine_classes
|
||||||
|
|
||||||
|
|
||||||
|
def is_native_struct(type_name):
|
||||||
|
global native_structures
|
||||||
|
return type_name in native_structures
|
||||||
|
|
||||||
|
|
||||||
def is_refcounted(type_name):
|
def is_refcounted(type_name):
|
||||||
return type_name in engine_classes and engine_classes[type_name]
|
return type_name in engine_classes and engine_classes[type_name]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue