summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-09-27 00:02:30 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2013-09-27 00:02:30 +0200
commitfb28aa5a20030ea51ea0237635bf4f9b35464001 (patch)
treedeb836721d7c0101bf939b62002fabbac5c57092
parent992ab9036ac55a04d3b39e2771339c18879c57e9 (diff)
downloadefl-fb28aa5a20030ea51ea0237635bf4f9b35464001.tar.gz
eo: eo_do_internal() supports objects and classes
eo_class_do() macro calls eo_do() eo_class_do_internal() is removed op_type argument is remove from eo_do, eo_vdo_internal Conflicts: src/lib/eo/eo.c
-rw-r--r--src/lib/eo/Eo.h25
-rw-r--r--src/lib/eo/eo.c115
2 files changed, 68 insertions, 72 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 573ae9e14a..91f02544fa 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -598,26 +598,25 @@ EAPI Eina_Bool eo_shutdown(void);
* A convenience wrapper around eo_do_internal()
* @see eo_do_internal
*/
-#define eo_do(obj, ...) eo_do_internal(__FILE__, __LINE__, obj, EO_OP_TYPE_REGULAR, __VA_ARGS__, EO_NOOP)
+#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, EO_OP_TYPE_REGULAR, args)
+#define eo_vdo(obj, args) eo_vdo_internal(__FILE__, __LINE__, obj, args)
/**
* @def eo_class_do
* A convenience wrapper around eo_class_do_internal()
* @see eo_class_do_internal
*/
-#define eo_class_do(klass, ...) eo_class_do_internal(__FILE__, __LINE__, klass, __VA_ARGS__, EO_NOOP)
+#define eo_class_do(klass, ...) eo_do(klass, __VA_ARGS__)
/**
* @brief Calls op functions of an object
* @param obj The object to work on
- * @param op_type The type of the ops that are passed.
* @param ... NULL terminated list of OPs and parameters.
* @return @c EINA_TRUE on success.
*
@@ -626,12 +625,11 @@ EAPI Eina_Bool eo_shutdown(void);
*
* @see #eo_do
*/
-EAPI Eina_Bool eo_do_internal(const char *file, int line, Eo *obj, Eo_Op_Type op_type, ...);
+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 op_type The type of the ops that are passed.
* @param ops NULL terminated list of OPs and parameters.
* @return @c EINA_TRUE on success.
*
@@ -640,20 +638,7 @@ EAPI Eina_Bool eo_do_internal(const char *file, int line, Eo *obj, Eo_Op_Type op
*
* @see #eo_vdo
*/
-EAPI Eina_Bool eo_vdo_internal(const char *file, int line, Eo *obj, Eo_Op_Type op_type, va_list *ops);
-
-/**
- * @brief Calls op functions of a class.
- * @param klass The class 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_class_do
- */
-EAPI Eina_Bool eo_class_do_internal(const char *file, int line, const Eo *klass, ...);
+EAPI Eina_Bool eo_vdo_internal(const char *file, int line, Eo *obj, va_list *ops);
/**
* @brief Calls the super function for the specific op.
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index ececc603e2..1a082e4dd4 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -275,20 +275,25 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op)
while (0)
static inline Eina_Bool
-_eo_op_internal(const char *file, int line, _Eo_Object *obj, const _Eo_Class *cur_klass,
+_eo_op_internal(const char *file, int line, _Eo 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)
+ if (op_desc && (op_type != op_desc->op_type))
{
- if (op_desc->op_type == EO_OP_TYPE_CLASS)
+ 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) ? op_desc->name : NULL, op);
- return EINA_FALSE;
+ 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
@@ -296,21 +301,29 @@ _eo_op_internal(const char *file, int line, _Eo_Object *obj, const _Eo_Class *cu
const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
if (EINA_LIKELY(func != NULL))
{
- void *func_data = _eo_data_scope_get(obj, func->src);
- func->func((Eo *)obj->obj_id, func_data, p_list);
+ if (op_type == EO_OP_TYPE_REGULAR)
+ {
+ void *func_data = _eo_data_scope_get(eo_ptr.obj, func->src);
+ func->func((Eo *)eo_ptr.obj->obj_id, func_data, p_list);
+ }
+ else
+ {
+ ((eo_op_func_type_class) func->func)(_eo_class_id_get(cur_klass), p_list);
+ }
return EINA_TRUE;
}
}
/* Try composite objects */
+ if (op_type == EO_OP_TYPE_REGULAR)
{
Eina_List *itr;
Eo *emb_obj_id;
- EINA_LIST_FOREACH(obj->composite_objects, itr, emb_obj_id)
+ EINA_LIST_FOREACH(eo_ptr.obj->composite_objects, itr, emb_obj_id)
{
/* FIXME: Clean this up a bit. */
EO_OBJ_POINTER_RETURN_VAL(emb_obj_id, emb_obj, EINA_FALSE);
- if (_eo_op_internal(file, line, emb_obj, emb_obj->klass, op_type, op, p_list))
+ if (_eo_op_internal(file, line, (_Eo)emb_obj, emb_obj->klass, op_type, op, p_list))
{
return EINA_TRUE;
}
@@ -320,7 +333,7 @@ _eo_op_internal(const char *file, int line, _Eo_Object *obj, const _Eo_Class *cu
}
static inline Eina_Bool
-_eo_dov_internal(const char *file, int line, _Eo_Object *obj, Eo_Op_Type op_type, va_list *p_list)
+_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;
@@ -332,7 +345,7 @@ _eo_dov_internal(const char *file, int line, _Eo_Object *obj, Eo_Op_Type op_type
op = va_arg(*p_list, Eo_Op);
while (op)
{
- if (!_eo_op_internal(file, line, obj, obj->klass, op_type, op, p_list))
+ if (!_eo_op_internal(file, line, (_Eo)obj, obj->klass, EO_OP_TYPE_REGULAR, op, p_list))
{
_EO_OP_ERR_NO_OP_PRINT(file, line, op, obj->klass);
ret = EINA_FALSE;
@@ -342,38 +355,64 @@ _eo_dov_internal(const char *file, int line, _Eo_Object *obj, Eo_Op_Type op_type
}
if (obj->do_error)
- ret = EINA_FALSE;
+ ret = EINA_FALSE;
obj->do_error = prev_error;
-
_eo_unref(obj);
return ret;
}
-EAPI Eina_Bool
-eo_do_internal(const char *file, int line, Eo *obj_id, Eo_Op_Type op_type, ...)
+static inline Eina_Bool
+_eo_class_dov_internal(const char *file, int line, _Eo_Class *klass, va_list *p_list)
{
Eina_Bool ret = EINA_TRUE;
- va_list p_list;
+ Eo_Op op = EO_NOOP;
- EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
+ op = va_arg(*p_list, Eo_Op);
+ while (op)
+ {
+ if (!_eo_op_internal(file, line, (_Eo)klass, klass, EO_OP_TYPE_CLASS, op, p_list))
+ {
+ _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass);
+ ret = EINA_FALSE;
+ break;
+ }
+ op = va_arg(*p_list, Eo_Op);
+ }
- va_start(p_list, op_type);
+ return ret;
+}
- ret = _eo_dov_internal(file, line, obj, op_type, &p_list);
+EAPI Eina_Bool
+eo_do_internal(const char *file, int line, const Eo *obj_id, ...)
+{
+ Eina_Bool ret = EINA_TRUE;
+ va_list p_list;
+ Eina_Bool obj_ref = !_eo_is_a_class(obj_id);
+ va_start(p_list, obj_id);
+ if (obj_ref)
+ {
+ EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
+ ret = _eo_obj_dov_internal(file, line, obj, &p_list);
+ }
+ else
+ {
+ EO_CLASS_POINTER_RETURN_VAL(obj_id, klass, EINA_FALSE);
+ ret = _eo_class_dov_internal(file, line, klass, &p_list);
+ }
va_end(p_list);
return ret;
}
EAPI Eina_Bool
-eo_vdo_internal(const char *file, int line, Eo *obj_id, Eo_Op_Type op_type, va_list *ops)
+eo_vdo_internal(const char *file, int line, Eo *obj_id, va_list *ops)
{
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
- return _eo_dov_internal(file, line, obj, op_type, ops);
+ return _eo_obj_dov_internal(file, line, obj, ops);
}
EAPI Eina_Bool
@@ -391,7 +430,7 @@ eo_do_super_internal(const char *file, int line, Eo *obj_id, const Eo *cur_klass
nklass = _eo_kls_itr_next(obj->klass, cur_klass, op);
va_start(p_list, op);
- if (!_eo_op_internal(file, line, obj, nklass, op_type, op, &p_list))
+ if (!_eo_op_internal(file, line, (_Eo)obj, nklass, op_type, op, &p_list))
{
_EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass);
ret = EINA_FALSE;
@@ -438,34 +477,6 @@ _eo_class_op_internal(const char *file, int line, _Eo_Class *klass, const _Eo_Cl
}
EAPI Eina_Bool
-eo_class_do_internal(const char *file, int line, const Eo *klass_id, ...)
-{
- Eina_Bool ret = EINA_TRUE;
- Eo_Op op = EO_NOOP;
- va_list p_list;
-
- EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE);
-
- va_start(p_list, klass_id);
-
- op = va_arg(p_list, Eo_Op);
- while (op)
- {
- if (!_eo_class_op_internal(file, line, (_Eo_Class *) klass, klass, op, &p_list))
- {
- _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass);
- ret = EINA_FALSE;
- break;
- }
- op = va_arg(p_list, Eo_Op);
- }
-
- va_end(p_list);
-
- return ret;
-}
-
-EAPI Eina_Bool
eo_class_do_super_internal(const char *file, int line, const Eo *klass_id,
const Eo *cur_klass_id, Eo_Op op, ...)
{
@@ -1077,7 +1088,7 @@ _eo_parent_internal_set(_Eo_Object *obj, ...)
va_list p_list;
va_start(p_list, obj);
- _eo_op_internal("eo.c", 1049, obj, obj->klass,
+ _eo_op_internal("eo.c", 1049, (_Eo)obj, obj->klass,
EO_OP_TYPE_REGULAR, EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET),
&p_list);
va_end(p_list);
@@ -1141,7 +1152,7 @@ eo_add_internal(const char *file, int line, const Eo *klass_id, Eo *parent_id, .
{
va_list p_list;
va_start(p_list, parent_id);
- do_err = !_eo_dov_internal(file, line, obj, EO_OP_TYPE_REGULAR, &p_list);
+ do_err = !_eo_obj_dov_internal(file, line, obj, &p_list);
va_end(p_list);
}