Merge pull request #1492 from dsnopek/4.2-cherrypicks-5
Cherry-picks for the godot-cpp 4.2 branch - 5th batchpull/1524/head
commit
9da6ecd144
|
@ -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
|
||||
|
||||
vararg = "is_vararg" in method and method["is_vararg"]
|
||||
if vararg:
|
||||
method_signature = "\ttemplate<typename... Args> 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, {len(method_arguments)} + sizeof...(Args)> 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
|
||||
|
||||
|
||||
|
|
|
@ -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<m_class>();
|
||||
#define GDREGISTER_VIRTUAL_CLASS(m_class) ClassDB::register_class<m_class>(true);
|
||||
#define GDREGISTER_ABSTRACT_CLASS(m_class) ClassDB::register_abstract_class<m_class>();
|
||||
#define GDREGISTER_INTERNAL_CLASS(m_class) ClassDB::register_internal_class<m_class>();
|
||||
#define GDREGISTER_CLASS(m_class) ::godot::ClassDB::register_class<m_class>();
|
||||
#define GDREGISTER_VIRTUAL_CLASS(m_class) ::godot::ClassDB::register_class<m_class>(true);
|
||||
#define GDREGISTER_ABSTRACT_CLASS(m_class) ::godot::ClassDB::register_abstract_class<m_class>();
|
||||
#define GDREGISTER_INTERNAL_CLASS(m_class) ::godot::ClassDB::register_internal_class<m_class>();
|
||||
|
||||
} // namespace godot
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) {
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(engine_singletons_mutex);
|
||||
singleton_objects.reserve(engine_singletons.size());
|
||||
for (const std::pair<StringName, Object *> &pair : engine_singletons) {
|
||||
for (const std::pair<const StringName, Object *> &pair : engine_singletons) {
|
||||
singleton_objects.push_back(pair.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue