summaryrefslogtreecommitdiffstats
path: root/core/object
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-05-23 15:14:01 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-05-25 21:46:22 -0500
commit77733faedea4bb9bc0fa148b576aaf737e96889a (patch)
treee55edf69ddb03d465c3800c6a40a321b6024dfd4 /core/object
parent2eec9a67d564b11326f44c5ef8b6b6f9aec251b9 (diff)
downloadredot-engine-77733faedea4bb9bc0fa148b576aaf737e96889a.tar.gz
Attempt to standardize Object ptrcall encoding on `Object **`
Diffstat (limited to 'core/object')
-rw-r--r--core/object/ref_counted.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h
index 58706fb9a9..3386514706 100644
--- a/core/object/ref_counted.h
+++ b/core/object/ref_counted.h
@@ -242,8 +242,11 @@ public:
template <class T>
struct PtrToArg<Ref<T>> {
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
+ if (p_ptr == nullptr) {
+ return Ref<T>();
+ }
// p_ptr points to a RefCounted object
- return Ref<T>(const_cast<T *>(reinterpret_cast<const T *>(p_ptr)));
+ return Ref<T>(const_cast<T *>(*reinterpret_cast<T *const *>(p_ptr)));
}
typedef Ref<T> EncodeT;
@@ -259,8 +262,11 @@ struct PtrToArg<const Ref<T> &> {
typedef Ref<T> EncodeT;
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
+ if (p_ptr == nullptr) {
+ return Ref<T>();
+ }
// p_ptr points to a RefCounted object
- return Ref<T>((T *)p_ptr);
+ return Ref<T>(*((T *const *)p_ptr));
}
};