Skip to content

Commit ca2da27

Browse files
Fix object return value of builtin types' methods.
1 parent 0ddef6e commit ca2da27

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

binding_generator.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,21 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
964964
result.append(method_signature + "{")
965965

966966
method_call = "\t"
967+
need_additional_right_bracke = False
967968
if "return_type" in method:
968-
method_call += f'return internal::_call_builtin_method_ptr_ret<{correct_type(method["return_type"])}>('
969+
return_type = method["return_type"]
970+
if not is_variant(return_type) and\
971+
not is_pod_type(return_type):
972+
if is_refcounted(return_type):
973+
# RefCounted
974+
method_call += f"return Ref<{return_type}>::_gde_internal_constructor("
975+
else:
976+
# Object
977+
method_call += f"return internal::get_object_instance_binding("
978+
method_call += f"internal::_call_builtin_method_ptr_ret<{correct_type(return_type)}>("
979+
need_additional_right_bracke = True
980+
else:
981+
method_call += f"return internal::_call_builtin_method_ptr_ret<{correct_type(return_type)}>("
969982
else:
970983
method_call += "internal::_call_builtin_method_ptr_no_ret("
971984
method_call += f'_method_bindings.method_{method["name"]}, '
@@ -986,7 +999,10 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
986999
result += encode
9871000
arguments.append(arg_name)
9881001
method_call += ", ".join(arguments)
989-
method_call += ");"
1002+
if need_additional_right_bracke:
1003+
method_call += "));"
1004+
else:
1005+
method_call += ");"
9901006

9911007
result.append(method_call)
9921008
result.append("}")

0 commit comments

Comments
 (0)