From fd8c249f57791033482fe2ea2210bde210c1d804 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Tue, 23 May 2023 15:17:06 -0500 Subject: [PATCH] Revert the changes from PR #1044 and #1045 --- include/godot_cpp/classes/ref.hpp | 7 ++++--- include/godot_cpp/core/method_ptrcall.hpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index b80227d9f7..038f6712f1 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -229,9 +229,9 @@ class Ref { template struct PtrToArg> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { - // Important: p_ptr is T*, not Ref*, since Object* is what engine gives to ptrcall. + GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr; ERR_FAIL_NULL_V(p_ptr, Ref()); - return Ref(reinterpret_cast(godot::internal::get_object_instance_binding(reinterpret_cast(const_cast(p_ptr))))); + return Ref(reinterpret_cast(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))); } typedef Ref EncodeT; @@ -253,8 +253,9 @@ struct PtrToArg &> { typedef Ref EncodeT; _FORCE_INLINE_ static Ref convert(const void *p_ptr) { + GDExtensionRefPtr ref = const_cast(p_ptr); ERR_FAIL_NULL_V(p_ptr, Ref()); - return Ref(reinterpret_cast(godot::internal::get_object_instance_binding(reinterpret_cast(const_cast(p_ptr))))); + return Ref(reinterpret_cast(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))); } }; diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 283f4b042d..a85cbc94c1 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -169,7 +169,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant); template struct PtrToArg { _FORCE_INLINE_ static T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::get_object_instance_binding(reinterpret_cast(const_cast(p_ptr)))); + return reinterpret_cast(godot::internal::get_object_instance_binding(*reinterpret_cast(const_cast(p_ptr)))); } typedef Object *EncodeT; _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { @@ -180,7 +180,7 @@ struct PtrToArg { template struct PtrToArg { _FORCE_INLINE_ static const T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::get_object_instance_binding(reinterpret_cast(const_cast(p_ptr)))); + return reinterpret_cast(godot::internal::get_object_instance_binding(*reinterpret_cast(const_cast(p_ptr)))); } typedef const Object *EncodeT; _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {