forked from enlightenment/efl
Eo2: Removed a lot of Eo1 code.
This commit is contained in:
parent
9d332da1f8
commit
3c46e7dab8
|
@ -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
|
||||
|
|
323
src/lib/eo/Eo.h
323
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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
483
src/lib/eo/eo.c
483
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,20 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#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)
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue