eo: eo_do_super_internal() supports objects and classes

eo_class_do_super() macro calls eo_do_super()
eo_class_do_super_internal() and _eo_class_op_internal() are removed

Conflicts:
	src/lib/eo/eo.c
This commit is contained in:
Jérémy Zurcher 2013-09-27 00:38:15 +02:00 committed by Tom Hacohen
parent c4b40aae0d
commit f4c1bff0f3
2 changed files with 20 additions and 88 deletions

View File

@ -651,7 +651,7 @@ EAPI Eina_Bool eo_vdo_internal(const char *file, int line, const Eo *obj, va_lis
*
* @see #eo_do
*/
#define eo_do_super(obj, cur_klass, ...) eo_do_super_internal(__FILE__, __LINE__, obj, cur_klass, EO_OP_TYPE_REGULAR, __VA_ARGS__)
#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.
@ -664,13 +664,12 @@ EAPI Eina_Bool eo_vdo_internal(const char *file, int line, const Eo *obj, va_lis
*
* @see #eo_class_do
*/
#define eo_class_do_super(klass, cur_klass, ...) eo_class_do_super_internal(__FILE__, __LINE__, klass, cur_klass, __VA_ARGS__)
#define eo_class_do_super(klass, cur_klass, ...) eo_do_super(klass, 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_type The type of the ops that are passed.
* @param op The wanted op.
* @param ... list of parameters.
* @return @c EINA_TRUE on success.
@ -680,22 +679,7 @@ EAPI Eina_Bool eo_vdo_internal(const char *file, int line, const Eo *obj, va_lis
* @see #eo_do
* @see #eo_do_super
*/
EAPI Eina_Bool eo_do_super_internal(const char *file, int line, Eo *obj, const Eo *cur_klass, Eo_Op_Type op_type, Eo_Op op, ...);
/**
* @brief Calls the super function for the specific op.
* @param klass The klass 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_class_do
* @see #eo_class_do_super
*/
EAPI Eina_Bool eo_class_do_super_internal(const char *file, int line, const Eo *klass, const Eo *cur_klass, Eo_Op op, ...);
EAPI Eina_Bool eo_do_super_internal(const char *file, int line, const Eo *obj, const Eo *cur_klass, Eo_Op op, ...);
/**
* @brief Gets the class of the object.

View File

@ -425,88 +425,36 @@ eo_vdo_internal(const char *file, int line, const Eo *obj_id, va_list *ops)
}
EAPI Eina_Bool
eo_do_super_internal(const char *file, int line, Eo *obj_id, const Eo *cur_klass_id,
Eo_Op_Type op_type, Eo_Op op, ...)
eo_do_super_internal(const char *file, int line, const Eo *obj_id, const Eo *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_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE);
/* Advance the kls itr. */
nklass = _eo_kls_itr_next(obj->klass, cur_klass, op);
va_start(p_list, op);
if (!_eo_op_internal(file, line, (_Eo)obj, nklass, op_type, op, &p_list))
if (_eo_is_a_class(obj_id))
{
_EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass);
ret = EINA_FALSE;
EO_CLASS_POINTER_RETURN_VAL(obj_id, klass, EINA_FALSE);
nklass = _eo_kls_itr_next(klass, cur_klass, op);
op_ret = _eo_op_internal(file, line, (_Eo)klass, nklass, EO_OP_TYPE_CLASS, op, &p_list);
}
else
{
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
nklass = _eo_kls_itr_next(obj->klass, cur_klass, op);
op_ret = _eo_op_internal(file, line, (_Eo)obj, nklass, EO_OP_TYPE_REGULAR, op, &p_list);
if (obj->do_error)
ret = EINA_FALSE;
}
va_end(p_list);
if (obj->do_error)
ret = EINA_FALSE;
if (!op_ret)
_EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass);
return ret;
}
static Eina_Bool
_eo_class_op_internal(const char *file, int line, _Eo_Class *klass, const _Eo_Class *cur_klass,
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 != EO_OP_TYPE_CLASS)
{
ERR("in %s:%d: Tried calling an instance op '%s' (0x%x) from a class context.",
file, line, (op_desc) ? op_desc->name : NULL, op);
return EINA_FALSE;
}
}
#else
(void) file;
(void) line;
#endif
{
const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
if (func)
{
((eo_op_func_type_class) func->func)(_eo_class_id_get(klass), p_list);
return EINA_TRUE;
}
}
return EINA_FALSE;
}
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, ...)
{
const _Eo_Class *nklass;
Eina_Bool ret = EINA_TRUE;
va_list p_list;
EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE);
EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE);
/* Advance the kls itr. */
nklass = _eo_kls_itr_next(klass, cur_klass, op);
va_start(p_list, op);
if (!_eo_class_op_internal(file, line, (_Eo_Class *) klass, nklass, op, &p_list))
{
_EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass);
ret = EINA_FALSE;
}
va_end(p_list);
return ret;
return (ret & op_ret);
}
EAPI const Eo *