eo2: fix obj_data retrieval and speed up

obj_data which is built from func->src not obj->klass.
replace eo2_func_get() and eo2_data_scope_get() calls
with one call to eo2_call_resolve().
This commit is contained in:
Jérémy Zurcher 2013-07-10 09:24:59 +02:00 committed by Tom Hacohen
parent 73f1d2a09e
commit ef873b7b29
2 changed files with 32 additions and 35 deletions

View File

@ -594,17 +594,23 @@ EAPI Eina_Bool eo_shutdown(void);
typedef struct _Eo_Internal _Eo;
#define EO_FUNC_CALL() func(objid, obj_data)
#define EO_FUNC_CALLV(...) func(objid, obj_data, __VA_ARGS__)
typedef struct _Eo2_Op_Call_Data
{
void *func;
void *data;
} Eo2_Op_Call_Data;
#define EO_FUNC_CALL() func(objid, call.data)
#define EO_FUNC_CALLV(...) func(objid, call.data, __VA_ARGS__)
/* XXX: Essential, because we need to adjust objid for comp objects. */
#define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet) \
Ret \
Name(_Eo *obj, Eo *objid) \
{ \
Ret (*func)(Eo *, void *obj_data) = eo2_func_get(obj, Id(Name)); \
if (!func) return DefRet; \
void *obj_data = eo2_data_scope_get(obj); \
Eo2_Op_Call_Data call; \
if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \
Ret (*func)(Eo *, void *obj_data) = call.func; \
return Func; \
}
@ -612,17 +618,16 @@ Name(_Eo *obj, Eo *objid) \
Ret \
Name(_Eo *obj, Eo *objid, __VA_ARGS__) \
{ \
Ret (*func)(Eo *, void *obj_data, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \
if (!func) return DefRet; \
void *obj_data = eo2_data_scope_get(obj); \
Eo2_Op_Call_Data call; \
if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \
Ret (*func)(Eo *, void *obj_data, __VA_ARGS__) = call.func; \
return Func; \
}
EAPI _Eo * eo2_do_start(Eo *obj_id);
EAPI void * eo2_data_scope_get(const _Eo *obj);
#define eo2_func_get(obj_id, op) eo2_func_get_internal(obj_id, NULL, op)
EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op);
#define eo2_call_resolve(obj_id, op, call) eo2_call_resolve_internal(obj_id, NULL, op, call)
EAPI Eina_Bool eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op, Eo2_Op_Call_Data *call);
/* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */

View File

@ -263,36 +263,28 @@ eo2_do_start(Eo *obj_id)
return obj;
}
EAPI void *eo2_data_scope_get(const _Eo *obj)
{
return _eo_data_scope_get(obj, obj->klass);
}
static void *
_eo2_func_get(const _Eo_Class *cur_klass, Eo_Op op)
{
{
const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
if (EINA_LIKELY(func != NULL))
{
return func->func;
}
}
/* Try composite objects */
/* FIXME!!! */
return NULL;
}
EAPI void *
eo2_func_get_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op)
EAPI Eina_Bool
eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call)
{
const _Eo_Class *klass;
const op_type_funcs *func;
if (klass_id)
klass = _eo_class_pointer_get(klass_id);
else
klass = obj->klass;
return _eo2_func_get(klass, op);
func = _eo_kls_itr_func_get(klass, op);
if (EINA_LIKELY(func != NULL))
{
call->func = func->func;
call->data = _eo_data_scope_get(obj, func->src);
return EINA_TRUE;
}
/* Try composite objects */
/* FIXME!!! */
return EINA_FALSE;
}
#define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \