build steps
This commit is contained in:
@@ -26,6 +26,10 @@ CPP_HEADER_NAME_OVERRIDES = {
|
||||
"Generic6DOFJoint3D": "generic6_dof_joint3d",
|
||||
"GradientTexture1D": "gradient_texture1_d",
|
||||
}
|
||||
# godot-cpp 4.5 renamed ClassDB to a ClassDBSingleton wrapper. Map the API
|
||||
# class name to the renamed C++ class and treat all of its methods as static
|
||||
# (so the generated native side calls ClassDBSingleton::get_singleton()->...).
|
||||
SINGLETON_CLASS_CPP_NAMES = {"ClassDB": "ClassDBSingleton"}
|
||||
HANDWRITTEN_PARTIAL_CLASSES = {"GodotObject", "Node"}
|
||||
CS_KEYWORDS = {
|
||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const",
|
||||
@@ -386,14 +390,14 @@ def build_generated_method(class_name, api_method, class_names, classes, global_
|
||||
return GeneratedMethod(
|
||||
class_name=class_name,
|
||||
cs_class_name=cs_class_name(class_name),
|
||||
cpp_class_name=class_name,
|
||||
cpp_class_name=SINGLETON_CLASS_CPP_NAMES.get(class_name, class_name),
|
||||
api_name=api_name,
|
||||
cpp_name=cpp_name,
|
||||
cs_name=cs_name,
|
||||
icall_suffix=icall_suffix,
|
||||
return_type=return_type,
|
||||
args=tuple(args),
|
||||
is_static=bool(api_method.get("is_static")),
|
||||
is_static=bool(api_method.get("is_static")) or class_name in SINGLETON_CLASS_CPP_NAMES,
|
||||
is_virtual=is_virtual,
|
||||
is_vararg=is_vararg,
|
||||
), None, None
|
||||
@@ -3311,7 +3315,10 @@ def generate_native_vararg_method_function(method):
|
||||
for arg in method.args:
|
||||
setup_lines.append(append_formal_vararg("args", arg))
|
||||
setup_lines.append(" append_managed_varargs(args, p_varargs);")
|
||||
target = method.cpp_class_name if method.is_static else "self"
|
||||
if method.is_static and method.class_name in SINGLETON_CLASS_CPP_NAMES:
|
||||
target = f"{method.cpp_class_name}::get_singleton()"
|
||||
else:
|
||||
target = method.cpp_class_name if method.is_static else "self"
|
||||
if method.return_type.category == "void":
|
||||
call_lines = [f" {target}->callv({call_method}, args);", *vararg_return_statement(method, "result").splitlines()]
|
||||
else:
|
||||
@@ -3331,7 +3338,13 @@ def generate_native_method_function(method):
|
||||
params = ([] if method.is_static else ["intptr_t p_native_ptr"]) + [cpp_native_param_declaration(arg) for arg in method.args]
|
||||
call_args = ", ".join(cpp_call_arg(arg) for arg in method.args)
|
||||
if method.is_static:
|
||||
call = f"{method.cpp_class_name}::{method.cpp_name}({call_args})" if call_args else f"{method.cpp_class_name}::{method.cpp_name}()"
|
||||
if method.class_name in SINGLETON_CLASS_CPP_NAMES:
|
||||
# godot-cpp 4.5 exposes ClassDB methods as non-static on
|
||||
# ClassDBSingleton; route them through the singleton instance.
|
||||
target = f"{method.cpp_class_name}::get_singleton()"
|
||||
call = f"{target}->{method.cpp_name}({call_args})" if call_args else f"{target}->{method.cpp_name}()"
|
||||
else:
|
||||
call = f"{method.cpp_class_name}::{method.cpp_name}({call_args})" if call_args else f"{method.cpp_class_name}::{method.cpp_name}()"
|
||||
return f"""{method.return_type.native_type} {fn}({', '.join(params)}) noexcept
|
||||
{{
|
||||
{cpp_return_statement(method, call)}
|
||||
|
||||
Reference in New Issue
Block a user