diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index e295a2b30aa1..a4d4b9161e12 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -225,29 +225,23 @@ class GDExtensionMethodBind : public MethodBind { // This is added here, but it's unlikely to be provided by most extensions. validated_call_func(method_userdata, extension_instance, reinterpret_cast(p_args), (GDExtensionVariantPtr)r_ret); } else { -#if 1 - // Slow code-path, but works for the time being. - Callable::CallError ce; - call(p_object, p_args, argument_count, ce); -#else - // This is broken, because it needs more information to do the calling properly - // If not provided, go via ptrcall, which is faster than resorting to regular call. const void **argptrs = (const void **)alloca(argument_count * sizeof(void *)); for (uint32_t i = 0; i < argument_count; i++) { argptrs[i] = VariantInternal::get_opaque_pointer(p_args[i]); } - bool returns = true; - void *ret_opaque; - if (returns) { + void *ret_opaque = nullptr; + if (r_ret) { + VariantInternal::initialize(r_ret, return_value_info.type); ret_opaque = VariantInternal::get_opaque_pointer(r_ret); - } else { - ret_opaque = nullptr; // May be unnecessary as this is ignored, but just in case. } ptrcall(p_object, argptrs, ret_opaque); -#endif + + if (r_ret && r_ret->get_type() == Variant::OBJECT) { + VariantInternal::update_object_id(r_ret); + } } } diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 782053b613e3..116210e8dea2 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -418,7 +418,7 @@ class VariantInternal { case Variant::PACKED_COLOR_ARRAY: return get_color_array(v); case Variant::OBJECT: - return v->_get_obj().obj; + return get_object(v); case Variant::VARIANT_MAX: ERR_FAIL_V(nullptr); }