Skip to content

Commit 769c268

Browse files
committed
Revert the changes from PR godotengine#1044 and godotengine#1045
1 parent 6250c3f commit 769c268

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

include/godot_cpp/classes/ref.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ class Ref {
229229
template <class T>
230230
struct PtrToArg<Ref<T>> {
231231
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
232-
// Important: p_ptr is T*, not Ref<T>*, since Object* is what engine gives to ptrcall.
232+
GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr;
233233
ERR_FAIL_NULL_V(p_ptr, Ref<T>());
234-
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr)))));
234+
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))));
235235
}
236236

237237
typedef Ref<T> EncodeT;
@@ -253,8 +253,9 @@ struct PtrToArg<const Ref<T> &> {
253253
typedef Ref<T> EncodeT;
254254

255255
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
256+
GDExtensionRefPtr ref = const_cast<GDExtensionRefPtr>(p_ptr);
256257
ERR_FAIL_NULL_V(p_ptr, Ref<T>());
257-
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr)))));
258+
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))));
258259
}
259260
};
260261

include/godot_cpp/core/method_ptrcall.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
169169
template <class T>
170170
struct PtrToArg<T *> {
171171
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
172-
return reinterpret_cast<T *>(godot::internal::get_object_instance_binding(reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr))));
172+
return reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
173173
}
174174
typedef Object *EncodeT;
175175
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
@@ -180,7 +180,7 @@ struct PtrToArg<T *> {
180180
template <class T>
181181
struct PtrToArg<const T *> {
182182
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
183-
return reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr))));
183+
return reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
184184
}
185185
typedef const Object *EncodeT;
186186
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {

0 commit comments

Comments
 (0)