summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-08-01 18:49:27 +0900
committerJérémy Zurcher <jeremy@asynk.ch>2013-08-01 18:49:27 +0900
commit187f70e48e1ab1e660a143b9ad240d4784a4ba68 (patch)
tree7f9929ac72565d5892f92f3da161b53f02f67bc8
parent2b59a446e3993b5bdeb6ee2f292aaa8f379d6eb2 (diff)
downloadefl-187f70e48e1ab1e660a143b9ad240d4784a4ba68.tar.gz
eo2: add hook for beinning and start of all function execution and for all _do.
NOTE: I don't know what the _CLASS_FUNC are, so I may have broken stuff there.
-rw-r--r--src/lib/eo/Eo.h133
-rw-r--r--src/lib/eo/eo.c9
-rw-r--r--src/lib/eo/eo2_base_class.c2
3 files changed, 114 insertions, 30 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 05301032f4..373689f401 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -629,28 +629,37 @@ typedef struct _Eo2_Op_Call_Data
void *data;
} Eo2_Op_Call_Data;
+typedef void (*Eo2_Hook_Call)(const Eo_Class *klass_id, const Eo *obj_id, void *func, ...);
+typedef void (*Eo2_Hook_Do)(const char *file, const char *func, int line, const Eo *obj_id);
+typedef void (*Eo2_Hook_Class_Do)(const char *file, const char *func, int line, const Eo_Class *klass_id);
+
+EAPI extern Eo2_Hook_Call eo2_hook_call_pre;
+EAPI extern Eo2_Hook_Call eo2_hook_call_post;
+EAPI extern Eo2_Hook_Do eo2_hook_do_pre;
+EAPI extern Eo2_Hook_Do eo2_hook_do_post;
+EAPI extern Eo2_Hook_Class_Do eo2_hook_class_do_pre;
+EAPI extern Eo2_Hook_Class_Do eo2_hook_class_do_post;
+
// to pass the internal function call to EO2_FUNC_BODY (as Func parameter)
-#define EO2_FUNC_CALL(...) _func_(call.obj_id, call.data, __VA_ARGS__)
-#define EO2_CLASS_FUNC_CALL(...) _func_(call.klass_id, __VA_ARGS__)
+#define EO2_FUNC_CALL(...) __VA_ARGS__
+#define EO2_CLASS_FUNC_CALL(...) __VA_ARGS__
+
+#define EO2_HOOK_CALL_PREPARE(Hook) \
+ if (Hook) \
+ Hook(call.klass_id, call.obj_id, call.func);
+
+#define EO2_HOOK_CALL_PREPAREV(Hook, ...) \
+ if (Hook) \
+ Hook(call.klass_id, call.obj_id, call.func, __VA_ARGS__);
// cache OP id, get real fct and object data then do the call
-#define _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \
- static Eo_Op op = EO_NOOP; \
- if ( op == EO_NOOP ) \
- op = eo2_api_op_id_get((void*)Name, EO_OP_TYPE_REGULAR); \
+#define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \
Eo2_Op_Call_Data call; \
- if (!eo2_call_resolve(op, &call)) return DefRet; \
- __##Name##_func _func_ = (__##Name##_func) call.func; \
- return Func; \
-
-#define _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \
static Eo_Op op = EO_NOOP; \
if ( op == EO_NOOP ) \
- op = eo2_api_op_id_get((void*)Name, EO_OP_TYPE_CLASS); \
- Eo2_Op_Call_Data call; \
+ op = eo2_api_op_id_get((void*)Name, Type); \
if (!eo2_call_resolve(op, &call)) return DefRet; \
__##Name##_func _func_ = (__##Name##_func) call.func; \
- return Func; \
// to define an EAPI function
#define EO2_FUNC_BODY(Name, Ret, DefRet) \
@@ -658,41 +667,99 @@ typedef struct _Eo2_Op_Call_Data
Name(void) \
{ \
typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \
- _EO2_FUNC_COMMON(Name, Ret, _func_(call.obj_id, call.data), DefRet)\
+ Ret _r; \
+ EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_REGULAR); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \
+ _r = _func_(call.obj_id, call.data); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \
+ return _r; \
}
-#define EO2_VOID_FUNC_BODY(Name) EO2_FUNC_BODY(Name, void, )
+#define EO2_VOID_FUNC_BODY(Name) \
+ void \
+ Name(void) \
+ { \
+ typedef void (*__##Name##_func)(Eo *, void *obj_data); \
+ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_REGULAR); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \
+ _func_(call.obj_id, call.data); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \
+ }
-#define EO2_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \
+#define EO2_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \
Ret \
Name(__VA_ARGS__) \
{ \
typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \
- _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \
+ Ret _r; \
+ EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_REGULAR); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \
+ _r = _func_(call.obj_id, call.data, Arguments); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \
+ return _r; \
}
-#define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__)
+#define EO2_VOID_FUNC_BODYV(Name, Arguments, ...) \
+ void \
+ Name(__VA_ARGS__) \
+ { \
+ typedef void (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \
+ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_REGULAR); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \
+ _func_(call.obj_id, call.data, Arguments); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \
+ }
// to define a EAPI class function
-#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet) \
- Ret \
- Name(void) \
- { \
- typedef Ret (*__##Name##_func)(Eo_Class *); \
- _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet) \
+#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet) \
+ Ret \
+ Name(void) \
+ { \
+ typedef Ret (*__##Name##_func)(Eo_Class *); \
+ Ret _r; \
+ EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_CLASS); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \
+ _r = _func_(call.klass_id); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \
+ return _r; \
}
-#define EO2_VOID_CLASS_FUNC_BODY(Name) EO2_CLASS_FUNC_BODY(Name, void, )
+#define EO2_VOID_CLASS_FUNC_BODY(Name) \
+ void \
+ Name(void) \
+ { \
+ typedef Ret (*__##Name##_func)(Eo_Class *); \
+ Ret _r; \
+ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_CLASS); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \
+ _func_(call.klass_id); \
+ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \
+ return _r; \
+ }
-#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \
+#define EO2_CLASS_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \
Ret \
Name(__VA_ARGS__) \
{ \
typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \
- _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \
+ Ret _r; \
+ EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_CLASS); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \
+ _r = _func_(call.klass_id, Arguments); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \
+ return _r; \
}
-#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , __VA_ARGS__)
+#define EO2_VOID_CLASS_FUNC_BODYV(Name, Arguments, ...) \
+ void \
+ Name(__VA_ARGS__) \
+ { \
+ typedef void (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \
+ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_CLASS); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \
+ _func_(call.klass_id, Arguments); \
+ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \
+ }
// OP ID of an overriding function
#define EO2_OP_OVERRIDE ((Eo_Op) -1)
@@ -728,48 +795,56 @@ EAPI int eo2_call_stack_depth();
do \
{ \
Eo *_objid_ = objid; \
+ if (eo2_hook_do_pre) eo2_hook_do_pre(__FILE__, __FUNCTION__, __LINE__, _objid_); \
if (eo2_do_start(_objid_, EINA_FALSE)) \
{ \
Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \
__VA_ARGS__; \
(void) _id_clean_; \
} \
+ if (eo2_hook_do_post) eo2_hook_do_post(__FILE__, __FUNCTION__, __LINE__, _objid_); \
} while (0)
#define eo2_do_super(objid, ...) \
do \
{ \
Eo *_objid_ = objid; \
+ if (eo2_hook_do_pre) eo2_hook_do_pre(__FILE__, __FUNCTION__, __LINE__, _objid_); \
if (eo2_do_start(_objid_, EINA_TRUE)) \
{ \
Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \
__VA_ARGS__; \
(void) _id_clean_; \
} \
+ if (eo2_hook_do_post) eo2_hook_do_post(__FILE__, __FUNCTION__, __LINE__, _objid_); \
} while (0)
#define eo2_class_do(clsid, ...) \
do \
{ \
const Eo_Class *_clsid_ = clsid; \
+ if (eo2_hook_class_do_pre) eo2_hook_class_do_pre(__FILE__, __FUNCTION__, __LINE__, _clsid_); \
if (eo2_class_do_start(_clsid_, EINA_FALSE)) \
{ \
const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \
__VA_ARGS__; \
(void) _id_clean_; \
} \
+ if (eo2_hook_class_do_post) eo2_hook_class_do_post(__FILE__, __FUNCTION__, __LINE__, _clsid_); \
} while (0)
#define eo2_class_super_do(clsid, ...) \
do \
{ \
const Eo_Class *_clsid_ = clsid; \
+ if (eo2_hook_class_do_pre) eo2_hook_class_do_pre(__FILE__, __FUNCTION__, __LINE__, _clsid_); \
if (eo2_class_do_start(_clsid_, EINA_TRUE)) \
{ \
const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \
__VA_ARGS__; \
(void) _id_clean_; \
} \
+ if (eo2_hook_class_do_post) eo2_hook_class_do_post(__FILE__, __FUNCTION__, __LINE__, _clsid_); \
} while (0)
/*****************************************************************************/
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index da2130a49a..e8c66fa521 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -253,6 +253,13 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op)
/************************************ EO2 ************************************/
+EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL;
+EAPI Eo2_Hook_Call eo2_hook_call_post = NULL;
+EAPI Eo2_Hook_Do eo2_hook_do_pre = NULL;
+EAPI Eo2_Hook_Do eo2_hook_do_post = NULL;
+EAPI Eo2_Hook_Class_Do eo2_hook_class_do_pre = NULL;
+EAPI Eo2_Hook_Class_Do eo2_hook_class_do_post = NULL;
+
static inline const _Eo_Class *
_eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass)
{
@@ -346,6 +353,8 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super)
fptr->klass = klass;
fptr->obj_data = EO2_INVALID_DATA;
+
+
return EINA_TRUE;
}
diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c
index 4d0610f772..676540b90d 100644
--- a/src/lib/eo/eo2_base_class.c
+++ b/src/lib/eo/eo2_base_class.c
@@ -532,8 +532,8 @@ end:
return ret;
}
EAPI EO2_FUNC_BODYV(eo2_event_callback_call, Eina_Bool,
- EO2_FUNC_CALL(desc, event_info),
EINA_FALSE,
+ EO2_FUNC_CALL(desc, event_info),
const Eo_Event_Description *desc,
void *event_info);