Fix GDVIRTUAL_NATIVE_PTR

This commit fixes the usage of GDExtensionPtr and GDExtensionConstPtr
in GDExtension by introducing the required VariantInternalAccessor
specializations.

Sponsored by Migeran (https://migeran.com)
This commit is contained in:
Gabor Koncz 2023-07-03 10:52:02 +02:00
parent 46424488ed
commit a2ede8c4da

View file

@ -70,6 +70,11 @@ struct GDExtensionPtr {
} \
}; \
template <> \
struct VariantInternalAccessor<GDExtensionConstPtr<const m_type>> { \
static _FORCE_INLINE_ const GDExtensionConstPtr<const m_type> &get(const Variant *v) { return *reinterpret_cast<const GDExtensionConstPtr<const m_type> *>(VariantInternal::get_int(v)); } \
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr<const m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \
}; \
template <> \
struct GDExtensionPtr<m_type> { \
m_type *data = nullptr; \
GDExtensionPtr() {} \
@ -83,6 +88,11 @@ struct GDExtensionPtr {
static _FORCE_INLINE_ GDExtensionPtr<m_type> cast(const Variant &p_variant) { \
return GDExtensionPtr<m_type>((m_type *)p_variant.operator uint64_t()); \
} \
}; \
template <> \
struct VariantInternalAccessor<GDExtensionPtr<m_type>> { \
static _FORCE_INLINE_ const GDExtensionPtr<m_type> &get(const Variant *v) { return *reinterpret_cast<const GDExtensionPtr<m_type> *>(VariantInternal::get_int(v)); } \
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr<m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \
};
template <class T>