Merge pull request #703 from AlphaSoftLLC/fix_struct_forward_declaration
commit
1863bd88ad
|
@ -99,6 +99,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 = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,6 +269,9 @@ 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:
|
||||||
|
if is_native_struct(type_name):
|
||||||
|
result.append(f"struct {type_name};")
|
||||||
|
else:
|
||||||
result.append(f"class {type_name};")
|
result.append(f"class {type_name};")
|
||||||
|
|
||||||
if len(used_classes) > 0:
|
if len(used_classes) > 0:
|
||||||
|
@ -792,6 +798,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"
|
||||||
|
@ -807,6 +814,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"])
|
||||||
|
|
||||||
|
@ -971,6 +980,9 @@ 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:
|
||||||
|
if is_native_struct(type_name):
|
||||||
|
result.append(f"struct {type_name};")
|
||||||
|
else:
|
||||||
result.append(f"class {type_name};")
|
result.append(f"class {type_name};")
|
||||||
|
|
||||||
if len(used_classes) > 0:
|
if len(used_classes) > 0:
|
||||||
|
@ -1764,6 +1776,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