From f5858ef6c69259c6f0d078e7ee45c0c6283572b0 Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 8 Sep 2021 15:07:23 -0300 Subject: [PATCH] Fix calling of native functions that return object types --- binding_generator.py | 4 ++-- include/godot_cpp/core/engine_ptrcall.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index 48b34aea..077af731 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -448,7 +448,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl result.append("String operator+(const wchar_t *p_chr, const String &p_str);") result.append("String operator+(const char16_t *p_chr, const String &p_str);") result.append("String operator+(const char32_t *p_chr, const String &p_str);") - + result.append("") result.append("} // namespace godot") @@ -1056,7 +1056,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner" is_ref = True else: - method_call += f"return ({correct_type(return_type)})internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner" + method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner" else: method_call += f"internal::_call_native_mb_no_ret(___method_bind, _owner" diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index 636a0c24..3cb9ae03 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -44,11 +44,11 @@ namespace godot { namespace internal { template -Object *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { +O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { GodotObject *ret = nullptr; std::array mb_args = { { (const GDNativeTypePtr)args... } }; internal::interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); - return (Object *)internal::interface->object_get_instance_binding(ret, internal::token, &O::___binding_callbacks); + return reinterpret_cast(internal::interface->object_get_instance_binding(ret, internal::token, &O::___binding_callbacks)); } template