GDExtension: Convert validated_call() to ptrcall() (rather than call())

This commit is contained in:
David Snopek 2023-10-04 10:00:52 -05:00
parent bfd78bb917
commit 55596eaac6
2 changed files with 8 additions and 14 deletions

View File

@ -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);
}
}
}

View File

@ -418,7 +418,7 @@ public:
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);
}