diff options
Diffstat (limited to 'core/object/object.h')
-rw-r--r-- | core/object/object.h | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/core/object/object.h b/core/object/object.h index 37b2e61dfe..461ed482fe 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -31,6 +31,7 @@ #ifndef OBJECT_H #define OBJECT_H +#include "core/extension/gdnative_interface.h" #include "core/object/object_id.h" #include "core/os/rw_lock.h" #include "core/os/spin_lock.h" @@ -101,6 +102,7 @@ enum PropertyHint { }; enum PropertyUsageFlags { + PROPERTY_USAGE_NONE = 0, PROPERTY_USAGE_STORAGE = 1, PROPERTY_USAGE_EDITOR = 2, PROPERTY_USAGE_NETWORK = 4, @@ -243,29 +245,18 @@ class MethodBind; struct ObjectNativeExtension { ObjectNativeExtension *parent = nullptr; + List<ObjectNativeExtension *> children; StringName parent_class_name; StringName class_name; bool editor_class = false; - bool (*set)(void *instance, const void *name, const void *value) = nullptr; - bool (*get)(void *instance, const void *name, void *ret_variant) = nullptr; - struct PInfo { - uint32_t type; - const char *name; - const char *class_name; - uint32_t hint; - const char *hint_string; - uint32_t usage; - }; - const PInfo *(*get_property_list)(void *instance, uint32_t *count) = nullptr; - void (*free_property_list)(void *instance, const PInfo *) = nullptr; - - //call is not used, as all methods registered in ClassDB - - void (*notification)(void *instance, int32_t what) = nullptr; - const char *(*to_string)(void *instance) = nullptr; - - void (*reference)(void *instance) = nullptr; - void (*unreference)(void *instance) = nullptr; + GDNativeExtensionClassSet set; + GDNativeExtensionClassGet get; + GDNativeExtensionClassGetPropertyList get_property_list; + GDNativeExtensionClassFreePropertyList free_property_list; + GDNativeExtensionClassNotification notification; + GDNativeExtensionClassToString to_string; + GDNativeExtensionClassReference reference; + GDNativeExtensionClassReference unreference; _FORCE_INLINE_ bool is_class(const String &p_class) const { const ObjectNativeExtension *e = this; @@ -277,11 +268,16 @@ struct ObjectNativeExtension { } return false; } - void *create_instance_userdata = nullptr; - void *(*create_instance)(void *create_instance_userdata) = nullptr; - void (*free_instance)(void *create_instance_userdata, void *instance) = nullptr; + void *class_userdata = nullptr; + + GDNativeExtensionClassCreateInstance create_instance; + GDNativeExtensionClassFreeInstance free_instance; + GDNativeExtensionClassGetVirtual get_virtual; }; +#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__) +#define GDVIRTUAL_BIND(m_name) ClassDB::add_virtual_method(get_class_static(), _gdvirtual_##m_name##_get_method_info()); + /* the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model. */ @@ -496,7 +492,7 @@ private: friend void postinitialize_handler(Object *); ObjectNativeExtension *_extension = nullptr; - void *_extension_instance = nullptr; + GDExtensionClassInstancePtr _extension_instance = nullptr; struct SignalData { struct Slot { @@ -553,8 +549,9 @@ private: Object(bool p_reference); protected: + friend class NativeExtensionMethodBind; _ALWAYS_INLINE_ const ObjectNativeExtension *_get_extension() const { return _extension; } - _ALWAYS_INLINE_ void *_get_extension_instance() const { return _extension_instance; } + _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; } virtual void _initialize_classv() { initialize_class(); } virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; }; virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; }; |