From 3c46e7dab884b7e1278c14e4c78d1a394d6bf94c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 1 Apr 2014 16:21:13 +0100 Subject: [PATCH] Eo2: Removed a lot of Eo1 code. --- src/Makefile_Eo.am | 2 - src/lib/eo/Eo.h | 323 ++--------- src/lib/eo/eo.c | 483 +---------------- src/lib/eo/eo2_base_class.c | 6 +- src/lib/eo/eo_base_class.c | 1013 ----------------------------------- src/lib/eo/eo_class_class.c | 20 - src/lib/eo/eo_private.h | 15 +- 7 files changed, 55 insertions(+), 1807 deletions(-) delete mode 100644 src/lib/eo/eo_base_class.c delete mode 100644 src/lib/eo/eo_class_class.c diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index bfefd27d73..c34b54b58c 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -10,8 +10,6 @@ lib_eo_libeo_la_SOURCES = \ lib/eo/eo.c \ lib/eo/eo_ptr_indirection.c \ lib/eo/eo_ptr_indirection.h \ -lib/eo/eo_class_class.c \ -lib/eo/eo_base_class.c \ lib/eo/eo2_base_class.c \ lib/eo/eo2_class_class.c \ lib/eo/eo_private.h diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index ffd2d7ded5..bd71f21257 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -229,20 +229,6 @@ EAPI void eo_dbg_info_free(Eo_Dbg_Info *info); * @} */ -/** - * @def EO_TYPECHECK(type, x) - * - * Checks x is castable to type "type" and casts it to it. - * @param type The C type to check against. - * @param x the variable to test and cast. - */ -#define EO_TYPECHECK(type, x) \ - ({ \ - type __x; \ - __x = x; \ - (type) __x; \ - }) - /** * @typedef Eo_Op * The Eo operation type id. @@ -446,7 +432,7 @@ typedef struct _Eo_Op_Description Eo_Op_Description; * @def EO_VERSION * The current version of EO. */ -#define EO_VERSION 1 +#define EO_VERSION 2 typedef struct _Eo2_Op_Description { @@ -470,8 +456,7 @@ struct _Eo_Class_Description Eo_Class_Type type; /**< The type of the class. */ struct { Eo_Op *base_op_id; - const Eo_Op_Description *descs; - Eo2_Op_Description *descs2; /**< EO2 */ + Eo2_Op_Description *descs2; size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ const Eo_Event_Description **events; /**< The event descriptions for this class. */ @@ -564,15 +549,6 @@ EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Cla */ EAPI Eina_Bool eo_isa(const Eo *obj, const Eo_Class *klass); -/** - * @brief Sets the OP functions for a class. - * @param klass the class to set the functions to. - * @param func_descs a NULL terminated array of #Eo_Op_Func_Description - * - * Should be called from within the class constructor. - */ -EAPI void eo_class_funcs_set(Eo_Class *klass, const Eo_Op_Func_Description *func_descs); - /** * @brief Gets the name of the passed class. * @param klass the class to work on. @@ -604,14 +580,14 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ -#define EO2_VERSION 2 +#define EO2_VERSION EO_VERSION // computes size of Eo2_Op_Description[] #define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) // Helpers macro to help populating #Eo_Class_Description. -#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, NULL, 0} -#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } +#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, 0} +#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data @@ -740,74 +716,6 @@ EAPI void _eo2_do_end(const Eo **ojb); /*****************************************************************************/ -/** - * @def eo_do - * A convenience wrapper around eo_do_internal() - * @see eo_do_internal - */ -#define eo_do(obj, ...) eo_do_internal(__FILE__, __LINE__, obj, __VA_ARGS__, EO_NOOP) - -/** - * @def eo_vdo - * A convenience wrapper around eo_vdo_internal() - * @see eo_vdo_internal - */ -#define eo_vdo(obj, args) eo_vdo_internal(__FILE__, __LINE__, obj, args) - -/** - * @brief Calls op functions of an object - * @param obj The object to work on - * @param ... NULL terminated list of OPs and parameters. - * @return @c EINA_TRUE on success. - * - * Use the helper macros, don't pass the parameters manually. - * Use #eo_do instead of this function. - * - * @see #eo_do - */ -EAPI Eina_Bool eo_do_internal(const char *file, int line, const Eo *obj, ...); - -/** - * @brief Calls op functions of an object - * @param obj The object to work on - * @param ops NULL terminated list of OPs and parameters. - * @return @c EINA_TRUE on success. - * - * Use the helper macros, don't pass the parameters manually. - * Use #eo_vdo instead of this function. - * - * @see #eo_vdo - */ -EAPI Eina_Bool eo_vdo_internal(const char *file, int line, const Eo *obj, va_list *ops); - -/** - * @brief Calls the super function for the specific op. - * @param obj The object to work on - * @param cur_klass The *current* class (use the class *after* this in the MRO). - * @param ... list of parameters. - * @return @c EINA_TRUE on success. - * - * Unlike eo_do(), this function only accepts one op. - * - * @see #eo_do - */ -#define eo_do_super(obj, cur_klass, ...) eo_do_super_internal(__FILE__, __LINE__, obj, cur_klass, __VA_ARGS__) - -/** - * @brief Calls the super function for the specific op. - * @param obj The object to work on - * @param cur_klass The *current* class (use the class *after* this in the MRO). - * @param op The wanted op. - * @param ... list of parameters. - * @return @c EINA_TRUE on success. - * - * Don't use this function, use the wrapping macros instead. - * - * @see #eo_do - * @see #eo_do_super - */ -EAPI Eina_Bool eo_do_super_internal(const char *file, int line, const Eo *obj, const Eo_Class *cur_klass, Eo_Op op, ...); - /** * @brief Gets the class of the object. * @param obj The object to work on @@ -840,11 +748,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add_custom */ -#define eo_add(klass, parent, ...) \ - ({ \ - const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo_constructor(), ## __VA_ARGS__, EO_NOOP); \ - }) #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ @@ -867,11 +770,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add */ -#define eo_add_custom(klass, parent, ...) \ - ({ \ - const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ - }) #define eo2_add_custom(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ @@ -883,19 +781,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); _tmp_obj; \ }) -/** - * @brief Create a new object. - * @param klass the class of the object to create. - * @param parent the parent to set to the object. - * @param ... The ops to run. With the constructor being first. - * @return An handle to the new object on success, NULL otherwise. - * - * Use the helper macros, don't pass the parameters manually. - * Use #eo_add or #eo_add_custom instead of this function. - * - * @see #eo_add - */ -EAPI Eo *eo_add_internal(const char *file, int line, const Eo_Class *klass, Eo *parent, ...); EAPI Eo * _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); EAPI Eo * _eo2_add_internal_end(const char *file, int line, const Eo *obj); @@ -1157,25 +1042,13 @@ EAPI Eina_Bool eo_composite_is(const Eo *comp_obj); * @def EO_CLASS_CLASS * The class type for the Eo Class class. */ -#define EO_CLASS_CLASS eo_class_class_get() #define EO2_CLASS_CLASS eo2_class_class_get() /** * @brief Use #EO_CLASS_CLASS * @internal * */ -EAPI const Eo_Class *eo_class_class_get(void); EAPI const Eo_Class *eo2_class_class_get(void); -/** - * @var EO_CLASS_CLASS_BASE_ID - * #EO_CLASS_CLASS 's base id. - */ -extern EAPI Eo_Op EO_CLASS_CLASS_BASE_ID; - -enum { - EO_CLASS_CLASS_SUB_ID_LAST -}; - /** * @} */ @@ -1189,13 +1062,11 @@ enum { * @def EO_BASE_CLASS * The class type for the Eo base class. */ -#define EO_BASE_CLASS eo_base_class_get() #define EO2_BASE_CLASS eo2_base_class_get() /** * @brief Use #EO_BASE_CLASS * @internal * */ -EAPI const Eo_Class *eo_base_class_get(void); EAPI const Eo_Class *eo2_base_class_get(void); /** @@ -1205,49 +1076,7 @@ EAPI const Eo_Class *eo2_base_class_get(void); typedef void (*eo_base_data_free_func)(void *); /** - * @var EO_BASE_BASE_ID - * #EO_BASE_CLASS 's base id. - */ -extern EAPI Eo_Op EO_BASE_BASE_ID; - -enum { - EO_BASE_SUB_ID_CONSTRUCTOR, - EO_BASE_SUB_ID_DESTRUCTOR, - EO_BASE_SUB_ID_PARENT_SET, - EO_BASE_SUB_ID_PARENT_GET, - EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW, - EO_BASE_SUB_ID_DATA_SET, - EO_BASE_SUB_ID_DATA_GET, - EO_BASE_SUB_ID_DATA_DEL, - EO_BASE_SUB_ID_WREF_ADD, - EO_BASE_SUB_ID_WREF_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_CALL, - EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL, - EO_BASE_SUB_ID_EVENT_FREEZE, - EO_BASE_SUB_ID_EVENT_THAW, - EO_BASE_SUB_ID_EVENT_FREEZE_GET, - EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE, - EO_BASE_SUB_ID_EVENT_GLOBAL_THAW, - EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET, - EO_BASE_SUB_ID_DBG_INFO_GET, - EO_BASE_SUB_ID_LAST -}; - -/** - * @def EO_BASE_ID(sub_id) - * Helper macro to get the full Op ID out of the sub_id for EO_BASE. - * @param sub_id the sub id inside EO_BASE. - */ -#define EO_BASE_ID(sub_id) (EO_BASE_BASE_ID + (sub_id)) - -/** - * @def eo_base_data_set(key, data, free_func) - * Set generic data to object. + * @brief Set generic data to object. * @param[in] key the key associated with the data * @param[in] data the data to set. * @param[in] free_func the func to free data with (NULL means "do nothing"). @@ -1255,46 +1084,34 @@ enum { * @see #eo_base_data_get * @see #eo_base_data_del */ -#define eo_base_data_set(key, data, free_func) EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(const void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func) -EAPI void -eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); +EAPI void eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); /** - * @def eo_base_data_get(key, data) - * Get generic data from object. + * @brief Get generic data from object. * @param[in] key the key associated with the data * @param[out] data the data for the key * * @see #eo_base_data_set * @see #eo_base_data_del */ -#define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data) -EAPI void * -eo2_base_data_get(const char *key); +EAPI void *eo2_base_data_get(const char *key); /** - * @def eo_dbg_info_get(root_node) - * Get dbg information from the object. + * @brief Get dbg information from the object. * @param[in] root node of the tree */ -#define eo_dbg_info_get(root_node) EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), EO_TYPECHECK(Eo_Dbg_Info *, root_node) -EAPI void -eo2_dbg_info_get(Eo_Dbg_Info *root_node); +EAPI void eo2_dbg_info_get(Eo_Dbg_Info *root_node); /** - * @def eo_base_data_del(key) - * Del generic data from object. + * @brief Del generic data from object. * @param[in] key the key associated with the data * * @see #eo_base_data_set * @see #eo_base_data_get */ -#define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key) -EAPI void -eo2_base_data_del(const char *key); +EAPI void eo2_base_data_del(const char *key); /** - * @def eo_parent_set * @brief Set the parent of an object * @param[in] parent the new parent. * @@ -1305,35 +1122,26 @@ eo2_base_data_del(const char *key); * @see eo_del() * @see eo_parent_get() */ -#define eo_parent_set(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), EO_TYPECHECK(Eo *, parent) -EAPI void -eo2_parent_set(Eo *parent); +EAPI void eo2_parent_set(Eo *parent); /** - * @def eo_parent_get * @brief Get the parent of an object * @param[out] a pointer to the parent object. * * @see eo_parent_set() */ -#define eo_parent_get(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), EO_TYPECHECK(Eo **, parent) -EAPI Eo * -eo2_parent_get(void); +EAPI Eo *eo2_parent_get(void); /** - * @def eo_children_iterator_new * @brief Get an iterator on all childrens * @param obj the object to get the childrens from. * @return a pointer to an Eina_Iterator containing all the childrens. * * @see eo_parent_set() */ -#define eo_children_iterator_new(it) EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), EO_TYPECHECK(Eina_Iterator **, it) -EAPI Eina_Iterator * -eo2_children_iterator_new(void); +EAPI Eina_Iterator *eo2_children_iterator_new(void); /** - * @def eo_wref_add * @brief Add a new weak reference to obj. * @param wref The pointer to use for the weak ref. * @@ -1344,20 +1152,15 @@ eo2_children_iterator_new(void); * * @see #eo_wref_del */ -#define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref) -EAPI void -eo2_wref_add(Eo **wref); +EAPI void eo2_wref_add(Eo **wref); /** - * @def eo_wref_del * @brief Delete the weak reference passed. * @param wref the weak reference to free. * * @see #eo_wref_add */ -#define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref) -EAPI void -eo2_wref_del(Eo **wref); +EAPI void eo2_wref_del(Eo **wref); /** * @def eo_weak_ref @@ -1371,10 +1174,6 @@ eo2_wref_del(Eo **wref); * @see eo_weak_unref * @see eo_wref_add */ -#define eo_weak_ref(wref) \ - do { \ - if (*wref) eo_do(*wref, eo_wref_add(wref)); \ - } while (0) #define eo2_weak_ref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_add(wref)); \ @@ -1393,10 +1192,6 @@ eo2_wref_del(Eo **wref); * @see eo_wref_del * @see eo_wref_del_safe */ -#define eo_weak_unref(wref) \ - do { \ - if (*wref) eo_do(*wref, eo_wref_del(wref)); \ - } while (0) #define eo2_weak_unref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_del(wref)); \ @@ -1412,32 +1207,25 @@ eo2_wref_del(Eo **wref); * * @see #eo_wref_del */ -#define eo_wref_del_safe(wref) eo_weak_unref(wref) #define eo2_wref_del_safe(wref) eo2_weak_unref(wref) /** - * @def eo_constructor * @brief Call the object's constructor. * * Should not be used with #eo_do. Only use it with #eo_do_super. * * @see #eo_destructor */ -#define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR) -EAPI void -eo2_constructor(void); +EAPI void eo2_constructor(void); /** - * @def eo_destructor * @brief Call the object's destructor. * * Should not be used with #eo_do. Only use it with #eo_do_super. * * @see #eo_constructor */ -#define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR) -EAPI void -eo2_destructor(void); +EAPI void eo2_destructor(void); /** * @addtogroup Eo_Events Eo's Event Handling @@ -1522,55 +1310,42 @@ struct _Eo_Callback_Array_Item } /** - * @def eo_event_callback_forwarder_add * @brief Add an event callback forwarder for an event and an object. * @param[in] desc The description of the event to listen to. * @param[in] new_obj The object to emit events from. * * @see eo_event_callback_forwarder_del() */ -#define eo_event_callback_forwarder_add(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) -EAPI void -eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); /** - * @def eo_event_callback_forwarder_del * @brief Remove an event callback forwarder for an event and an object. * @param[in] desc The description of the event to listen to. * @param[in] new_obj The object to emit events from. * * @see eo_event_callback_forwarder_add() */ -#define eo_event_callback_forwarder_del(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) -EAPI void -eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); /** - * @def eo_event_freeze * @brief freeze events of object. * * Prevents event callbacks from being called for the object. * * @see #eo_event_thaw */ -#define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE) -EAPI void -eo2_event_freeze(void); +EAPI void eo2_event_freeze(void); /** - * @def eo_event_thaw * @brief thaw events of object. * * Lets event callbacks be called for the object. * * @see #eo_event_freeze */ -#define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW) -EAPI void -eo2_event_thaw(void); +EAPI void eo2_event_thaw(void); /** - * @def eo_event_freeze_get * @brief return freeze events of object. * * @param[out] fcount The event freeze count of the object. @@ -1580,12 +1355,9 @@ eo2_event_thaw(void); * @see #eo_event_freeze * @see #eo_event_thaw */ -#define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount) -EAPI int -eo2_event_freeze_get(void); +EAPI int eo2_event_freeze_get(void); /** - * @def eo_event_global_freeze * @brief freeze events of object. * * Prevents event callbacks from being called for the object. @@ -1593,12 +1365,9 @@ eo2_event_freeze_get(void); * @see #eo_event_freeze * @see #eo_event_global_thaw */ -#define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE) -EAPI void -eo2_event_global_freeze(void); +EAPI void eo2_event_global_freeze(void); /** - * @def eo_event_global_thaw * @brief thaw events of object. * * Lets event callbacks be called for the object. @@ -1606,12 +1375,9 @@ eo2_event_global_freeze(void); * @see #eo_event_thaw * @see #eo_event_global_freeze */ -#define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW) -EAPI void -eo2_event_global_thaw(void); +EAPI void eo2_event_global_thaw(void); /** - * @def eo_event_global_freeze_get * @brief return freeze events of object. * * @param[out] fcount The event freeze count of the object. @@ -1622,9 +1388,7 @@ eo2_event_global_thaw(void); * @see #eo_event_global_freeze * @see #eo_event_global_thaw */ -#define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount) -EAPI int -eo2_event_global_freeze_get(void); +EAPI int eo2_event_global_freeze_get(void); /** * @def eo_event_callback_add(obj, desc, cb, data) @@ -1637,15 +1401,11 @@ eo2_event_global_freeze_get(void); * * @see eo_event_callback_priority_add() */ -#define eo_event_callback_add(desc, cb, data) \ - eo_event_callback_priority_add(desc, \ - EO_CALLBACK_PRIORITY_DEFAULT, cb, data) #define eo2_event_callback_add(desc, cb, data) \ eo2_event_callback_priority_add(desc, \ EO_CALLBACK_PRIORITY_DEFAULT, cb, data) /** - * @def eo_event_callback_priority_add * @brief Add a callback for an event with a specific priority. * @param[in] desc The description of the event to listen to. * @param[in] priority The priority of the callback. @@ -1656,24 +1416,19 @@ eo2_event_global_freeze_get(void); * * @see #eo_event_callback_add */ -#define eo_event_callback_priority_add(desc, priority, cb, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(Eo_Event_Cb, cb), EO_TYPECHECK(const void *, data) -EAPI void -eo2_event_callback_priority_add(const Eo_Event_Description *desc, +EAPI void eo2_event_callback_priority_add(const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb func, const void *user_data); /** - * @def eo_event_callback_del * @brief Del a callback with a specific data associated to it for an event. * @param[in] desc The description of the event to listen to. * @param[in] func the callback to delete. * @param[in] user_data The data to compare. * */ -#define eo_event_callback_del(desc, func, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Event_Cb, func), EO_TYPECHECK(const void *, user_data) -EAPI void -eo2_event_callback_del(const Eo_Event_Description *desc, +EAPI void eo2_event_callback_del(const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data); @@ -1687,15 +1442,11 @@ eo2_event_callback_del(const Eo_Event_Description *desc, * * @see eo_event_callback_array_priority_add() */ -#define eo_event_callback_array_add(array, data) \ - eo_event_callback_array_priority_add(array, \ - EO_CALLBACK_PRIORITY_DEFAULT, data) #define eo2_event_callback_array_add(array, data) \ eo2_event_callback_array_priority_add(array, \ EO_CALLBACK_PRIORITY_DEFAULT, data) /** - * @def eo_event_callback_array_priority_add * @brief Add a callback array for an event with a specific priority. * @param[in] array an #Eo_Callback_Array_Item of events to listen to. * @param[in] priority The priority of the callback. @@ -1705,34 +1456,26 @@ eo2_event_callback_del(const Eo_Event_Description *desc, * * @see #eo_event_callback_add */ -#define eo_event_callback_array_priority_add(array, priority, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(const void *, data) -EAPI void -eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, +EAPI void eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, const void *user_data); /** - * @def eo_event_callback_array_del * @brief Del a callback array with a specific data associated to it for an event. * @param[in] array an #Eo_Callback_Array_Item of events to listen to. * @param[in] user_data The data to compare. * */ -#define eo_event_callback_array_del(array, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(const void *, user_data) -EAPI void -eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, +EAPI void eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, const void *user_data); /** - * @def eo_event_callback_call * @brief Call the callbacks for an event of an object. * @param[in] desc The description of the event to call. * @param[in] event_info Extra event info to pass to the callbacks. * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise. */ -#define eo_event_callback_call(desc, event_info, aborted) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(const void *, event_info), EO_TYPECHECK(Eina_Bool *, aborted) -EAPI Eina_Bool -eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); +EAPI Eina_Bool eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); /** * @} diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 1687090a17..24b515f2fe 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -28,8 +28,7 @@ static inline void *_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *k static inline void *_eo_data_xref_internal(const char *file, int line, _Eo_Object *obj, const _Eo_Class *klass, const _Eo_Object *ref_obj); static inline void _eo_data_xunref_internal(_Eo_Object *obj, void *data, const _Eo_Object *ref_obj); static const _Eo_Class *_eo_op_class_get(Eo_Op op); -static const Eo_Op_Description *_eo_op_id_desc_get(Eo_Op op); -static const char * _eo_op_id_name_get(Eo_Op op, int version); +static const char * _eo_op_id_name_get(Eo_Op op); /* Start of Dich */ @@ -108,7 +107,7 @@ _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) if (fsrc->src == klass) { const _Eo_Class *op_kls = _eo_op_class_get(op); - const char *op_name = _eo_op_id_name_get(op, op_kls->desc->version); + const char *op_name = _eo_op_id_name_get(op); ERR("Class '%s': Overriding func %p for op %d (%s:'%s') with %p.", klass->desc->name, fsrc->func, op, op_kls->desc->name, op_name, func); return EINA_FALSE; @@ -137,10 +136,6 @@ _dich_func_clean_all(_Eo_Class *klass) /* END OF DICH */ -static const Eo_Op_Description noop_desc = - EO_OP_DESCRIPTION(EO_NOOP, "No operation."); - - static inline Eina_Bool _eo_is_a_class(const Eo *eo_id) { @@ -189,26 +184,6 @@ _eo_op_class_get(Eo_Op op) return NULL; } -static const Eo_Op_Description * -_eo_op_id_desc_get(Eo_Op op) -{ - const _Eo_Class *klass; - - if (op == EO_NOOP) - return &noop_desc; - - klass = _eo_op_class_get(op); - - if (klass) - { - Eo_Op sub_id = op - klass->base_id; - if (sub_id < klass->desc->ops.count) - return klass->desc->ops.descs + sub_id; - } - - return NULL; -} - static const Eo2_Op_Description * _eo2_op_id_desc_get(Eo_Op op) { @@ -236,18 +211,10 @@ _eo2_op_id_desc_get(Eo_Op op) } static const char * -_eo_op_id_name_get(Eo_Op op, int version) +_eo_op_id_name_get(Eo_Op op) { - if (version == EO2_VERSION) - { - const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); - return (desc) ? desc->doc : NULL; - } - else - { - const Eo_Op_Description *desc = _eo_op_id_desc_get(op); - return (desc) ? desc->name : NULL; - } + const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); + return (desc) ? desc->doc : NULL; } static inline const op_type_funcs * @@ -278,32 +245,6 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op o return NULL; } -static inline const _Eo_Class * -_eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) -{ - const op_type_funcs *fsrc; - fsrc = _eo2_kls_itr_next(orig_kls, cur_klass, op); - - return (fsrc) ? fsrc->src : NULL; -} - -static inline const op_type_funcs * -_eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) -{ - const _Eo_Class *klass = cur_klass; - if (klass) - { - const op_type_funcs *func = _dich_func_get(klass, op); - - if (func && func->func) - { - return func; - } - } - - return NULL; -} - /************************************ EO2 ************************************/ EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL; @@ -883,211 +824,18 @@ _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) const _Eo_Class *op_klass = _eo_op_class_get(op); \ const char *_dom_name = (op_klass) ? op_klass->desc->name : NULL; \ ERR("in %s:%d: Can't execute function %s:%s (op 0x%x) for class '%s'. Aborting.", \ - file, line, _dom_name, _eo_op_id_name_get(op, op_klass->desc->version), op, \ + file, line, _dom_name, _eo_op_id_name_get(op), op, \ (klass) ? klass->desc->name : NULL); \ } \ while (0) -static inline Eina_Bool -_eo_op_internal(const char *file, int line, Eo_Base *eo_ptr, const _Eo_Class *cur_klass, - Eo_Op_Type op_type, Eo_Op op, va_list *p_list) -{ -#ifdef EO_DEBUG - const Eo_Op_Description *op_desc = _eo_op_id_desc_get(op); - - if (op_desc && (op_type != op_desc->op_type)) - { - if (op_type == EO_OP_TYPE_REGULAR) - { - ERR("in %s:%d: Tried calling a class op '%s' (0x%x) from a non-class context.", - file, line, op_desc->name, op); - } - else - { - ERR("in %s:%d: Tried calling an instance op '%s' (0x%x) from a class context.", - file, line, op_desc->name, op); - } - return EINA_FALSE; - } -#endif - - { - const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op); - if (EINA_LIKELY(func != NULL)) - { - void *func_data = NULL; - Eo *calling_obj; - if (op_type == EO_OP_TYPE_REGULAR) - { - func_data = _eo_data_scope_get((_Eo_Object *) eo_ptr, func->src); - calling_obj = _eo_id_get((_Eo_Object *) eo_ptr); - } - else - { - calling_obj = _eo_class_id_get(cur_klass); - } - func->func(calling_obj, func_data, p_list); - return EINA_TRUE; - } - } - - /* Try composite objects */ - if (op_type == EO_OP_TYPE_REGULAR) - { - const _Eo_Object **comp_itr = ((_Eo_Object *) eo_ptr)->composites; - if (!comp_itr) return EINA_FALSE; - - for (unsigned int i = 0; i < ((_Eo_Object *) eo_ptr)->klass->composites_count; i++, comp_itr++) - if (*comp_itr) - { - if (_eo_op_internal(file, line, (Eo_Base *) (*comp_itr), (*comp_itr)->klass, op_type, op, p_list)) - { - return EINA_TRUE; - } - } - } - - return EINA_FALSE; -} - -static inline Eina_Bool -_eo_dov_internal(const char *file, int line, Eo_Base *obj, const _Eo_Class *klass, Eo_Op_Type op_type, va_list *p_list) -{ - Eina_Bool ret = EINA_TRUE; - Eo_Op op = EO_NOOP; - - op = va_arg(*p_list, Eo_Op); - while (op) - { - if (!_eo_op_internal(file, line, obj, klass, op_type, op, p_list)) - { - _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass); - ret = EINA_FALSE; - break; - } - op = va_arg(*p_list, Eo_Op); - } - - return ret; -} - -static inline Eina_Bool -_eo_obj_dov_internal(const char *file, int line, _Eo_Object *obj, va_list *p_list) -{ - Eina_Bool prev_error; - Eina_Bool ret = EINA_TRUE; - - prev_error = obj->do_error; - _eo_ref(obj); - - ret = _eo_dov_internal(file, line, (Eo_Base *) obj, obj->klass, EO_OP_TYPE_REGULAR, p_list); - - if (obj->do_error) - ret = EINA_FALSE; - - obj->do_error = prev_error; - _eo_unref(obj); - - return ret; -} - -static inline Eina_Bool -_eo_class_dov_internal(const char *file, int line, _Eo_Class *klass, va_list *p_list) -{ - return _eo_dov_internal(file, line, (Eo_Base *) klass, klass, EO_OP_TYPE_CLASS, p_list); -} - -EAPI Eina_Bool -eo_do_internal(const char *file, int line, const Eo *eo_id, ...) -{ - Eina_Bool ret = EINA_TRUE; - va_list p_list; - Eina_Bool class_ref = _eo_is_a_class(eo_id); - - if (class_ref) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - - va_start(p_list, eo_id); - ret = _eo_class_dov_internal(file, line, klass, &p_list); - va_end(p_list); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - - va_start(p_list, eo_id); - ret = _eo_obj_dov_internal(file, line, obj, &p_list); - va_end(p_list); - } - - return ret; -} - -EAPI Eina_Bool -eo_vdo_internal(const char *file, int line, const Eo *eo_id, va_list *ops) -{ - Eina_Bool class_ref = _eo_is_a_class(eo_id); - - if (class_ref) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - return _eo_class_dov_internal(file, line, klass, ops); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - return _eo_obj_dov_internal(file, line, obj, ops); - } -} - -EAPI Eina_Bool -eo_do_super_internal(const char *file, int line, const Eo *eo_id, const Eo_Class *cur_klass_id, Eo_Op op, ...) -{ - const _Eo_Class *nklass; - Eina_Bool op_ret = EINA_TRUE; - Eina_Bool ret = EINA_TRUE; - va_list p_list; - - EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - - if (_eo_is_a_class(eo_id)) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - - va_start(p_list, op); - nklass = _eo_kls_itr_next(klass, cur_klass, op); - op_ret = _eo_op_internal(file, line, (Eo_Base *) klass, nklass, EO_OP_TYPE_CLASS, op, &p_list); - va_end(p_list); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - - va_start(p_list, op); - nklass = _eo_kls_itr_next(obj->klass, cur_klass, op); - op_ret = _eo_op_internal(file, line, (Eo_Base *) obj, nklass, EO_OP_TYPE_REGULAR, op, &p_list); - if (obj->do_error) - ret = EINA_FALSE; - va_end(p_list); - } - - if (!op_ret) - _EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass); - - return (ret & op_ret); -} - EAPI const Eo_Class * eo_class_get(const Eo *eo_id) { if (_eo_is_a_class(eo_id)) { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); - if (_klass->desc->version == EO2_VERSION) - return eo2_class_class_get(); - else - return eo_class_class_get(); + return eo2_class_class_get(); } EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); @@ -1265,40 +1013,6 @@ _eo_class_constructor(_Eo_Class *klass) klass->desc->class_constructor(_eo_class_id_get(klass)); } -EAPI void -eo_class_funcs_set(Eo_Class *klass_id, const Eo_Op_Func_Description *func_descs) -{ - EO_CLASS_POINTER_RETURN(klass_id, klass); - - const Eo_Op_Func_Description *itr; - itr = func_descs; - if (itr) - { - for ( ; itr->op_type != EO_OP_TYPE_INVALID ; itr++) - { - const Eo_Op_Description *op_desc = _eo_op_id_desc_get(itr->op); - - if (EINA_UNLIKELY(!op_desc || (itr->op == EO_NOOP))) - { - ERR("Setting implementation for non-existent op 0x%x for class '%s'. Func index: %lu", itr->op, klass->desc->name, (unsigned long) (itr - func_descs)); - } - else if (EINA_LIKELY(itr->op_type == op_desc->op_type)) - { - _dich_func_set(klass, itr->op, itr->func); - } - else - { - ERR("Set function's op type (0x%x) is different than the one in the op description (%d) for op '%s:%s'. Func index: %lu", - itr->op_type, - (op_desc) ? op_desc->op_type : EO_OP_TYPE_REGULAR, - klass->desc->name, - (op_desc) ? op_desc->name : NULL, - (unsigned long) (itr - func_descs)); - } - } - } -} - static void eo_class_free(_Eo_Class *klass) { @@ -1324,56 +1038,6 @@ eo_class_free(_Eo_Class *klass) free(klass); } -/* DEVCHECK */ -static Eina_Bool -_eo_class_check_op_descs(const Eo_Class_Description *desc) -{ - const Eo_Op_Description *itr; - size_t i; - - if (desc->ops.count > 0) - { - if (!desc->ops.base_op_id) - { - ERR("Class '%s' has a non-zero ops count, but base_id is NULL.", - desc->name); - return EINA_FALSE; - } - - if (!desc->ops.descs) - { - ERR("Class '%s' has a non-zero ops count, but there are no descs.", - desc->name); - return EINA_FALSE; - } - } - - itr = desc->ops.descs; - for (i = 0 ; i < desc->ops.count ; i++, itr++) - { - if (itr->sub_op != i) - { - if (itr->name) - { - ERR("Wrong order in Ops description for class '%s'. Expected 0x%lx and got 0x%lx", desc->name, (unsigned long) i, (unsigned long) itr->sub_op); - } - else - { - ERR("Found too few Ops description for class '%s'. Expected 0x%lx descriptions, but found 0x%lx.", desc->name, (unsigned long) desc->ops.count, (unsigned long) i); - } - return EINA_FALSE; - } - } - - if (itr && itr->name) - { - ERR("Found extra Ops description for class '%s'. Expected %lu descriptions, but found more.", desc->name, (unsigned long) desc->ops.count); - return EINA_FALSE; - } - - return EINA_TRUE; -} - /* Not really called, just used for the ptr... */ static void _eo_class_isa_func(Eo *eo_id EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) @@ -1392,12 +1056,6 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(desc->name, NULL); - if (desc->version != EO2_VERSION) - { - if (!_eo_class_check_op_descs(desc)) - return NULL; - } - _Eo_Class *parent = _eo_class_pointer_get(parent_id); #ifndef HAVE_EO_ID if (parent && !EINA_MAGIC_CHECK((Eo_Base *) parent, EO_CLASS_EINA_MAGIC)) @@ -1635,16 +1293,13 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } } - if (desc->version == EO2_VERSION) + if (!_eo2_class_funcs_set(klass)) { - if (!_eo2_class_funcs_set(klass)) - { - eina_spinlock_free(&klass->objects.trash_lock); - eina_spinlock_free(&klass->iterators.trash_lock); - _dich_func_clean_all(klass); - free(klass); + eina_spinlock_free(&klass->objects.trash_lock); + eina_spinlock_free(&klass->iterators.trash_lock); + _dich_func_clean_all(klass); + free(klass); return NULL; - } } eina_spinlock_take(&_eo_class_creation_lock); @@ -1684,103 +1339,6 @@ eo_isa(const Eo *eo_id, const Eo_Class *klass_id) return (func && (func->func == _eo_class_isa_func)); } -// A little bit hacky, but does the job -static void -_eo_parent_internal_set(_Eo_Object *obj, ...) -{ - va_list p_list; - - va_start(p_list, obj); - _eo_op_internal(__FILE__, __LINE__, (Eo_Base *) obj, obj->klass, - EO_OP_TYPE_REGULAR, EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), - &p_list); - va_end(p_list); -} - -EAPI Eo * -eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id, ...) -{ - Eina_Bool do_err; - _Eo_Object *obj; - EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, NULL); - - if (parent_id) - { - EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, NULL); - } - - if (EINA_UNLIKELY(klass->desc->type != EO_CLASS_TYPE_REGULAR)) - { - ERR("in %s:%d: Class '%s' is not instantiate-able. Aborting.", file, line, klass->desc->name); - return NULL; - } - - eina_spinlock_take(&klass->objects.trash_lock); - obj = eina_trash_pop(&klass->objects.trash); - if (obj) - { - memset(obj, 0, klass->obj_size); - klass->objects.trash_count--; - } - else - { - obj = calloc(1, klass->obj_size); - } - eina_spinlock_release(&klass->objects.trash_lock); - - obj->refcount++; - obj->klass = klass; - if (klass->composites_count == 0) - obj->composites = NULL; - else - obj->composites = (const _Eo_Object **) - ((char *) obj + klass->obj_size - (klass->composites_count * sizeof(_Eo_Object *))); - -#ifndef HAVE_EO_ID - EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC); -#endif - Eo_Id obj_id = _eo_id_allocate(obj); - obj->header.id = obj_id; - - _eo_condtor_reset(obj); - - _eo_ref(obj); - - _eo_parent_internal_set(obj, parent_id); - - /* Run the relevant do stuff. */ - { - va_list p_list; - va_start(p_list, parent_id); - do_err = !_eo_obj_dov_internal(file, line, obj, &p_list); - va_end(p_list); - } - - if (EINA_UNLIKELY(do_err)) - { - ERR("in %s:%d, Object of class '%s' - One of the object constructors have failed.", - file, line, klass->desc->name); - goto fail; - } - - if (!obj->condtor_done) - { - ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", - file, line, klass->desc->name); - goto fail; - } - - _eo_unref(obj); - - return _eo_id_get(obj); - -fail: - /* Unref twice, once for the ref above, and once for the basic object ref. */ - _eo_unref(obj); - _eo_unref(obj); - return NULL; -} - EAPI Eo * eo_xref_internal(const char *file, int line, Eo *obj_id, const Eo *ref_obj_id) { @@ -1853,10 +1411,7 @@ EAPI void eo_del(const Eo *obj) { EO_OBJ_POINTER_RETURN(obj, _obj); - if (_obj->klass->desc->version == EO2_VERSION) - eo2_do((Eo *) obj, eo2_parent_set(NULL)); - else - eo_do((Eo *) obj, eo_parent_set(NULL)); + eo2_do((Eo *) obj, eo2_parent_set(NULL)); eo_unref(obj); } @@ -2106,7 +1661,7 @@ eo_init(void) EINA_LOG_STATE_INIT); /* bootstrap EO_CLASS_CLASS */ - (void) eo_class_class_get(); + (void) eo2_class_class_get(); if (_eo2_call_stack_key != 0) WRN("_eo2_call_stack_key already set, this should not happen."); @@ -2191,10 +1746,7 @@ eo_composite_attach(Eo *comp_obj_id, Eo *parent_id) comp_obj->composite = EINA_TRUE; *comp_dst = comp_obj; - if (comp_obj->klass->desc->version == EO2_VERSION) - eo2_do(comp_obj_id, eo2_parent_set(parent_id)); - else - eo_do(comp_obj_id, eo_parent_set(parent_id)); + eo2_do(comp_obj_id, eo2_parent_set(parent_id)); return EINA_TRUE; } @@ -2216,10 +1768,7 @@ eo_composite_detach(Eo *comp_obj_id, Eo *parent_id) { comp_obj->composite = EINA_FALSE; *comp_itr = NULL; - if (comp_obj->klass->desc->version == EO2_VERSION) - eo2_do(comp_obj_id, eo2_parent_set(NULL)); - else - eo_do(comp_obj_id, eo_parent_set(NULL)); + eo2_do(comp_obj_id, eo2_parent_set(NULL)); return EINA_TRUE; } } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 3cf4b8fd4c..936cabedbb 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -121,7 +121,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) { Private_Data *old_parent_pd; - old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); + old_parent_pd = eo_data_scope_get(pd->parent, EO2_BASE_CLASS); if (old_parent_pd) { old_parent_pd->children = eina_list_remove(old_parent_pd->children, @@ -140,7 +140,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) if (parent_id) { Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); + parent_pd = eo_data_scope_get(parent_id, EO2_BASE_CLASS); if (EINA_LIKELY(parent_pd != NULL)) { @@ -910,7 +910,7 @@ EAPI const Eina_Value_Type *EO2_DBG_INFO_TYPE = &_EO2_DBG_INFO_TYPE; /* EO_BASE_CLASS stuff */ -#define MY_CLASS EO_BASE_CLASS +#define MY_CLASS EO2_BASE_CLASS /* FIXME: Set proper type descriptions. */ // FIXME: eo2 multiple definition diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c deleted file mode 100644 index c83b19bb23..0000000000 --- a/src/lib/eo/eo_base_class.c +++ /dev/null @@ -1,1013 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "Eo.h" -#include "eo_ptr_indirection.h" -#include "eo_private.h" - -EAPI Eo_Op EO_BASE_BASE_ID = 0; - -static int event_freeze_count = 0; - -typedef struct _Eo_Callback_Description Eo_Callback_Description; - -typedef struct -{ - Eina_List *children; - Eo *parent; - - Eina_Inlist *generic_data; - Eo ***wrefs; - - Eo_Callback_Description *callbacks; - unsigned short walking_list; - unsigned short event_freeze_count; - Eina_Bool deletions_waiting : 1; -} Private_Data; - -typedef struct -{ - EINA_INLIST; - Eina_Stringshare *key; - void *data; - eo_base_data_free_func free_func; -} Eo_Generic_Data_Node; - -static void -_eo_generic_data_node_free(Eo_Generic_Data_Node *node) -{ - eina_stringshare_del(node->key); - if (node->free_func) - node->free_func(node->data); - free(node); -} - -static void -_eo_generic_data_del_all(Private_Data *pd) -{ - Eina_Inlist *nnode; - Eo_Generic_Data_Node *node = NULL; - - EINA_INLIST_FOREACH_SAFE(pd->generic_data, nnode, node) - { - pd->generic_data = eina_inlist_remove(pd->generic_data, - EINA_INLIST_GET(node)); - - _eo_generic_data_node_free(node); - } -} - -static void -_data_set(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = class_data; - - EO_PARAMETER_GET(const char *, key, list); - EO_PARAMETER_GET(const void *, data, list); - EO_PARAMETER_GET(eo_base_data_free_func, free_func, list); - - Eo_Generic_Data_Node *node; - - if (!key) return; - - eo_do(obj, eo_base_data_del(key)); - - node = malloc(sizeof(Eo_Generic_Data_Node)); - if (!node) return; - node->key = eina_stringshare_add(key); - node->data = (void *) data; - node->free_func = free_func; - pd->generic_data = eina_inlist_prepend(pd->generic_data, - EINA_INLIST_GET(node)); -} - -static void -_data_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - /* We don't really change it... */ - Eo_Generic_Data_Node *node; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const char *, key, list); - EO_PARAMETER_GET(void **, data, list); - - if (!data) return; - *data = NULL; - - if (!key) return; - - EINA_INLIST_FOREACH(pd->generic_data, node) - { - if (!strcmp(node->key, key)) - { - pd->generic_data = - eina_inlist_promote(pd->generic_data, EINA_INLIST_GET(node)); - *data = node->data; - return; - } - } -} - -static void -_parent_set(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(Eo *, parent_id, list); - - if (pd->parent == parent_id) - return ; - - if (eo_composite_is(obj) && pd->parent) - { - eo_composite_detach(obj, pd->parent); - } - - if (pd->parent) - { - Private_Data *old_parent_pd; - - old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); - if (old_parent_pd) - { - old_parent_pd->children = eina_list_remove(old_parent_pd->children, - obj); - } - else - { - ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.", - pd->parent, obj); - } - - eo_xunref(obj, pd->parent); - } - - /* Set new parent */ - if (parent_id) - { - Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); - - if (EINA_LIKELY(parent_pd != NULL)) - { - pd->parent = parent_id; - parent_pd->children = eina_list_append(parent_pd->children, - obj); - eo_xref(obj, pd->parent); - } - else - { - pd->parent = NULL; - ERR("New parent %p for object %p is not a valid Eo object.", - parent_id, obj); - } - } - else - { - pd->parent = NULL; - } -} - -static void -_parent_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(Eo **, parent_id, list); - - if (!parent_id) return ; - *parent_id = pd->parent; -} - - -/* Children accessor */ -typedef struct _Eo_Children_Iterator Eo_Children_Iterator; -struct _Eo_Children_Iterator -{ - Eina_Iterator iterator; - Eina_List *current; - _Eo_Object *obj; - Eo *obj_id; - -}; - -static Eina_Bool -_eo_children_iterator_next(Eo_Children_Iterator *it, void **data) -{ - if (!it->current) return EINA_FALSE; - - if (data) *data = eina_list_data_get(it->current); - it->current = eina_list_next(it->current); - - return EINA_TRUE; -} - -static Eo * -_eo_children_iterator_container(Eo_Children_Iterator *it) -{ - return it->obj_id; -} - -static void -_eo_children_iterator_free(Eo_Children_Iterator *it) -{ - _Eo_Class *klass; - _Eo_Object *obj; - - klass = (_Eo_Class*) it->obj->klass; - obj = it->obj; - - eina_spinlock_take(&klass->iterators.trash_lock); - if (klass->iterators.trash_count < 8) - { - klass->iterators.trash_count++; - eina_trash_push(&klass->iterators.trash, it); - } - else - { - free(it); - } - eina_spinlock_release(&klass->iterators.trash_lock); - - _eo_unref(obj); -} - -static void -_children_iterator_new(Eo *obj_id, void *class_data, va_list *list) -{ - Private_Data *pd = class_data; - _Eo_Class *klass; - - EO_PARAMETER_GET(Eo_Children_Iterator **, it, list); - EO_OBJ_POINTER_RETURN(obj_id, obj); - - if (!it) return ; - *it = NULL; - - if (!pd->children) return ; - - klass = (_Eo_Class *) obj->klass; - - eina_spinlock_take(&klass->iterators.trash_lock); - *it = eina_trash_pop(&klass->iterators.trash); - if (*it) - { - klass->iterators.trash_count--; - memset(*it, 0, sizeof (Eo_Children_Iterator)); - } - else - { - *it = calloc(1, sizeof (Eo_Children_Iterator)); - } - eina_spinlock_release(&klass->iterators.trash_lock); - if (!*it) return ; - - EINA_MAGIC_SET(&(*it)->iterator, EINA_MAGIC_ITERATOR); - (*it)->current = obj->children; - (*it)->obj = _eo_ref(obj); - (*it)->obj_id = obj_id; - - (*it)->iterator.next = FUNC_ITERATOR_NEXT(_eo_children_iterator_next); - (*it)->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eo_children_iterator_container); - (*it)->iterator.free = FUNC_ITERATOR_FREE(_eo_children_iterator_free); -} - -static void -_dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, - va_list *data EINA_UNUSED) -{ /* No info required in the meantime */ - return; -} - -static void -_data_del(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Eo_Generic_Data_Node *node; - Private_Data *pd = class_data; - - EO_PARAMETER_GET(const char *, key, list); - - if (!key) return; - - EINA_INLIST_FOREACH(pd->generic_data, node) - { - if (!strcmp(node->key, key)) - { - pd->generic_data = eina_inlist_remove(pd->generic_data, - EINA_INLIST_GET(node)); - _eo_generic_data_node_free(node); - return; - } - } -} - -/* Weak reference. */ - -static inline size_t -_wref_count(Private_Data *pd) -{ - size_t count = 0; - if (!pd->wrefs) - return 0; - - Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) - count++; - - return count; -} - -static void -_wref_add(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - size_t count; - Eo ***tmp; - - EO_PARAMETER_GET(Eo **, wref, list); - - count = _wref_count(pd); - count += 1; /* New wref. */ - - tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1)); - if (!tmp) return ; - pd->wrefs = tmp; - - pd->wrefs[count - 1] = wref; - pd->wrefs[count] = NULL; - *wref = obj; -} - -static void -_wref_del(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - size_t count; - - EO_PARAMETER_GET(Eo **, wref, list); - - if (*wref != obj) - { - ERR("Wref is a weak ref to %p, while this function was called on %p.", - *wref, obj); - return; - } - - if (!pd->wrefs) - { - ERR("There are no weak refs for object %p", obj); - *wref = NULL; - return; - } - - /* Move the last item in the array instead of the current wref. */ - count = _wref_count(pd); - - { - Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) - { - if (*itr == wref) - { - *itr = pd->wrefs[count - 1]; - break; - } - } - - if (!*itr) - { - ERR("Wref %p is not associated with object %p", wref, obj); - *wref = NULL; - return; - } - } - - if (count > 1) - { - Eo ***tmp; - // No count--; because of the NULL that is not included in the count. */ - tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * count); - if (!tmp) return ; - pd->wrefs = tmp; - pd->wrefs[count - 1] = NULL; - } - else - { - free(pd->wrefs); - pd->wrefs = NULL; - } - - *wref = NULL; -} - -static inline void -_wref_destruct(Private_Data *pd) -{ - Eo ***itr; - if (!pd->wrefs) - return; - - for (itr = pd->wrefs ; *itr ; itr++) - { - **itr = NULL; - } - - free(pd->wrefs); -} - -/* EOF Weak reference. */ - -/* Event callbacks */ - -/* Callbacks */ - -struct _Eo_Callback_Description -{ - Eo_Callback_Description *next; - - union - { - Eo_Callback_Array_Item item; - const Eo_Callback_Array_Item *item_array; - } items; - - void *func_data; - Eo_Callback_Priority priority; - - Eina_Bool delete_me : 1; - Eina_Bool func_array : 1; -}; - -/* Actually remove, doesn't care about walking list, or delete_me */ -static void -_eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) -{ - Eo_Callback_Description *itr, *pitr = NULL; - - itr = pd->callbacks; - - for ( ; itr ; ) - { - Eo_Callback_Description *titr = itr; - itr = itr->next; - - if (titr == cb) - { - if (pitr) - { - pitr->next = titr->next; - } - else - { - pd->callbacks = titr->next; - } - free(titr); - } - else - { - pitr = titr; - } - } -} - -/* Actually remove, doesn't care about walking list, or delete_me */ -static void -_eo_callback_remove_all(Private_Data *pd) -{ - while (pd->callbacks) - { - Eo_Callback_Description *next = pd->callbacks->next; - free(pd->callbacks); - pd->callbacks = next; - } -} - -static inline void -_eo_callbacks_clear(Private_Data *pd) -{ - Eo_Callback_Description *cb = NULL; - - /* If there are no deletions waiting. */ - if (!pd->deletions_waiting) - return; - - /* Abort if we are currently walking the list. */ - if (pd->walking_list > 0) - return; - - pd->deletions_waiting = EINA_FALSE; - - for (cb = pd->callbacks ; cb ; ) - { - Eo_Callback_Description *titr = cb; - cb = cb->next; - - if (titr->delete_me) - { - _eo_callback_remove(pd, titr); - } - } -} - -static void -_eo_callbacks_sorted_insert(Private_Data *pd, Eo_Callback_Description *cb) -{ - Eo_Callback_Description *itr, *itrp = NULL; - for (itr = pd->callbacks ; itr && (itr->priority < cb->priority) ; - itr = itr->next) - { - itrp = itr; - } - - if (itrp) - { - cb->next = itrp->next; - itrp->next = cb; - } - else - { - cb->next = pd->callbacks; - pd->callbacks = cb; - } -} - -static void -_ev_cb_priority_add(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_ENUM_GET(Eo_Callback_Priority, priority, list); - EO_PARAMETER_GET(Eo_Event_Cb, func, list); - EO_PARAMETER_GET(const void *, data, list); - - cb = calloc(1, sizeof(*cb)); - if (!cb) return ; - cb->items.item.desc = desc; - cb->items.item.func = func; - cb->func_data = (void *) data; - cb->priority = priority; - _eo_callbacks_sorted_insert(pd, cb); - - { - const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, arr, NULL)); - } -} - -static void -_ev_cb_del(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo_Event_Cb, func, list); - EO_PARAMETER_GET(void *, user_data, list); - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if ((cb->items.item.desc == desc) && (cb->items.item.func == func) && - (cb->func_data == user_data)) - { - const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - - cb->delete_me = EINA_TRUE; - pd->deletions_waiting = EINA_TRUE; - _eo_callbacks_clear(pd); - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, arr, NULL)); - return; - } - } - - DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); -} - -static void -_ev_cb_array_priority_add(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Callback_Array_Item *, array, list); - EO_PARAMETER_ENUM_GET(Eo_Callback_Priority, priority, list); - EO_PARAMETER_GET(const void *, data, list); - - cb = calloc(1, sizeof(*cb)); - if (!cb) return ; - cb->func_data = (void *) data; - cb->priority = priority; - cb->items.item_array = array; - cb->func_array = EINA_TRUE; - _eo_callbacks_sorted_insert(pd, cb); - - { - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, array, NULL)); - } -} - -static void -_ev_cb_array_del(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Callback_Array_Item *, array, list); - EO_PARAMETER_GET(void *, user_data, list); - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if ((cb->items.item_array == array) && (cb->func_data == user_data)) - { - cb->delete_me = EINA_TRUE; - pd->deletions_waiting = EINA_TRUE; - _eo_callbacks_clear(pd); - - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, array, NULL)); - return; - } - } - - DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data); -} - -static void -_ev_cb_call(Eo *obj_id, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(void *, event_info, list); - EO_PARAMETER_GET(Eina_Bool *, ret, list); - - EO_OBJ_POINTER_RETURN(obj_id, obj); - - if (ret) *ret = EINA_TRUE; - - _eo_ref(obj); - pd->walking_list++; - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if (!cb->delete_me) - { - if (cb->func_array) - { - const Eo_Callback_Array_Item *it; - - for (it = cb->items.item_array ; it->func ; it++) - { - if (it->desc != desc) - continue; - if (!it->desc->unfreezable && - (event_freeze_count || pd->event_freeze_count)) - continue; - - /* Abort callback calling if the func says so. */ - if (!it->func((void *) cb->func_data, obj_id, desc, - (void *) event_info)) - { - if (ret) *ret = EINA_FALSE; - goto end; - } - } - } - else - { - if (cb->items.item.desc != desc) - continue; - if ((!cb->items.item.desc - || !cb->items.item.desc->unfreezable) && - (event_freeze_count || pd->event_freeze_count)) - continue; - - /* Abort callback calling if the func says so. */ - if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, - (void *) event_info)) - { - if (ret) *ret = EINA_FALSE; - goto end; - } - } - } - } - -end: - pd->walking_list--; - _eo_callbacks_clear(pd); - _eo_unref(obj); -} - -static Eina_Bool -_eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) -{ - (void) obj; - Eo *new_obj = (Eo *) data; - Eina_Bool ret; - - eo_do(new_obj, eo_event_callback_call(desc, event_info, &ret)); - - return ret; -} - -/* FIXME: Change default priority? Maybe call later? */ -static void -_ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo *, new_obj, list); - - /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - - eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj)); -} - -static void -_ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo *, new_obj, list); - - /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - - eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj)); -} - -static void -_ev_freeze(Eo *obj EINA_UNUSED, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = (Private_Data *) class_data; - pd->event_freeze_count++; -} - -static void -_ev_thaw(Eo *obj, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = (Private_Data *) class_data; - if (pd->event_freeze_count > 0) - { - pd->event_freeze_count--; - } - else - { - ERR("Events for object %p have already been thawed.", obj); - } -} - -static void -_ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - EO_PARAMETER_GET(int *, ret, list); - - *ret = pd->event_freeze_count; -} - -static void -_ev_global_freeze(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - event_freeze_count++; -} - -static void -_ev_global_thaw(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - if (event_freeze_count > 0) - { - event_freeze_count--; - } - else - { - ERR("Global events have already been thawed."); - } -} - -static void -_ev_global_freeze_get(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(int *, ret, list); - - *ret = event_freeze_count; -} - -/* Eo_Dbg */ -EAPI void -eo_dbg_info_free(Eo_Dbg_Info *info) -{ - eina_value_flush(&(info->value)); - free(info); -} - -static Eina_Bool -_eo_dbg_info_setup(const Eina_Value_Type *type, void *mem) -{ - memset(mem, 0, type->value_size); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_flush(const Eina_Value_Type *type EINA_UNUSED, void *_mem) -{ - Eo_Dbg_Info *mem = *(Eo_Dbg_Info **) _mem; - eina_stringshare_del(mem->name); - eina_value_flush(&(mem->value)); - free(mem); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, void *_dst) -{ - const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src; - Eo_Dbg_Info **dst = _dst; - - *dst = calloc(1, sizeof(Eo_Dbg_Info)); - if (!*dst) return EINA_FALSE; - (*dst)->name = eina_stringshare_ref((*src)->name); - eina_value_copy(&((*src)->value), &((*dst)->value)); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem) -{ - /* FIXME: For the meanwhile, just use the inner type for the value. */ - const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) type_mem; - if (convert == EINA_VALUE_TYPE_STRINGSHARE || - convert == EINA_VALUE_TYPE_STRING) - { - Eina_Bool ret; - const char *other_mem; - char *inner_val = eina_value_to_string(&(*src)->value); - other_mem = inner_val; - ret = eina_value_type_pset(convert, convert_mem, &other_mem); - free(inner_val); - return ret; - } - return EINA_FALSE; -} - -static Eina_Bool -_eo_dbg_info_pset(const Eina_Value_Type *type EINA_UNUSED, void *_mem, const void *_ptr) -{ - Eo_Dbg_Info **mem = _mem; - if (*mem) - free(*mem); - *mem = (void *) _ptr; - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_pget(const Eina_Value_Type *type EINA_UNUSED, const void *_mem, void *_ptr) -{ - Eo_Dbg_Info **ptr = _ptr; - *ptr = (void *) _mem; - return EINA_TRUE; -} - -static const Eina_Value_Type _EO_DBG_INFO_TYPE = { - EINA_VALUE_TYPE_VERSION, - sizeof(Eo_Dbg_Info *), - "Eo_Dbg_Info_Ptr", - _eo_dbg_info_setup, - _eo_dbg_info_flush, - _eo_dbg_info_copy, - NULL, - _eo_dbg_info_convert_to, - NULL, - NULL, - _eo_dbg_info_pset, - _eo_dbg_info_pget -}; - -EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE; - - -/* EOF event callbacks */ - - -/* EO_BASE_CLASS stuff */ -#define MY_CLASS EO_BASE_CLASS - -/* FIXME: Set proper type descriptions. */ -EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = - EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); -EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = - EO_EVENT_DESCRIPTION("callback,del", "A callback was deleted."); -EAPI const Eo_Event_Description _EO_EV_DEL = - EO_HOT_EVENT_DESCRIPTION("del", "Obj is being deleted."); - -static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); - - _eo_condtor_done(obj); -} - -static void -_destructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = class_data; - Eo *child; - - DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); - - EINA_LIST_FREE(pd->children, child) - eo_do(child, eo_parent_set(NULL)); - - _eo_generic_data_del_all(class_data); - _wref_destruct(class_data); - _eo_callback_remove_all(class_data); - - _eo_condtor_done(obj); -} - -static void -_class_constructor(Eo_Class *klass) -{ - event_freeze_count = 0; - - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), _parent_set), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), _parent_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), _children_iterator_new), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), _data_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), _wref_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), _wref_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), _ev_cb_priority_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), _ev_cb_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD), _ev_cb_array_priority_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL), _ev_cb_array_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), _ev_cb_call), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), _ev_cb_forwarder_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), _ev_cb_forwarder_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE), _ev_freeze), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW), _ev_thaw), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), _ev_freeze_get), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE), _ev_global_freeze), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW), _ev_global_thaw), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), _ev_global_freeze_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_CONSTRUCTOR, "Constructor"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DESTRUCTOR, "Destructor"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_PARENT_SET, "Set parent"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_PARENT_GET, "Get parent"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW, "Children Iterator"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_SET, "Set data for key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_GET, "Get data for key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_DEL, "Del key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_WREF_ADD, "Add a weak ref to the object."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_WREF_DEL, "Delete the weak ref."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD, "Add an event callback with a priority."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL, "Delete an event callback"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD, "Add an event callback array with a priority."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL, "Delete an event callback array"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL, "Call the event callbacks for an event."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD, "Add an event forwarder."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL, "Delete an event forwarder."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_FREEZE, "Freezes events."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_THAW, "Thaws events."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_FREEZE_GET, "Get event freeze counter."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE, "Freezes events globally."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW, "Thaws events globally."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET, "Get global event freeze counter."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DBG_INFO_GET, "Get debug info list for obj."), - EO_OP_DESCRIPTION_SENTINEL -}; - -static const Eo_Event_Description *event_desc[] = { - EO_EV_CALLBACK_ADD, - EO_EV_CALLBACK_DEL, - EO_EV_DEL, - NULL -}; - -static const Eo_Class_Description class_desc = { - EO_VERSION, - "Eo_Base", - EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO_CLASS_DESCRIPTION_OPS(&EO_BASE_BASE_ID, op_desc, EO_BASE_SUB_ID_LAST), - event_desc, - sizeof(Private_Data), - _class_constructor, - NULL -}; - -EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo_class_class.c b/src/lib/eo/eo_class_class.c deleted file mode 100644 index 654e2efcca..0000000000 --- a/src/lib/eo/eo_class_class.c +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "Eo.h" - -EAPI Eo_Op EO_CLASS_CLASS_BASE_ID = 0; - -static const Eo_Class_Description class_desc = { - EO_VERSION, - "Eo_Abstract_Class", - EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO_CLASS_DESCRIPTION_OPS(&EO_CLASS_CLASS_BASE_ID, NULL, EO_CLASS_CLASS_SUB_ID_LAST), - NULL, - 0, - NULL, - NULL -}; - -EO_DEFINE_CLASS(eo_class_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index b398ff080f..17b3e8aedb 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -213,21 +213,12 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) const _Eo_Class *klass = obj->klass; - if (klass->desc->version == EO2_VERSION) - eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); - else - eo_do(_eo_id_get(obj), eo_event_callback_call(EO_EV_DEL, NULL, NULL)); + eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); _eo_condtor_reset(obj); - if (klass->desc->version == EO2_VERSION) - { - // FIXME: eo2 - do_err = EINA_FALSE; - eo2_do(_eo_id_get(obj), eo2_destructor();); - } - else - do_err = !eo_do(_eo_id_get(obj), eo_destructor()); + do_err = EINA_FALSE; + eo2_do(_eo_id_get(obj), eo2_destructor();); if (EINA_UNLIKELY(do_err)) {