Merge pull request #1485 from dsnopek/classdb-call-static-method
Fix vararg methods forwarded to the `ClassDB` singletonpull/1490/head
commit
64f1bc847a
|
@ -1670,13 +1670,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
result.append("\t \\")
|
result.append("\t \\")
|
||||||
|
|
||||||
for method in class_api["methods"]:
|
for method in class_api["methods"]:
|
||||||
# ClassDBSingleton shouldn't have any static or vararg methods, but if some appear later, lets skip them.
|
# ClassDBSingleton shouldn't have any static methods, but if some appear later, lets skip them.
|
||||||
if vararg:
|
|
||||||
continue
|
|
||||||
if "is_static" in method and method["is_static"]:
|
if "is_static" in method and method["is_static"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
method_signature = "\tstatic "
|
vararg = "is_vararg" in method and method["is_vararg"]
|
||||||
|
if vararg:
|
||||||
|
method_signature = "\ttemplate<typename... Args> static "
|
||||||
|
else:
|
||||||
|
method_signature = "\tstatic "
|
||||||
|
|
||||||
return_type = None
|
return_type = None
|
||||||
if "return_type" in method:
|
if "return_type" in method:
|
||||||
return_type = correct_type(method["return_type"].replace("ClassDBSingleton", "ClassDB"), None, False)
|
return_type = correct_type(method["return_type"].replace("ClassDBSingleton", "ClassDB"), None, False)
|
||||||
|
@ -1698,7 +1701,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
method_arguments = method["arguments"]
|
method_arguments = method["arguments"]
|
||||||
|
|
||||||
method_signature += make_function_parameters(
|
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 += ") { \\"
|
method_signature += ") { \\"
|
||||||
|
@ -1712,6 +1715,8 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
method_body += f"({return_type})"
|
method_body += f"({return_type})"
|
||||||
method_body += f'ClassDBSingleton::get_singleton()->{method["name"]}('
|
method_body += f'ClassDBSingleton::get_singleton()->{method["name"]}('
|
||||||
method_body += ", ".join(map(lambda x: escape_identifier(x["name"]), method_arguments))
|
method_body += ", ".join(map(lambda x: escape_identifier(x["name"]), method_arguments))
|
||||||
|
if vararg:
|
||||||
|
method_body += ", args..."
|
||||||
method_body += "); \\"
|
method_body += "); \\"
|
||||||
|
|
||||||
result.append(method_body)
|
result.append(method_body)
|
||||||
|
@ -2359,9 +2364,9 @@ def make_varargs_template(
|
||||||
args_array = f"\tstd::array<Variant, {len(method_arguments)} + sizeof...(Args)> variant_args {{ "
|
args_array = f"\tstd::array<Variant, {len(method_arguments)} + sizeof...(Args)> variant_args {{ "
|
||||||
for argument in method_arguments:
|
for argument in method_arguments:
|
||||||
if argument["type"] == "Variant":
|
if argument["type"] == "Variant":
|
||||||
args_array += argument["name"]
|
args_array += escape_identifier(argument["name"])
|
||||||
else:
|
else:
|
||||||
args_array += f'Variant({argument["name"]})'
|
args_array += f'Variant({escape_identifier(argument["name"])})'
|
||||||
args_array += ", "
|
args_array += ", "
|
||||||
|
|
||||||
args_array += "Variant(args)... };"
|
args_array += "Variant(args)... };"
|
||||||
|
|
Loading…
Reference in New Issue