diff --git a/core/variant/native_ptr.h b/core/variant/native_ptr.h index ea811daabf0..9199b128458 100644 --- a/core/variant/native_ptr.h +++ b/core/variant/native_ptr.h @@ -53,36 +53,46 @@ struct GDExtensionPtr { operator Variant() const { return uint64_t(data); } }; -#define GDVIRTUAL_NATIVE_PTR(m_type) \ - template <> \ - struct GDExtensionConstPtr { \ - const m_type *data = nullptr; \ - GDExtensionConstPtr() {} \ - GDExtensionConstPtr(const m_type *p_assign) { data = p_assign; } \ - static const char *get_name() { return "const " #m_type; } \ - operator const m_type *() const { return data; } \ - operator Variant() const { return uint64_t(data); } \ - }; \ - template <> \ - struct VariantCaster> { \ - static _FORCE_INLINE_ GDExtensionConstPtr cast(const Variant &p_variant) { \ - return GDExtensionConstPtr((const m_type *)p_variant.operator uint64_t()); \ - } \ - }; \ - template <> \ - struct GDExtensionPtr { \ - m_type *data = nullptr; \ - GDExtensionPtr() {} \ - GDExtensionPtr(m_type *p_assign) { data = p_assign; } \ - static const char *get_name() { return #m_type; } \ - operator m_type *() const { return data; } \ - operator Variant() const { return uint64_t(data); } \ - }; \ - template <> \ - struct VariantCaster> { \ - static _FORCE_INLINE_ GDExtensionPtr cast(const Variant &p_variant) { \ - return GDExtensionPtr((m_type *)p_variant.operator uint64_t()); \ - } \ +#define GDVIRTUAL_NATIVE_PTR(m_type) \ + template <> \ + struct GDExtensionConstPtr { \ + const m_type *data = nullptr; \ + GDExtensionConstPtr() {} \ + GDExtensionConstPtr(const m_type *p_assign) { data = p_assign; } \ + static const char *get_name() { return "const " #m_type; } \ + operator const m_type *() const { return data; } \ + operator Variant() const { return uint64_t(data); } \ + }; \ + template <> \ + struct VariantCaster> { \ + static _FORCE_INLINE_ GDExtensionConstPtr cast(const Variant &p_variant) { \ + return GDExtensionConstPtr((const m_type *)p_variant.operator uint64_t()); \ + } \ + }; \ + template <> \ + struct VariantInternalAccessor> { \ + static _FORCE_INLINE_ const GDExtensionConstPtr &get(const Variant *v) { return *reinterpret_cast *>(VariantInternal::get_int(v)); } \ + static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \ + }; \ + template <> \ + struct GDExtensionPtr { \ + m_type *data = nullptr; \ + GDExtensionPtr() {} \ + GDExtensionPtr(m_type *p_assign) { data = p_assign; } \ + static const char *get_name() { return #m_type; } \ + operator m_type *() const { return data; } \ + operator Variant() const { return uint64_t(data); } \ + }; \ + template <> \ + struct VariantCaster> { \ + static _FORCE_INLINE_ GDExtensionPtr cast(const Variant &p_variant) { \ + return GDExtensionPtr((m_type *)p_variant.operator uint64_t()); \ + } \ + }; \ + template <> \ + struct VariantInternalAccessor> { \ + static _FORCE_INLINE_ const GDExtensionPtr &get(const Variant *v) { return *reinterpret_cast *>(VariantInternal::get_int(v)); } \ + static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \ }; template