@@ -964,8 +964,20 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
964964 result .append (method_signature + "{" )
965965
966966 method_call = "\t "
967+ is_ref = False
968+
967969 if "return_type" in method :
968- method_call += f'return internal::_call_builtin_method_ptr_ret<{ correct_type (method ["return_type" ])} >('
970+ return_type = method ["return_type" ]
971+ meta_type = method ["return_value" ]["meta" ] if "meta" in method ["return_value" ] else None
972+ if is_enum (return_type ):
973+ method_call += f"return ({ get_gdextension_type (correct_type (return_type , meta_type ))} )internal::_call_builtin_method_ptr_ret<int64_t>("
974+ elif is_pod_type (return_type ) or is_variant (return_type ):
975+ method_call += f"return internal::_call_builtin_method_ptr_ret<{ get_gdextension_type (correct_type (return_type , meta_type ))} >("
976+ elif is_refcounted (return_type ):
977+ method_call += f"return Ref<{ return_type } >::_gde_internal_constructor(internal::_call_builtin_method_ptr_ret_obj<{ return_type } >("
978+ is_ref = True
979+ else :
980+ method_call += f"return internal::_call_builtin_method_ptr_ret_obj<{ return_type } >("
969981 else :
970982 method_call += "internal::_call_builtin_method_ptr_no_ret("
971983 method_call += f'_method_bindings.method_{ method ["name" ]} , '
@@ -986,6 +998,9 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
986998 result += encode
987999 arguments .append (arg_name )
9881000 method_call += ", " .join (arguments )
1001+
1002+ if is_ref :
1003+ method_call += ")" # Close Ref<> constructor.
9891004 method_call += ");"
9901005
9911006 result .append (method_call )
0 commit comments