Merge pull request #78971 from kisg/fix_gdvirtual_native_ptr
Fix `GDVIRTUAL_NATIVE_PTR` by adding missing `VariantInternalAccessor` specializations
This commit is contained in:
commit
b9dfb4968a
1 changed files with 40 additions and 30 deletions
|
@ -53,36 +53,46 @@ struct GDExtensionPtr {
|
||||||
operator Variant() const { return uint64_t(data); }
|
operator Variant() const { return uint64_t(data); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GDVIRTUAL_NATIVE_PTR(m_type) \
|
#define GDVIRTUAL_NATIVE_PTR(m_type) \
|
||||||
template <> \
|
template <> \
|
||||||
struct GDExtensionConstPtr<const m_type> { \
|
struct GDExtensionConstPtr<const m_type> { \
|
||||||
const m_type *data = nullptr; \
|
const m_type *data = nullptr; \
|
||||||
GDExtensionConstPtr() {} \
|
GDExtensionConstPtr() {} \
|
||||||
GDExtensionConstPtr(const m_type *p_assign) { data = p_assign; } \
|
GDExtensionConstPtr(const m_type *p_assign) { data = p_assign; } \
|
||||||
static const char *get_name() { return "const " #m_type; } \
|
static const char *get_name() { return "const " #m_type; } \
|
||||||
operator const m_type *() const { return data; } \
|
operator const m_type *() const { return data; } \
|
||||||
operator Variant() const { return uint64_t(data); } \
|
operator Variant() const { return uint64_t(data); } \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
struct VariantCaster<GDExtensionConstPtr<const m_type>> { \
|
struct VariantCaster<GDExtensionConstPtr<const m_type>> { \
|
||||||
static _FORCE_INLINE_ GDExtensionConstPtr<const m_type> cast(const Variant &p_variant) { \
|
static _FORCE_INLINE_ GDExtensionConstPtr<const m_type> cast(const Variant &p_variant) { \
|
||||||
return GDExtensionConstPtr<const m_type>((const m_type *)p_variant.operator uint64_t()); \
|
return GDExtensionConstPtr<const m_type>((const m_type *)p_variant.operator uint64_t()); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
struct GDExtensionPtr<m_type> { \
|
struct VariantInternalAccessor<GDExtensionConstPtr<const m_type>> { \
|
||||||
m_type *data = nullptr; \
|
static _FORCE_INLINE_ const GDExtensionConstPtr<const m_type> &get(const Variant *v) { return *reinterpret_cast<const GDExtensionConstPtr<const m_type> *>(VariantInternal::get_int(v)); } \
|
||||||
GDExtensionPtr() {} \
|
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr<const m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \
|
||||||
GDExtensionPtr(m_type *p_assign) { data = p_assign; } \
|
}; \
|
||||||
static const char *get_name() { return #m_type; } \
|
template <> \
|
||||||
operator m_type *() const { return data; } \
|
struct GDExtensionPtr<m_type> { \
|
||||||
operator Variant() const { return uint64_t(data); } \
|
m_type *data = nullptr; \
|
||||||
}; \
|
GDExtensionPtr() {} \
|
||||||
template <> \
|
GDExtensionPtr(m_type *p_assign) { data = p_assign; } \
|
||||||
struct VariantCaster<GDExtensionPtr<m_type>> { \
|
static const char *get_name() { return #m_type; } \
|
||||||
static _FORCE_INLINE_ GDExtensionPtr<m_type> cast(const Variant &p_variant) { \
|
operator m_type *() const { return data; } \
|
||||||
return GDExtensionPtr<m_type>((m_type *)p_variant.operator uint64_t()); \
|
operator Variant() const { return uint64_t(data); } \
|
||||||
} \
|
}; \
|
||||||
|
template <> \
|
||||||
|
struct VariantCaster<GDExtensionPtr<m_type>> { \
|
||||||
|
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>
|
template <class T>
|
||||||
|
|
Loading…
Add table
Reference in a new issue