|
@@ -137,20 +137,22 @@ public:
|
|
|
} \
|
|
|
\
|
|
|
static void free(void *data, GDExtensionClassInstancePtr ptr) { \
|
|
|
- Memory::free_static(reinterpret_cast<m_class *>(ptr)); \
|
|
|
+ if (ptr) { \
|
|
|
+ m_class *cls = reinterpret_cast<m_class *>(ptr); \
|
|
|
+ cls->~m_class(); \
|
|
|
+ ::godot::Memory::free_static(cls); \
|
|
|
+ } \
|
|
|
} \
|
|
|
\
|
|
|
static void set_object_instance(GDExtensionClassInstancePtr p_instance, GDNativeObjectPtr p_object_instance) { \
|
|
|
- reinterpret_cast<m_class *>(p_instance)->_owner = reinterpret_cast<GodotObject *>(p_object_instance); \
|
|
|
+ godot::internal::interface->object_set_instance_binding(p_object_instance, godot::internal::token, p_instance, &m_class::___binding_callbacks); \
|
|
|
+ reinterpret_cast<m_class *>(p_instance)->_owner = reinterpret_cast<godot::GodotObject *>(p_object_instance); \
|
|
|
} \
|
|
|
\
|
|
|
static void *___binding_create_callback(void *p_token, void *p_instance) { \
|
|
|
- m_class *result = new ("") m_class; \
|
|
|
- result->_owner = reinterpret_cast<godot::GodotObject *>(p_instance); \
|
|
|
- return result; \
|
|
|
+ return nullptr; \
|
|
|
} \
|
|
|
static void ___binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
|
|
|
- Memory::free_static(reinterpret_cast<m_class *>(p_binding)); \
|
|
|
} \
|
|
|
static GDNativeBool ___binding_reference_callback(void *p_token, void *p_instance, GDNativeBool p_reference) { \
|
|
|
return true; \
|
|
@@ -162,9 +164,10 @@ public:
|
|
|
}; \
|
|
|
\
|
|
|
static m_class *_new() { \
|
|
|
- static GDNativeClassConstructor ___constructor = godot::internal::interface->classdb_get_constructor(#m_class); \
|
|
|
+ static GDNativeExtensionPtr ___extension = nullptr; \
|
|
|
+ static GDNativeClassConstructor ___constructor = godot::internal::interface->classdb_get_constructor(#m_class, &___extension); \
|
|
|
CHECK_CLASS_CONSTRUCTOR(___constructor, m_class); \
|
|
|
- GDNativeObjectPtr obj = ___constructor(); \
|
|
|
+ GDNativeObjectPtr obj = godot::internal::interface->classdb_construct_object(___constructor, ___extension); \
|
|
|
return reinterpret_cast<m_class *>(godot::internal::interface->object_get_instance_binding(obj, godot::internal::token, &m_class::___binding_callbacks)); \
|
|
|
} \
|
|
|
\
|
|
@@ -205,7 +208,7 @@ public:
|
|
|
___binding_reference_callback, \
|
|
|
}; \
|
|
|
static m_class *_new() { \
|
|
|
- static GDNativeClassConstructor ___constructor = godot::internal::interface->classdb_get_constructor(#m_class); \
|
|
|
+ static GDNativeClassConstructor ___constructor = godot::internal::interface->classdb_get_constructor(#m_class, nullptr); \
|
|
|
CHECK_CLASS_CONSTRUCTOR(___constructor, m_class); \
|
|
|
GDNativeObjectPtr obj = ___constructor(); \
|
|
|
return reinterpret_cast<m_class *>(godot::internal::interface->object_get_instance_binding(obj, godot::internal::token, &m_class::___binding_callbacks)); \
|