summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/godot_cpp')
-rw-r--r--include/godot_cpp/classes/wrapped.hpp198
-rw-r--r--include/godot_cpp/core/memory.hpp23
-rw-r--r--include/godot_cpp/variant/variant.hpp14
3 files changed, 126 insertions, 109 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index af2ce4c..f8f921b 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -365,105 +365,109 @@ public:
_gde_binding_create_callback, \
_gde_binding_free_callback, \
_gde_binding_reference_callback, \
- };
+ }; \
+ \
+private:
// Don't use this for your classes, use GDCLASS() instead.
-#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) \
-private: \
- inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
- void operator=(const m_class &p_rval) {} \
- \
-protected: \
- virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
- return &_gde_binding_callbacks; \
- } \
- \
- m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
- m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
- \
- static void (*_get_bind_methods())() { \
- return nullptr; \
- } \
- \
- static void (Wrapped::*_get_notification())(int) { \
- return nullptr; \
- } \
- \
- static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \
- return nullptr; \
- } \
- \
- static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \
- return nullptr; \
- } \
- \
- static inline bool has_get_property_list() { \
- return false; \
- } \
- \
- static void (Wrapped::*_get_get_property_list())(List<PropertyInfo> * p_list) const { \
- return nullptr; \
- } \
- \
- static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \
- return nullptr; \
- } \
- \
- static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \
- return nullptr; \
- } \
- \
- static void (Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \
- return nullptr; \
- } \
- \
- static String (Wrapped::*_get_to_string())() const { \
- return nullptr; \
- } \
- \
-public: \
- typedef m_class self_type; \
- \
- static void initialize_class() {} \
- \
- static ::godot::StringName &get_class_static() { \
- static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \
- return string_name; \
- } \
- \
- static ::godot::StringName &get_parent_class_static() { \
- return m_inherits::get_class_static(); \
- } \
- \
- static GDExtensionObjectPtr create(void *data) { \
- return nullptr; \
- } \
- \
- static GDExtensionClassInstancePtr recreate(void *data, GDExtensionObjectPtr obj) { \
- return nullptr; \
- } \
- \
- static void free(void *data, GDExtensionClassInstancePtr ptr) { \
- } \
- \
- static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \
- /* Do not call memnew here, we don't want the post-initializer to be called */ \
- return new ("") m_class((GodotObject *)p_instance); \
- } \
- static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
- /* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \
- reinterpret_cast<m_class *>(p_binding)->~m_class(); \
- Memory::free_static(reinterpret_cast<m_class *>(p_binding)); \
- } \
- static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \
- return true; \
- } \
- static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \
- _gde_binding_create_callback, \
- _gde_binding_free_callback, \
- _gde_binding_reference_callback, \
- }; \
- m_class() : m_class(#m_alias_for) {}
+#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \
+private: \
+ inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
+ void operator=(const m_class &p_rval) {} \
+ \
+protected: \
+ virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
+ return &_gde_binding_callbacks; \
+ } \
+ \
+ m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
+ m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
+ \
+ static void (*_get_bind_methods())() { \
+ return nullptr; \
+ } \
+ \
+ static void (Wrapped::*_get_notification())(int) { \
+ return nullptr; \
+ } \
+ \
+ static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \
+ return nullptr; \
+ } \
+ \
+ static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \
+ return nullptr; \
+ } \
+ \
+ static inline bool has_get_property_list() { \
+ return false; \
+ } \
+ \
+ static void (Wrapped::*_get_get_property_list())(List<PropertyInfo> * p_list) const { \
+ return nullptr; \
+ } \
+ \
+ static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \
+ return nullptr; \
+ } \
+ \
+ static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \
+ return nullptr; \
+ } \
+ \
+ static void (Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \
+ return nullptr; \
+ } \
+ \
+ static String (Wrapped::*_get_to_string())() const { \
+ return nullptr; \
+ } \
+ \
+public: \
+ typedef m_class self_type; \
+ \
+ static void initialize_class() {} \
+ \
+ static ::godot::StringName &get_class_static() { \
+ static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \
+ return string_name; \
+ } \
+ \
+ static ::godot::StringName &get_parent_class_static() { \
+ return m_inherits::get_class_static(); \
+ } \
+ \
+ static GDExtensionObjectPtr create(void *data) { \
+ return nullptr; \
+ } \
+ \
+ static GDExtensionClassInstancePtr recreate(void *data, GDExtensionObjectPtr obj) { \
+ return nullptr; \
+ } \
+ \
+ static void free(void *data, GDExtensionClassInstancePtr ptr) { \
+ } \
+ \
+ static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \
+ /* Do not call memnew here, we don't want the post-initializer to be called */ \
+ return new ("", "") m_class((GodotObject *)p_instance); \
+ } \
+ static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
+ /* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \
+ reinterpret_cast<m_class *>(p_binding)->~m_class(); \
+ Memory::free_static(reinterpret_cast<m_class *>(p_binding)); \
+ } \
+ static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \
+ return true; \
+ } \
+ static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \
+ _gde_binding_create_callback, \
+ _gde_binding_free_callback, \
+ _gde_binding_reference_callback, \
+ }; \
+ m_class() : m_class(#m_alias_for) {} \
+ \
+private:
// Don't use this for your classes, use GDCLASS() instead.
#define GDEXTENSION_CLASS(m_class, m_inherits) GDEXTENSION_CLASS_ALIAS(m_class, m_class, m_inherits)
diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp
index 548f330..97a2b13 100644
--- a/include/godot_cpp/core/memory.hpp
+++ b/include/godot_cpp/core/memory.hpp
@@ -44,20 +44,21 @@
#define PAD_ALIGN 16 //must always be greater than this at much
#endif
-void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
-void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool
-void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory
+// p_dummy argument is added to avoid conflicts with the engine functions when both engine and GDExtension are built as a static library on iOS.
+void *operator new(size_t p_size, const char *p_dummy, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
+void *operator new(size_t p_size, const char *p_dummy, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool
+void *operator new(size_t p_size, const char *p_dummy, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory
-_ALWAYS_INLINE_ void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description) {
+_ALWAYS_INLINE_ void *operator new(size_t p_size, const char *p_dummy, void *p_pointer, size_t check, const char *p_description) {
return p_pointer;
}
#ifdef _MSC_VER
// When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291).
// The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete.
-void operator delete(void *p_mem, const char *p_description);
-void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size));
-void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description);
+void operator delete(void *p_mem, const char *p_dummy, const char *p_description);
+void operator delete(void *p_mem, const char *p_dummy, void *(*p_allocfunc)(size_t p_size));
+void operator delete(void *p_mem, const char *p_dummy, void *p_pointer, size_t check, const char *p_description);
#endif
namespace godot {
@@ -85,10 +86,10 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
#define memrealloc(m_mem, m_size) ::godot::Memory::realloc_static(m_mem, m_size)
#define memfree(m_mem) ::godot::Memory::free_static(m_mem)
-#define memnew(m_class) ::godot::_post_initialize(new ("") m_class)
+#define memnew(m_class) ::godot::_post_initialize(new ("", "") m_class)
-#define memnew_allocator(m_class, m_allocator) ::godot::_post_initialize(new (m_allocator::alloc) m_class)
-#define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new (m_placement, sizeof(m_class), "") m_class)
+#define memnew_allocator(m_class, m_allocator) ::godot::_post_initialize(new ("", m_allocator::alloc) m_class)
+#define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new ("", m_placement, sizeof(m_class), "") m_class)
// Generic comparator used in Map, List, etc.
template <class T>
@@ -154,7 +155,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
/* call operator new */
for (size_t i = 0; i < p_elements; i++) {
- new (&elems[i], sizeof(T), p_descr) T;
+ new ("", &elems[i], sizeof(T), p_descr) T;
}
}
diff --git a/include/godot_cpp/variant/variant.hpp b/include/godot_cpp/variant/variant.hpp
index 3e8738c..fc41014 100644
--- a/include/godot_cpp/variant/variant.hpp
+++ b/include/godot_cpp/variant/variant.hpp
@@ -154,10 +154,18 @@ public:
Variant(int64_t v);
Variant(int32_t v) :
Variant(static_cast<int64_t>(v)) {}
- Variant(uint32_t v) :
+ Variant(int16_t v) :
+ Variant(static_cast<int64_t>(v)) {}
+ Variant(int8_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint64_t v) :
Variant(static_cast<int64_t>(v)) {}
+ Variant(uint32_t v) :
+ Variant(static_cast<int64_t>(v)) {}
+ Variant(uint16_t v) :
+ Variant(static_cast<int64_t>(v)) {}
+ Variant(uint8_t v) :
+ Variant(static_cast<int64_t>(v)) {}
Variant(double v);
Variant(float v) :
Variant((double)v) {}
@@ -209,8 +217,12 @@ public:
operator bool() const;
operator int64_t() const;
operator int32_t() const;
+ operator int16_t() const;
+ operator int8_t() const;
operator uint64_t() const;
operator uint32_t() const;
+ operator uint16_t() const;
+ operator uint8_t() const;
operator double() const;
operator float() const;
operator String() const;