diff options
| author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-27 16:06:50 +0200 |
|---|---|---|
| committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-27 16:13:24 +0200 |
| commit | 80fdb9146f33daf7b5630ec0cd513e0ddae0d372 (patch) | |
| tree | 83764f035767965340caf283791d0d89eb8e96b8 /include/godot_cpp | |
| parent | a44e9aa3f917d9943921f75edfbdae87ea1531b7 (diff) | |
| download | redot-cpp-80fdb9146f33daf7b5630ec0cd513e0ddae0d372.tar.gz | |
Add pointers support for virtual methods.
As introduced in godot for virtual methods.
Custom structs are not yet supported.
Diffstat (limited to 'include/godot_cpp')
| -rw-r--r-- | include/godot_cpp/core/method_ptrcall.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 2812755..dc62716 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -184,6 +184,47 @@ struct PtrToArg<const T *> { } }; +// Pointers. +#define GDVIRTUAL_NATIVE_PTR(m_type) \ + template <> \ + struct PtrToArg<m_type *> { \ + _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ + return (m_type *)(*(void **)p_ptr); \ + } \ + typedef m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ + *((void **)p_ptr) = p_var; \ + } \ + }; \ + \ + template <> \ + struct PtrToArg<const m_type *> { \ + _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ + return (const m_type *)(*(const void **)p_ptr); \ + } \ + typedef const m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ + *((void **)p_ptr) = p_var; \ + } \ + } + +GDVIRTUAL_NATIVE_PTR(bool); +GDVIRTUAL_NATIVE_PTR(char); +GDVIRTUAL_NATIVE_PTR(char16_t); +GDVIRTUAL_NATIVE_PTR(char32_t); +GDVIRTUAL_NATIVE_PTR(wchar_t); +GDVIRTUAL_NATIVE_PTR(uint8_t); +GDVIRTUAL_NATIVE_PTR(uint8_t *); +GDVIRTUAL_NATIVE_PTR(int8_t); +GDVIRTUAL_NATIVE_PTR(uint16_t); +GDVIRTUAL_NATIVE_PTR(int16_t); +GDVIRTUAL_NATIVE_PTR(uint32_t); +GDVIRTUAL_NATIVE_PTR(int32_t); +GDVIRTUAL_NATIVE_PTR(int64_t); +GDVIRTUAL_NATIVE_PTR(uint64_t); +GDVIRTUAL_NATIVE_PTR(float); +GDVIRTUAL_NATIVE_PTR(double); + } // namespace godot #endif // ! GODOT_CPP_METHOD_PTRCALL_HPP |
