Rename interface to gdn_interface because it's a defined keyword under windows

This commit is contained in:
Bastiaan Olij
2021-10-28 19:20:56 +11:00
parent 5148aad3d4
commit ef528d3a86
19 changed files with 246 additions and 240 deletions

View File

@@ -240,7 +240,7 @@ public:
template <class T>
struct PtrToArg<Ref<T>> {
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
return Ref<T>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
return Ref<T>(godot::internal::gdn_interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
}
typedef Ref<T> EncodeT;
@@ -255,7 +255,7 @@ struct PtrToArg<const Ref<T> &> {
typedef Ref<T> EncodeT;
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
return Ref<T>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
return Ref<T>(godot::internal::gdn_interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
}
};

View File

@@ -94,126 +94,126 @@ struct Creator<T, typename std::enable_if<std::is_base_of_v<godot::Wrapped, T>>:
#define CHECK_CLASS_CONSTRUCTOR(m_constructor, m_class)
#endif
#define GDCLASS(m_class, m_inherits) \
private: \
friend class ClassDB; \
\
using SelfType = m_class; \
\
protected: \
static void (*_get_bind_methods())() { \
return &m_class::_bind_methods; \
} \
\
template <class T> \
static void register_virtuals() { \
m_inherits::register_virtuals<T>(); \
} \
\
public: \
static void initialize_class() { \
static bool initialized = false; \
if (initialized) { \
return; \
} \
m_inherits::initialize_class(); \
if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \
_bind_methods(); \
m_inherits::register_virtuals<m_class>(); \
} \
initialized = true; \
} \
\
static const char *get_class_static() { \
return #m_class; \
} \
\
static const char *get_parent_class_static() { \
return #m_inherits; \
} \
\
static GDExtensionClassInstancePtr create(void *data) { \
return reinterpret_cast<GDExtensionClassInstancePtr>(new ("") m_class); \
} \
\
static void free(void *data, GDExtensionClassInstancePtr 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) { \
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) { \
return nullptr; \
} \
static void ___binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
} \
static GDNativeBool ___binding_reference_callback(void *p_token, void *p_instance, GDNativeBool p_reference) { \
return true; \
} \
static constexpr GDNativeInstanceBindingCallbacks ___binding_callbacks = { \
___binding_create_callback, \
___binding_free_callback, \
___binding_reference_callback, \
}; \
\
static m_class *_new() { \
static GDNativeExtensionPtr ___extension = nullptr; \
static GDNativeClassConstructor ___constructor = godot::internal::interface->classdb_get_constructor(#m_class, &___extension); \
CHECK_CLASS_CONSTRUCTOR(___constructor, m_class); \
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)); \
} \
\
#define GDCLASS(m_class, m_inherits) \
private: \
friend class ClassDB; \
\
using SelfType = m_class; \
\
protected: \
static void (*_get_bind_methods())() { \
return &m_class::_bind_methods; \
} \
\
template <class T> \
static void register_virtuals() { \
m_inherits::register_virtuals<T>(); \
} \
\
public: \
static void initialize_class() { \
static bool initialized = false; \
if (initialized) { \
return; \
} \
m_inherits::initialize_class(); \
if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \
_bind_methods(); \
m_inherits::register_virtuals<m_class>(); \
} \
initialized = true; \
} \
\
static const char *get_class_static() { \
return #m_class; \
} \
\
static const char *get_parent_class_static() { \
return #m_inherits; \
} \
\
static GDExtensionClassInstancePtr create(void *data) { \
return reinterpret_cast<GDExtensionClassInstancePtr>(new ("") m_class); \
} \
\
static void free(void *data, GDExtensionClassInstancePtr 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) { \
godot::internal::gdn_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) { \
return nullptr; \
} \
static void ___binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
} \
static GDNativeBool ___binding_reference_callback(void *p_token, void *p_instance, GDNativeBool p_reference) { \
return true; \
} \
static constexpr GDNativeInstanceBindingCallbacks ___binding_callbacks = { \
___binding_create_callback, \
___binding_free_callback, \
___binding_reference_callback, \
}; \
\
static m_class *_new() { \
static GDNativeExtensionPtr ___extension = nullptr; \
static GDNativeClassConstructor ___constructor = godot::internal::gdn_interface->classdb_get_constructor(#m_class, &___extension); \
CHECK_CLASS_CONSTRUCTOR(___constructor, m_class); \
GDNativeObjectPtr obj = godot::internal::gdn_interface->classdb_construct_object(___constructor, ___extension); \
return reinterpret_cast<m_class *>(godot::internal::gdn_interface->object_get_instance_binding(obj, godot::internal::token, &m_class::___binding_callbacks)); \
} \
\
private:
// Don't use this for your classes, use GDCLASS() instead.
#define GDNATIVE_CLASS(m_class, m_inherits) \
protected: \
static void (*_get_bind_methods())() { \
return nullptr; \
} \
\
public: \
static void initialize_class() {} \
\
static const char *get_class_static() { \
return #m_class; \
} \
\
static const char *get_parent_class_static() { \
return #m_inherits; \
} \
\
static void *___binding_create_callback(void *p_token, void *p_instance) { \
m_class *obj = new ("") m_class; \
obj->_owner = (godot::GodotObject *)p_instance; \
return obj; \
} \
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; \
} \
static constexpr GDNativeInstanceBindingCallbacks ___binding_callbacks = { \
___binding_create_callback, \
___binding_free_callback, \
___binding_reference_callback, \
}; \
static m_class *_new() { \
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)); \
} \
\
#define GDNATIVE_CLASS(m_class, m_inherits) \
protected: \
static void (*_get_bind_methods())() { \
return nullptr; \
} \
\
public: \
static void initialize_class() {} \
\
static const char *get_class_static() { \
return #m_class; \
} \
\
static const char *get_parent_class_static() { \
return #m_inherits; \
} \
\
static void *___binding_create_callback(void *p_token, void *p_instance) { \
m_class *obj = new ("") m_class; \
obj->_owner = (godot::GodotObject *)p_instance; \
return obj; \
} \
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; \
} \
static constexpr GDNativeInstanceBindingCallbacks ___binding_callbacks = { \
___binding_create_callback, \
___binding_free_callback, \
___binding_reference_callback, \
}; \
static m_class *_new() { \
static GDNativeClassConstructor ___constructor = godot::internal::gdn_interface->classdb_get_constructor(#m_class, nullptr); \
CHECK_CLASS_CONSTRUCTOR(___constructor, m_class); \
GDNativeObjectPtr obj = ___constructor(); \
return reinterpret_cast<m_class *>(godot::internal::gdn_interface->object_get_instance_binding(obj, godot::internal::token, &m_class::___binding_callbacks)); \
} \
\
private:
#endif // ! GODOT_CPP_WRAPPED_HPP