diff options
author | David Snopek <dsnopek@gmail.com> | 2023-10-04 10:00:52 -0500 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2023-10-04 10:53:17 -0500 |
commit | 55596eaac66036a4e75b0809e6062badba16004b (patch) | |
tree | 439c52c4d9a3578ea19adf773b8864ae3bacf528 /core/extension/gdextension.cpp | |
parent | bfd78bb917887cfc1fd842ba23570394cad8bedb (diff) | |
download | redot-engine-55596eaac66036a4e75b0809e6062badba16004b.tar.gz |
GDExtension: Convert `validated_call()` to `ptrcall()` (rather than `call()`)
Diffstat (limited to 'core/extension/gdextension.cpp')
-rw-r--r-- | core/extension/gdextension.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 7e280466a8..a7c6555615 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -225,29 +225,23 @@ public: // This is added here, but it's unlikely to be provided by most extensions. validated_call_func(method_userdata, extension_instance, reinterpret_cast<GDExtensionConstVariantPtr *>(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); + } } } |