summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-03-01 10:12:44 +0000
committerTom Hacohen <tom@stosb.com>2016-03-01 14:18:11 +0000
commit3a424edbee81cf137beb65331ec90af638f53e3c (patch)
tree604dff0dba8701a12c966d2e3203ea4e200f077e
parent74304319e43f00ac72a79080f7ee98dd7a6a622a (diff)
downloadefl-3a424edbee81cf137beb65331ec90af638f53e3c.tar.gz
snap
-rw-r--r--src/lib/eo/Eo.h43
-rw-r--r--src/lib/eo/eo.c88
-rw-r--r--src/lib/eo/eo_private.h7
3 files changed, 76 insertions, 62 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 03e6f57975..33ea03852f 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -99,6 +99,8 @@ extern "C" {
* @{
*/
+typedef struct _Eo_Object _Eo_Object;
+
/**
* @typedef Eo
* The basic Object type.
@@ -452,7 +454,8 @@ EAPI Eina_Bool eo_shutdown(void);
// to fetch internal function and object data at once
typedef struct _Eo_Op_Call_Data
{
- Eo *obj;
+ Eo *eo_id;
+ _Eo_Object *obj;
void *func;
void *data;
} Eo_Op_Call_Data;
@@ -497,7 +500,7 @@ typedef struct _Eo_Call_Cache
#endif
// cache OP id, get real fct and object data then do the call
-#define EO_FUNC_COMMON_OP(Name, DefRet) \
+#define EO_FUNC_COMMON_OP(Obj, Name, DefRet) \
static Eo_Call_Cache ___cache; /* static 0 by default */ \
Eo_Op_Call_Data ___call; \
if (EINA_UNLIKELY(___cache.op == EO_NOOP)) \
@@ -505,49 +508,53 @@ typedef struct _Eo_Call_Cache
___cache.op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \
if (___cache.op == EO_NOOP) return DefRet; \
} \
- if (!_eo_call_resolve(#Name, &___call, &___cache, \
+ if (!_eo_call_resolve(Obj, #Name, &___call, &___cache, \
__FILE__, __LINE__)) return DefRet; \
_Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \
// to define an EAPI function
#define EO_FUNC_BODY(Name, Ret, DefRet) \
Ret \
- Name(void) \
+ Name(Eo *obj) \
{ \
typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data); \
Ret _r; \
- EO_FUNC_COMMON_OP(Name, DefRet); \
- _r = _func_(___call.obj, ___call.data); \
+ EO_FUNC_COMMON_OP(obj, Name, DefRet); \
+ _r = _func_(___call.eo_id, ___call.data); \
+ _eo_call_end(&___call); \
return _r; \
}
#define EO_VOID_FUNC_BODY(Name) \
void \
- Name(void) \
+ Name(Eo *obj) \
{ \
typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data); \
- EO_FUNC_COMMON_OP(Name, ); \
- _func_(___call.obj, ___call.data); \
+ EO_FUNC_COMMON_OP(obj, Name, ); \
+ _func_(___call.eo_id, ___call.data); \
+ _eo_call_end(&___call); \
}
#define EO_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \
Ret \
- Name(__VA_ARGS__) \
+ Name(Eo *obj, __VA_ARGS__) \
{ \
typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \
Ret _r; \
- EO_FUNC_COMMON_OP(Name, DefRet); \
- _r = _func_(___call.obj, ___call.data, Arguments); \
+ EO_FUNC_COMMON_OP(obj, Name, DefRet); \
+ _r = _func_(___call.eo_id, ___call.data, Arguments); \
+ _eo_call_end(&___call); \
return _r; \
}
#define EO_VOID_FUNC_BODYV(Name, Arguments, ...) \
void \
- Name(__VA_ARGS__) \
+ Name(Eo *obj, __VA_ARGS__) \
{ \
typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \
- EO_FUNC_COMMON_OP(Name, ); \
- _func_(___call.obj, ___call.data, Arguments); \
+ EO_FUNC_COMMON_OP(obj, Name, ); \
+ _func_(___call.eo_id, ___call.data, Arguments); \
+ _eo_call_end(&___call); \
}
#ifndef _WIN32
@@ -565,13 +572,13 @@ typedef struct _Eo_Call_Cache
EAPI Eo_Op _eo_api_op_id_get(const void *api_func);
// gets the real function pointer and the object data
-EAPI Eina_Bool _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *callcache, const char *file, int line);
+EAPI Eina_Bool _eo_call_resolve(Eo *obj, const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *callcache, const char *file, int line);
// start of eo_do barrier, gets the object pointer and ref it, put it on the stask
EAPI Eina_Bool _eo_do_start(const Eo *eo_id);
-// end of the eo_do barrier, unref the obj, move the stack pointer
-EAPI void _eo_do_end(const Eo *eo_id);
+// end of the eo_do barrier, unref the obj
+EAPI void _eo_call_end(Eo_Op_Call_Data *call);
// end of the eo_add. Calls finalize among others
EAPI Eo * _eo_add_end(void *eo_stack);
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 0e7a5e90a0..869785f9f5 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -440,21 +440,39 @@ _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
}
EAPI Eina_Bool
-_eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, const char *file, int line)
+_eo_call_resolve(Eo *eo_id, const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, const char *file, int line)
{
- Eo_Stack_Frame *fptr;
- const _Eo_Class *klass, *inputklass;
+ const _Eo_Class *klass, *inputklass, *main_klass;
+ const _Eo_Class *cur_klass = NULL;
+ _Eo_Object *obj = NULL;
const op_type_funcs *func;
Eina_Bool is_obj;
- fptr = _EO_CALL_STACK_GET()->frame_ptr;
-
- if (EINA_UNLIKELY(!fptr->o.obj))
+ if (EINA_UNLIKELY(!eo_id))
return EINA_FALSE;
- is_obj = fptr->is_obj;
+ call->eo_id = eo_id;
+
+ is_obj = _eo_is_a_obj(eo_id);
+
+ if (is_obj)
+ {
+ EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
+ obj = _obj;
+ klass = _obj->klass;
+ call->obj = obj;
+ _eo_ref(_obj);
+ }
+ else
+ {
+ EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
+ klass = _klass;
+ call->obj = NULL;
+ call->data = NULL;
+ }
+
+ inputklass = main_klass = klass;
- inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
if (!cache->op)
{
@@ -466,9 +484,9 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
}
/* If we have a current class, we need to itr to the next. */
- if (fptr->cur_klass)
+ if (cur_klass)
{
- func = _eo_kls_itr_next(klass, fptr->cur_klass, cache->op);
+ func = _eo_kls_itr_next(klass, cur_klass, cache->op);
if (!func)
goto end;
@@ -492,13 +510,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
call->func = func->func;
if (is_obj)
{
- call->obj = (Eo *) fptr->o.obj->header.id;
- call->data = (char *)fptr->o.obj + cache->off[i].off;
- }
- else
- {
- call->obj = _eo_class_id_get(inputklass);
- call->data = NULL;
+ call->data = (char *) obj + cache->off[i].off;
}
return EINA_TRUE;
}
@@ -517,17 +529,11 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
if (is_obj)
{
- call->obj = (Eo *) fptr->o.obj->header.id;
- call->data = _eo_data_scope_get(fptr->o.obj, func->src);
- }
- else
- {
- call->obj = _eo_class_id_get(klass);
- call->data = NULL;
+ call->data = _eo_data_scope_get(obj, func->src);
}
# if EO_CALL_CACHE_SIZE > 0
- if (!fptr->cur_klass)
+ if (!cur_klass)
{
# if EO_CALL_CACHE_SIZE > 1
const int slot = cache->next_slot;
@@ -536,7 +542,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
# endif
cache->index[slot].klass = (const void *)inputklass;
cache->entry[slot].func = (const void *)func;
- cache->off[slot].off = (int)((long)((char *)call->data - (char *)fptr->o.obj));
+ cache->off[slot].off = (int)((long)((char *)call->data - (char *)obj));
# if EO_CALL_CACHE_SIZE > 1
cache->next_slot = (slot + 1) % EO_CALL_CACHE_SIZE;
# endif
@@ -560,7 +566,7 @@ end:
{
Eina_List *itr;
Eo *emb_obj_id;
- EINA_LIST_FOREACH(((_Eo_Object *) fptr->o.obj)->composite_objects, itr, emb_obj_id)
+ EINA_LIST_FOREACH(obj->composite_objects, itr, emb_obj_id)
{
_Eo_Object *emb_obj = _eo_obj_pointer_get((Eo_Id)emb_obj_id);
@@ -573,7 +579,8 @@ end:
if (EINA_LIKELY(func->func && func->src))
{
- call->obj = _eo_id_get(emb_obj);
+ call->eo_id = _eo_id_get(emb_obj);
+ call->obj = obj; /* FIXME-tom: Hack, we retain the previous object so we unref it... */
call->func = func->func;
call->data = _eo_data_scope_get(emb_obj, func->src);
@@ -583,15 +590,12 @@ end:
}
{
- const _Eo_Class *main_klass;
- main_klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
-
/* If it's a do_super call. */
- if (fptr->cur_klass)
+ if (cur_klass)
{
ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'.",
file, line, func_name, cache->op, main_klass->desc->name,
- fptr->cur_klass->desc->name);
+ cur_klass->desc->name);
}
else
{
@@ -603,6 +607,12 @@ end:
return EINA_FALSE;
}
+EAPI void
+_eo_call_end(Eo_Op_Call_Data *call)
+{
+ _eo_unref(call->obj);
+}
+
static inline Eina_Bool
_eo_api_func_equal(const void *api_func1, const void *api_func2)
{
@@ -806,20 +816,19 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo
_eo_ref(obj);
- eo_do(eo_id, eo_parent_set(parent_id));
+ eo_parent_set(eo_id, parent_id);
/* If there's a parent. Ref. Eo_add should return an object with either a
* parent ref, or with the lack of, just a ref. */
{
- Eo *parent_tmp;
- if (ref && eo_do_ret(eo_id, parent_tmp, eo_parent_get()))
+ if (ref && eo_parent_get(eo_id))
{
_eo_ref(obj);
}
}
/* eo_id can change here. Freeing is done on the resolved object. */
- eo_do(eo_id, eo_id = eo_constructor());
+ eo_id = eo_constructor(eo_id);
if (!eo_id)
{
ERR("Object of class '%s' - Error while constructing object",
@@ -1476,10 +1485,9 @@ eo_unref(const Eo *obj_id)
EAPI void
eo_del(const Eo *obj)
{
- Eo *parent_tmp;
- if (eo_do_ret(obj, parent_tmp, eo_parent_get()))
+ if (eo_parent_get(obj))
{
- eo_do(obj, eo_parent_set(NULL));
+ eo_parent_set(obj, NULL);
}
else
{
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index 869745c364..3ee413477e 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -61,7 +61,6 @@ extern int _eo_log_dom;
typedef uintptr_t Eo_Id;
typedef struct _Eo_Class _Eo_Class;
-typedef struct _Eo_Object _Eo_Object;
typedef struct _Eo_Header Eo_Header;
/* Retrieves the pointer to the object from the id */
@@ -214,11 +213,11 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj)
const _Eo_Class *klass = obj->klass;
- eo_do(_eo_id_get(obj), eo_event_callback_call(EO_BASE_EVENT_DEL, NULL));
+ eo_event_callback_call(_eo_id_get(obj), EO_BASE_EVENT_DEL, NULL);
_eo_condtor_reset(obj);
- eo_do(_eo_id_get(obj), eo_destructor());
+ eo_destructor(_eo_id_get(obj));
if (!obj->condtor_done)
{
@@ -232,7 +231,7 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj)
Eo *emb_obj;
EINA_LIST_FOREACH_SAFE(obj->composite_objects, itr, itr_n, emb_obj)
{
- eo_do(_eo_id_get(obj), eo_composite_detach(emb_obj));
+ eo_composite_detach(_eo_id_get(obj), emb_obj);
}
}