diff options
Diffstat (limited to 'core/object.h')
-rw-r--r-- | core/object.h | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/core/object.h b/core/object.h index 6e2aa9e494..8ed5bcdf25 100644 --- a/core/object.h +++ b/core/object.h @@ -108,13 +108,13 @@ enum PropertyUsageFlags { -#define ADD_SIGNAL( m_signal ) ObjectTypeDB::add_signal( get_type_static(), m_signal ) -#define ADD_PROPERTY( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), m_property, m_setter, m_getter ) -#define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), m_property, m_setter, m_getter, m_index ) -#define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter ) -#define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter, m_index ) -#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter ) -#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter, m_index ) +#define ADD_SIGNAL( m_signal ) ClassDB::add_signal( get_class_static(), m_signal ) +#define ADD_PROPERTY( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), m_property, m_setter, m_getter ) +#define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), m_property, m_setter, m_getter, m_index ) +#define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter ) +#define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter, m_index ) +#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter ) +#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter, m_index ) struct PropertyInfo { @@ -175,7 +175,7 @@ struct MethodInfo { }; // old cast_to -//if ( is_type(T::get_type_static()) ) +//if ( is_type(T::get_class_static()) ) //return static_cast<T*>(this); ////else //return NULL; @@ -196,33 +196,33 @@ private: -#define OBJ_TYPE( m_type, m_inherits )\ +#define GDCLASS( m_class, m_inherits )\ private:\ - void operator=(const m_type& p_rval) {}\ - mutable StringName _type_name;\ - friend class ObjectTypeDB;\ + void operator=(const m_class& p_rval) {}\ + mutable StringName _class_name;\ + friend class ClassDB;\ public:\ -virtual String get_type() const { \ - return String(#m_type);\ +virtual String get_class() const { \ + return String(#m_class);\ }\ -virtual const StringName* _get_type_namev() const { \ - if (!_type_name)\ - _type_name=get_type_static();\ - return &_type_name;\ +virtual const StringName* _get_class_namev() const { \ + if (!_class_name)\ + _class_name=get_class_static();\ + return &_class_name;\ }\ -static _FORCE_INLINE_ void* get_type_ptr_static() { \ +static _FORCE_INLINE_ void* get_class_ptr_static() { \ static int ptr;\ return &ptr;\ }\ -static _FORCE_INLINE_ String get_type_static() { \ - return String(#m_type);\ +static _FORCE_INLINE_ String get_class_static() { \ + return String(#m_class);\ }\ -static _FORCE_INLINE_ String get_parent_type_static() { \ - return m_inherits::get_type_static();\ +static _FORCE_INLINE_ String get_parent_class_static() { \ + return m_inherits::get_class_static();\ }\ static void get_inheritance_list_static(List<String>* p_inheritance_list) { \ m_inherits::get_inheritance_list_static(p_inheritance_list);\ - p_inheritance_list->push_back(String(#m_type));\ + p_inheritance_list->push_back(String(#m_class));\ }\ static String get_category_static() { \ String category = m_inherits::get_category_static();\ @@ -236,85 +236,85 @@ static String get_category_static() { \ static String inherits_static() {\ return String(#m_inherits);\ }\ -virtual bool is_type(const String& p_type) const { return (p_type==(#m_type))?true:m_inherits::is_type(p_type); }\ -virtual bool is_type_ptr(void *p_ptr) const { return (p_ptr==get_type_ptr_static())?true:m_inherits::is_type_ptr(p_ptr); }\ +virtual bool is_class(const String& p_class) const { return (p_class==(#m_class))?true:m_inherits::is_class(p_class); }\ +virtual bool is_class_ptr(void *p_ptr) const { return (p_ptr==get_class_ptr_static())?true:m_inherits::is_class_ptr(p_ptr); }\ \ \ static void get_valid_parents_static(List<String> *p_parents) {\ \ - if (m_type::_get_valid_parents_static!=m_inherits::_get_valid_parents_static) { \ - m_type::_get_valid_parents_static(p_parents);\ + if (m_class::_get_valid_parents_static!=m_inherits::_get_valid_parents_static) { \ + m_class::_get_valid_parents_static(p_parents);\ }\ \ m_inherits::get_valid_parents_static(p_parents);\ }\ protected:\ _FORCE_INLINE_ static void (*_get_bind_methods())() {\ - return &m_type::_bind_methods;\ + return &m_class::_bind_methods;\ }\ public:\ -static void initialize_type() {\ +static void initialize_class() {\ static bool initialized=false;\ if (initialized)\ return;\ - m_inherits::initialize_type();\ - ObjectTypeDB::_add_type<m_type>();\ - if (m_type::_get_bind_methods() != m_inherits::_get_bind_methods())\ + m_inherits::initialize_class();\ + ClassDB::_add_class<m_class>();\ + if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods())\ _bind_methods();\ initialized=true;\ }\ protected:\ -virtual void _initialize_typev() {\ - initialize_type();\ +virtual void _initialize_classv() {\ + initialize_class();\ }\ _FORCE_INLINE_ bool (Object::* (_get_get() const))(const StringName& p_name,Variant&) const {\ - return (bool (Object::*)(const StringName&,Variant&)const) &m_type::_get;\ + return (bool (Object::*)(const StringName&,Variant&)const) &m_class::_get;\ }\ virtual bool _getv(const StringName& p_name, Variant& r_ret) const { \ - if (m_type::_get_get() != m_inherits::_get_get()) {\ + if (m_class::_get_get() != m_inherits::_get_get()) {\ if (_get(p_name,r_ret))\ return true;\ }\ return m_inherits::_getv(p_name,r_ret);\ }\ _FORCE_INLINE_ bool (Object::* (_get_set() const))(const StringName& p_name,const Variant &p_property) {\ - return (bool (Object::*)(const StringName&, const Variant&))&m_type::_set;\ + return (bool (Object::*)(const StringName&, const Variant&))&m_class::_set;\ }\ virtual bool _setv(const StringName& p_name,const Variant &p_property) { \ if (m_inherits::_setv(p_name,p_property)) return true;\ - if (m_type::_get_set() != m_inherits::_get_set()) {\ + if (m_class::_get_set() != m_inherits::_get_set()) {\ return _set(p_name,p_property);\ \ }\ return false;\ }\ _FORCE_INLINE_ void (Object::* (_get_get_property_list() const))(List<PropertyInfo> *p_list) const{\ - return (void (Object::*)(List<PropertyInfo>*)const)&m_type::_get_property_list;\ + return (void (Object::*)(List<PropertyInfo>*)const)&m_class::_get_property_list;\ }\ virtual void _get_property_listv(List<PropertyInfo> *p_list,bool p_reversed) const { \ if (!p_reversed) {\ m_inherits::_get_property_listv(p_list,p_reversed);\ }\ - p_list->push_back( PropertyInfo(Variant::NIL,get_type_static(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_CATEGORY));\ + p_list->push_back( PropertyInfo(Variant::NIL,get_class_static(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_CATEGORY));\ if (!_is_gpl_reversed())\ - ObjectTypeDB::get_property_list(#m_type,p_list,true,this);\ - if (m_type::_get_get_property_list() != m_inherits::_get_get_property_list()) {\ + ClassDB::get_property_list(#m_class,p_list,true,this);\ + if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) {\ _get_property_list(p_list);\ }\ if (_is_gpl_reversed())\ - ObjectTypeDB::get_property_list(#m_type,p_list,true,this);\ + ClassDB::get_property_list(#m_class,p_list,true,this);\ if (p_reversed) {\ m_inherits::_get_property_listv(p_list,p_reversed);\ }\ \ }\ _FORCE_INLINE_ void (Object::* (_get_notification() const))(int){\ - return (void (Object::*)(int)) &m_type::_notification;\ + return (void (Object::*)(int)) &m_class::_notification;\ }\ virtual void _notificationv(int p_notification,bool p_reversed) { \ if (!p_reversed) \ m_inherits::_notificationv(p_notification,p_reversed);\ - if (m_type::_get_notification() != m_inherits::_get_notification()) {\ + if (m_class::_get_notification() != m_inherits::_get_notification()) {\ _notification(p_notification);\ }\ if (p_reversed)\ @@ -329,9 +329,9 @@ protected:\ _FORCE_INLINE_ static String _get_category() { return m_category; }\ private: -#define OBJ_SAVE_TYPE(m_type) \ +#define OBJ_SAVE_TYPE(m_class) \ public: \ -virtual String get_save_type() const { return #m_type; }\ +virtual String get_save_class() const { return #m_class; }\ private: class ScriptInstance; @@ -415,8 +415,8 @@ friend void postinitialize_handler(Object*); ScriptInstance *script_instance; RefPtr script; Dictionary metadata; - mutable StringName _type_name; - mutable const StringName* _type_ptr; + mutable StringName _class_name; + mutable const StringName* _class_ptr; void _add_user_signal(const String& p_name, const Array& p_pargs=Array()); bool _has_user_signal(const StringName& p_name) const; @@ -431,7 +431,7 @@ friend void postinitialize_handler(Object*); protected: virtual bool _use_builtin_script() const { return false; } - virtual void _initialize_typev() { initialize_type(); } + 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; }; virtual void _get_property_listv(List<PropertyInfo> *p_list,bool p_reversed) const {}; @@ -474,10 +474,10 @@ protected: Variant _call_deferred_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); - virtual const StringName* _get_type_namev() const { - if (!_type_name) - _type_name=get_type_static(); - return &_type_name; + virtual const StringName* _get_class_namev() const { + if (!_class_name) + _class_name=get_class_static(); + return &_class_name; } DVector<String> _get_meta_list_bind() const; @@ -486,11 +486,11 @@ protected: void _clear_internal_resource_paths(const Variant &p_var); -friend class ObjectTypeDB; +friend class ClassDB; virtual void _validate_property(PropertyInfo& property) const; public: //should be protected, but bug in clang++ - static void initialize_type(); + static void initialize_class(); _FORCE_INLINE_ static void register_custom_data_to_otdb() {}; public: @@ -500,7 +500,7 @@ public: #else _FORCE_INLINE_ void _change_notify(const char *p_what="") { } #endif - static void* get_type_ptr_static() { + static void* get_class_ptr_static() { static int ptr; return &ptr; } @@ -521,7 +521,7 @@ public: #else if (!this) return NULL; - if (is_type_ptr(T::get_type_ptr_static())) + if (is_class_ptr(T::get_class_ptr_static())) return static_cast<T*>(this); else return NULL; @@ -536,7 +536,7 @@ public: #else if (!this) return NULL; - if (is_type_ptr(T::get_type_ptr_static())) + if (is_class_ptr(T::get_class_ptr_static())) return static_cast<const T*>(this); else return NULL; @@ -552,24 +552,24 @@ public: /* TYPE API */ static void get_inheritance_list_static(List<String>* p_inheritance_list) { p_inheritance_list->push_back("Object"); } - static String get_type_static() { return "Object"; } - static String get_parent_type_static() { return String(); } + static String get_class_static() { return "Object"; } + static String get_parent_class_static() { return String(); } static String get_category_static() { return String(); } - virtual String get_type() const { return "Object"; } - virtual String get_save_type() const { return get_type(); } //type stored when saving + virtual String get_class() const { return "Object"; } + virtual String get_save_class() const { return get_class(); } //class stored when saving - virtual bool is_type(const String& p_type) const { return (p_type=="Object"); } - virtual bool is_type_ptr(void *p_ptr) const { return get_type_ptr_static()==p_ptr; } + virtual bool is_class(const String& p_class) const { return (p_class=="Object"); } + virtual bool is_class_ptr(void *p_ptr) const { return get_class_ptr_static()==p_ptr; } - _FORCE_INLINE_ const StringName& get_type_name() const { - if (!_type_ptr) { - return *_get_type_namev(); + _FORCE_INLINE_ const StringName& get_class_name() const { + if (!_class_ptr) { + return *_get_class_namev(); } else { - return *_type_ptr; + return *_class_ptr; } } |