38 #define VARIANT_ARG_LIST const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant() 39 #define VARIANT_ARG_PASS p_arg1,p_arg2,p_arg3,p_arg4,p_arg5 40 #define VARIANT_ARG_DECLARE const Variant& p_arg1,const Variant& p_arg2,const Variant& p_arg3,const Variant& p_arg4,const Variant& p_arg5 41 #define VARIANT_ARG_MAX 5 42 #define VARIANT_ARGPTRS const Variant *argptr[5]={&p_arg1,&p_arg2,&p_arg3,&p_arg4,&p_arg5}; 43 #define VARIANT_ARGPTRS_PASS *argptr[0],*argptr[1],*argptr[2],*argptr[3],*argptr[4] 44 #define VARIANT_ARGS_FROM_ARRAY(m_arr) m_arr[0],m_arr[1],m_arr[2],m_arr[3],m_arr[4] 53 PROPERTY_HINT_EXP_RANGE,
55 PROPERTY_HINT_EXP_EASING,
57 PROPERTY_HINT_SPRITE_FRAME,
58 PROPERTY_HINT_KEY_ACCEL,
60 PROPERTY_HINT_ALL_FLAGS,
63 PROPERTY_HINT_GLOBAL_FILE,
64 PROPERTY_HINT_GLOBAL_DIR,
65 PROPERTY_HINT_RESOURCE_TYPE,
66 PROPERTY_HINT_MULTILINE_TEXT,
67 PROPERTY_HINT_COLOR_NO_ALPHA,
68 PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
69 PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
73 enum PropertyUsageFlags {
75 PROPERTY_USAGE_STORAGE=1,
76 PROPERTY_USAGE_EDITOR=2,
77 PROPERTY_USAGE_NETWORK=4,
78 PROPERTY_USAGE_EDITOR_HELPER=8,
79 PROPERTY_USAGE_CHECKABLE=16,
80 PROPERTY_USAGE_CHECKED=32,
81 PROPERTY_USAGE_INTERNATIONALIZED=64,
82 PROPERTY_USAGE_BUNDLE=128,
83 PROPERTY_USAGE_CATEGORY=256,
84 PROPERTY_USAGE_STORE_IF_NONZERO=512,
85 PROPERTY_USAGE_STORE_IF_NONONE=1024,
86 PROPERTY_USAGE_NO_INSTANCE_STATE=2048,
88 PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK,
89 PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED,
90 PROPERTY_USAGE_NOEDITOR=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_NETWORK,
96 #define ADD_SIGNAL( m_signal ) ObjectTypeDB::add_signal( get_type_static(), m_signal ) 97 #define ADD_PROPERTY( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), m_property, m_setter, m_getter ) 98 #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 ) 99 #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 ) 100 #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 ) 101 #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 ) 102 #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 ) 114 PropertyInfo() { type=Variant::NIL; hint=PROPERTY_HINT_NONE; usage = PROPERTY_USAGE_DEFAULT; }
115 PropertyInfo( Variant::Type p_type,
const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE,
const String& p_hint_string=
"",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
116 type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
119 return name<p_info.name;
136 inline bool operator<(
const MethodInfo& p_method)
const {
return id==p_method.id?(name < p_method.name):(
id<p_method.id); }
164 #define REVERSE_GET_PROPERTY_LIST \ 166 _FORCE_INLINE_ bool _is_gpl_reversed() const { return true; };\ 169 #define UNREVERSE_GET_PROPERTY_LIST \ 171 _FORCE_INLINE_ bool _is_gpl_reversed() const { return false; };\ 176 #define OBJ_TYPE( m_type, m_inherits )\ 178 void operator=(const m_type& p_rval) {}\ 179 mutable StringName _type_name;\ 180 friend class ObjectTypeDB;\ 182 virtual String get_type() const { \ 183 return String(#m_type);\ 185 virtual const StringName* _get_type_namev() const { \ 187 _type_name=get_type_static();\ 190 static _FORCE_INLINE_ void* get_type_ptr_static() { \ 194 static _FORCE_INLINE_ String get_type_static() { \ 195 return String(#m_type);\ 197 static _FORCE_INLINE_ String get_parent_type_static() { \ 198 return m_inherits::get_type_static();\ 200 static void get_inheritance_list_static(List<String>* p_inheritance_list) { \ 201 m_inherits::get_inheritance_list_static(p_inheritance_list);\ 202 p_inheritance_list->push_back(String(#m_type));\ 204 static String get_category_static() { \ 205 String category = m_inherits::get_category_static();\ 206 if (_get_category!=m_inherits::_get_category) {\ 209 category+=_get_category();\ 213 static String inherits_static() {\ 214 return String(#m_inherits);\ 216 virtual bool is_type(const String& p_type) const { return (p_type==(#m_type))?true:m_inherits::is_type(p_type); }\ 217 virtual bool is_type_ptr(void *p_ptr) const { return (p_ptr==get_type_ptr_static())?true:m_inherits::is_type_ptr(p_ptr); }\ 220 static void get_valid_parents_static(List<String> *p_parents) {\ 222 if (m_type::_get_valid_parents_static!=m_inherits::_get_valid_parents_static) { \ 223 m_type::_get_valid_parents_static(p_parents);\ 226 m_inherits::get_valid_parents_static(p_parents);\ 229 _FORCE_INLINE_ static void (*_get_bind_methods())() {\ 230 return &m_type::_bind_methods;\ 233 static void initialize_type() {\ 234 static bool initialized=false;\ 237 m_inherits::initialize_type();\ 238 ObjectTypeDB::_add_type<m_type>();\ 239 if (m_type::_get_bind_methods() != m_inherits::_get_bind_methods())\ 244 virtual void _initialize_typev() {\ 247 _FORCE_INLINE_ bool (Object::* (_get_get() const))(const StringName& p_name,Variant&) const {\ 248 return (bool (Object::*)(const StringName&,Variant&)const) &m_type::_get;\ 250 virtual bool _getv(const StringName& p_name, Variant& r_ret) const { \ 251 if (m_type::_get_get() != m_inherits::_get_get()) {\ 252 if (_get(p_name,r_ret))\ 255 return m_inherits::_getv(p_name,r_ret);\ 257 _FORCE_INLINE_ bool (Object::* (_get_set() const))(const StringName& p_name,const Variant &p_property) {\ 258 return (bool (Object::*)(const StringName&, const Variant&))&m_type::_set;\ 260 virtual bool _setv(const StringName& p_name,const Variant &p_property) { \ 261 if (m_inherits::_setv(p_name,p_property)) return true;\ 262 if (m_type::_get_set() != m_inherits::_get_set()) {\ 263 return _set(p_name,p_property);\ 268 _FORCE_INLINE_ void (Object::* (_get_get_property_list() const))(List<PropertyInfo> *p_list) const{\ 269 return (void (Object::*)(List<PropertyInfo>*)const)&m_type::_get_property_list;\ 271 virtual void _get_property_listv(List<PropertyInfo> *p_list,bool p_reversed) const { \ 273 m_inherits::_get_property_listv(p_list,p_reversed);\ 275 p_list->push_back( PropertyInfo(Variant::NIL,get_type_static(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_CATEGORY));\ 276 if (!_is_gpl_reversed())\ 277 ObjectTypeDB::get_property_list(#m_type,p_list,true);\ 278 if (m_type::_get_get_property_list() != m_inherits::_get_get_property_list()) {\ 279 _get_property_list(p_list);\ 281 if (_is_gpl_reversed())\ 282 ObjectTypeDB::get_property_list(#m_type,p_list,true);\ 284 m_inherits::_get_property_listv(p_list,p_reversed);\ 288 _FORCE_INLINE_ void (Object::* (_get_notification() const))(int){\ 289 return (void (Object::*)(int)) &m_type::_notification;\ 291 virtual void _notificationv(int p_notification,bool p_reversed) { \ 293 m_inherits::_notificationv(p_notification,p_reversed);\ 294 if (m_type::_get_notification() != m_inherits::_get_notification()) {\ 295 _notification(p_notification);\ 298 m_inherits::_notificationv(p_notification,p_reversed);\ 304 #define OBJ_CATEGORY(m_category)\ 306 _FORCE_INLINE_ static String _get_category() { return m_category; }\ 309 #define OBJ_SAVE_TYPE(m_type) \ 311 virtual String get_save_type() const { return #m_type; }\ 315 typedef uint32_t ObjectID;
335 bool operator<(
const Connection& p_conn)
const;
338 Connection() { source=NULL; target=NULL; flags=0; }
343 friend class _ObjectDebugLock;
345 friend bool predelete_handler(
Object*);
346 friend void postinitialize_handler(
Object*);
356 _FORCE_INLINE_
bool operator<(
const Target& p_target)
const {
return (_id==p_target._id)?(method<p_target.method):(_id<p_target._id); }
358 Target(
const ObjectID& p_id,
const StringName& p_method) { _id=p_id; method=p_method; }
384 uint32_t _instance_ID;
386 void _postinitialize();
398 bool _has_user_signal(
const StringName& p_name)
const;
400 Array _get_signal_list()
const;
401 Array _get_signal_connection_list(
const String& p_signal)
const;
405 void property_list_changed_notify();
409 virtual bool _use_builtin_script()
const {
return false; }
410 virtual void _initialize_typev() { initialize_type(); }
411 virtual bool _setv(
const StringName& p_name,
const Variant &p_property) {
return false; };
412 virtual bool _getv(
const StringName& p_name,
Variant &r_property)
const {
return false; };
413 virtual void _get_property_listv(
List<PropertyInfo> *p_list,
bool p_reversed)
const {};
414 virtual void _notificationv(
int p_notification,
bool p_reversed) {};
416 static String _get_category() {
return ""; }
417 static void _bind_methods();
421 void _notification(
int p_notification) {};
423 _FORCE_INLINE_
static void (*_get_bind_methods())() {
424 return &Object::_bind_methods;
427 return &Object::_get;
430 return &Object::_set;
433 return &Object::_get_property_list;
435 _FORCE_INLINE_ void (
Object::* (_get_notification()
const))(int){
436 return &Object::_notification;
438 static void get_valid_parents_static(
List<String> *p_parents);
439 static void _get_valid_parents_static(
List<String> *p_parents);
442 void cancel_delete();
444 virtual void _changed_callback(
Object *p_changed,
const char *p_prop);
453 virtual const StringName* _get_type_namev()
const {
455 _type_name=get_type_static();
460 Array _get_property_list_bind()
const;
461 Array _get_method_list_bind()
const;
463 void _clear_internal_resource_paths(
const Variant &p_var);
466 static void initialize_type();
467 _FORCE_INLINE_
static void register_custom_data_to_otdb() {};
472 _FORCE_INLINE_
void _change_notify(
const char *p_property=
"") { _edited=
true;
for(
Set<Object*>::Element *E=change_receptors.front();E;E=E->next()) ((
Object*)(E->get()))->_changed_callback(
this,p_property); }
474 _FORCE_INLINE_
void _change_notify(
const char *p_what=
"") { }
476 static void* get_type_ptr_static() {
481 bool _is_gpl_reversed()
const {
return false; }
483 _FORCE_INLINE_ ObjectID get_instance_ID()
const {
return _instance_ID; }
486 void add_change_receptor(
Object *p_receptor );
487 void remove_change_receptor(
Object *p_receptor );
493 return SAFE_CAST<T*>(
this);
497 if (is_type_ptr(T::get_type_ptr_static()))
498 return static_cast<T*>(
this);
505 const T *cast_to()
const {
508 return SAFE_CAST<const T*>(
this);
512 if (is_type_ptr(T::get_type_ptr_static()))
513 return static_cast<const T*>(
this);
521 NOTIFICATION_POSTINITIALIZE=0,
522 NOTIFICATION_PREDELETE=1
526 static void get_inheritance_list_static(
List<String>* p_inheritance_list) { p_inheritance_list->
push_back(
"Object"); }
528 static String get_type_static() {
return "Object"; }
529 static String get_parent_type_static() {
return String(); }
530 static String get_category_static() {
return String(); }
533 virtual String get_type()
const {
return "Object"; }
534 virtual String get_save_type()
const {
return get_type(); }
538 virtual bool is_type(
const String& p_type)
const {
return (p_type==
"Object"); }
539 virtual bool is_type_ptr(
void *p_ptr)
const {
return get_type_ptr_static()==p_ptr; }
541 _FORCE_INLINE_
const StringName& get_type_name()
const {
543 return *_get_type_namev();
558 bool has_method(
const StringName& p_method)
const;
562 virtual void call_multilevel(
const StringName& p_method,
const Variant** p_args,
int p_argcount);
563 virtual void call_multilevel_reversed(
const StringName& p_method,
const Variant** p_args,
int p_argcount);
565 void call_multilevel(
const StringName& p_name, VARIANT_ARG_LIST);
567 void notification(
int p_notification,
bool p_reversed=
false);
570 virtual Variant getvar(
const Variant& p_key,
bool *r_valid=NULL)
const;
571 virtual void setvar(
const Variant& p_key,
const Variant& p_value,
bool *r_valid=NULL);
575 void set_script(
const RefPtr& p_script);
576 RefPtr get_script()
const;
580 bool has_meta(
const String& p_name)
const;
581 void set_meta(
const String& p_name,
const Variant& p_value );
586 void set_edited(
bool p_edited);
587 bool is_edited()
const;
591 _FORCE_INLINE_
ScriptInstance* get_script_instance()
const {
return script_instance; }
594 void add_user_signal(
const MethodInfo& p_signal);
595 void emit_signal(
const StringName& p_name,VARIANT_ARG_LIST);
596 void emit_signal(
const StringName& p_name,
const Variant** p_args,
int p_argcount);
605 void call_deferred(
const StringName& p_method,VARIANT_ARG_LIST);
607 void set_block_signals(
bool p_block);
608 bool is_blocking_signals()
const;
610 Variant::Type get_static_property_type(
const StringName& p_property,
bool *r_valid=NULL)
const;
612 virtual void get_translatable_strings(
List<String> *p_strings)
const;
619 bool _is_queued_for_deletion;
620 bool is_queued_for_deletion()
const;
622 _FORCE_INLINE_
void set_message_translation(
bool p_enable) { _can_translate=p_enable; }
623 _FORCE_INLINE_
bool can_translate_messages()
const {
return _can_translate; }
625 void clear_internal_resource_paths();
633 bool predelete_handler(
Object *p_object);
634 void postinitialize_handler(
Object *p_object);
638 struct ObjectPtrHash {
640 static _FORCE_INLINE_ uint32_t hash(
const Object *p_obj) {
647 return HashMapHahserDefault::hash((uint64_t)u.i);
654 static uint32_t instance_counter;
656 friend void unregister_core_types();
658 static void cleanup();
659 static uint32_t add_instance(
Object *p_object);
660 static void remove_instance(
Object *p_object);
663 typedef void (*DebugFunc)(
Object *p_obj);
665 static Object *get_instance(uint32_t p_instance_ID);
666 static void debug_objects(DebugFunc p_func);
667 static int get_object_count();
670 _FORCE_INLINE_
static bool instance_validate(
Object* p_ptr) {
672 return instance_checks.has(p_ptr);
675 _FORCE_INLINE_
static bool instance_validate(
Object* p_ptr) {
return true; }
684 #include "object_type_db.h"
Element * push_back(const T &value)
Definition: list.h:220
Definition: safe_refcount.h:336
Definition: string_db.h:48
Definition: dictionary.h:42
Definition: script_language.h:109
Definition: variant.h:379