Rename interface to gdn_interface because it's a defined keyword under windows
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -106,7 +106,7 @@ template <class T>
|
||||
struct VariantCasterAndValidate {
|
||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDNativeCallError &r_error) {
|
||||
GDNativeVariantType argtype = GetTypeInfo<T>::VARIANT_TYPE;
|
||||
if (!internal::interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
if (!internal::gdn_interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
|
||||
r_error.error = GDNATIVE_CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = p_arg_idx;
|
||||
@@ -121,7 +121,7 @@ template <class T>
|
||||
struct VariantCasterAndValidate<T &> {
|
||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDNativeCallError &r_error) {
|
||||
GDNativeVariantType argtype = GetTypeInfo<T>::VARIANT_TYPE;
|
||||
if (!internal::interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
if (!internal::gdn_interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
|
||||
r_error.error = GDNATIVE_CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = p_arg_idx;
|
||||
@@ -136,7 +136,7 @@ template <class T>
|
||||
struct VariantCasterAndValidate<const T &> {
|
||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDNativeCallError &r_error) {
|
||||
GDNativeVariantType argtype = GetTypeInfo<T>::VARIANT_TYPE;
|
||||
if (!internal::interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
if (!internal::gdn_interface->variant_can_convert_strict(static_cast<GDNativeVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
|
||||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
|
||||
r_error.error = GDNATIVE_CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = p_arg_idx;
|
||||
|
||||
@@ -163,7 +163,7 @@ void ClassDB::register_class() {
|
||||
(void *)cl.name, //void *class_userdata;
|
||||
};
|
||||
|
||||
internal::interface->classdb_register_extension_class(internal::library, cl.name, cl.parent_name, &class_info);
|
||||
internal::gdn_interface->classdb_register_extension_class(internal::library, cl.name, cl.parent_name, &class_info);
|
||||
|
||||
// call bind_methods etc. to register all members of the class
|
||||
T::initialize_class();
|
||||
|
||||
@@ -47,22 +47,22 @@ template <class O, class... Args>
|
||||
O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
|
||||
GodotObject *ret = nullptr;
|
||||
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } };
|
||||
internal::interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
|
||||
return reinterpret_cast<O *>(internal::interface->object_get_instance_binding(ret, internal::token, &O::___binding_callbacks));
|
||||
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
|
||||
return reinterpret_cast<O *>(internal::gdn_interface->object_get_instance_binding(ret, internal::token, &O::___binding_callbacks));
|
||||
}
|
||||
|
||||
template <class R, class... Args>
|
||||
R _call_native_mb_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
|
||||
R ret;
|
||||
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } };
|
||||
internal::interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
|
||||
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
void _call_native_mb_no_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
|
||||
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } };
|
||||
internal::interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
|
||||
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
|
||||
}
|
||||
|
||||
template <class R, class... Args>
|
||||
@@ -78,7 +78,7 @@ Object *_call_utility_ret_obj(const GDNativePtrUtilityFunction func, void *insta
|
||||
GodotObject *ret = nullptr;
|
||||
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } };
|
||||
func(&ret, mb_args.data(), mb_args.size());
|
||||
return (Object *)internal::interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks);
|
||||
return (Object *)internal::gdn_interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
|
||||
@@ -90,7 +90,7 @@ void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wra
|
||||
|
||||
template <class T, std::enable_if_t<std::is_base_of_v<godot::Wrapped, T>, bool> = true>
|
||||
void memdelete(T *p_class) {
|
||||
godot::internal::interface->object_destroy(p_class->_owner);
|
||||
godot::internal::gdn_interface->object_destroy(p_class->_owner);
|
||||
}
|
||||
|
||||
#define memnew_arr(m_class, m_count) memnew_arr_template<m_class>(m_count)
|
||||
|
||||
@@ -165,7 +165,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
|
||||
template <class T>
|
||||
struct PtrToArg<T *> {
|
||||
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
||||
return reinterpret_cast<T *>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
|
||||
return reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
|
||||
}
|
||||
typedef Object *EncodeT;
|
||||
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
||||
@@ -176,7 +176,7 @@ struct PtrToArg<T *> {
|
||||
template <class T>
|
||||
struct PtrToArg<const T *> {
|
||||
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
||||
return reinterpret_cast<const T *>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
|
||||
return reinterpret_cast<const T *>(godot::internal::gdn_interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
|
||||
}
|
||||
typedef const Object *EncodeT;
|
||||
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
||||
|
||||
@@ -136,11 +136,11 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const char *p_name, const Args
|
||||
|
||||
template <class T>
|
||||
T *Object::cast_to(Object *p_object) {
|
||||
GDNativeObjectPtr casted = internal::interface->object_cast_to(p_object->_owner, internal::interface->classdb_get_class_tag(T::get_class_static()));
|
||||
GDNativeObjectPtr casted = internal::gdn_interface->object_cast_to(p_object->_owner, internal::gdn_interface->classdb_get_class_tag(T::get_class_static()));
|
||||
if (casted == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<T *>(internal::interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks));
|
||||
return reinterpret_cast<T *>(internal::gdn_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks));
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace godot {
|
||||
|
||||
namespace internal {
|
||||
|
||||
extern "C" const GDNativeInterface *interface;
|
||||
extern "C" const GDNativeInterface *gdn_interface;
|
||||
extern "C" GDNativeExtensionClassLibraryPtr library;
|
||||
extern "C" void *token;
|
||||
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
static void free_instance_callback(void *p_token, void *p_instance, void *p_binding);
|
||||
|
||||
class InitObject {
|
||||
const GDNativeInterface *interface;
|
||||
const GDNativeInterface *gdn_interface;
|
||||
const GDNativeExtensionClassLibraryPtr library;
|
||||
GDNativeInitialization *initialization;
|
||||
|
||||
public:
|
||||
InitObject(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) :
|
||||
interface(p_interface),
|
||||
gdn_interface(p_interface),
|
||||
library(p_library),
|
||||
initialization(r_initialization){};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user