diff --git a/binding_generator.py b/binding_generator.py index bb1bc3e0..95084922 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -1535,13 +1535,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us result.append("\t \\") for method in class_api["methods"]: - # ClassDBSingleton shouldn't have any static or vararg methods, but if some appear later, lets skip them. - if vararg: - continue + # ClassDBSingleton shouldn't have any static methods, but if some appear later, lets skip them. if "is_static" in method and method["is_static"]: continue - method_signature = "\tstatic " + vararg = "is_vararg" in method and method["is_vararg"] + if vararg: + method_signature = "\ttemplate static " + else: + method_signature = "\tstatic " + return_type = None if "return_type" in method: return_type = correct_type(method["return_type"].replace("ClassDBSingleton", "ClassDB"), None, False) @@ -1563,7 +1566,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us method_arguments = method["arguments"] method_signature += make_function_parameters( - method_arguments, include_default=True, for_builtin=True, is_vararg=False + method_arguments, include_default=True, for_builtin=True, is_vararg=vararg ) method_signature += ") { \\" @@ -1577,6 +1580,8 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us method_body += f"({return_type})" method_body += f'ClassDBSingleton::get_singleton()->{method["name"]}(' method_body += ", ".join(map(lambda x: escape_identifier(x["name"]), method_arguments)) + if vararg: + method_body += ", args..." method_body += "); \\" result.append(method_body) @@ -2224,9 +2229,9 @@ def make_varargs_template( args_array = f"\tstd::array variant_args {{ " for argument in method_arguments: if argument["type"] == "Variant": - args_array += argument["name"] + args_array += escape_identifier(argument["name"]) else: - args_array += f'Variant({argument["name"]})' + args_array += f'Variant({escape_identifier(argument["name"])})' args_array += ", " args_array += "Variant(args)... };" @@ -2426,6 +2431,7 @@ def correct_default_value(value, type_name): "null": "nullptr", '""': "String()", '&""': "StringName()", + '^""': "NodePath()", "[]": "Array()", "{}": "Dictionary()", "Transform2D(1, 0, 0, 1, 0, 0)": "Transform2D()", # Default transform. @@ -2437,6 +2443,10 @@ def correct_default_value(value, type_name): return f"{type_name}()" if value.startswith("Array["): return f"{{}}" + if value.startswith("&"): + return value[1::] + if value.startswith("^"): + return value[1::] return value diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 9cc24b57..87a40895 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -338,10 +338,10 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p return bind; } -#define GDREGISTER_CLASS(m_class) ClassDB::register_class(); -#define GDREGISTER_VIRTUAL_CLASS(m_class) ClassDB::register_class(true); -#define GDREGISTER_ABSTRACT_CLASS(m_class) ClassDB::register_abstract_class(); -#define GDREGISTER_INTERNAL_CLASS(m_class) ClassDB::register_internal_class(); +#define GDREGISTER_CLASS(m_class) ::godot::ClassDB::register_class(); +#define GDREGISTER_VIRTUAL_CLASS(m_class) ::godot::ClassDB::register_class(true); +#define GDREGISTER_ABSTRACT_CLASS(m_class) ::godot::ClassDB::register_abstract_class(); +#define GDREGISTER_INTERNAL_CLASS(m_class) ::godot::ClassDB::register_internal_class(); } // namespace godot diff --git a/src/core/class_db.cpp b/src/core/class_db.cpp index 2f82a352..23ad94f7 100644 --- a/src/core/class_db.cpp +++ b/src/core/class_db.cpp @@ -388,7 +388,7 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) { { std::lock_guard lock(engine_singletons_mutex); singleton_objects.reserve(engine_singletons.size()); - for (const std::pair &pair : engine_singletons) { + for (const std::pair &pair : engine_singletons) { singleton_objects.push_back(pair.second); } } diff --git a/src/core/object.cpp b/src/core/object.cpp index d2e10ffb..410daf85 100644 --- a/src/core/object.cpp +++ b/src/core/object.cpp @@ -75,7 +75,7 @@ MethodInfo::operator Dictionary() const { dict["name"] = name; dict["args"] = internal::convert_property_list(arguments); Array da; - for (int i = 0; i < default_arguments.size(); i++) { + for (size_t i = 0; i < default_arguments.size(); i++) { da.push_back(default_arguments[i]); } dict["default_args"] = da;