From 35856fdd13dfca2b4b3193ba8702bccf1fe144b2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 8 Jul 2013 16:31:36 +0100 Subject: [PATCH 001/169] eo2: Eo2 first commit. --- src/lib/eo/Eo.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/eo/eo.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 7f77b393cf..3d65d0a078 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -592,6 +592,50 @@ EAPI Eina_Bool eo_init(void); */ EAPI Eina_Bool eo_shutdown(void); +typedef struct _Eo_Internal _Eo; + +/* XXX: Essential, because we need to adjust objid for comp objects. */ +#define EO_FUNC(Name, Ret, Id, Func, DefRet, ...) \ +Ret \ +Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ +{ \ + Ret (*func)(Eo *, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ + if (func) \ + { \ + return Func; \ + } \ + else \ + { \ + return DefRet; \ + } \ +} + + +EAPI _Eo * eo2_do_start(Eo *obj_id); +#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); + +/* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */ + +#define eo2_do_end(obj) eo_unref(obj) + +#define eo_o _obj_, _objid_ + +#define eo2_do(objid, ...) \ +do \ +{ \ + Eo *_objid_ = obj; \ + _Eo *_obj_ = eo2_do_start(obj); \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(obj); \ +} while (0) + +#define eo2_class_do(clsid, ...) \ +do \ +{ \ + do { __VA_ARGS__ ; } while (0); \ +} while (0) + /** * @def eo_do * A convenience wrapper around eo_do_internal() diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7842aa8a91..0cc724bda6 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -255,6 +255,41 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) return NULL; } +EAPI _Eo * +eo2_do_start(Eo *obj_id) +{ + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + _eo_ref(obj); + return obj; +} + +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) +{ + const _Eo_Class *klass; + if (klass_id) + klass = _eo_class_pointer_get(klass_id); + else + klass = obj->klass; + return _eo2_func_get(klass, op); +} + #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \ do \ { \ From 2e3ad3be10145378f5889b855372a54e12e24b53 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 9 Jul 2013 10:48:30 +0100 Subject: [PATCH 002/169] eo2: fix wrong eo2_do macro as reported by Jeremy. --- src/lib/eo/Eo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 3d65d0a078..796f6ec557 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -624,10 +624,10 @@ EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op); #define eo2_do(objid, ...) \ do \ { \ - Eo *_objid_ = obj; \ - _Eo *_obj_ = eo2_do_start(obj); \ + Eo *_objid_ = objid; \ + _Eo *_obj_ = eo2_do_start(_objid_); \ do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(obj); \ + eo2_do_end(_objid_); \ } while (0) #define eo2_class_do(clsid, ...) \ From 787cffd3f910f986421340f851e2459f47d722ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 9 Jul 2013 13:59:34 +0200 Subject: [PATCH 003/169] eo2: macro eo_o => eo2_o for clarity --- src/lib/eo/Eo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 796f6ec557..91b4715b57 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -619,7 +619,7 @@ EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op); #define eo2_do_end(obj) eo_unref(obj) -#define eo_o _obj_, _objid_ +#define eo2_o _obj_, _objid_ #define eo2_do(objid, ...) \ do \ From bfa48634cf347e78f4a12d259bbf4520038e2983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 9 Jul 2013 14:11:05 +0200 Subject: [PATCH 004/169] eo2: EO_FUNC -> EO_FUNC_BODY use macro to build the function body, the function prototype is a regular one --- src/lib/eo/Eo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 91b4715b57..19162e6c36 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -594,9 +594,11 @@ EAPI Eina_Bool eo_shutdown(void); typedef struct _Eo_Internal _Eo; +#define EO_FUNC_CALL(...) func(objid, __VA_ARGS__) + /* XXX: Essential, because we need to adjust objid for comp objects. */ -#define EO_FUNC(Name, Ret, Id, Func, DefRet, ...) \ -Ret \ +#define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet, ...) \ +EAPI Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ Ret (*func)(Eo *, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ @@ -620,6 +622,7 @@ EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op); #define eo2_do_end(obj) eo_unref(obj) #define eo2_o _obj_, _objid_ +#define eo2_a _Eo *obj, Eo *objid #define eo2_do(objid, ...) \ do \ From 71341334a91a20d0ece27d6996aa25789d5142c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 9 Jul 2013 14:21:11 +0200 Subject: [PATCH 005/169] eo2: add eo2_data_scope_get() use it in function body --- src/lib/eo/Eo.h | 14 +++++--------- src/lib/eo/eo.c | 5 +++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 19162e6c36..d6b8d6a99e 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -594,7 +594,7 @@ EAPI Eina_Bool eo_shutdown(void); typedef struct _Eo_Internal _Eo; -#define EO_FUNC_CALL(...) func(objid, __VA_ARGS__) +#define EO_FUNC_CALL(...) func(obj_data, __VA_ARGS__) /* XXX: Essential, because we need to adjust objid for comp objects. */ #define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet, ...) \ @@ -602,18 +602,14 @@ EAPI Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ Ret (*func)(Eo *, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ - if (func) \ - { \ - return Func; \ - } \ - else \ - { \ - return DefRet; \ - } \ + if (!func) return DefRet; \ + void *obj_data = eo2_data_scope_get(obj); \ + 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); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 0cc724bda6..7d557f78eb 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -263,6 +263,11 @@ 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) { From 9e042c06860157ec18c9b90fb94f371ab94a8f41 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 9 Jul 2013 15:49:45 +0100 Subject: [PATCH 006/169] eo2: pass the object id and data to function call --- src/lib/eo/Eo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index d6b8d6a99e..816ac67dfd 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -594,14 +594,14 @@ EAPI Eina_Bool eo_shutdown(void); typedef struct _Eo_Internal _Eo; -#define EO_FUNC_CALL(...) func(obj_data, __VA_ARGS__) +#define EO_FUNC_CALL(...) func(objid, obj_data, __VA_ARGS__) /* XXX: Essential, because we need to adjust objid for comp objects. */ #define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet, ...) \ EAPI Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ - Ret (*func)(Eo *, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ + 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); \ return Func; \ From 73f1d2a09e21ea673af6ca6b609ef2f38625acdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 9 Jul 2013 17:43:46 +0200 Subject: [PATCH 007/169] eo2: add macros for functions with no argument --- src/lib/eo/Eo.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 816ac67dfd..d522d98469 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -594,11 +594,22 @@ EAPI Eina_Bool eo_shutdown(void); typedef struct _Eo_Internal _Eo; -#define EO_FUNC_CALL(...) func(objid, obj_data, __VA_ARGS__) +#define EO_FUNC_CALL() func(objid, obj_data) +#define EO_FUNC_CALLV(...) func(objid, obj_data, __VA_ARGS__) /* XXX: Essential, because we need to adjust objid for comp objects. */ -#define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet, ...) \ -EAPI Ret \ +#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); \ + return Func; \ +} + +#define EO_FUNC_BODYV(Name, Ret, Id, Func, DefRet, ...) \ +Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ Ret (*func)(Eo *, void *obj_data, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ From ef873b7b2983f833c251222402a309e1e39240fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 10 Jul 2013 09:24:59 +0200 Subject: [PATCH 008/169] 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(). --- src/lib/eo/Eo.h | 27 ++++++++++++++++----------- src/lib/eo/eo.c | 40 ++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index d522d98469..ef395a8d51 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -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. */ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7d557f78eb..532dbcd850 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -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) \ From d0153fabc155e9fa10d286d7fc63db276b0c7335 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Wed, 25 Dec 2013 14:34:26 +0100 Subject: [PATCH 009/169] eo2: make macro pass C++ compiler. --- src/lib/eo/Eo.h | 65 +++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index ef395a8d51..c639cc0f84 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -604,26 +604,27 @@ typedef struct _Eo2_Op_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) \ -{ \ - 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; \ -} - -#define EO_FUNC_BODYV(Name, Ret, Id, Func, DefRet, ...) \ -Ret \ -Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ -{ \ - 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; \ -} +#define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet) \ + Ret \ + Name(_Eo *obj, Eo *objid) \ + { \ + typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ + Eo2_Op_Call_Data call; \ + if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \ + __##Name##_func func = (__##Name##_func) call.func; \ + return Func; \ + } +#define EO_FUNC_BODYV(Name, Ret, Id, Func, DefRet, ...) \ + Ret \ + Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ + { \ + typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ + Eo2_Op_Call_Data call; \ + if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \ + __##Name##_func func = (__##Name##_func) call.func; \ + return Func; \ + } EAPI _Eo * eo2_do_start(Eo *obj_id); #define eo2_call_resolve(obj_id, op, call) eo2_call_resolve_internal(obj_id, NULL, op, call) @@ -636,20 +637,20 @@ EAPI Eina_Bool eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass, Eo_Op #define eo2_o _obj_, _objid_ #define eo2_a _Eo *obj, Eo *objid -#define eo2_do(objid, ...) \ -do \ -{ \ - Eo *_objid_ = objid; \ - _Eo *_obj_ = eo2_do_start(_objid_); \ - do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(_objid_); \ -} while (0) +#define eo2_do(objid, ...) \ + do \ + { \ + Eo *_objid_ = objid; \ + _Eo *_obj_ = eo2_do_start(_objid_); \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(_objid_); \ + } while (0) -#define eo2_class_do(clsid, ...) \ -do \ -{ \ - do { __VA_ARGS__ ; } while (0); \ -} while (0) +#define eo2_class_do(clsid, ...) \ + do \ + { \ + do { __VA_ARGS__ ; } while (0); \ + } while (0) /** * @def eo_do From 473609e1d31a9638a751c5d545b4f3ea5a969f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 14:51:52 +0100 Subject: [PATCH 010/169] eo2: eliminate the need of OPID and Eo_Op_Func_Description at class elaboration, sort the op descriptions using the function pointer. when calling a function, do a dichotomic search in the class op descriptions to find the corresponding OP_ID, then keep it in a static variable. --- src/lib/eo/Eo.h | 45 +++++++++++++++++++++++++++---------- src/lib/eo/eo.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index c639cc0f84..2760a3d924 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -448,6 +448,15 @@ typedef struct _Eo_Op_Description Eo_Op_Description; */ #define EO_VERSION 1 +typedef struct _Eo2_Op_Description +{ + void *func; /**< The static function to call for the op. */ + void *api_func; /**< The EAPI function offering this op. */ + Eo_Op op; /**< The op. */ + Eo_Op_Type op_type; /**< The type of the Op. */ + const char *doc; /**< Explanation about the Op. */ +} Eo2_Op_Description; + /** * @struct _Eo_Class_Description * This struct holds the description of a class. @@ -604,32 +613,44 @@ typedef struct _Eo2_Op_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) \ +#define EO_FUNC_BODY(Name, Ret, Func, DefRet, OpDescs) \ Ret \ Name(_Eo *obj, Eo *objid) \ { \ + static Eo_Op op = EO_NOOP; \ + if ( op == EO_NOOP ) op = eo2_get_op_id(OpDescs, (void*)Name); \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ Eo2_Op_Call_Data call; \ - if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \ - __##Name##_func func = (__##Name##_func) call.func; \ + if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ + __##Name##_func func = (__##Name##_func) call.func; \ return Func; \ } -#define EO_FUNC_BODYV(Name, Ret, Id, Func, DefRet, ...) \ - Ret \ - Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ - { \ - typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - Eo2_Op_Call_Data call; \ - if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \ - __##Name##_func func = (__##Name##_func) call.func; \ - return Func; \ +#define EO_FUNC_BODYV(Name, Ret, Func, DefRet, OpDescs, ...) \ + Ret \ + Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ + { \ + static Eo_Op op = EO_NOOP; \ + if ( op == EO_NOOP ) op = eo2_get_op_id(OpDescs, (void*)Name); \ + typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ + Eo2_Op_Call_Data call; \ + if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ + __##Name##_func func = (__##Name##_func) call.func; \ + return Func; \ } EAPI _Eo * eo2_do_start(Eo *obj_id); + #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); +EAPI Eo_Op eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func); + +#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) + +EAPI void +eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n); + /* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */ #define eo2_do_end(obj) eo_unref(obj) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 532dbcd850..feb41f392b 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -287,6 +287,65 @@ eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_C return EINA_FALSE; } + +EAPI Eo_Op +eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func) +{ + Eo2_Op_Description *op_desc; + + /* should do a binary search */ + for (op_desc = op_descs; op_desc->op != EO_NOOP; op_desc++) + { + if (op_desc->api_func == api_func) + return op_desc->op; + } + + return EO_NOOP; +} + +static int +eo2_fct_cmp(const void *p1, const void *p2) +{ + const Eo2_Op_Description *op1, *op2; + op1 = (Eo2_Op_Description *) p1; + op2 = (Eo2_Op_Description *) p2; + if (op1->api_func > op2->api_func) return -1; + else if (op1->api_func < op2->api_func) return 1; + else return 0; +} + +EAPI void +eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n) +{ + int i, base_op_id; + _Eo_Class *klass; + Eo2_Op_Description *op_desc; + + klass = _eo_class_pointer_get(klass_id); + EO_MAGIC_RETURN(klass, EO_CLASS_EINA_MAGIC); + + base_op_id = *klass->desc->ops.base_op_id; + + /* so that eo2_get_op_id can do a binary search to get the OP from the api_func */ + qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_fct_cmp); + + i = 0; + for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) + { + // take care of overriding, maybe ok ?? + if (op_desc->op == EO_NOOP) + { + op_desc->op = base_op_id + i; + i++; + } + /* printf("%d %p %p\n", op_desc->op, op_desc->api_func, op_desc->func); */ + // no need to check func->op_type != op_desc->op_type + // as op_descs wourd replace op_desc + // what about func->op == EO_NOOP ?? + _dich_func_set(klass, op_desc->op, op_desc->func); + } +} + #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \ do \ { \ From 23ae1fc453f27f001cb69ccea8bc7e82c6e26b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 11 Jul 2013 14:15:39 +0200 Subject: [PATCH 011/169] eo2: use internal unref, break if eo2_start returns NULL --- src/lib/eo/Eo.h | 17 ++++++++++------- src/lib/eo/eo.c | 6 ++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 2760a3d924..bf39e5e868 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -653,18 +653,21 @@ eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n); /* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */ -#define eo2_do_end(obj) eo_unref(obj) +EAPI void eo2_unref_internal(_Eo *obj); + +#define eo2_do_end(obj) eo2_unref_internal(obj) #define eo2_o _obj_, _objid_ #define eo2_a _Eo *obj, Eo *objid -#define eo2_do(objid, ...) \ - do \ - { \ - Eo *_objid_ = objid; \ +#define eo2_do(objid, ...) \ + do \ + { \ + Eo *_objid_ = objid; \ _Eo *_obj_ = eo2_do_start(_objid_); \ - do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(_objid_); \ + if (!_obj_) break; \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(_obj_); \ } while (0) #define eo2_class_do(clsid, ...) \ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index feb41f392b..713a66c3e0 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -263,6 +263,12 @@ eo2_do_start(Eo *obj_id) return obj; } +EAPI void +eo2_unref_internal(_Eo *obj) +{ + _eo_unref(obj); +} + EAPI Eina_Bool eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) { From bc6019c154456c353a64067da8bdacfe0807bdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 18 Jul 2013 07:10:07 +0000 Subject: [PATCH 012/169] eo2: add comments end clean up --- src/lib/eo/Eo.h | 68 +++++++++++++++++++++++++++++-------------------- src/lib/eo/eo.c | 16 +++++++----- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index bf39e5e868..988675346b 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -601,65 +601,76 @@ EAPI Eina_Bool eo_init(void); */ EAPI Eina_Bool eo_shutdown(void); +/************************************ EO2 ************************************/ + +// computes size of Eo2_Op_Description[] +#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) + +// sort Eo2_Op_Description[] by eapi_func then attribute OP ids +EAPI void +eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n); + +// opaque type used to pass object pointer to EAPI calls typedef struct _Eo_Internal _Eo; +// to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data { void *func; void *data; } Eo2_Op_Call_Data; +// EAPI function declaration first argument +#define eo2_a _Eo *obj, Eo *objid +// EAPI function call first argument +#define eo2_o _obj_, _objid_ + +// to pass the internal function call to EO_FUNC_BODY (as Func parameter) #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, Func, DefRet, OpDescs) \ - Ret \ - Name(_Eo *obj, Eo *objid) \ - { \ +// cache OP id, get real fct and object data then do the call +#define _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) op = eo2_get_op_id(OpDescs, (void*)Name); \ - typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ __##Name##_func func = (__##Name##_func) call.func; \ return Func; \ + +/* XXX: Essential, because we need to adjust objid for comp objects. */ +// to define an EAPI function +#define EO_FUNC_BODY(Name, Ret, Func, DefRet, OpDescs) \ + Ret \ + Name(_Eo *obj, Eo *objid) \ + { \ + typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ + _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ } #define EO_FUNC_BODYV(Name, Ret, Func, DefRet, OpDescs, ...) \ Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ - static Eo_Op op = EO_NOOP; \ - if ( op == EO_NOOP ) op = eo2_get_op_id(OpDescs, (void*)Name); \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - Eo2_Op_Call_Data call; \ - if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ - __##Name##_func func = (__##Name##_func) call.func; \ - return Func; \ + _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ } -EAPI _Eo * eo2_do_start(Eo *obj_id); +// returns the OP id corresponding to the given api_func +EAPI Eo_Op eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func); +// gets the real function pointer and the object data #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); -EAPI Eo_Op eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func); +// start of eo2_do barrier, gets the object pointer and ref it +EAPI _Eo * eo2_do_start(Eo *obj_id); -#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) - -EAPI void -eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n); - -/* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */ - -EAPI void eo2_unref_internal(_Eo *obj); - -#define eo2_do_end(obj) eo2_unref_internal(obj) - -#define eo2_o _obj_, _objid_ -#define eo2_a _Eo *obj, Eo *objid +// end of the eo2_do barrier, unref the obj +EAPI void eo2_do_end(_Eo *obj); +// eo object method calls batch, +// DO NOT use return statement in it, use break if necessary #define eo2_do(objid, ...) \ do \ { \ @@ -670,12 +681,15 @@ EAPI void eo2_unref_internal(_Eo *obj); eo2_do_end(_obj_); \ } while (0) +// FIXME #define eo2_class_do(clsid, ...) \ do \ { \ do { __VA_ARGS__ ; } while (0); \ } while (0) +/*****************************************************************************/ + /** * @def eo_do * A convenience wrapper around eo_do_internal() diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 713a66c3e0..0412d3c48c 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -255,6 +255,8 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) return NULL; } +/************************************ EO2 ************************************/ + EAPI _Eo * eo2_do_start(Eo *obj_id) { @@ -264,7 +266,7 @@ eo2_do_start(Eo *obj_id) } EAPI void -eo2_unref_internal(_Eo *obj) +eo2_do_end(_Eo *obj) { _eo_unref(obj); } @@ -299,7 +301,7 @@ eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func) { Eo2_Op_Description *op_desc; - /* should do a binary search */ + /* do a binary search, when it's swallowed by _Eo_Class_Description */ for (op_desc = op_descs; op_desc->op != EO_NOOP; op_desc++) { if (op_desc->api_func == api_func) @@ -310,7 +312,7 @@ eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func) } static int -eo2_fct_cmp(const void *p1, const void *p2) +eo2_api_funcs_cmp(const void *p1, const void *p2) { const Eo2_Op_Description *op1, *op2; op1 = (Eo2_Op_Description *) p1; @@ -332,8 +334,8 @@ eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n) base_op_id = *klass->desc->ops.base_op_id; - /* so that eo2_get_op_id can do a binary search to get the OP from the api_func */ - qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_fct_cmp); + /* to speed up eo2_get_op_id */ + qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); i = 0; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) @@ -346,12 +348,12 @@ eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n) } /* printf("%d %p %p\n", op_desc->op, op_desc->api_func, op_desc->func); */ // no need to check func->op_type != op_desc->op_type - // as op_descs wourd replace op_desc - // what about func->op == EO_NOOP ?? _dich_func_set(klass, op_desc->op, op_desc->func); } } +/*****************************************************************************/ + #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \ do \ { \ From 731f8e1dea2c13945134a64cef3b317643740d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:02:25 +0100 Subject: [PATCH 013/169] eo2: add optional macros eo2_call[v] --- src/lib/eo/Eo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 988675346b..5205764d9c 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -669,6 +669,10 @@ EAPI _Eo * eo2_do_start(Eo *obj_id); // end of the eo2_do barrier, unref the obj EAPI void eo2_do_end(_Eo *obj); +// optional helper +#define eo2_call(api_func) api_func(eo2_o) +#define eo2_callv(api_func, ...) api_func(eo2_o, __VA_ARGS__) + // eo object method calls batch, // DO NOT use return statement in it, use break if necessary #define eo2_do(objid, ...) \ From 41aff7524dd0216cef3749d6b6d9a24f616fa4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 22 Jul 2013 14:06:29 +0000 Subject: [PATCH 014/169] eo2: clear _obj_ ptr at the end of eo2_do --- src/lib/eo/Eo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 5205764d9c..8391802b96 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -683,6 +683,7 @@ EAPI void eo2_do_end(_Eo *obj); if (!_obj_) break; \ do { __VA_ARGS__ ; } while (0); \ eo2_do_end(_obj_); \ + _obj_ = NULL; \ } while (0) // FIXME From f05f51dd60abf37fed81ef7fc467e167b0fdc34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:04:26 +0100 Subject: [PATCH 015/169] eo2: _Eo_Class_Description swallows op_descs remove OpDescs argument from macros, eo2_get_op_id() uses binary search --- src/lib/eo/Eo.h | 20 +++++++++----------- src/lib/eo/eo.c | 38 ++++++++++++++++++++++++++++---------- src/lib/eo/eo_base_class.c | 1 + 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 8391802b96..afa10bf184 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -477,6 +477,7 @@ struct _Eo_Class_Description size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */ void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */ void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */ + Eo2_Op_Description *op_descs; /**< should replace ops.descs */ }; /** @@ -603,12 +604,9 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ -// computes size of Eo2_Op_Description[] -#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) - // sort Eo2_Op_Description[] by eapi_func then attribute OP ids EAPI void -eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n); +eo2_class_funcs_set(Eo_Class *klass_id); // opaque type used to pass object pointer to EAPI calls typedef struct _Eo_Internal _Eo; @@ -630,9 +628,9 @@ typedef struct _Eo2_Op_Call_Data #define EO_FUNC_CALLV(...) func(objid, call.data, __VA_ARGS__) // cache OP id, get real fct and object data then do the call -#define _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ +#define _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ static Eo_Op op = EO_NOOP; \ - if ( op == EO_NOOP ) op = eo2_get_op_id(OpDescs, (void*)Name); \ + if ( op == EO_NOOP ) op = eo2_get_op_id(obj, (void*)Name); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ __##Name##_func func = (__##Name##_func) call.func; \ @@ -640,24 +638,24 @@ typedef struct _Eo2_Op_Call_Data /* XXX: Essential, because we need to adjust objid for comp objects. */ // to define an EAPI function -#define EO_FUNC_BODY(Name, Ret, Func, DefRet, OpDescs) \ +#define EO_FUNC_BODY(Name, Ret, Func, DefRet) \ Ret \ Name(_Eo *obj, Eo *objid) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ - _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ + _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ } -#define EO_FUNC_BODYV(Name, Ret, Func, DefRet, OpDescs, ...) \ +#define EO_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - _EO_FUNC_COMMON(Name, Ret, Func, DefRet, OpDescs) \ + _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ } // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func); +EAPI Eo_Op eo2_get_op_id(_Eo *obj, void *api_func); // gets the real function pointer and the object data #define eo2_call_resolve(obj_id, op, call) eo2_call_resolve_internal(obj_id, NULL, op, call) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 0412d3c48c..8a69b2a23c 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -297,14 +297,26 @@ eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_C EAPI Eo_Op -eo2_get_op_id(Eo2_Op_Description *op_descs, void *api_func) +eo2_get_op_id(_Eo *obj, void *api_func) { + int imin, imax, imid; Eo2_Op_Description *op_desc; + Eo2_Op_Description *op_descs; - /* do a binary search, when it's swallowed by _Eo_Class_Description */ - for (op_desc = op_descs; op_desc->op != EO_NOOP; op_desc++) + imin = 0; + imax = obj->klass->desc->ops.count - 1; + op_descs = obj->klass->desc->op_descs; + + while (imax >= imin) { - if (op_desc->api_func == api_func) + imid = (imax + imin) / 2; + op_desc = op_descs + imid; + + if (op_desc->api_func > api_func) + imin = imid + 1; + else if (op_desc->api_func < api_func) + imax = imid - 1; + else return op_desc->op; } @@ -323,9 +335,9 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) } EAPI void -eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n) +eo2_class_funcs_set(Eo_Class *klass_id) { - int i, base_op_id; + int i, base_op_id, n; _Eo_Class *klass; Eo2_Op_Description *op_desc; @@ -334,15 +346,21 @@ eo2_class_funcs_set(Eo_Class *klass_id, Eo2_Op_Description *op_descs, int n) base_op_id = *klass->desc->ops.base_op_id; - /* to speed up eo2_get_op_id */ - qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + // klass->desc->ops.count only counts class OP, not _constructor or _destructor + for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); + n = op_desc - klass->desc->op_descs; + + qsort((void*)klass->desc->op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); i = 0; - for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) + for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { - // take care of overriding, maybe ok ?? if (op_desc->op == EO_NOOP) { + if(op_desc->api_func == NULL) + ERR("Setting implementation for NULL EAPI for class '%s'. Func index: %lu", + klass->desc->name, (unsigned long) (op_desc - klass->desc->op_descs)); + op_desc->op = base_op_id + i; i++; } diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index c83b19bb23..b5a5edd72e 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -1007,6 +1007,7 @@ static const Eo_Class_Description class_desc = { event_desc, sizeof(Private_Data), _class_constructor, + NULL, NULL }; From 3295c8faaa0dec55b6a0d08ec97fc22761ad7ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:05:44 +0100 Subject: [PATCH 016/169] eo2: add macros to feed op_descs --- src/lib/eo/Eo.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index afa10bf184..d128c6a3f3 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -654,6 +654,12 @@ typedef struct _Eo2_Op_Call_Data _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ } +// FIXME: OP ID +#define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"} +#define EO2_OP_DESTRUCTOR(_private) { _private, NULL, 2, EO_OP_TYPE_REGULAR, "Destructor"} +#define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} +#define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} + // returns the OP id corresponding to the given api_func EAPI Eo_Op eo2_get_op_id(_Eo *obj, void *api_func); From 48c2c1dfba787274e7e0e5ef428b5a858d572a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 22 Jul 2013 17:31:58 +0000 Subject: [PATCH 017/169] eo2: rename func parameter into _func_ --- src/lib/eo/Eo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index d128c6a3f3..8c3c00eb8b 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -624,8 +624,8 @@ typedef struct _Eo2_Op_Call_Data #define eo2_o _obj_, _objid_ // to pass the internal function call to EO_FUNC_BODY (as Func parameter) -#define EO_FUNC_CALL() func(objid, call.data) -#define EO_FUNC_CALLV(...) func(objid, call.data, __VA_ARGS__) +#define EO_FUNC_CALL() _func_(objid, call.data) +#define EO_FUNC_CALLV(...) _func_(objid, call.data, __VA_ARGS__) // cache OP id, get real fct and object data then do the call #define _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ @@ -633,7 +633,7 @@ typedef struct _Eo2_Op_Call_Data if ( op == EO_NOOP ) op = eo2_get_op_id(obj, (void*)Name); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ - __##Name##_func func = (__##Name##_func) call.func; \ + __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ /* XXX: Essential, because we need to adjust objid for comp objects. */ From 6bb29b378b85350b4639b38b8ab58affbd496375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:09:16 +0100 Subject: [PATCH 018/169] eo2: add EO_FUNC_BODY_VOID and EO_FUNC_BODY_VOIDV macros --- src/lib/eo/Eo.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 8c3c00eb8b..ddb716553a 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -624,8 +624,7 @@ typedef struct _Eo2_Op_Call_Data #define eo2_o _obj_, _objid_ // to pass the internal function call to EO_FUNC_BODY (as Func parameter) -#define EO_FUNC_CALL() _func_(objid, call.data) -#define EO_FUNC_CALLV(...) _func_(objid, call.data, __VA_ARGS__) +#define EO_FUNC_CALL(...) _func_(objid, call.data, __VA_ARGS__) // cache OP id, get real fct and object data then do the call #define _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ @@ -633,19 +632,21 @@ typedef struct _Eo2_Op_Call_Data if ( op == EO_NOOP ) op = eo2_get_op_id(obj, (void*)Name); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ - __##Name##_func _func_ = (__##Name##_func) call.func; \ + __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ /* XXX: Essential, because we need to adjust objid for comp objects. */ // to define an EAPI function -#define EO_FUNC_BODY(Name, Ret, Func, DefRet) \ +#define EO_FUNC_BODY(Name, Ret, DefRet) \ Ret \ Name(_Eo *obj, Eo *objid) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ - _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ + _EO_FUNC_COMMON(Name, Ret, _func_(objid, call.data), DefRet) \ } +#define EO_FUNC_BODY_VOID(Name) EO_FUNC_BODY(Name, void, ) + #define EO_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ @@ -654,6 +655,8 @@ typedef struct _Eo2_Op_Call_Data _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ } +#define EO_FUNC_BODY_VOIDV(Name, Func, ...) EO_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) + // FIXME: OP ID #define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"} #define EO2_OP_DESTRUCTOR(_private) { _private, NULL, 2, EO_OP_TYPE_REGULAR, "Destructor"} From 8ef9e1c00d45e41ce7257e3a8ba9af3c3884a7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:10:42 +0100 Subject: [PATCH 019/169] eo2: use EO2 instead of EO in macro names --- src/lib/eo/Eo.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index ddb716553a..bfd9fde438 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -623,11 +623,11 @@ typedef struct _Eo2_Op_Call_Data // EAPI function call first argument #define eo2_o _obj_, _objid_ -// to pass the internal function call to EO_FUNC_BODY (as Func parameter) -#define EO_FUNC_CALL(...) _func_(objid, call.data, __VA_ARGS__) +// to pass the internal function call to EO2_FUNC_BODY (as Func parameter) +#define EO2_FUNC_CALL(...) _func_(objid, call.data, __VA_ARGS__) // cache OP id, get real fct and object data then do the call -#define _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ +#define _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \ static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) op = eo2_get_op_id(obj, (void*)Name); \ Eo2_Op_Call_Data call; \ @@ -637,25 +637,25 @@ typedef struct _Eo2_Op_Call_Data /* XXX: Essential, because we need to adjust objid for comp objects. */ // to define an EAPI function -#define EO_FUNC_BODY(Name, Ret, DefRet) \ +#define EO2_FUNC_BODY(Name, Ret, DefRet) \ Ret \ Name(_Eo *obj, Eo *objid) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ - _EO_FUNC_COMMON(Name, Ret, _func_(objid, call.data), DefRet) \ + _EO2_FUNC_COMMON(Name, Ret, _func_(objid, call.data), DefRet) \ } -#define EO_FUNC_BODY_VOID(Name) EO_FUNC_BODY(Name, void, ) +#define EO2_VOID_FUNC_BODY(Name) EO2_FUNC_BODY(Name, void, ) -#define EO_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ +#define EO2_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \ + _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \ } -#define EO_FUNC_BODY_VOIDV(Name, Func, ...) EO_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) +#define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // FIXME: OP ID #define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"} From 2490a1bef26b3b9b578843a940b57acabbc18e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:12:06 +0100 Subject: [PATCH 020/169] eo2: better op_descs integration struct _Eo_Class_Description swallows Eo2_Op_Description *descs2; --- src/lib/eo/Eo.h | 10 ++++++++-- src/lib/eo/eo.c | 35 ++++++++++++++++++++++------------- src/lib/eo/eo_base_class.c | 1 - 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index bfd9fde438..e5fa687eee 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -471,13 +471,13 @@ struct _Eo_Class_Description struct { Eo_Op *base_op_id; const Eo_Op_Description *descs; + Eo2_Op_Description *descs2; /**< EO2 */ size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ const Eo_Event_Description **events; /**< The event descriptions for this class. */ size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */ void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */ void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */ - Eo2_Op_Description *op_descs; /**< should replace ops.descs */ }; /** @@ -493,7 +493,7 @@ typedef struct _Eo_Class_Description Eo_Class_Description; * @param op_descs the op descriptions array. * @param count the number of ops in the op descriptions array. */ -#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count } +#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, NULL, count } /** * @def EO_OP_DESCRIPTION(op, doc) @@ -604,6 +604,12 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ +// computes size of Eo2_Op_Description[] +#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) + +// An helper macro to help populating #Eo_Class_Description. +#define EO2_CLASS_DESCRIPTION_OPS(op_descs, count) { NULL, NULL, op_descs, count } + // sort Eo2_Op_Description[] by eapi_func then attribute OP ids EAPI void eo2_class_funcs_set(Eo_Class *klass_id); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8a69b2a23c..906183a9e2 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -305,7 +305,7 @@ eo2_get_op_id(_Eo *obj, void *api_func) imin = 0; imax = obj->klass->desc->ops.count - 1; - op_descs = obj->klass->desc->op_descs; + op_descs = obj->klass->desc->ops.descs2; while (imax >= imin) { @@ -337,32 +337,33 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) EAPI void eo2_class_funcs_set(Eo_Class *klass_id) { - int i, base_op_id, n; + int op_id, n; _Eo_Class *klass; Eo2_Op_Description *op_desc; + Eo2_Op_Description *op_descs; klass = _eo_class_pointer_get(klass_id); EO_MAGIC_RETURN(klass, EO_CLASS_EINA_MAGIC); + op_descs = klass->desc->ops.descs2; - base_op_id = *klass->desc->ops.base_op_id; // klass->desc->ops.count only counts class OP, not _constructor or _destructor - for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); - n = op_desc - klass->desc->op_descs; + for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); + n = op_desc - op_descs; - qsort((void*)klass->desc->op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); - i = 0; - for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) + op_id = klass->base_id; + for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if (op_desc->op == EO_NOOP) { if(op_desc->api_func == NULL) ERR("Setting implementation for NULL EAPI for class '%s'. Func index: %lu", - klass->desc->name, (unsigned long) (op_desc - klass->desc->op_descs)); + klass->desc->name, (unsigned long) (op_desc - op_descs)); - op_desc->op = base_op_id + i; - i++; + op_desc->op = op_id; + op_id++; } /* printf("%d %p %p\n", op_desc->op, op_desc->api_func, op_desc->func); */ // no need to check func->op_type != op_desc->op_type @@ -886,8 +887,16 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) DBG("Started building class '%s'", desc->name); - if (!_eo_class_check_op_descs(desc)) - return NULL; + if (desc->version == 1) + { + if (!_eo_class_check_op_descs(desc)) + return NULL; + } + else { + // FIXME: jeyzu + /* if (!_eo2_class_check_op_descs(desc)) */ + /* return NULL; */ + } _Eo_Class *parent = _eo_class_pointer_get(parent_id); #ifndef HAVE_EO_ID diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index b5a5edd72e..c83b19bb23 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -1007,7 +1007,6 @@ static const Eo_Class_Description class_desc = { event_desc, sizeof(Private_Data), _class_constructor, - NULL, NULL }; From a645076979b77e974937c5851a518de805769d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:13:41 +0100 Subject: [PATCH 021/169] eo2: eo2_base_class on it's way --- src/lib/eo/eo2_base_class.c | 821 ++++++++++++++++++++++++++++++++++++ src/lib/eo/eo2_base_class.h | 80 ++++ 2 files changed, 901 insertions(+) create mode 100644 src/lib/eo/eo2_base_class.c create mode 100644 src/lib/eo/eo2_base_class.h diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c new file mode 100644 index 0000000000..583719bc5b --- /dev/null +++ b/src/lib/eo/eo2_base_class.c @@ -0,0 +1,821 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "eo2_base_class.h" +#include "eo_ptr_indirection.h" +#include "eo_private.h" + +static int event_freeze_count = 0; + +typedef struct _Eo_Callback_Description Eo_Callback_Description; + +typedef struct +{ + Eina_Inlist *generic_data; + Eo ***wrefs; + + Eo_Callback_Description *callbacks; + unsigned short walking_list; + unsigned short event_freeze_count; + Eina_Bool deletions_waiting : 1; +} Private_Data; + +typedef struct +{ + EINA_INLIST; + Eina_Stringshare *key; + void *data; + eo_base_data_free_func free_func; +} Eo_Generic_Data_Node; + +static void +_eo_generic_data_node_free(Eo_Generic_Data_Node *node) +{ + eina_stringshare_del(node->key); + if (node->free_func) + node->free_func(node->data); + free(node); +} + +static void +_eo_generic_data_del_all(Private_Data *pd) +{ + Eina_Inlist *nnode; + Eo_Generic_Data_Node *node = NULL; + + EINA_INLIST_FOREACH_SAFE(pd->generic_data, nnode, node) + { + pd->generic_data = eina_inlist_remove(pd->generic_data, + EINA_INLIST_GET(node)); + + _eo_generic_data_node_free(node); + } +} + +static void +_data_set(Eo *obj, void *class_data, + const char *key, const void *data, eo_base_data_free_func free_func) +{ + Private_Data *pd = class_data; + + Eo_Generic_Data_Node *node; + + if (!key) return; + + eo_do(obj, eo_base_data_del(key)); + + node = malloc(sizeof(Eo_Generic_Data_Node)); + node->key = eina_stringshare_add(key); + node->data = (void *) data; + node->free_func = free_func; + pd->generic_data = eina_inlist_prepend(pd->generic_data, + EINA_INLIST_GET(node)); +} +EAPI EO2_VOID_FUNC_BODYV(data_set, EO2_FUNC_CALL(key, data, free_func), + const char *key, const void *data, eo_base_data_free_func free_func); + +static void * +_data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) +{ + /* We don't really change it... */ + Eo_Generic_Data_Node *node; + Private_Data *pd = (Private_Data *) class_data; + + if (!key) return NULL; + + EINA_INLIST_FOREACH(pd->generic_data, node) + { + if (!strcmp(node->key, key)) + { + pd->generic_data = + eina_inlist_promote(pd->generic_data, EINA_INLIST_GET(node)); + return node->data; + } + } + + return NULL; +} +EAPI EO2_VOID_FUNC_BODYV(data_get, EO2_FUNC_CALL(key), const char *key); + +static void +_dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) +{ /* No info required in the meantime */ + return; +} +EAPI EO2_VOID_FUNC_BODY(dbg_info_get); + +static void +_data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) +{ + Eo_Generic_Data_Node *node; + Private_Data *pd = class_data; + + if (!key) return; + + EINA_INLIST_FOREACH(pd->generic_data, node) + { + if (!strcmp(node->key, key)) + { + pd->generic_data = eina_inlist_remove(pd->generic_data, + EINA_INLIST_GET(node)); + _eo_generic_data_node_free(node); + return; + } + } +} +EAPI EO2_VOID_FUNC_BODYV(data_del, EO2_FUNC_CALL(key), const char *key); + +/* Weak reference. */ + +static inline size_t +_wref_count(Private_Data *pd) +{ + size_t count = 0; + if (!pd->wrefs) + return 0; + + Eo ***itr; + for (itr = pd->wrefs ; *itr ; itr++) + count++; + + return count; +} + +static void +_wref_add(Eo *obj, void *class_data, Eo **wref) +{ + Private_Data *pd = (Private_Data *) class_data; + size_t count; + + count = _wref_count(pd); + count += 1; /* New wref. */ + + pd->wrefs= realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1)); + + pd->wrefs[count - 1] = wref; + pd->wrefs[count] = NULL; + *wref = obj; +} +EAPI EO2_VOID_FUNC_BODYV(wref_add, EO2_FUNC_CALL(wref), Eo **wref); + +static void +_wref_del(Eo *obj, void *class_data, Eo **wref) +{ + Private_Data *pd = (Private_Data *) class_data; + size_t count; + + if (*wref != obj) + { + ERR("Wref is a weak ref to %p, while this function was called on %p.", + *wref, obj); + return; + } + + if (!pd->wrefs) + { + ERR("There are no weak refs for object %p", obj); + *wref = NULL; + return; + } + + /* Move the last item in the array instead of the current wref. */ + count = _wref_count(pd); + + { + Eo ***itr; + for (itr = pd->wrefs ; *itr ; itr++) + { + if (*itr == wref) + { + *itr = pd->wrefs[count - 1]; + break; + } + } + + if (!*itr) + { + ERR("Wref %p is not associated with object %p", wref, obj); + *wref = NULL; + return; + } + } + + if (count > 1) + { + // No count--; because of the NULL that is not included in the count. */ + pd->wrefs = realloc(pd->wrefs, sizeof(*pd->wrefs) * count); + pd->wrefs[count - 1] = NULL; + } + else + { + free(pd->wrefs); + pd->wrefs = NULL; + } + + *wref = NULL; +} +EAPI EO2_VOID_FUNC_BODYV(wref_del, EO2_FUNC_CALL(wref), Eo **wref); + +static inline void +_wref_destruct(Private_Data *pd) +{ + Eo ***itr; + if (!pd->wrefs) + return; + + for (itr = pd->wrefs ; *itr ; itr++) + { + **itr = NULL; + } + + free(pd->wrefs); +} + +/* EOF Weak reference. */ + +/* Event callbacks */ + +/* Callbacks */ + +struct _Eo_Callback_Description +{ + Eo_Callback_Description *next; + + union + { + Eo_Callback_Array_Item item; + const Eo_Callback_Array_Item *item_array; + } items; + + void *func_data; + Eo_Callback_Priority priority; + + Eina_Bool delete_me : 1; + Eina_Bool func_array : 1; +}; + +/* Actually remove, doesn't care about walking list, or delete_me */ +static void +_eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) +{ + Eo_Callback_Description *itr, *pitr; + + itr = pitr = pd->callbacks; + if (pd->callbacks == cb) + pd->callbacks = cb->next; + + for ( ; itr ; ) + { + Eo_Callback_Description *titr = itr; + itr = itr->next; + + if (titr == cb) + { + if (pitr) + { + pitr->next = titr->next; + } + free(titr); + } + else + { + pitr = titr; + } + } +} + +/* Actually remove, doesn't care about walking list, or delete_me */ +static void +_eo_callback_remove_all(Private_Data *pd) +{ + while (pd->callbacks) + { + Eo_Callback_Description *next = pd->callbacks->next; + free(pd->callbacks); + pd->callbacks = next; + } +} + +static void +_eo_callbacks_clear(Private_Data *pd) +{ + Eo_Callback_Description *cb = NULL; + + /* If there are no deletions waiting. */ + if (!pd->deletions_waiting) + return; + + /* Abort if we are currently walking the list. */ + if (pd->walking_list > 0) + return; + + pd->deletions_waiting = EINA_FALSE; + + for (cb = pd->callbacks ; cb ; ) + { + Eo_Callback_Description *titr = cb; + cb = cb->next; + + if (titr->delete_me) + { + _eo_callback_remove(pd, titr); + } + } +} + +static void +_eo_callbacks_sorted_insert(Private_Data *pd, Eo_Callback_Description *cb) +{ + Eo_Callback_Description *itr, *itrp = NULL; + for (itr = pd->callbacks ; itr && (itr->priority < cb->priority) ; + itr = itr->next) + { + itrp = itr; + } + + if (itrp) + { + cb->next = itrp->next; + itrp->next = cb; + } + else + { + cb->next = pd->callbacks; + pd->callbacks = cb; + } +} + +static void +_ev_cb_priority_add(Eo *obj, void *class_data, + const Eo_Event_Description *desc, + Eo_Callback_Priority priority, + Eo_Event_Cb func, + const void *user_data) +{ + Eo_Callback_Description *cb; + Private_Data *pd = (Private_Data *) class_data; + + cb = calloc(1, sizeof(*cb)); + cb->items.item.desc = desc; + cb->items.item.func = func; + cb->func_data = (void *) user_data; + cb->priority = priority; + _eo_callbacks_sorted_insert(pd, cb); + + { + const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, arr, NULL)); + } +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_priority_add, + EO2_FUNC_CALL(desc, priority, func, user_data), + const Eo_Event_Description *desc, + Eo_Callback_Priority priority, + Eo_Event_Cb func, + const void *user_data); + +static void +_ev_cb_del(Eo *obj, void *class_data, + const Eo_Event_Description *desc, + Eo_Event_Cb func, + void *user_data) +{ + Eo_Callback_Description *cb; + Private_Data *pd = (Private_Data *) class_data; + + for (cb = pd->callbacks ; cb ; cb = cb->next) + { + if ((cb->items.item.desc == desc) && (cb->items.item.func == func) && + (cb->func_data == user_data)) + { + const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; + + cb->delete_me = EINA_TRUE; + pd->deletions_waiting = EINA_TRUE; + _eo_callbacks_clear(pd); + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, arr, NULL)); + return; + } + } + + DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_del, + EO2_FUNC_CALL(desc, func, user_data), + const Eo_Event_Description *desc, + Eo_Event_Cb func, + const void *user_data); + +static void +_ev_cb_array_priority_add(Eo *obj, void *class_data, + const Eo_Callback_Array_Item *array, + Eo_Callback_Priority priority, + const void *user_data) +{ + Eo_Callback_Description *cb; + Private_Data *pd = (Private_Data *) class_data; + + cb = calloc(1, sizeof(*cb)); + cb->func_data = (void *) user_data; + cb->priority = priority; + cb->items.item_array = array; + cb->func_array = EINA_TRUE; + _eo_callbacks_sorted_insert(pd, cb); + + { + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, array, NULL)); + } +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_array_priority_add, + EO2_FUNC_CALL(array, priority, user_data), + const Eo_Callback_Array_Item *array, + Eo_Callback_Priority priority, + const void *user_data); + +static void +_ev_cb_array_del(Eo *obj, void *class_data, + const Eo_Callback_Array_Item *array, + void *user_data) +{ + Eo_Callback_Description *cb; + Private_Data *pd = (Private_Data *) class_data; + + for (cb = pd->callbacks ; cb ; cb = cb->next) + { + if ((cb->items.item_array == array) && (cb->func_data == user_data)) + { + cb->delete_me = EINA_TRUE; + pd->deletions_waiting = EINA_TRUE; + _eo_callbacks_clear(pd); + + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, array, NULL)); + return; + } + } + + DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data); +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_array_del, + EO2_FUNC_CALL(array, user_data), + const Eo_Callback_Array_Item *array, + const void *user_data); + +static Eina_Bool +_ev_cb_call(Eo *obj_id, void *class_data, + const Eo_Event_Description *desc, + void *event_info) +{ + Eina_Bool ret; + Eo_Callback_Description *cb; + Private_Data *pd = (Private_Data *) class_data; + + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); + + ret = EINA_TRUE; + + _eo_ref(obj); + pd->walking_list++; + + for (cb = pd->callbacks ; cb ; cb = cb->next) + { + if (!cb->delete_me) + { + if (cb->func_array) + { + const Eo_Callback_Array_Item *it; + + for (it = cb->items.item_array ; it->func ; it++) + { + if (it->desc != desc) + continue; + if (!it->desc->unfreezable && + (event_freeze_count || pd->event_freeze_count)) + continue; + + /* Abort callback calling if the func says so. */ + if (!it->func((void *) cb->func_data, obj_id, desc, + (void *) event_info)) + { + ret = EINA_FALSE; + goto end; + } + } + } + else + { + if (cb->items.item.desc != desc) + continue; + if ((!cb->items.item.desc + || !cb->items.item.desc->unfreezable) && + (event_freeze_count || pd->event_freeze_count)) + continue; + + /* Abort callback calling if the func says so. */ + if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, + (void *) event_info)) + { + ret = EINA_FALSE; + goto end; + } + } + } + } + +end: + pd->walking_list--; + _eo_callbacks_clear(pd); + _eo_unref(obj); + + return ret; +} +EAPI EO2_FUNC_BODYV(ev_cb_call, Eina_Bool, + EO2_FUNC_CALL(desc, event_info), + EINA_FALSE, + const Eo_Event_Description *desc, + void *event_info); + +static Eina_Bool +_eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +{ + (void) obj; + Eo *new_obj = (Eo *) data; + Eina_Bool ret; + + eo_do(new_obj, eo_event_callback_call(desc, event_info, &ret)); + + return ret; +} + +/* FIXME: Change default priority? Maybe call later? */ +static void +_ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, + const Eo_Event_Description *desc, + Eo *new_obj) +{ + + /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ + + eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj)); +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_forwarder_add, + EO2_FUNC_CALL(desc, new_obj), + const Eo_Event_Description *desc, + Eo *new_obj); + +static void +_ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, + const Eo_Event_Description *desc, + Eo *new_obj) +{ + + /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ + + eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj)); +} +EAPI EO2_VOID_FUNC_BODYV(ev_cb_forwarder_del, + EO2_FUNC_CALL(desc, new_obj), + const Eo_Event_Description *desc, + Eo *new_obj); + +static void +_ev_freeze(Eo *obj EINA_UNUSED, void *class_data) +{ + Private_Data *pd = (Private_Data *) class_data; + pd->event_freeze_count++; +} +EAPI EO2_VOID_FUNC_BODY(ev_freeze); + +static void +_ev_thaw(Eo *obj, void *class_data) +{ + Private_Data *pd = (Private_Data *) class_data; + if (pd->event_freeze_count > 0) + { + pd->event_freeze_count--; + } + else + { + ERR("Events for object %p have already been thawed.", obj); + } +} +EAPI EO2_VOID_FUNC_BODY(ev_thaw); + +static int +_ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) +{ + Private_Data *pd = (Private_Data *) class_data; + + return pd->event_freeze_count; +} +EAPI EO2_FUNC_BODY(ev_freeze_get, int, 0); + +static void +_ev_global_freeze(const Eo_Class *klass EINA_UNUSED) +{ + event_freeze_count++; +} +EAPI EO2_VOID_FUNC_BODY(ev_global_freeze); + +static void +_ev_global_thaw(const Eo_Class *klass EINA_UNUSED) +{ + if (event_freeze_count > 0) + { + event_freeze_count--; + } + else + { + ERR("Global events have already been thawed."); + } +} +EAPI EO2_VOID_FUNC_BODY(ev_global_thaw); + +static int +_ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED) +{ + return event_freeze_count; +} +EAPI EO2_FUNC_BODY(ev_global_freeze_get, int, 0); + +/* Eo_Dbg */ +EAPI void +eo2_dbg_info_free(Eo_Dbg_Info *info) +{ + eina_value_flush(&(info->value)); + free(info); +} + +static Eina_Bool +_eo_dbg_info_setup(const Eina_Value_Type *type, void *mem) +{ + memset(mem, 0, type->value_size); + return EINA_TRUE; +} + +static Eina_Bool +_eo_dbg_info_flush(const Eina_Value_Type *type EINA_UNUSED, void *_mem) +{ + Eo_Dbg_Info *mem = *(Eo_Dbg_Info **) _mem; + eina_stringshare_del(mem->name); + eina_value_flush(&(mem->value)); + free(mem); + return EINA_TRUE; +} + +static Eina_Bool +_eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, void *_dst) +{ + const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src; + Eo_Dbg_Info **dst = _dst; + *dst = calloc(1, sizeof(Eo_Dbg_Info)); + (*dst)->name = eina_stringshare_ref((*src)->name); + eina_value_copy(&((*src)->value), &((*dst)->value)); + return EINA_TRUE; +} + +static Eina_Bool +_eo_dbg_info_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem) +{ + /* FIXME: For the meanwhile, just use the inner type for the value. */ + const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) type_mem; + if (convert == EINA_VALUE_TYPE_STRINGSHARE || + convert == EINA_VALUE_TYPE_STRING) + { + Eina_Bool ret; + const char *other_mem; + char *inner_val = eina_value_to_string(&(*src)->value); + other_mem = inner_val; + ret = eina_value_type_pset(convert, convert_mem, &other_mem); + free(inner_val); + return ret; + } + + eina_error_set(EINA_ERROR_VALUE_FAILED); + return EINA_FALSE; +} + +static Eina_Bool +_eo_dbg_info_pset(const Eina_Value_Type *type EINA_UNUSED, void *_mem, const void *_ptr) +{ + Eo_Dbg_Info **mem = _mem; + if (*mem) + free(*mem); + *mem = (void *) _ptr; + return EINA_TRUE; +} + +static Eina_Bool +_eo_dbg_info_pget(const Eina_Value_Type *type EINA_UNUSED, const void *_mem, void *_ptr) +{ + Eo_Dbg_Info **ptr = _ptr; + *ptr = (void *) _mem; + return EINA_TRUE; +} + +static const Eina_Value_Type _EO2_DBG_INFO_TYPE = { + EINA_VALUE_TYPE_VERSION, + sizeof(Eo_Dbg_Info *), + "Eo_Dbg_Info_Ptr", + _eo_dbg_info_setup, + _eo_dbg_info_flush, + _eo_dbg_info_copy, + NULL, + _eo_dbg_info_convert_to, + NULL, + NULL, + _eo_dbg_info_pset, + _eo_dbg_info_pget +}; + +EAPI const Eina_Value_Type *EO2_DBG_INFO_TYPE = &_EO2_DBG_INFO_TYPE; + + +/* EOF event callbacks */ + + +/* EO_BASE_CLASS stuff */ +#define MY_CLASS EO_BASE_CLASS + +/* FIXME: Set proper type descriptions. */ +/* EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = */ +/* EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); */ +/* EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = */ +/* EO_EVENT_DESCRIPTION("callback,del", "A callback was deleted."); */ +/* EAPI const Eo_Event_Description _EO_EV_DEL = */ +/* EO_HOT_EVENT_DESCRIPTION("del", "Obj is being deleted."); */ + +static void +_constructor(Eo *obj, void *class_data EINA_UNUSED) +{ + DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); + + _eo_condtor_done(obj); +} + +static void +_destructor(Eo *obj, void *class_data) +{ + DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); + + _eo_generic_data_del_all(class_data); + _wref_destruct(class_data); + _eo_callback_remove_all(class_data); + + _eo_condtor_done(obj); +} + +static void +_class_constructor(Eo_Class *klass) +{ + event_freeze_count = 0; + eo2_class_funcs_set(klass); +} + +Eo2_Op_Description op_descs [] = { + EO2_OP_CONSTRUCTOR(_constructor), + EO2_OP_DESTRUCTOR(_destructor), + EO2_OP_FUNC(_data_set, data_set, "Set data for key."), + EO2_OP_FUNC(_data_get, data_get, "Get data for key."), + EO2_OP_FUNC(_data_del, data_del, "Del key."), + EO2_OP_FUNC(_wref_add, wref_add, "Add a weak ref to the object."), + EO2_OP_FUNC(_wref_del, wref_del, "Delete the weak ref."), + EO2_OP_FUNC(_ev_cb_priority_add, ev_cb_priority_add, "Add an event callback with a priority."), + EO2_OP_FUNC(_ev_cb_del, ev_cb_del, "Delete an event callback"), + EO2_OP_FUNC(_ev_cb_array_priority_add, ev_cb_array_priority_add, "Add an event callback array with a priority."), + EO2_OP_FUNC(_ev_cb_array_del, ev_cb_array_del, "Delete an event callback array"), + EO2_OP_FUNC(_ev_cb_call, ev_cb_call, "Call the event callbacks for an event."), + EO2_OP_FUNC(_ev_cb_forwarder_add, ev_cb_forwarder_add, "Add an event forwarder."), + EO2_OP_FUNC(_ev_cb_forwarder_del, ev_cb_forwarder_del, "Delete an event forwarder."), + EO2_OP_FUNC(_ev_freeze, ev_freeze, "Freezes events."), + EO2_OP_FUNC(_ev_thaw, ev_thaw, "Thaws events."), + EO2_OP_FUNC(_ev_freeze_get, ev_freeze_get, "Get event freeze counter."), + EO2_OP_FUNC(_ev_global_freeze, ev_global_freeze, "Freezes events globally."), + EO2_OP_FUNC(_ev_global_thaw, ev_global_thaw, "Thaws events globally."), + EO2_OP_FUNC(_ev_global_freeze_get, ev_global_freeze_get, "Get global event freeze counter."), + EO2_OP_FUNC(_dbg_info_get, dbg_info_get, "Get debug info list for obj."), + EO2_OP_SENTINEL +}; + +// FIXME +static const Eo_Event_Description *event_desc[] = { + EO_EV_CALLBACK_ADD, + EO_EV_CALLBACK_DEL, + EO_EV_DEL, + NULL +}; + +static const Eo_Class_Description class_desc = { + 2, + "Eo Base", + EO_CLASS_TYPE_REGULAR_NO_INSTANT, + EO2_CLASS_DESCRIPTION_OPS(op_descs, OP_DESC_SIZE(op_descs)), + event_desc, + sizeof(Private_Data), + _class_constructor, + NULL +}; + +EO_DEFINE_CLASS(eo2_base_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo2_base_class.h b/src/lib/eo/eo2_base_class.h new file mode 100644 index 0000000000..c4400b8827 --- /dev/null +++ b/src/lib/eo/eo2_base_class.h @@ -0,0 +1,80 @@ +#ifndef _EO2_BASE_CLASS_H +#define _EO2_BASE_CLASS_H + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "Eo.h" +/* #include "eo_ptr_indirection.h" */ +/* #include "eo_private.h" */ + +EAPI void +data_set(eo2_a, const char *key, const void *data, eo_base_data_free_func free_func); + +EAPI void +data_get(eo2_a, const char *key); + +EAPI void +data_del(eo2_a, const char *key); + +EAPI void +wref_add(eo2_a, Eo **wref); + +EAPI void +wref_del(eo2_a, Eo **wref); + +EAPI void +ev_cb_priority_add(eo2_a, const Eo_Event_Description *desc, + Eo_Callback_Priority priority, Eo_Event_Cb func, + const void *user_data); + +EAPI void +ev_cb_del(eo2_a, const Eo_Event_Description *desc, Eo_Event_Cb func, + const void *user_data); + +EAPI void +ev_cb_array_priority_add(eo2_a, const Eo_Callback_Array_Item *array, + Eo_Callback_Priority priority, const void *user_data); + +EAPI void +ev_cb_array_del(eo2_a, const Eo_Callback_Array_Item *array, + const void *user_data); + +EAPI Eina_Bool +ev_cb_call(eo2_a, const Eo_Event_Description *desc, void *event_info); + +EAPI void +ev_cb_forwarder_add(eo2_a, const Eo_Event_Description *desc, Eo *new_obj); + +EAPI void +ev_cb_forwarder_del(eo2_a, const Eo_Event_Description *desc, Eo *new_obj); + +EAPI void +ev_freeze(eo2_a); + +EAPI void +ev_thaw(eo2_a); + +EAPI int +ev_freeze_get(eo2_a); + +EAPI void +ev_global_freeze(eo2_a); + +EAPI void +ev_global_thaw(eo2_a); + +EAPI int +ev_global_freeze_get(eo2_a); + +EAPI void +dbg_info_get(eo2_a); + +EAPI void +eo2_dbg_info_free(Eo_Dbg_Info *info); + +EAPI const Eo_Class *eo2_base_class_get(void); +#define EO2_BASE_CLASS eo2_base_class_get() + +#endif /* _EO2_BASE_CLASS_H */ From 6a16edc88808d30efc1bda7cfb2c959e23330150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:16:34 +0100 Subject: [PATCH 022/169] eo2: call stack Proof Of Concept no grow/shrink or thread local storage --- src/lib/eo/Eo.h | 50 +++++++++-------------- src/lib/eo/eo.c | 80 +++++++++++++++++++++++++++++++++---- src/lib/eo/eo2_base_class.h | 38 +++++++++--------- src/lib/eo/eo_private.h | 1 + 4 files changed, 110 insertions(+), 59 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e5fa687eee..457e3ca6ad 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -614,48 +614,40 @@ EAPI Eina_Bool eo_shutdown(void); EAPI void eo2_class_funcs_set(Eo_Class *klass_id); -// opaque type used to pass object pointer to EAPI calls -typedef struct _Eo_Internal _Eo; - // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data { - void *func; - void *data; + Eo *obj_id; + void *func; + void *data; } Eo2_Op_Call_Data; -// EAPI function declaration first argument -#define eo2_a _Eo *obj, Eo *objid -// EAPI function call first argument -#define eo2_o _obj_, _objid_ - // to pass the internal function call to EO2_FUNC_BODY (as Func parameter) -#define EO2_FUNC_CALL(...) _func_(objid, call.data, __VA_ARGS__) +#define EO2_FUNC_CALL(...) _func_(call.obj_id, call.data, __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_get_op_id(obj, (void*)Name); \ + if ( op == EO_NOOP ) op = eo2_get_op_id((void*)Name); \ Eo2_Op_Call_Data call; \ - if (!eo2_call_resolve(obj, op, &call)) return DefRet; \ + if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ -/* XXX: Essential, because we need to adjust objid for comp objects. */ // to define an EAPI function #define EO2_FUNC_BODY(Name, Ret, DefRet) \ Ret \ - Name(_Eo *obj, Eo *objid) \ + Name() \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ - _EO2_FUNC_COMMON(Name, Ret, _func_(objid, call.data), DefRet) \ + _EO2_FUNC_COMMON(Name, Ret, _func_(call.obj_id, call.data), DefRet)\ } #define EO2_VOID_FUNC_BODY(Name) EO2_FUNC_BODY(Name, void, ) #define EO2_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ - Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ + Name(__VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \ @@ -670,21 +662,17 @@ typedef struct _Eo2_Op_Call_Data #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_get_op_id(_Eo *obj, void *api_func); +EAPI Eo_Op eo2_get_op_id(void *api_func); // gets the real function pointer and the object data -#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); +#define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) +EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op_Call_Data *call); -// start of eo2_do barrier, gets the object pointer and ref it -EAPI _Eo * eo2_do_start(Eo *obj_id); +// start of eo2_do barrier, gets the object pointer and ref it, put it on the stask +EAPI Eina_Bool eo2_do_start(Eo *obj_id); -// end of the eo2_do barrier, unref the obj -EAPI void eo2_do_end(_Eo *obj); - -// optional helper -#define eo2_call(api_func) api_func(eo2_o) -#define eo2_callv(api_func, ...) api_func(eo2_o, __VA_ARGS__) +// end of the eo2_do barrier, unref the obj, move the stack pointer +EAPI void eo2_do_end(); // eo object method calls batch, // DO NOT use return statement in it, use break if necessary @@ -692,11 +680,9 @@ EAPI void eo2_do_end(_Eo *obj); do \ { \ Eo *_objid_ = objid; \ - _Eo *_obj_ = eo2_do_start(_objid_); \ - if (!_obj_) break; \ + if (!eo2_do_start(_objid_)) break; \ do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(_obj_); \ - _obj_ = NULL; \ + eo2_do_end(); \ } while (0) // FIXME diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 906183a9e2..d21b5f3788 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -257,25 +257,77 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) /************************************ EO2 ************************************/ -EAPI _Eo * +// FIXME: per thread stack, grow/shrink +#define EO2_INVALID_DATA (void *) -1 +#define EO2_CALL_STACK_SIZE 5 +typedef struct _Eo2_Stack_Frame +{ + Eo *obj_id; + _Eo *obj; + void *obj_data; + +} Eo2_Stack_Frame; + +typedef struct _Eo2_Call_Stack { + Eo2_Stack_Frame stack[EO2_CALL_STACK_SIZE]; + Eo2_Stack_Frame *frame_ptr; +} Eo2_Call_Stack; + +static Eo2_Call_Stack eo2_call_stack = { + { + { NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, EO2_INVALID_DATA }, + }, + NULL }; + +EAPI Eina_Bool eo2_do_start(Eo *obj_id) { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); _eo_ref(obj); - return obj; + + if (eo2_call_stack.frame_ptr == NULL) + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + else + eo2_call_stack.frame_ptr++; + + if (eo2_call_stack.frame_ptr->obj_id != NULL) + ERR("eo2 call stack is not clear, you must have used a return statement in a eo2_do macro"); + + if ((eo2_call_stack.frame_ptr - eo2_call_stack.stack) >= EO2_CALL_STACK_SIZE) + ERR("eo2 call stack overflow !!!"); + + eo2_call_stack.frame_ptr->obj = obj; + eo2_call_stack.frame_ptr->obj_id = obj_id; + eo2_call_stack.frame_ptr->obj_data = EO2_INVALID_DATA; + + return EINA_TRUE; } EAPI void -eo2_do_end(_Eo *obj) +eo2_do_end() { - _eo_unref(obj); + _eo_unref(eo2_call_stack.frame_ptr->obj); + + eo2_call_stack.frame_ptr->obj = NULL; + eo2_call_stack.frame_ptr->obj_id = NULL; + eo2_call_stack.frame_ptr->obj_data = EO2_INVALID_DATA; + + if (eo2_call_stack.frame_ptr == &eo2_call_stack.stack[0]) + eo2_call_stack.frame_ptr = NULL; + else + eo2_call_stack.frame_ptr--; } EAPI Eina_Bool -eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) +eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) { const _Eo_Class *klass; const op_type_funcs *func; + const _Eo * obj = eo2_call_stack.frame_ptr->obj; if (klass_id) klass = _eo_class_pointer_get(klass_id); @@ -285,8 +337,19 @@ eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_C func = _eo_kls_itr_func_get(klass, op); if (EINA_LIKELY(func != NULL)) { + call->obj_id = eo2_call_stack.frame_ptr->obj_id; call->func = func->func; - call->data = _eo_data_scope_get(obj, func->src); + + if (func->src == obj->klass) + { + if (eo2_call_stack.frame_ptr->obj_data == EO2_INVALID_DATA) + eo2_call_stack.frame_ptr->obj_data = _eo_data_scope_get(obj, func->src); + + call->data = eo2_call_stack.frame_ptr->obj_data; + } + else + call->data = _eo_data_scope_get(obj, func->src); + return EINA_TRUE; } @@ -297,11 +360,12 @@ eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_C EAPI Eo_Op -eo2_get_op_id(_Eo *obj, void *api_func) +eo2_get_op_id(void *api_func) { int imin, imax, imid; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; + const _Eo * obj = eo2_call_stack.frame_ptr->obj; imin = 0; imax = obj->klass->desc->ops.count - 1; diff --git a/src/lib/eo/eo2_base_class.h b/src/lib/eo/eo2_base_class.h index c4400b8827..ff40eb51aa 100644 --- a/src/lib/eo/eo2_base_class.h +++ b/src/lib/eo/eo2_base_class.h @@ -10,66 +10,66 @@ /* #include "eo_private.h" */ EAPI void -data_set(eo2_a, const char *key, const void *data, eo_base_data_free_func free_func); +data_set(const char *key, const void *data, eo_base_data_free_func free_func); EAPI void -data_get(eo2_a, const char *key); +data_get(const char *key); EAPI void -data_del(eo2_a, const char *key); +data_del(const char *key); EAPI void -wref_add(eo2_a, Eo **wref); +wref_add(Eo **wref); EAPI void -wref_del(eo2_a, Eo **wref); +wref_del(Eo **wref); EAPI void -ev_cb_priority_add(eo2_a, const Eo_Event_Description *desc, +ev_cb_priority_add(const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb func, const void *user_data); EAPI void -ev_cb_del(eo2_a, const Eo_Event_Description *desc, Eo_Event_Cb func, +ev_cb_del(const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data); EAPI void -ev_cb_array_priority_add(eo2_a, const Eo_Callback_Array_Item *array, +ev_cb_array_priority_add(const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, const void *user_data); EAPI void -ev_cb_array_del(eo2_a, const Eo_Callback_Array_Item *array, +ev_cb_array_del(const Eo_Callback_Array_Item *array, const void *user_data); EAPI Eina_Bool -ev_cb_call(eo2_a, const Eo_Event_Description *desc, void *event_info); +ev_cb_call(const Eo_Event_Description *desc, void *event_info); EAPI void -ev_cb_forwarder_add(eo2_a, const Eo_Event_Description *desc, Eo *new_obj); +ev_cb_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); EAPI void -ev_cb_forwarder_del(eo2_a, const Eo_Event_Description *desc, Eo *new_obj); +ev_cb_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); EAPI void -ev_freeze(eo2_a); +ev_freeze(); EAPI void -ev_thaw(eo2_a); +ev_thaw(); EAPI int -ev_freeze_get(eo2_a); +ev_freeze_get(); EAPI void -ev_global_freeze(eo2_a); +ev_global_freeze(); EAPI void -ev_global_thaw(eo2_a); +ev_global_thaw(); EAPI int -ev_global_freeze_get(eo2_a); +ev_global_freeze_get(); EAPI void -dbg_info_get(eo2_a); +dbg_info_get(); EAPI void eo2_dbg_info_free(Eo_Dbg_Info *info); diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index a985556b70..621bab43cd 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -60,6 +60,7 @@ typedef uintptr_t Eo_Id; typedef struct _Eo_Class _Eo_Class; typedef struct _Eo_Object _Eo_Object; typedef struct _Eo_Base Eo_Base; +typedef struct _Eo_Internal _Eo; /* Retrieves the pointer to the object from the id */ static inline _Eo_Object *_eo_obj_pointer_get(const Eo_Id obj_id); From 8b6b9532c52986bd9d595d161ff4127798aceb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 15:19:07 +0100 Subject: [PATCH 023/169] eo2: Eo.h swallows eo2_base_class.h --- src/lib/eo/Eo.h | 65 ++++++++++++++++++++++++++++++ src/lib/eo/eo2_base_class.c | 5 ++- src/lib/eo/eo2_base_class.h | 80 ------------------------------------- 3 files changed, 68 insertions(+), 82 deletions(-) delete mode 100644 src/lib/eo/eo2_base_class.h diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 457e3ca6ad..9ef0b181da 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1119,11 +1119,13 @@ enum { * The class type for the Eo base class. */ #define EO_BASE_CLASS eo_base_class_get() +#define EO2_BASE_CLASS eo2_base_class_get() /** * @brief Use #EO_BASE_CLASS * @internal * */ EAPI const Eo_Class *eo_base_class_get(void); +EAPI const Eo_Class *eo2_base_class_get(void); /** * @typedef eo_base_data_free_func @@ -1183,6 +1185,8 @@ enum { * @see #eo_base_data_del */ #define eo_base_data_set(key, data, free_func) EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(const void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func) +EAPI void +eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); /** * @def eo_base_data_get(key, data) @@ -1194,6 +1198,8 @@ enum { * @see #eo_base_data_del */ #define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data) +EAPI void +eo2_base_data_get(const char *key); /** * @def eo_dbg_info_get(root_node) @@ -1201,6 +1207,8 @@ enum { * @param[in] root node of the tree */ #define eo_dbg_info_get(root_node) EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), EO_TYPECHECK(Eo_Dbg_Info *, root_node) +EAPI void +eo2_dbg_info_get(); /** * @def eo_base_data_del(key) @@ -1211,6 +1219,8 @@ enum { * @see #eo_base_data_get */ #define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key) +EAPI void +eo2_base_data_del(const char *key); /** * @def eo_parent_set @@ -1258,6 +1268,8 @@ enum { * @see #eo_wref_del */ #define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref) +EAPI void +eo2_wref_add(Eo **wref); /** * @def eo_wref_del @@ -1267,6 +1279,8 @@ enum { * @see #eo_wref_add */ #define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref) +EAPI void +eo2_wref_del(Eo **wref); /** * @def eo_weak_ref @@ -1284,6 +1298,10 @@ enum { do { \ if (*wref) eo_do(*wref, eo_wref_add(wref)); \ } while (0) +#define eo2_weak_ref(wref) \ + do { \ + if (*wref) eo2_do(*wref, eo2_wref_add(wref)); \ + } while (0); /** * @def eo_weak_unref @@ -1302,6 +1320,10 @@ enum { do { \ if (*wref) eo_do(*wref, eo_wref_del(wref)); \ } while (0) +#define eo2_weak_unref(wref) \ + do { \ + if (*wref) eo2_do(*wref, eo2_wref_del(wref)); \ + } while (0); /** * @def eo_wref_del_safe @@ -1314,6 +1336,7 @@ enum { * @see #eo_wref_del */ #define eo_wref_del_safe(wref) eo_weak_unref(wref) +#define eo2_wref_del_safe(wref) eo2_weak_unref(wref) /** * @def eo_constructor @@ -1324,6 +1347,7 @@ enum { * @see #eo_destructor */ #define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR) +// FIXME: eo2 /** * @def eo_destructor @@ -1334,6 +1358,7 @@ enum { * @see #eo_constructor */ #define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR) +// FIXME: eo2 /** * @addtogroup Eo_Events Eo's Event Handling @@ -1426,6 +1451,8 @@ struct _Eo_Callback_Array_Item * @see eo_event_callback_forwarder_del() */ #define eo_event_callback_forwarder_add(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) +EAPI void +eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); /** * @def eo_event_callback_forwarder_del @@ -1436,6 +1463,8 @@ struct _Eo_Callback_Array_Item * @see eo_event_callback_forwarder_add() */ #define eo_event_callback_forwarder_del(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) +EAPI void +eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); /** * @def eo_event_freeze @@ -1446,6 +1475,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_thaw */ #define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE) +EAPI void +eo2_event_freeze(); /** * @def eo_event_thaw @@ -1456,6 +1487,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_freeze */ #define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW) +EAPI void +eo2_event_thaw(); /** * @def eo_event_freeze_get @@ -1469,6 +1502,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_thaw */ #define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount) +EAPI int +eo2_event_freeze_get(); /** * @def eo_event_global_freeze @@ -1480,6 +1515,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_global_thaw */ #define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE) +EAPI void +eo2_event_global_freeze(); /** * @def eo_event_global_thaw @@ -1491,6 +1528,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_global_freeze */ #define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW) +EAPI void +eo2_event_global_thaw(); /** * @def eo_event_global_freeze_get @@ -1505,6 +1544,8 @@ struct _Eo_Callback_Array_Item * @see #eo_event_global_thaw */ #define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount) +EAPI int +eo2_event_global_freeze_get(); /** * @def eo_event_callback_add(obj, desc, cb, data) @@ -1520,6 +1561,9 @@ struct _Eo_Callback_Array_Item #define eo_event_callback_add(desc, cb, data) \ eo_event_callback_priority_add(desc, \ EO_CALLBACK_PRIORITY_DEFAULT, cb, data) +#define eo2_event_callback_add(desc, cb, data) \ + eo2_event_callback_priority_add(desc, \ + EO_CALLBACK_PRIORITY_DEFAULT, cb, data) /** * @def eo_event_callback_priority_add @@ -1534,6 +1578,11 @@ struct _Eo_Callback_Array_Item * @see #eo_event_callback_add */ #define eo_event_callback_priority_add(desc, priority, cb, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(Eo_Event_Cb, cb), EO_TYPECHECK(const void *, data) +EAPI void +eo2_event_callback_priority_add(const Eo_Event_Description *desc, + Eo_Callback_Priority priority, + Eo_Event_Cb func, + const void *user_data); /** * @def eo_event_callback_del @@ -1544,6 +1593,10 @@ struct _Eo_Callback_Array_Item * */ #define eo_event_callback_del(desc, func, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Event_Cb, func), EO_TYPECHECK(const void *, user_data) +EAPI void +eo2_event_callback_del(const Eo_Event_Description *desc, + Eo_Event_Cb func, + const void *user_data); /** * @def eo_event_callback_array_add(obj, desc, cb, data) @@ -1558,6 +1611,9 @@ struct _Eo_Callback_Array_Item #define eo_event_callback_array_add(array, data) \ eo_event_callback_array_priority_add(array, \ EO_CALLBACK_PRIORITY_DEFAULT, data) +#define eo2_event_callback_array_add(array, data) \ + eo2_event_callback_array_priority_add(array, \ + EO_CALLBACK_PRIORITY_DEFAULT, data) /** * @def eo_event_callback_array_priority_add @@ -1571,6 +1627,10 @@ struct _Eo_Callback_Array_Item * @see #eo_event_callback_add */ #define eo_event_callback_array_priority_add(array, priority, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(const void *, data) +EAPI void +eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, + Eo_Callback_Priority priority, + const void *user_data); /** * @def eo_event_callback_array_del @@ -1580,6 +1640,9 @@ struct _Eo_Callback_Array_Item * */ #define eo_event_callback_array_del(array, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(const void *, user_data) +EAPI void +eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, + const void *user_data); /** * @def eo_event_callback_call @@ -1589,6 +1652,8 @@ struct _Eo_Callback_Array_Item * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise. */ #define eo_event_callback_call(desc, event_info, aborted) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(const void *, event_info), EO_TYPECHECK(Eina_Bool *, aborted) +EAPI Eina_Bool +eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); /** * @} diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 583719bc5b..57cb13c230 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -4,7 +4,7 @@ #include -#include "eo2_base_class.h" +#include "Eo.h" #include "eo_ptr_indirection.h" #include "eo_private.h" @@ -740,6 +740,7 @@ EAPI const Eina_Value_Type *EO2_DBG_INFO_TYPE = &_EO2_DBG_INFO_TYPE; #define MY_CLASS EO_BASE_CLASS /* FIXME: Set proper type descriptions. */ +// FIXME: eo2 multiple definition /* EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = */ /* EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); */ /* EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = */ @@ -799,7 +800,7 @@ Eo2_Op_Description op_descs [] = { EO2_OP_SENTINEL }; -// FIXME +// FIXME: eo2 static const Eo_Event_Description *event_desc[] = { EO_EV_CALLBACK_ADD, EO_EV_CALLBACK_DEL, diff --git a/src/lib/eo/eo2_base_class.h b/src/lib/eo/eo2_base_class.h deleted file mode 100644 index ff40eb51aa..0000000000 --- a/src/lib/eo/eo2_base_class.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _EO2_BASE_CLASS_H -#define _EO2_BASE_CLASS_H - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "Eo.h" -/* #include "eo_ptr_indirection.h" */ -/* #include "eo_private.h" */ - -EAPI void -data_set(const char *key, const void *data, eo_base_data_free_func free_func); - -EAPI void -data_get(const char *key); - -EAPI void -data_del(const char *key); - -EAPI void -wref_add(Eo **wref); - -EAPI void -wref_del(Eo **wref); - -EAPI void -ev_cb_priority_add(const Eo_Event_Description *desc, - Eo_Callback_Priority priority, Eo_Event_Cb func, - const void *user_data); - -EAPI void -ev_cb_del(const Eo_Event_Description *desc, Eo_Event_Cb func, - const void *user_data); - -EAPI void -ev_cb_array_priority_add(const Eo_Callback_Array_Item *array, - Eo_Callback_Priority priority, const void *user_data); - -EAPI void -ev_cb_array_del(const Eo_Callback_Array_Item *array, - const void *user_data); - -EAPI Eina_Bool -ev_cb_call(const Eo_Event_Description *desc, void *event_info); - -EAPI void -ev_cb_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); - -EAPI void -ev_cb_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); - -EAPI void -ev_freeze(); - -EAPI void -ev_thaw(); - -EAPI int -ev_freeze_get(); - -EAPI void -ev_global_freeze(); - -EAPI void -ev_global_thaw(); - -EAPI int -ev_global_freeze_get(); - -EAPI void -dbg_info_get(); - -EAPI void -eo2_dbg_info_free(Eo_Dbg_Info *info); - -EAPI const Eo_Class *eo2_base_class_get(void); -#define EO2_BASE_CLASS eo2_base_class_get() - -#endif /* _EO2_BASE_CLASS_H */ From 58cb65b8957a8570b2971e27396f9d9ea8307e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 24 Jul 2013 22:01:14 +0000 Subject: [PATCH 024/169] eo2: eo2_base_class, one step further --- src/lib/eo/Eo.h | 9 +++- src/lib/eo/eo2_base_class.c | 84 +++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 9ef0b181da..fcf71afc6e 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -604,6 +604,8 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ +#define EO2_VERSION 2 + // computes size of Eo2_Op_Description[] #define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) @@ -659,6 +661,7 @@ typedef struct _Eo2_Op_Call_Data #define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"} #define EO2_OP_DESTRUCTOR(_private) { _private, NULL, 2, EO_OP_TYPE_REGULAR, "Destructor"} #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} +#define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func @@ -1347,7 +1350,8 @@ eo2_wref_del(Eo **wref); * @see #eo_destructor */ #define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR) -// FIXME: eo2 +EAPI void +eo2_constructor(); /** * @def eo_destructor @@ -1358,7 +1362,8 @@ eo2_wref_del(Eo **wref); * @see #eo_constructor */ #define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR) -// FIXME: eo2 +EAPI void +eo2_destructor(); /** * @addtogroup Eo_Events Eo's Event Handling diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 57cb13c230..1e17431f34 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -74,7 +74,7 @@ _data_set(Eo *obj, void *class_data, pd->generic_data = eina_inlist_prepend(pd->generic_data, EINA_INLIST_GET(node)); } -EAPI EO2_VOID_FUNC_BODYV(data_set, EO2_FUNC_CALL(key, data, free_func), +EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_set, EO2_FUNC_CALL(key, data, free_func), const char *key, const void *data, eo_base_data_free_func free_func); static void * @@ -98,14 +98,14 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) return NULL; } -EAPI EO2_VOID_FUNC_BODYV(data_get, EO2_FUNC_CALL(key), const char *key); +EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_get, EO2_FUNC_CALL(key), const char *key); static void _dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { /* No info required in the meantime */ return; } -EAPI EO2_VOID_FUNC_BODY(dbg_info_get); +EAPI EO2_VOID_FUNC_BODY(eo2_dbg_info_get); static void _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) @@ -126,7 +126,7 @@ _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) } } } -EAPI EO2_VOID_FUNC_BODYV(data_del, EO2_FUNC_CALL(key), const char *key); +EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_del, EO2_FUNC_CALL(key), const char *key); /* Weak reference. */ @@ -159,7 +159,7 @@ _wref_add(Eo *obj, void *class_data, Eo **wref) pd->wrefs[count] = NULL; *wref = obj; } -EAPI EO2_VOID_FUNC_BODYV(wref_add, EO2_FUNC_CALL(wref), Eo **wref); +EAPI EO2_VOID_FUNC_BODYV(eo2_wref_add, EO2_FUNC_CALL(wref), Eo **wref); static void _wref_del(Eo *obj, void *class_data, Eo **wref) @@ -217,7 +217,7 @@ _wref_del(Eo *obj, void *class_data, Eo **wref) *wref = NULL; } -EAPI EO2_VOID_FUNC_BODYV(wref_del, EO2_FUNC_CALL(wref), Eo **wref); +EAPI EO2_VOID_FUNC_BODYV(eo2_wref_del, EO2_FUNC_CALL(wref), Eo **wref); static inline void _wref_destruct(Private_Data *pd) @@ -370,7 +370,7 @@ _ev_cb_priority_add(Eo *obj, void *class_data, eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, arr, NULL)); } } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_priority_add, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_priority_add, EO2_FUNC_CALL(desc, priority, func, user_data), const Eo_Event_Description *desc, Eo_Callback_Priority priority, @@ -403,7 +403,7 @@ _ev_cb_del(Eo *obj, void *class_data, DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_del, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_del, EO2_FUNC_CALL(desc, func, user_data), const Eo_Event_Description *desc, Eo_Event_Cb func, @@ -429,7 +429,7 @@ _ev_cb_array_priority_add(Eo *obj, void *class_data, eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, array, NULL)); } } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_array_priority_add, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_array_priority_add, EO2_FUNC_CALL(array, priority, user_data), const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, @@ -458,7 +458,7 @@ _ev_cb_array_del(Eo *obj, void *class_data, DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data); } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_array_del, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_array_del, EO2_FUNC_CALL(array, user_data), const Eo_Callback_Array_Item *array, const void *user_data); @@ -531,7 +531,7 @@ end: return ret; } -EAPI EO2_FUNC_BODYV(ev_cb_call, Eina_Bool, +EAPI EO2_FUNC_BODYV(eo2_event_callback_call, Eina_Bool, EO2_FUNC_CALL(desc, event_info), EINA_FALSE, const Eo_Event_Description *desc, @@ -560,7 +560,7 @@ _ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj)); } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_forwarder_add, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_add, EO2_FUNC_CALL(desc, new_obj), const Eo_Event_Description *desc, Eo *new_obj); @@ -575,7 +575,7 @@ _ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj)); } -EAPI EO2_VOID_FUNC_BODYV(ev_cb_forwarder_del, +EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_del, EO2_FUNC_CALL(desc, new_obj), const Eo_Event_Description *desc, Eo *new_obj); @@ -586,7 +586,7 @@ _ev_freeze(Eo *obj EINA_UNUSED, void *class_data) Private_Data *pd = (Private_Data *) class_data; pd->event_freeze_count++; } -EAPI EO2_VOID_FUNC_BODY(ev_freeze); +EAPI EO2_VOID_FUNC_BODY(eo2_event_freeze); static void _ev_thaw(Eo *obj, void *class_data) @@ -601,7 +601,7 @@ _ev_thaw(Eo *obj, void *class_data) ERR("Events for object %p have already been thawed.", obj); } } -EAPI EO2_VOID_FUNC_BODY(ev_thaw); +EAPI EO2_VOID_FUNC_BODY(eo2_event_thaw); static int _ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) @@ -610,14 +610,14 @@ _ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) return pd->event_freeze_count; } -EAPI EO2_FUNC_BODY(ev_freeze_get, int, 0); +EAPI EO2_FUNC_BODY(eo2_event_freeze_get, int, 0); static void _ev_global_freeze(const Eo_Class *klass EINA_UNUSED) { event_freeze_count++; } -EAPI EO2_VOID_FUNC_BODY(ev_global_freeze); +EAPI EO2_VOID_FUNC_BODY(eo2_event_global_freeze); static void _ev_global_thaw(const Eo_Class *klass EINA_UNUSED) @@ -631,14 +631,14 @@ _ev_global_thaw(const Eo_Class *klass EINA_UNUSED) ERR("Global events have already been thawed."); } } -EAPI EO2_VOID_FUNC_BODY(ev_global_thaw); +EAPI EO2_VOID_FUNC_BODY(eo2_event_global_thaw); static int _ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED) { return event_freeze_count; } -EAPI EO2_FUNC_BODY(ev_global_freeze_get, int, 0); +EAPI EO2_FUNC_BODY(eo2_event_global_freeze_get, int, 0); /* Eo_Dbg */ EAPI void @@ -755,6 +755,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) _eo_condtor_done(obj); } +EAPI EO2_VOID_FUNC_BODY(eo2_constructor); static void _destructor(Eo *obj, void *class_data) @@ -767,6 +768,7 @@ _destructor(Eo *obj, void *class_data) _eo_condtor_done(obj); } +EAPI EO2_VOID_FUNC_BODY(eo2_destructor); static void _class_constructor(Eo_Class *klass) @@ -776,27 +778,27 @@ _class_constructor(Eo_Class *klass) } Eo2_Op_Description op_descs [] = { - EO2_OP_CONSTRUCTOR(_constructor), - EO2_OP_DESTRUCTOR(_destructor), - EO2_OP_FUNC(_data_set, data_set, "Set data for key."), - EO2_OP_FUNC(_data_get, data_get, "Get data for key."), - EO2_OP_FUNC(_data_del, data_del, "Del key."), - EO2_OP_FUNC(_wref_add, wref_add, "Add a weak ref to the object."), - EO2_OP_FUNC(_wref_del, wref_del, "Delete the weak ref."), - EO2_OP_FUNC(_ev_cb_priority_add, ev_cb_priority_add, "Add an event callback with a priority."), - EO2_OP_FUNC(_ev_cb_del, ev_cb_del, "Delete an event callback"), - EO2_OP_FUNC(_ev_cb_array_priority_add, ev_cb_array_priority_add, "Add an event callback array with a priority."), - EO2_OP_FUNC(_ev_cb_array_del, ev_cb_array_del, "Delete an event callback array"), - EO2_OP_FUNC(_ev_cb_call, ev_cb_call, "Call the event callbacks for an event."), - EO2_OP_FUNC(_ev_cb_forwarder_add, ev_cb_forwarder_add, "Add an event forwarder."), - EO2_OP_FUNC(_ev_cb_forwarder_del, ev_cb_forwarder_del, "Delete an event forwarder."), - EO2_OP_FUNC(_ev_freeze, ev_freeze, "Freezes events."), - EO2_OP_FUNC(_ev_thaw, ev_thaw, "Thaws events."), - EO2_OP_FUNC(_ev_freeze_get, ev_freeze_get, "Get event freeze counter."), - EO2_OP_FUNC(_ev_global_freeze, ev_global_freeze, "Freezes events globally."), - EO2_OP_FUNC(_ev_global_thaw, ev_global_thaw, "Thaws events globally."), - EO2_OP_FUNC(_ev_global_freeze_get, ev_global_freeze_get, "Get global event freeze counter."), - EO2_OP_FUNC(_dbg_info_get, dbg_info_get, "Get debug info list for obj."), + EO2_OP_FUNC(_constructor, eo2_constructor, "Constructor."), + EO2_OP_FUNC(_destructor, eo2_destructor, "Destructor."), + EO2_OP_FUNC(_data_set, eo2_base_data_set, "Set data for key."), + EO2_OP_FUNC(_data_get, eo2_base_data_get, "Get data for key."), + EO2_OP_FUNC(_data_del, eo2_base_data_del, "Del key."), + EO2_OP_FUNC(_wref_add, eo2_wref_add, "Add a weak ref to the object."), + EO2_OP_FUNC(_wref_del, eo2_wref_del, "Delete the weak ref."), + EO2_OP_FUNC(_ev_cb_priority_add, eo2_event_callback_priority_add, "Add an event callback with a priority."), + EO2_OP_FUNC(_ev_cb_del, eo2_event_callback_del, "Delete an event callback"), + EO2_OP_FUNC(_ev_cb_array_priority_add, eo2_event_callback_array_priority_add, "Add an event callback array with a priority."), + EO2_OP_FUNC(_ev_cb_array_del, eo2_event_callback_array_del, "Delete an event callback array"), + EO2_OP_FUNC(_ev_cb_call, eo2_event_callback_call, "Call the event callbacks for an event."), + EO2_OP_FUNC(_ev_cb_forwarder_add, eo2_event_callback_forwarder_add, "Add an event forwarder."), + EO2_OP_FUNC(_ev_cb_forwarder_del, eo2_event_callback_forwarder_del, "Delete an event forwarder."), + EO2_OP_CLASS_FUNC(_ev_freeze, eo2_event_freeze, "Freezes events."), + EO2_OP_CLASS_FUNC(_ev_thaw, eo2_event_thaw, "Thaws events."), + EO2_OP_CLASS_FUNC(_ev_freeze_get, eo2_event_freeze_get, "Get event freeze counter."), + EO2_OP_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), + EO2_OP_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), + EO2_OP_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), + EO2_OP_FUNC(_dbg_info_get, eo2_dbg_info_get, "Get debug info list for obj."), EO2_OP_SENTINEL }; @@ -809,7 +811,7 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - 2, + EO2_VERSION, "Eo Base", EO_CLASS_TYPE_REGULAR_NO_INSTANT, EO2_CLASS_DESCRIPTION_OPS(op_descs, OP_DESC_SIZE(op_descs)), From 68fb3d4c035042e84d3489b4f2e04f445ce5a74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 24 Jul 2013 22:08:37 +0000 Subject: [PATCH 025/169] eo2: improve func overriding add klass_id parameter to eo2_get_op_id() in op descriptions, allow NULL fct pointer for virtual, and use EO2_OP_OVERRIDE to declare overriding. --- src/lib/eo/Eo.h | 11 ++++++----- src/lib/eo/eo.c | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index fcf71afc6e..98949787ab 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -630,7 +630,7 @@ typedef struct _Eo2_Op_Call_Data // 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_get_op_id((void*)Name); \ + if ( op == EO_NOOP ) op = eo2_get_op_id((void*)Name, NULL); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -657,15 +657,16 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) -// FIXME: OP ID -#define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"} -#define EO2_OP_DESTRUCTOR(_private) { _private, NULL, 2, EO_OP_TYPE_REGULAR, "Destructor"} +// OP ID of an overriding function +#define EO2_OP_OVERRIDE ((Eo_Op) -1) + #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} +#define EO2_OP_FUNC_OVERRIDE(_private, _api, _doc) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_get_op_id(void *api_func); +EAPI Eo_Op eo2_get_op_id(void *api_func, const Eo_Class *klass); // gets the real function pointer and the object data #define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index d21b5f3788..be864e74f9 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -360,16 +360,21 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * EAPI Eo_Op -eo2_get_op_id(void *api_func) +eo2_get_op_id(void *api_func, const Eo_Class *klass_id) { int imin, imax, imid; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; - const _Eo * obj = eo2_call_stack.frame_ptr->obj; + const _Eo_Class *klass; + + if (klass_id) + klass = _eo_class_pointer_get(klass_id); + else + klass = eo2_call_stack.frame_ptr->obj->klass; imin = 0; - imax = obj->klass->desc->ops.count - 1; - op_descs = obj->klass->desc->ops.descs2; + imax = klass->desc->ops.count - 1; + op_descs = klass->desc->ops.descs2; while (imax >= imin) { @@ -401,7 +406,7 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) EAPI void eo2_class_funcs_set(Eo_Class *klass_id) { - int op_id, n; + int op_id; _Eo_Class *klass; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; @@ -410,27 +415,35 @@ eo2_class_funcs_set(Eo_Class *klass_id) EO_MAGIC_RETURN(klass, EO_CLASS_EINA_MAGIC); op_descs = klass->desc->ops.descs2; - - // klass->desc->ops.count only counts class OP, not _constructor or _destructor - for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); - n = op_desc - op_descs; - - qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); op_id = klass->base_id; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { + if(op_desc->api_func == NULL) + ERR("Setting implementation for NULL API. Class '%s', Func index: %lu", + klass->desc->name, (unsigned long) (op_desc - op_descs)); + if (op_desc->op == EO_NOOP) { - if(op_desc->api_func == NULL) - ERR("Setting implementation for NULL EAPI for class '%s'. Func index: %lu", + op_desc->op = op_id; + op_id++; + } + else if (op_desc->op == EO2_OP_OVERRIDE) + { + if (klass->parent == NULL) + ERR("Can't inherit from a NULL parent. Class '%s', Func index: %lu", klass->desc->name, (unsigned long) (op_desc - op_descs)); - op_desc->op = op_id; - op_id++; + op_desc->op = eo2_get_op_id(op_desc->api_func, _eo_class_id_get(klass->parent)); + + if (op_desc->op == EO_NOOP) + ERR("API func %p, not found in direct parent '%s'. Class '%s', Func index: %lu", + op_desc->api_func, klass->parent->desc->name, + klass->desc->name, (unsigned long) (op_desc - op_descs)); } - /* printf("%d %p %p\n", op_desc->op, op_desc->api_func, op_desc->func); */ - // no need to check func->op_type != op_desc->op_type + + /* printf("%d %p %p %s\n", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); */ _dich_func_set(klass, op_desc->op, op_desc->func); } } From c17a30dfb9c1316d45c4f5c5f43046d35bb69ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 24 Jul 2013 22:10:26 +0000 Subject: [PATCH 026/169] eo2: add cur_klass in call Stack and eo2_do_super in eo2_do_start(), reuse previous stack fetched pointers when possible --- src/lib/eo/Eo.h | 25 +++++++---- src/lib/eo/eo.c | 113 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 99 insertions(+), 39 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 98949787ab..fdb233b9ba 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -673,20 +673,29 @@ EAPI Eo_Op eo2_get_op_id(void *api_func, const Eo_Class *klass); EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj_id); +EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(); // eo object method calls batch, // DO NOT use return statement in it, use break if necessary -#define eo2_do(objid, ...) \ - do \ - { \ - Eo *_objid_ = objid; \ - if (!eo2_do_start(_objid_)) break; \ - do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(); \ +#define eo2_do(objid, ...) \ + do \ + { \ + Eo *_objid_ = objid; \ + if (!eo2_do_start(_objid_, EINA_FALSE)) break; \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(); \ + } while (0) + +#define eo2_do_super(objid, ...) \ + do \ + { \ + Eo *_objid_ = objid; \ + if (!eo2_do_start(_objid_, EINA_TRUE)) break; \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(); \ } while (0) // FIXME diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index be864e74f9..b38fc30b9d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -257,14 +257,31 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) /************************************ EO2 ************************************/ +static inline const _Eo_Class * +_eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) +{ + const _Eo_Class **kls_itr = NULL; + + /* Find the kls itr. */ + kls_itr = orig_kls->mro; + while (*kls_itr && (*kls_itr != cur_klass)) + kls_itr++; + + if (*kls_itr) + return *(++kls_itr); + + return NULL; +} + // FIXME: per thread stack, grow/shrink #define EO2_INVALID_DATA (void *) -1 #define EO2_CALL_STACK_SIZE 5 typedef struct _Eo2_Stack_Frame { - Eo *obj_id; - _Eo *obj; - void *obj_data; + Eo *obj_id; + _Eo *obj; + const _Eo_Class *cur_klass; + void *obj_data; } Eo2_Stack_Frame; @@ -275,34 +292,59 @@ typedef struct _Eo2_Call_Stack { static Eo2_Call_Stack eo2_call_stack = { { - { NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, NULL, EO2_INVALID_DATA }, + { NULL, NULL, NULL, EO2_INVALID_DATA }, }, NULL }; EAPI Eina_Bool -eo2_do_start(Eo *obj_id) +eo2_do_start(Eo *obj_id, Eina_Bool do_super) { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); - _eo_ref(obj); + _Eo * obj; + const _Eo_Class *cur_klass; + Eo2_Stack_Frame *fptr; - if (eo2_call_stack.frame_ptr == NULL) - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + fptr = eo2_call_stack.frame_ptr; + if ((fptr != NULL) && (fptr->obj_id == obj_id)) + { + obj = fptr->obj; + if (do_super) + cur_klass = _eo2_kls_itr_next(obj->klass, fptr->cur_klass); + else + cur_klass = fptr->cur_klass; + eo2_call_stack.frame_ptr++; + } else - eo2_call_stack.frame_ptr++; + { + obj = _eo_obj_pointer_get((Eo_Id)obj_id); + if (!obj) return EINA_FALSE; + if (do_super) + cur_klass = _eo2_kls_itr_next(obj->klass, obj->klass); + else + cur_klass = obj->klass; + if (fptr == NULL) + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + else + eo2_call_stack.frame_ptr++; + } - if (eo2_call_stack.frame_ptr->obj_id != NULL) - ERR("eo2 call stack is not clear, you must have used a return statement in a eo2_do macro"); + fptr = eo2_call_stack.frame_ptr; - if ((eo2_call_stack.frame_ptr - eo2_call_stack.stack) >= EO2_CALL_STACK_SIZE) + if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_SIZE) ERR("eo2 call stack overflow !!!"); - eo2_call_stack.frame_ptr->obj = obj; - eo2_call_stack.frame_ptr->obj_id = obj_id; - eo2_call_stack.frame_ptr->obj_data = EO2_INVALID_DATA; + if (fptr->obj_id != NULL) + ERR("eo2 call stack is not clear, you must have used a return statement in a eo2_do macro"); + + _eo_ref(obj); + + fptr->obj = obj; + fptr->obj_id = obj_id; + fptr->cur_klass = cur_klass; + fptr->obj_data = EO2_INVALID_DATA; return EINA_TRUE; } @@ -310,13 +352,18 @@ eo2_do_start(Eo *obj_id) EAPI void eo2_do_end() { - _eo_unref(eo2_call_stack.frame_ptr->obj); + Eo2_Stack_Frame *fptr; - eo2_call_stack.frame_ptr->obj = NULL; - eo2_call_stack.frame_ptr->obj_id = NULL; - eo2_call_stack.frame_ptr->obj_data = EO2_INVALID_DATA; + fptr = eo2_call_stack.frame_ptr; - if (eo2_call_stack.frame_ptr == &eo2_call_stack.stack[0]) + _eo_unref(fptr->obj); + + fptr->obj = NULL; + fptr->obj_id = NULL; + fptr->cur_klass = NULL; + fptr->obj_data = EO2_INVALID_DATA; + + if (fptr == &eo2_call_stack.stack[0]) eo2_call_stack.frame_ptr = NULL; else eo2_call_stack.frame_ptr--; @@ -325,27 +372,31 @@ eo2_do_end() EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) { + Eo2_Stack_Frame *fptr; + const _Eo * obj; const _Eo_Class *klass; const op_type_funcs *func; - const _Eo * obj = eo2_call_stack.frame_ptr->obj; + + fptr = eo2_call_stack.frame_ptr; + obj = fptr->obj; if (klass_id) klass = _eo_class_pointer_get(klass_id); else - klass = obj->klass; + klass = fptr->cur_klass; func = _eo_kls_itr_func_get(klass, op); if (EINA_LIKELY(func != NULL)) { - call->obj_id = eo2_call_stack.frame_ptr->obj_id; + call->obj_id = fptr->obj_id; call->func = func->func; if (func->src == obj->klass) { - if (eo2_call_stack.frame_ptr->obj_data == EO2_INVALID_DATA) - eo2_call_stack.frame_ptr->obj_data = _eo_data_scope_get(obj, func->src); + if (fptr->obj_data == EO2_INVALID_DATA) + fptr->obj_data = _eo_data_scope_get(obj, func->src); - call->data = eo2_call_stack.frame_ptr->obj_data; + call->data = fptr->obj_data; } else call->data = _eo_data_scope_get(obj, func->src); From 7621758c8038546c76d7131c13ee2bb951f5e5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 24 Jul 2013 22:11:00 +0000 Subject: [PATCH 027/169] eo2: use EO2_VERSION --- src/lib/eo/eo.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index b38fc30b9d..05415a25d7 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1013,18 +1013,17 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(desc->name, NULL); - DBG("Started building class '%s'", desc->name); - - if (desc->version == 1) + if (desc->version == EO2_VERSION) + { + // FIXME: eo2 + /* if (!_eo2_class_check_op_descs(desc)) */ + /* return NULL; */ + } + else { if (!_eo_class_check_op_descs(desc)) return NULL; } - else { - // FIXME: jeyzu - /* if (!_eo2_class_check_op_descs(desc)) */ - /* return NULL; */ - } _Eo_Class *parent = _eo_class_pointer_get(parent_id); #ifndef HAVE_EO_ID From 2edd305507806021705076747f0080fa6481b93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 16:13:14 +0100 Subject: [PATCH 028/169] eo2: set eo2_constructor and eo2_destructor chaining --- src/lib/eo/Eo.h | 5 +++++ src/lib/eo/eo.c | 3 +++ src/lib/eo/eo_private.h | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index fdb233b9ba..d791e0e2f7 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -812,6 +812,11 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); const Eo_Class *_tmp_klass = klass; \ eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo_constructor(), ## __VA_ARGS__, EO_NOOP); \ }) +#define eo2_add(klass, parent, ...) \ + ({ \ + const Eo_Class *_tmp_klass = klass; \ + eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ + }) /** * @def eo_add_custom diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 05415a25d7..3b33e446e8 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1362,6 +1362,9 @@ eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent _eo_parent_internal_set(obj, parent_id); + if (klass->desc->version == EO2_VERSION) + eo2_do((Eo *)obj_id, eo2_constructor()); + /* Run the relevant do stuff. */ { va_list p_list; diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 621bab43cd..9af5a51f74 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -216,9 +216,22 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) const _Eo_Class *klass = obj->klass; + if (klass->desc->version == EO2_VERSION) + eo2_do((Eo *)obj->obj_id, eo2_event_callback_call(EO_EV_DEL, NULL);); + else + eo_do((Eo *) obj->obj_id, eo_event_callback_call(EO_EV_DEL, NULL, NULL)); + _eo_condtor_reset(obj); - do_err = eo_do(_eo_id_get(obj), eo_destructor()); + if (klass->desc->version == EO2_VERSION) + { + // FIXME: eo2 + do_err = EINA_TRUE; + eo2_do((Eo *)obj->obj_id, eo2_destructor();); + } + else + do_err = eo_do((Eo *)obj->obj_id, eo_destructor()); + if (EINA_UNLIKELY(!do_err)) { ERR("in %s:%d: Object of class '%s' - One of the object destructors have failed.", From 1d9d0cee9c3acbdbd791e0ae73f5bd52c86ef89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 16:14:55 +0100 Subject: [PATCH 029/169] eo2: EO2_OP_FUNC_OVERRIDE copy doc from overriden func --- src/lib/eo/Eo.h | 6 +++--- src/lib/eo/eo.c | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index d791e0e2f7..01cc9de396 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -630,7 +630,7 @@ typedef struct _Eo2_Op_Call_Data // 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_get_op_id((void*)Name, NULL); \ + if ( op == EO_NOOP ) op = eo2_api_op_id_get((void*)Name, NULL); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -662,11 +662,11 @@ typedef struct _Eo2_Op_Call_Data #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} -#define EO2_OP_FUNC_OVERRIDE(_private, _api, _doc) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, _doc} +#define EO2_OP_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_get_op_id(void *api_func, const Eo_Class *klass); +EAPI Eo_Op eo2_api_op_id_get(void *api_func, const Eo_Class *klass); // gets the real function pointer and the object data #define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 3b33e446e8..ab00a69b27 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -410,8 +410,8 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * } -EAPI Eo_Op -eo2_get_op_id(void *api_func, const Eo_Class *klass_id) +static inline const Eo2_Op_Description * +_eo2_api_desc_get(void *api_func, const Eo_Class *klass_id) { int imin, imax, imid; Eo2_Op_Description *op_desc; @@ -437,10 +437,22 @@ eo2_get_op_id(void *api_func, const Eo_Class *klass_id) else if (op_desc->api_func < api_func) imax = imid - 1; else - return op_desc->op; + return op_desc; } - return EO_NOOP; + return NULL; +} + +EAPI Eo_Op +eo2_api_op_id_get(void *api_func, const Eo_Class *klass_id) +{ + const Eo2_Op_Description *desc; + + desc = _eo2_api_desc_get(api_func, klass_id); + if (desc == NULL) + return EO_NOOP; + + return desc->op; } static int @@ -459,6 +471,7 @@ eo2_class_funcs_set(Eo_Class *klass_id) { int op_id; _Eo_Class *klass; + const Eo2_Op_Description *api_desc; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; @@ -486,7 +499,14 @@ eo2_class_funcs_set(Eo_Class *klass_id) ERR("Can't inherit from a NULL parent. Class '%s', Func index: %lu", klass->desc->name, (unsigned long) (op_desc - op_descs)); - op_desc->op = eo2_get_op_id(op_desc->api_func, _eo_class_id_get(klass->parent)); + api_desc = _eo2_api_desc_get(op_desc->api_func, _eo_class_id_get(klass->parent)); + + if (api_desc == NULL) + ERR("Can't find api func %p description in '%s' parent class. Class '%s', Func index: %lu", + op_desc->api_func, klass->parent->desc->name, klass->desc->name, (unsigned long) (op_desc - op_descs)); + + op_desc->op = api_desc->op; + op_desc->doc = api_desc->doc; if (op_desc->op == EO_NOOP) ERR("API func %p, not found in direct parent '%s'. Class '%s', Func index: %lu", From 9c4731f606c1edec944c91c2df95007c05921e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 02:34:16 +0200 Subject: [PATCH 030/169] eo2: eo2_api_op_id_get search in parent klasses too --- src/lib/eo/eo.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index ab00a69b27..85bc0c9c7d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -411,17 +411,11 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * static inline const Eo2_Op_Description * -_eo2_api_desc_get(void *api_func, const Eo_Class *klass_id) +_eo2_api_desc_get(void *api_func, const _Eo_Class *klass) { int imin, imax, imid; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; - const _Eo_Class *klass; - - if (klass_id) - klass = _eo_class_pointer_get(klass_id); - else - klass = eo2_call_stack.frame_ptr->obj->klass; imin = 0; imax = klass->desc->ops.count - 1; @@ -447,10 +441,22 @@ EAPI Eo_Op eo2_api_op_id_get(void *api_func, const Eo_Class *klass_id) { const Eo2_Op_Description *desc; + const _Eo_Class *klass; - desc = _eo2_api_desc_get(api_func, klass_id); - if (desc == NULL) - return EO_NOOP; + if (klass_id) + klass = _eo_class_pointer_get(klass_id); + else + klass = eo2_call_stack.frame_ptr->obj->klass; + + while (klass) + { + desc = _eo2_api_desc_get(api_func, klass); + if (desc) break; + klass = klass->parent; + } + + if (desc == NULL) + return EO_NOOP; return desc->op; } @@ -499,7 +505,7 @@ eo2_class_funcs_set(Eo_Class *klass_id) ERR("Can't inherit from a NULL parent. Class '%s', Func index: %lu", klass->desc->name, (unsigned long) (op_desc - op_descs)); - api_desc = _eo2_api_desc_get(op_desc->api_func, _eo_class_id_get(klass->parent)); + api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent); if (api_desc == NULL) ERR("Can't find api func %p description in '%s' parent class. Class '%s', Func index: %lu", From 21b31a2f975717e06999abf18793db761c0d3927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 02:34:46 +0200 Subject: [PATCH 031/169] eo2: eo2_base_class uses eo2 stuff only, I hope --- src/lib/eo/eo2_base_class.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 1e17431f34..b0b3e24cda 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -65,7 +65,7 @@ _data_set(Eo *obj, void *class_data, if (!key) return; - eo_do(obj, eo_base_data_del(key)); + eo2_do(obj, eo2_base_data_del(key); ); node = malloc(sizeof(Eo_Generic_Data_Node)); node->key = eina_stringshare_add(key); @@ -367,7 +367,7 @@ _ev_cb_priority_add(Eo *obj, void *class_data, { const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, arr, NULL)); + eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_ADD, (void *)arr)); } } EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_priority_add, @@ -396,7 +396,7 @@ _ev_cb_del(Eo *obj, void *class_data, cb->delete_me = EINA_TRUE; pd->deletions_waiting = EINA_TRUE; _eo_callbacks_clear(pd); - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, arr, NULL)); + eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_DEL, (void *)arr); ); return; } } @@ -426,7 +426,7 @@ _ev_cb_array_priority_add(Eo *obj, void *class_data, _eo_callbacks_sorted_insert(pd, cb); { - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, array, NULL)); + eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_ADD, (void *)array); ); } } EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_array_priority_add, @@ -451,7 +451,7 @@ _ev_cb_array_del(Eo *obj, void *class_data, pd->deletions_waiting = EINA_TRUE; _eo_callbacks_clear(pd); - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, array, NULL)); + eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_DEL, (void *)array); ); return; } } @@ -542,9 +542,9 @@ _eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *de { (void) obj; Eo *new_obj = (Eo *) data; - Eina_Bool ret; + Eina_Bool ret = EINA_FALSE; - eo_do(new_obj, eo_event_callback_call(desc, event_info, &ret)); + eo2_do(new_obj, ret = eo2_event_callback_call(desc, (void *)event_info); ); return ret; } @@ -558,7 +558,7 @@ _ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj)); + eo2_do(obj, eo2_event_callback_add(desc, _eo_event_forwarder_callback, new_obj); ); } EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_add, EO2_FUNC_CALL(desc, new_obj), @@ -573,7 +573,7 @@ _ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj)); + eo2_do(obj, eo2_event_callback_del(desc, _eo_event_forwarder_callback, new_obj); ); } EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_del, EO2_FUNC_CALL(desc, new_obj), From d61a31a64576615df49dd8749e3a4bdf214772fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 02:47:59 +0200 Subject: [PATCH 032/169] eo2: can't detect return in a eo2_do macro, *sigh* --- src/lib/eo/eo.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 85bc0c9c7d..4ff62d40f1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -336,9 +336,6 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_SIZE) ERR("eo2 call stack overflow !!!"); - if (fptr->obj_id != NULL) - ERR("eo2 call stack is not clear, you must have used a return statement in a eo2_do macro"); - _eo_ref(obj); fptr->obj = obj; From 5febcc9ff1a23eaa3a9fb1829ca5c7a0919d1187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 03:05:06 +0200 Subject: [PATCH 033/169] eo2: oops, forgot to init desc to NULL in eo2_api_op_id_get() --- src/lib/eo/eo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 4ff62d40f1..8630754f93 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -444,6 +444,7 @@ eo2_api_op_id_get(void *api_func, const Eo_Class *klass_id) klass = _eo_class_pointer_get(klass_id); else klass = eo2_call_stack.frame_ptr->obj->klass; + desc = NULL; while (klass) { From 13b1d03deff635f0de9433fc547a8bec227837b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 08:39:34 +0200 Subject: [PATCH 034/169] eo2: _eo2_api_desc_get() searches the class hierarchy --- src/lib/eo/eo.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8630754f93..98378569ac 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -414,21 +414,26 @@ _eo2_api_desc_get(void *api_func, const _Eo_Class *klass) Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; - imin = 0; - imax = klass->desc->ops.count - 1; - op_descs = klass->desc->ops.descs2; - - while (imax >= imin) + while (klass) { - imid = (imax + imin) / 2; - op_desc = op_descs + imid; + imin = 0; + imax = klass->desc->ops.count - 1; + op_descs = klass->desc->ops.descs2; - if (op_desc->api_func > api_func) - imin = imid + 1; - else if (op_desc->api_func < api_func) - imax = imid - 1; - else - return op_desc; + while (imax >= imin) + { + imid = (imax + imin) / 2; + op_desc = op_descs + imid; + + if (op_desc->api_func > api_func) + imin = imid + 1; + else if (op_desc->api_func < api_func) + imax = imid - 1; + else + return op_desc; + } + + klass = klass->parent; } return NULL; @@ -444,14 +449,8 @@ eo2_api_op_id_get(void *api_func, const Eo_Class *klass_id) klass = _eo_class_pointer_get(klass_id); else klass = eo2_call_stack.frame_ptr->obj->klass; - desc = NULL; - while (klass) - { - desc = _eo2_api_desc_get(api_func, klass); - if (desc) break; - klass = klass->parent; - } + desc = _eo2_api_desc_get(api_func, klass); if (desc == NULL) return EO_NOOP; @@ -506,8 +505,8 @@ eo2_class_funcs_set(Eo_Class *klass_id) api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent); if (api_desc == NULL) - ERR("Can't find api func %p description in '%s' parent class. Class '%s', Func index: %lu", - op_desc->api_func, klass->parent->desc->name, klass->desc->name, (unsigned long) (op_desc - op_descs)); + ERR("Can't find api func %p description in class hierarchy. Class '%s', Func index: %lu", + op_desc->api_func, klass->desc->name, (unsigned long) (op_desc - op_descs)); op_desc->op = api_desc->op; op_desc->doc = api_desc->doc; From ec1e507465d70f78ba443f8e573ad6bd5dea59a6 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 26 Jul 2013 10:27:08 +0100 Subject: [PATCH 035/169] eo2: explicitly put void as the arguments in a zero argument function (macro). --- src/lib/eo/Eo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 01cc9de396..2e6729b2a8 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -639,7 +639,7 @@ typedef struct _Eo2_Op_Call_Data // to define an EAPI function #define EO2_FUNC_BODY(Name, Ret, DefRet) \ Ret \ - Name() \ + Name(void) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ _EO2_FUNC_COMMON(Name, Ret, _func_(call.obj_id, call.data), DefRet)\ From ca5221e0f97c3cd0fba89b949277cc6a1ea49d6c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 26 Jul 2013 10:29:54 +0100 Subject: [PATCH 036/169] eo2: compile eo2_base_class when compiling libeo. --- src/Makefile_Eo.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 230ff9e794..6675a46d12 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -12,6 +12,7 @@ lib/eo/eo_ptr_indirection.c \ lib/eo/eo_ptr_indirection.h \ lib/eo/eo_class_class.c \ lib/eo/eo_base_class.c \ +lib/eo/eo2_base_class.c \ lib/eo/eo_private.h lib_eo_libeo_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EO_CFLAGS@ From 1aa3b1536f672dd2daa67e160d895cca40b344b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 26 Jul 2013 17:14:52 +0200 Subject: [PATCH 037/169] eo2: add virtual func support --- src/lib/eo/Eo.h | 2 ++ src/lib/eo/eo.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 2e6729b2a8..dbcd42d7a5 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -659,10 +659,12 @@ typedef struct _Eo2_Op_Call_Data // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) +#define EO2_OP_VIRTUAL ((Eo_Op) -2) #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} #define EO2_OP_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} +#define EO2_OP_FUNC_VIRTUAL(_api, _doc) {NULL, _api, EO2_OP_VIRTUAL, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 98378569ac..65ead71cb4 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -382,9 +382,17 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * else klass = fptr->cur_klass; - func = _eo_kls_itr_func_get(klass, op); + if (!klass) + return EINA_FALSE; + + func = _dich_func_get(klass, op); if (EINA_LIKELY(func != NULL)) { + if (func->func == NULL) + { + ERR("you called a pure virtual func"); + return EINA_FALSE; + } call->obj_id = fptr->obj_id; call->func = func->func; @@ -496,6 +504,11 @@ eo2_class_funcs_set(Eo_Class *klass_id) op_desc->op = op_id; op_id++; } + else if (op_desc->op == EO2_OP_VIRTUAL) + { + op_desc->op = op_id; + op_id++; + } else if (op_desc->op == EO2_OP_OVERRIDE) { if (klass->parent == NULL) From eeff3e898c47315ffbdc260fc5259293481d04c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 27 Jul 2013 22:42:24 +0200 Subject: [PATCH 038/169] eo2: EO2_CALL_STACK_SIZE -> EO2_CALL_STACK_DEPTH --- src/lib/eo/eo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 65ead71cb4..9632aa83ef 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -275,7 +275,7 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) // FIXME: per thread stack, grow/shrink #define EO2_INVALID_DATA (void *) -1 -#define EO2_CALL_STACK_SIZE 5 +#define EO2_CALL_STACK_DEPTH 5 typedef struct _Eo2_Stack_Frame { Eo *obj_id; @@ -286,7 +286,7 @@ typedef struct _Eo2_Stack_Frame } Eo2_Stack_Frame; typedef struct _Eo2_Call_Stack { - Eo2_Stack_Frame stack[EO2_CALL_STACK_SIZE]; + Eo2_Stack_Frame stack[EO2_CALL_STACK_DEPTH]; Eo2_Stack_Frame *frame_ptr; } Eo2_Call_Stack; @@ -333,7 +333,7 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) fptr = eo2_call_stack.frame_ptr; - if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_SIZE) + if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_DEPTH) ERR("eo2 call stack overflow !!!"); _eo_ref(obj); From adc1ac0c23c581b4dee558f472d50abd86357bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 27 Jul 2013 22:46:50 +0200 Subject: [PATCH 039/169] eo2: add eo2_call_stack_depth --- src/lib/eo/Eo.h | 2 ++ src/lib/eo/eo.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index dbcd42d7a5..ea3709f171 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -680,6 +680,8 @@ EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(); +EAPI int eo2_call_stack_depth(); + // eo object method calls batch, // DO NOT use return statement in it, use break if necessary #define eo2_do(objid, ...) \ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 9632aa83ef..bdb51059f8 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -300,6 +300,13 @@ static Eo2_Call_Stack eo2_call_stack = { }, NULL }; +EAPI int +eo2_call_stack_depth() +{ + return ((eo2_call_stack.frame_ptr == NULL) ? 0 : + 1 + (eo2_call_stack.frame_ptr - eo2_call_stack.stack)); +} + EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super) { From b6991985edf788851720632a0593d3a1a8112f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 25 Dec 2013 16:22:42 +0100 Subject: [PATCH 040/169] eo2: eo2_do() uses __attribute__ cleanup to protect us against bad use of break, goto, return ... in eo2_do, we use __attribute__((cleanup(eo2_do_end))) to ensure that eo2_do_end() is called whatever. --- src/lib/eo/Eo.h | 14 +++++++------- src/lib/eo/eo.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index ea3709f171..49b51792e9 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -678,28 +678,28 @@ EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); // end of the eo2_do barrier, unref the obj, move the stack pointer -EAPI void eo2_do_end(); +EAPI void eo2_do_end(Eo **ojb); EAPI int eo2_call_stack_depth(); +#define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) + // eo object method calls batch, // DO NOT use return statement in it, use break if necessary #define eo2_do(objid, ...) \ do \ { \ - Eo *_objid_ = objid; \ + Eo *_objid_ EO2_DO_CLEANUP = objid; \ if (!eo2_do_start(_objid_, EINA_FALSE)) break; \ - do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(); \ + __VA_ARGS__; \ } while (0) #define eo2_do_super(objid, ...) \ do \ { \ - Eo *_objid_ = objid; \ + Eo *_objid_ EO2_DO_CLEANUP = objid; \ if (!eo2_do_start(_objid_, EINA_TRUE)) break; \ - do { __VA_ARGS__ ; } while (0); \ - eo2_do_end(); \ + __VA_ARGS__; \ } while (0) // FIXME diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index bdb51059f8..c18f8a31eb 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -354,7 +354,7 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) } EAPI void -eo2_do_end() +eo2_do_end(Eo **objid EINA_UNUSED) { Eo2_Stack_Frame *fptr; From 329d752c594cd8124ef84bae6f12928202217f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 16:16:55 +0100 Subject: [PATCH 041/169] eo2: do not call eo2_do_end() if eo2_do_start() fail --- src/lib/eo/Eo.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 49b51792e9..da420c7bb0 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -685,21 +685,22 @@ EAPI int eo2_call_stack_depth(); #define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) // eo object method calls batch, -// DO NOT use return statement in it, use break if necessary #define eo2_do(objid, ...) \ do \ { \ + if (!eo2_do_start(objid, EINA_FALSE)) break; \ Eo *_objid_ EO2_DO_CLEANUP = objid; \ - if (!eo2_do_start(_objid_, EINA_FALSE)) break; \ __VA_ARGS__; \ + (void) _objid_; \ } while (0) #define eo2_do_super(objid, ...) \ do \ { \ + if (!eo2_do_start(objid, EINA_TRUE)) break; \ Eo *_objid_ EO2_DO_CLEANUP = objid; \ - if (!eo2_do_start(_objid_, EINA_TRUE)) break; \ __VA_ARGS__; \ + (void) _objid_; \ } while (0) // FIXME From 3ae5b846f7b6f8a97e1addaabfc83623f9046b96 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 29 Jul 2013 16:11:47 +0100 Subject: [PATCH 042/169] eo2: cleaned up eo2_do macros. cleaned up the cleanup attribute usage. don't use objid more than once (it's a macro). --- src/lib/eo/Eo.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index da420c7bb0..e19f7d6eb9 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -688,19 +688,25 @@ EAPI int eo2_call_stack_depth(); #define eo2_do(objid, ...) \ do \ { \ - if (!eo2_do_start(objid, EINA_FALSE)) break; \ - Eo *_objid_ EO2_DO_CLEANUP = objid; \ - __VA_ARGS__; \ - (void) _objid_; \ + Eo *_objid_ = objid; \ + if (eo2_do_start(_objid_, EINA_FALSE)) \ + { \ + Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ } while (0) #define eo2_do_super(objid, ...) \ do \ { \ - if (!eo2_do_start(objid, EINA_TRUE)) break; \ - Eo *_objid_ EO2_DO_CLEANUP = objid; \ - __VA_ARGS__; \ - (void) _objid_; \ + Eo *_objid_ = objid; \ + if (eo2_do_start(_objid_, EINA_TRUE)) \ + { \ + Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ } while (0) // FIXME From 56f48ac817c503ee3849a1065621f8d766d0488c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 29 Jul 2013 17:32:20 +0100 Subject: [PATCH 043/169] eo2: fixed dbg_info_get function to accept the correct number of params. --- src/lib/eo/Eo.h | 2 +- src/lib/eo/eo2_base_class.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e19f7d6eb9..e9ba310daf 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1237,7 +1237,7 @@ eo2_base_data_get(const char *key); */ #define eo_dbg_info_get(root_node) EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), EO_TYPECHECK(Eo_Dbg_Info *, root_node) EAPI void -eo2_dbg_info_get(); +eo2_dbg_info_get(Eo_Dbg_Info *root_node); /** * @def eo_base_data_del(key) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index b0b3e24cda..beacc5c04e 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -101,11 +101,11 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_get, EO2_FUNC_CALL(key), const char *key); static void -_dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) +_dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo_Dbg_Info *root_node EINA_UNUSED) { /* No info required in the meantime */ return; } -EAPI EO2_VOID_FUNC_BODY(eo2_dbg_info_get); +EAPI EO2_VOID_FUNC_BODYV(eo2_dbg_info_get, EO2_FUNC_CALL(root_node), Eo_Dbg_Info *root_node); static void _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) From 8307ed5aa86e12b1d29d3be1905f1b33ec72e256 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 29 Jul 2013 17:50:56 +0100 Subject: [PATCH 044/169] eo2: cleaned up EO2_CLASS_DESCRIPTION_OPS and OP_DESC_SIZE (renamed). --- src/lib/eo/Eo.h | 4 ++-- src/lib/eo/eo2_base_class.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e9ba310daf..f917c8e063 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -607,10 +607,10 @@ EAPI Eina_Bool eo_shutdown(void); #define EO2_VERSION 2 // computes size of Eo2_Op_Description[] -#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) +#define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) // An helper macro to help populating #Eo_Class_Description. -#define EO2_CLASS_DESCRIPTION_OPS(op_descs, count) { NULL, NULL, op_descs, count } +#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } // sort Eo2_Op_Description[] by eapi_func then attribute OP ids EAPI void diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index beacc5c04e..218975245b 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -814,7 +814,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Eo Base", EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO2_CLASS_DESCRIPTION_OPS(op_descs, OP_DESC_SIZE(op_descs)), + EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), _class_constructor, From 2d5baec80cb07b23513e6b9d32ee9935bcbde327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 29 Jul 2013 22:13:13 +0200 Subject: [PATCH 045/169] eo2: call _eo2_class_funcs_set from _eo_class_constructor --- src/lib/eo/Eo.h | 4 ---- src/lib/eo/eo.c | 8 ++++---- src/lib/eo/eo2_base_class.c | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index f917c8e063..e2c29f11b0 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -612,10 +612,6 @@ EAPI Eina_Bool eo_shutdown(void); // An helper macro to help populating #Eo_Class_Description. #define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } -// sort Eo2_Op_Description[] by eapi_func then attribute OP ids -EAPI void -eo2_class_funcs_set(Eo_Class *klass_id); - // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data { diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index c18f8a31eb..8cc8bb36a1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -485,16 +485,13 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) } EAPI void -eo2_class_funcs_set(Eo_Class *klass_id) +_eo2_class_funcs_set(_Eo_Class *klass) { int op_id; - _Eo_Class *klass; const Eo2_Op_Description *api_desc; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; - klass = _eo_class_pointer_get(klass_id); - EO_MAGIC_RETURN(klass, EO_CLASS_EINA_MAGIC); op_descs = klass->desc->ops.descs2; qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); @@ -925,6 +922,9 @@ _eo_class_constructor(_Eo_Class *klass) klass->constructed = EINA_TRUE; + if (klass->desc->version == EO2_VERSION) + _eo2_class_funcs_set(klass); + if (klass->desc->class_constructor) klass->desc->class_constructor(_eo_class_id_get(klass)); } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 218975245b..4d0610f772 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -771,10 +771,9 @@ _destructor(Eo *obj, void *class_data) EAPI EO2_VOID_FUNC_BODY(eo2_destructor); static void -_class_constructor(Eo_Class *klass) +_class_constructor(Eo_Class *klass EINA_UNUSED) { event_freeze_count = 0; - eo2_class_funcs_set(klass); } Eo2_Op_Description op_descs [] = { From 42ad23c5c87b44fd982849f17b6ab8f540407c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 16:23:55 +0100 Subject: [PATCH 046/169] eo2: eo2_add accepts non-defauld constructors --- src/lib/eo/Eo.h | 2 +- src/lib/eo/eo.c | 20 +++++++++++++++++--- src/lib/eo/eo_private.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e2c29f11b0..9724663beb 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -822,7 +822,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ + eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo2_constructor, ## __VA_ARGS__, EO_NOOP); \ }) /** diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8cc8bb36a1..168bac008c 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1405,10 +1405,24 @@ eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent _eo_parent_internal_set(obj, parent_id); - if (klass->desc->version == EO2_VERSION) - eo2_do((Eo *)obj_id, eo2_constructor()); - /* Run the relevant do stuff. */ + if (klass->desc->version == EO2_VERSION) + { + eo2_constructor_type constr; + va_list p_list; + if(eo2_do_start((Eo *)obj_id, EINA_FALSE)) + { + va_start(p_list, parent_id); + while ((constr = va_arg(p_list, eo2_constructor_type))) + constr(); + va_end(p_list); + eo2_do_end(NULL); + do_err = EINA_FALSE; + } + else + do_err = EINA_TRUE; + } + else { va_list p_list; va_start(p_list, parent_id); diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 9af5a51f74..a645a910a8 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -61,6 +61,7 @@ typedef struct _Eo_Class _Eo_Class; typedef struct _Eo_Object _Eo_Object; typedef struct _Eo_Base Eo_Base; typedef struct _Eo_Internal _Eo; +typedef void (*eo2_constructor_type)(void); /* Retrieves the pointer to the object from the id */ static inline _Eo_Object *_eo_obj_pointer_get(const Eo_Id obj_id); From e82c0f6bf770ff9bd7286102cdfe2b9d5896442d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 29 Jul 2013 23:52:46 +0200 Subject: [PATCH 047/169] eo2: fix indent --- src/lib/eo/eo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 168bac008c..79523f9f0d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -918,7 +918,7 @@ static void _eo_class_constructor(_Eo_Class *klass) { if (klass->constructed) - return; + return; klass->constructed = EINA_TRUE; @@ -926,7 +926,7 @@ _eo_class_constructor(_Eo_Class *klass) _eo2_class_funcs_set(klass); if (klass->desc->class_constructor) - klass->desc->class_constructor(_eo_class_id_get(klass)); + klass->desc->class_constructor(_eo_class_id_get(klass)); } EAPI void From 28d66a98582b0a3ac9363f44c0fb4666e7235b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 29 Jul 2013 23:57:45 +0200 Subject: [PATCH 048/169] eo2: eo_del_internal use same logic as in eo_add_internal --- src/lib/eo/eo_private.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index a645a910a8..bd3795346a 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -227,13 +227,13 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) if (klass->desc->version == EO2_VERSION) { // FIXME: eo2 - do_err = EINA_TRUE; + do_err = EINA_FALSE; eo2_do((Eo *)obj->obj_id, eo2_destructor();); } else - do_err = eo_do((Eo *)obj->obj_id, eo_destructor()); + do_err = !eo_do((Eo *)obj->obj_id, eo_destructor()); - if (EINA_UNLIKELY(!do_err)) + if (EINA_UNLIKELY(do_err)) { ERR("in %s:%d: Object of class '%s' - One of the object destructors have failed.", file, line, klass->desc->name); From 7be0748b349800e8adbf1419f0b3d2c4fcba274d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 30 Jul 2013 15:02:35 +0200 Subject: [PATCH 049/169] eo2: implement class function support --- src/lib/eo/Eo.h | 68 ++++++++++++++++++++++++++---- src/lib/eo/eo.c | 107 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 146 insertions(+), 29 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 9724663beb..6e05e63a40 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -615,13 +615,15 @@ EAPI Eina_Bool eo_shutdown(void); // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data { - Eo *obj_id; - void *func; - void *data; + Eo *obj_id; + Eo_Class *klass_id; + void *func; + void *data; } Eo2_Op_Call_Data; // 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__) // cache OP id, get real fct and object data then do the call #define _EO2_FUNC_COMMON(Name, Ret, Func, DefRet) \ @@ -632,6 +634,14 @@ typedef struct _Eo2_Op_Call_Data __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ +#define _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ + static Eo_Op op = EO_NOOP; \ + if ( op == EO_NOOP ) op = eo2_api_op_id_get((void*)Name, Class); \ + Eo2_Op_Call_Data call; \ + 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) \ Ret \ @@ -653,6 +663,27 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) +// to define a EAPI class function +#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ + Ret \ + Name(void) \ + { \ + typedef Ret (*__##Name##_func)(Eo_Class *); \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet, Class) \ + } + +#define EO2_VOID_CLASS_FUNC_BODY(Name, Class) EO2_CLASS_FUNC_BODY(Name, void, , Class) + +#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ + Ret \ + Name(__VA_ARGS__) \ + { \ + typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ + } + +#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, Class, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , Class, __VA_ARGS__) + // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) #define EO2_OP_VIRTUAL ((Eo_Op) -2) @@ -660,6 +691,7 @@ typedef struct _Eo2_Op_Call_Data #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} #define EO2_OP_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} +#define EO2_OP_CLASS_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} #define EO2_OP_FUNC_VIRTUAL(_api, _doc) {NULL, _api, EO2_OP_VIRTUAL, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} @@ -672,13 +704,16 @@ EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); +EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, Eina_Bool do_super); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(Eo **ojb); +EAPI void eo2_class_do_end(const Eo_Class **klass); EAPI int eo2_call_stack_depth(); #define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) +#define EO2_CLASS_DO_CLEANUP __attribute__((cleanup(eo2_class_do_end))) // eo object method calls batch, #define eo2_do(objid, ...) \ @@ -705,11 +740,28 @@ EAPI int eo2_call_stack_depth(); } \ } while (0) -// FIXME -#define eo2_class_do(clsid, ...) \ - do \ - { \ - do { __VA_ARGS__ ; } while (0); \ +#define eo2_class_do(clsid, ...) \ + do \ + { \ + const Eo_Class *_clsid_ = clsid; \ + if (eo2_class_do_start(_clsid_, EINA_FALSE)) \ + { \ + const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ + } while (0) + +#define eo2_class_super_do(clsid, ...) \ + do \ + { \ + const Eo_Class *_clsid_ = clsid; \ + if (eo2_class_do_start(_clsid_, EINA_TRUE)) \ + { \ + const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ } while (0) /*****************************************************************************/ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 79523f9f0d..33485a5eb9 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -280,7 +280,7 @@ typedef struct _Eo2_Stack_Frame { Eo *obj_id; _Eo *obj; - const _Eo_Class *cur_klass; + const _Eo_Class *klass; void *obj_data; } Eo2_Stack_Frame; @@ -311,7 +311,7 @@ EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super) { _Eo * obj; - const _Eo_Class *cur_klass; + const _Eo_Class *klass; Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; @@ -319,9 +319,9 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) { obj = fptr->obj; if (do_super) - cur_klass = _eo2_kls_itr_next(obj->klass, fptr->cur_klass); + klass = _eo2_kls_itr_next(obj->klass, fptr->klass); else - cur_klass = fptr->cur_klass; + klass = fptr->klass; eo2_call_stack.frame_ptr++; } else @@ -329,9 +329,9 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) obj = _eo_obj_pointer_get((Eo_Id)obj_id); if (!obj) return EINA_FALSE; if (do_super) - cur_klass = _eo2_kls_itr_next(obj->klass, obj->klass); + klass = _eo2_kls_itr_next(obj->klass, obj->klass); else - cur_klass = obj->klass; + klass = obj->klass; if (fptr == NULL) eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; else @@ -347,24 +347,65 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) fptr->obj = obj; fptr->obj_id = obj_id; - fptr->cur_klass = cur_klass; + fptr->klass = klass; fptr->obj_data = EO2_INVALID_DATA; return EINA_TRUE; } -EAPI void -eo2_do_end(Eo **objid EINA_UNUSED) +EAPI Eina_Bool +eo2_class_do_start(const Eo_Class *klass_id, Eina_Bool do_super EINA_UNUSED) +{ + Eo2_Stack_Frame *fptr; + const _Eo_Class *klass; + + fptr = eo2_call_stack.frame_ptr; + if ((fptr != NULL) && (fptr->klass->class_id == (Eo_Class_Id) klass_id)) + { + if (do_super) + klass = _eo2_kls_itr_next(fptr->klass, fptr->klass); + else + klass = fptr->klass; + eo2_call_stack.frame_ptr++; + } + else + { + klass = _eo_class_pointer_get(klass_id); + EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); + if (do_super) + klass = _eo2_kls_itr_next(klass, klass); + if (fptr == NULL) + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + else + eo2_call_stack.frame_ptr++; + } + + fptr = eo2_call_stack.frame_ptr; + + if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_DEPTH) + ERR("eo2 call stack overflow !!!"); + + fptr->obj = NULL; + fptr->obj_id = NULL; + fptr->klass = klass; + fptr->obj_data = EO2_INVALID_DATA; + + return EINA_TRUE; +} + +static inline void +_eo2_do_end(Eina_Bool obj_do) { Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; - _eo_unref(fptr->obj); + if(obj_do) + _eo_unref(fptr->obj); fptr->obj = NULL; fptr->obj_id = NULL; - fptr->cur_klass = NULL; + fptr->klass = NULL; fptr->obj_data = EO2_INVALID_DATA; if (fptr == &eo2_call_stack.stack[0]) @@ -373,6 +414,18 @@ eo2_do_end(Eo **objid EINA_UNUSED) eo2_call_stack.frame_ptr--; } +EAPI void +eo2_do_end(Eo **obj_id EINA_UNUSED) +{ + _eo2_do_end(EINA_TRUE); +} + +EAPI void +eo2_class_do_end(const Eo_Class **klass_id EINA_UNUSED) +{ + _eo2_do_end(EINA_FALSE); +} + EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) { @@ -385,12 +438,17 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * obj = fptr->obj; if (klass_id) - klass = _eo_class_pointer_get(klass_id); + { + klass = _eo_class_pointer_get(klass_id); + EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); + } else - klass = fptr->cur_klass; + { + klass = fptr->klass; + if (!klass) + return EINA_FALSE; + } - if (!klass) - return EINA_FALSE; func = _dich_func_get(klass, op); if (EINA_LIKELY(func != NULL)) @@ -400,18 +458,24 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * ERR("you called a pure virtual func"); return EINA_FALSE; } + call->klass_id = (Eo_Class *) klass->class_id; call->obj_id = fptr->obj_id; call->func = func->func; - if (func->src == obj->klass) + if (obj) { - if (fptr->obj_data == EO2_INVALID_DATA) - fptr->obj_data = _eo_data_scope_get(obj, func->src); + if (func->src == obj->klass) + { + if (fptr->obj_data == EO2_INVALID_DATA) + fptr->obj_data = _eo_data_scope_get(obj, func->src); - call->data = fptr->obj_data; + call->data = fptr->obj_data; + } + else + call->data = _eo_data_scope_get(obj, func->src); } else - call->data = _eo_data_scope_get(obj, func->src); + call->data = NULL; return EINA_TRUE; } @@ -497,6 +561,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); op_id = klass->base_id; + /* printf("elaborate class '%s' \n", klass->desc->name); */ for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if(op_desc->api_func == NULL) @@ -534,7 +599,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) klass->desc->name, (unsigned long) (op_desc - op_descs)); } - /* printf("%d %p %p %s\n", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); */ + /* printf(" %d %p %p %s\n", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); */ _dich_func_set(klass, op_desc->op, op_desc->func); } } From 5f45e57b89b2bc3ffa904fd33ced8fe718c6e0dc Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 30 Jul 2013 14:12:03 +0100 Subject: [PATCH 050/169] eo2: revert "eo2_add accepts non-defauld constructors" We want to have normal functions as non-default constructors, not va_arg ones. What we should do is split the object creation to two parts again. The creation, the constructing (changes using the macro) and the verification/end part that checks the constructor has been called. This reverts commit 2ff2ce1894f173b306a896bda595e1a7768c074d. --- src/lib/eo/Eo.h | 2 +- src/lib/eo/eo.c | 18 ++---------------- src/lib/eo/eo_private.h | 1 - 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 6e05e63a40..44e622eec5 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -874,7 +874,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo2_constructor, ## __VA_ARGS__, EO_NOOP); \ + eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ }) /** diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 33485a5eb9..1a48d24bb0 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1472,22 +1472,8 @@ eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent /* Run the relevant do stuff. */ if (klass->desc->version == EO2_VERSION) - { - eo2_constructor_type constr; - va_list p_list; - if(eo2_do_start((Eo *)obj_id, EINA_FALSE)) - { - va_start(p_list, parent_id); - while ((constr = va_arg(p_list, eo2_constructor_type))) - constr(); - va_end(p_list); - eo2_do_end(NULL); - do_err = EINA_FALSE; - } - else - do_err = EINA_TRUE; - } - else + eo2_do((Eo *)obj_id, eo2_constructor()); + /* Run the relevant do stuff. */ { va_list p_list; va_start(p_list, parent_id); diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index bd3795346a..614483f9b8 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -61,7 +61,6 @@ typedef struct _Eo_Class _Eo_Class; typedef struct _Eo_Object _Eo_Object; typedef struct _Eo_Base Eo_Base; typedef struct _Eo_Internal _Eo; -typedef void (*eo2_constructor_type)(void); /* Retrieves the pointer to the object from the id */ static inline _Eo_Object *_eo_obj_pointer_get(const Eo_Id obj_id); From ac2f6d0bf5ed36ef2585c22f54126324e52db177 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 30 Jul 2013 16:08:25 +0100 Subject: [PATCH 051/169] eo2: updated the access test to use eo2. --- src/tests/eo/access/access_inherit.c | 28 +++++++---------------- src/tests/eo/access/access_inherit.h | 11 +--------- src/tests/eo/access/access_main.c | 4 ++-- src/tests/eo/access/access_simple.c | 33 +++++++++------------------- src/tests/eo/access/access_simple.h | 11 +--------- 5 files changed, 22 insertions(+), 65 deletions(-) diff --git a/src/tests/eo/access/access_inherit.c b/src/tests/eo/access/access_inherit.c index b42a4a6c6e..676aa051fe 100644 --- a/src/tests/eo/access/access_inherit.c +++ b/src/tests/eo/access/access_inherit.c @@ -7,42 +7,30 @@ #include "access_simple_protected.h" #include "access_inherit.h" -EAPI Eo_Op INHERIT_BASE_ID = 0; - #define MY_CLASS INHERIT_CLASS static void -_prot_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +_prot_print(Eo *obj, void *class_data EINA_UNUSED) { Simple_Protected_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); - (void) list; printf("%s %d\n", __func__, pd->protected_x1); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODY(inherit_prot_print); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "Print protected var x1."), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_desc[] = { + EO2_OP_FUNC(_prot_print, inherit_prot_print, "Print protocted var x1."), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_desc), NULL, 0, - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/access/access_inherit.h b/src/tests/eo/access/access_inherit.h index f701dae484..0c1543698c 100644 --- a/src/tests/eo/access/access_inherit.h +++ b/src/tests/eo/access/access_inherit.h @@ -1,16 +1,7 @@ #ifndef INHERIT_H #define INHERIT_H -extern EAPI Eo_Op INHERIT_BASE_ID; - -enum { - INHERIT_SUB_ID_PROT_PRINT, - INHERIT_SUB_ID_LAST -}; - -#define INHERIT_ID(sub_id) (INHERIT_BASE_ID + sub_id) - -#define inherit_prot_print() INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT) +EAPI void inherit_prot_print(void); #define INHERIT_CLASS inherit_class_get() const Eo_Class *inherit_class_get(void); diff --git a/src/tests/eo/access/access_main.c b/src/tests/eo/access/access_main.c index 61cd381167..3f624f9acd 100644 --- a/src/tests/eo/access/access_main.c +++ b/src/tests/eo/access/access_main.c @@ -13,9 +13,9 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(INHERIT_CLASS, NULL); + Eo *obj = eo2_add(INHERIT_CLASS, NULL); - eo_do(obj, simple_a_set(1), inherit_prot_print()); + eo2_do(obj, simple_a_set(1), inherit_prot_print()); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); printf("Pub: %d\n", pd->public_x2); diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c index 42fa259e40..38fcf46563 100644 --- a/src/tests/eo/access/access_simple.c +++ b/src/tests/eo/access/access_simple.c @@ -6,8 +6,6 @@ #include "access_simple.h" #include "access_simple_protected.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - typedef struct { Simple_Protected_Data protected; @@ -20,34 +18,23 @@ EAPI const Eo_Event_Description _EV_A_CHANGED = #define MY_CLASS SIMPLE_CLASS static void -_a_set(Eo *obj, void *class_data, va_list *list) +_a_set(Eo *obj, void *class_data, int a) { Private_Data *pd = class_data; - int a; - a = va_arg(*list, int); pd->a = a; printf("%s %d\n", __func__, pd->a); pd->protected.protected_x1 = a + 1; pd->protected.public.public_x2 = a + 2; - eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL)); + eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_desc[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property A."), + EO2_OP_SENTINEL }; static const Eo_Event_Description *event_desc[] = { @@ -56,15 +43,15 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_desc), event_desc, sizeof(Private_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL) diff --git a/src/tests/eo/access/access_simple.h b/src/tests/eo/access/access_simple.h index 11624b7d20..31a11f6106 100644 --- a/src/tests/eo/access/access_simple.h +++ b/src/tests/eo/access/access_simple.h @@ -1,21 +1,12 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_LAST -}; - typedef struct { int public_x2; } Simple_Public_Data; -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) +EAPI void simple_a_set(int a); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) From feb5a5dc9e47f6c0d9efb667618ce2288efd966d Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 30 Jul 2013 17:22:26 +0100 Subject: [PATCH 052/169] eo2: fix backslash alignment. This is one of the reasons why I hate backslash alignments, you end up fixing style when you should be working on code. --- src/lib/eo/Eo.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 44e622eec5..20f30d5113 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -664,22 +664,22 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // to define a EAPI class function -#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ - Ret \ - Name(void) \ - { \ - typedef Ret (*__##Name##_func)(Eo_Class *); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet, Class) \ +#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ + Ret \ + Name(void) \ + { \ + typedef Ret (*__##Name##_func)(Eo_Class *); \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet, Class) \ } #define EO2_VOID_CLASS_FUNC_BODY(Name, Class) EO2_CLASS_FUNC_BODY(Name, void, , Class) -#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ - Ret \ - Name(__VA_ARGS__) \ - { \ - typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ +#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ + Ret \ + Name(__VA_ARGS__) \ + { \ + typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ } #define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, Class, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , Class, __VA_ARGS__) From 4f73887b4718f25734b9842ffa9393259b5ed906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 31 Jul 2013 09:59:15 +0200 Subject: [PATCH 053/169] eo2: remove EO2_OP_FUNC_VIRTUAL a pure virtual function is an EO2_OP_FUNC with NULL as private function implementation pointer --- src/lib/eo/Eo.h | 2 -- src/lib/eo/eo.c | 5 ----- 2 files changed, 7 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 20f30d5113..5446c5ce37 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -686,13 +686,11 @@ typedef struct _Eo2_Op_Call_Data // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) -#define EO2_OP_VIRTUAL ((Eo_Op) -2) #define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} #define EO2_OP_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} #define EO2_OP_CLASS_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} -#define EO2_OP_FUNC_VIRTUAL(_api, _doc) {NULL, _api, EO2_OP_VIRTUAL, EO_OP_TYPE_REGULAR, _doc} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 1a48d24bb0..57d0ad6468 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -573,11 +573,6 @@ _eo2_class_funcs_set(_Eo_Class *klass) op_desc->op = op_id; op_id++; } - else if (op_desc->op == EO2_OP_VIRTUAL) - { - op_desc->op = op_id; - op_id++; - } else if (op_desc->op == EO2_OP_OVERRIDE) { if (klass->parent == NULL) From 1db137fa8c5bb634fc0d7bf19fccf974dff91e53 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 31 Jul 2013 17:16:59 +0100 Subject: [PATCH 054/169] eo2: fixed EO2_CLASS_FUNC_BODY and etc. functions. --- src/lib/eo/Eo.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 5446c5ce37..9015b1b06e 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -634,9 +634,10 @@ typedef struct _Eo2_Op_Call_Data __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ -#define _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ +#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, Class); \ + if ( op == EO_NOOP ) \ + op = eo2_api_op_id_get((void*)Name, call.klass_id); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -664,25 +665,25 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // to define a EAPI class function -#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ +#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, Class) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet) \ } -#define EO2_VOID_CLASS_FUNC_BODY(Name, Class) EO2_CLASS_FUNC_BODY(Name, void, , Class) +#define EO2_VOID_CLASS_FUNC_BODY(Name) EO2_CLASS_FUNC_BODY(Name, void, ) -#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ +#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ Name(__VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \ } -#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, Class, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , Class, __VA_ARGS__) +#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) From 2bd03348e3e99b024ba1fbca1d84fec2481e9163 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 31 Jul 2013 17:20:40 +0100 Subject: [PATCH 055/169] eo2: revert "fixed EO2_CLASS_FUNC_BODY and etc. functions." Still need to change it to get call earlier. Oversight because of incomplete make files. This reverts commit 1ea966c3bef7384a91e386477dc07015ed18d33f. --- src/lib/eo/Eo.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 9015b1b06e..5446c5ce37 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -634,10 +634,9 @@ typedef struct _Eo2_Op_Call_Data __##Name##_func _func_ = (__##Name##_func) call.func; \ return Func; \ -#define _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \ +#define _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ static Eo_Op op = EO_NOOP; \ - if ( op == EO_NOOP ) \ - op = eo2_api_op_id_get((void*)Name, call.klass_id); \ + if ( op == EO_NOOP ) op = eo2_api_op_id_get((void*)Name, Class); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -665,25 +664,25 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // to define a EAPI class function -#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet) \ +#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ Ret \ Name(void) \ { \ typedef Ret (*__##Name##_func)(Eo_Class *); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet, Class) \ } -#define EO2_VOID_CLASS_FUNC_BODY(Name) EO2_CLASS_FUNC_BODY(Name, void, ) +#define EO2_VOID_CLASS_FUNC_BODY(Name, Class) EO2_CLASS_FUNC_BODY(Name, void, , Class) -#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ +#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ Ret \ Name(__VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ } -#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) +#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, Class, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , Class, __VA_ARGS__) // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) From 8959832be4b73fbb1aeb8358ed9440441f7c31fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 31 Jul 2013 23:37:06 +0200 Subject: [PATCH 056/169] eo2: fixed EO2_CLASS_FUNC_BODY and etc. functions. --- src/lib/eo/Eo.h | 22 ++++++++++++---------- src/lib/eo/eo.c | 27 +++++++++++++++++++++------ 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 5446c5ce37..293261bd13 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -628,15 +628,17 @@ typedef struct _Eo2_Op_Call_Data // 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, NULL); \ + if ( op == EO_NOOP ) \ + op = eo2_api_op_id_get((void*)Name, EO_OP_TYPE_REGULAR); \ 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, Class) \ +#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, Class); \ + if ( op == EO_NOOP ) \ + op = eo2_api_op_id_get((void*)Name, EO_OP_TYPE_CLASS); \ Eo2_Op_Call_Data call; \ if (!eo2_call_resolve(op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -664,25 +666,25 @@ typedef struct _Eo2_Op_Call_Data #define EO2_VOID_FUNC_BODYV(Name, Func, ...) EO2_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // to define a EAPI class function -#define EO2_CLASS_FUNC_BODY(Name, Ret, DefRet, Class) \ +#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, Class) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, _func_(call.klass_id), DefRet) \ } -#define EO2_VOID_CLASS_FUNC_BODY(Name, Class) EO2_CLASS_FUNC_BODY(Name, void, , Class) +#define EO2_VOID_CLASS_FUNC_BODY(Name) EO2_CLASS_FUNC_BODY(Name, void, ) -#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, Class, ...) \ +#define EO2_CLASS_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \ Ret \ Name(__VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ - _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet, Class) \ + _EO2_CLASS_FUNC_COMMON(Name, Ret, Func, DefRet) \ } -#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, Class, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , Class, __VA_ARGS__) +#define EO2_VOID_CLASS_FUNC_BODYV(Name, Func, ...) EO2_CLASS_FUNC_BODYV(Name, void, Func, , __VA_ARGS__) // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) @@ -694,7 +696,7 @@ typedef struct _Eo2_Op_Call_Data #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_api_op_id_get(void *api_func, const Eo_Class *klass); +EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); // gets the real function pointer and the object data #define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 57d0ad6468..b9af6e526e 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -487,7 +487,7 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data * static inline const Eo2_Op_Description * -_eo2_api_desc_get(void *api_func, const _Eo_Class *klass) +_eo2_api_desc_get(const void *api_func, const _Eo_Class *klass) { int imin, imax, imid; Eo2_Op_Description *op_desc; @@ -519,20 +519,35 @@ _eo2_api_desc_get(void *api_func, const _Eo_Class *klass) } EAPI Eo_Op -eo2_api_op_id_get(void *api_func, const Eo_Class *klass_id) +eo2_api_op_id_get(const void *api_func, const Eo_Op_Type op_type) { const Eo2_Op_Description *desc; const _Eo_Class *klass; - if (klass_id) - klass = _eo_class_pointer_get(klass_id); - else + if (op_type == EO_OP_TYPE_REGULAR) klass = eo2_call_stack.frame_ptr->obj->klass; + else if (op_type == EO_OP_TYPE_CLASS) + klass = eo2_call_stack.frame_ptr->klass; + else + { + ERR("api func %p, unknown op type %d", api_func, op_type); + return EO_NOOP; + } desc = _eo2_api_desc_get(api_func, klass); if (desc == NULL) - return EO_NOOP; + { + ERR("unable to resolve api func %p, op type %d", api_func,op_type); + return EO_NOOP; + } + + if (desc->op_type != op_type) + { + ERR("api func %p resolves to %d, op type %d instead of %d", + api_func, (int) desc->op, desc->op_type, op_type); + return EO_NOOP; + } return desc->op; } From ebc90200a69a4afebc9b7ecf022289cda76eb734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 16:33:18 +0100 Subject: [PATCH 057/169] eo2: sprinkle with 'const' --- src/lib/eo/Eo.h | 6 +++--- src/lib/eo/eo.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 293261bd13..c2dfe3178b 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -700,11 +700,11 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); // gets the real function pointer and the object data #define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) -EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op_Call_Data *call); +EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); -EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, Eina_Bool do_super); +EAPI Eina_Bool eo2_do_start(Eo *obj_id, const Eina_Bool do_super); +EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(Eo **ojb); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index b9af6e526e..8e1b1f1e84 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -308,7 +308,7 @@ eo2_call_stack_depth() } EAPI Eina_Bool -eo2_do_start(Eo *obj_id, Eina_Bool do_super) +eo2_do_start(Eo *obj_id, const Eina_Bool do_super) { _Eo * obj; const _Eo_Class *klass; @@ -354,7 +354,7 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super) } EAPI Eina_Bool -eo2_class_do_start(const Eo_Class *klass_id, Eina_Bool do_super EINA_UNUSED) +eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super) { Eo2_Stack_Frame *fptr; const _Eo_Class *klass; @@ -394,7 +394,7 @@ eo2_class_do_start(const Eo_Class *klass_id, Eina_Bool do_super EINA_UNUSED) } static inline void -_eo2_do_end(Eina_Bool obj_do) +_eo2_do_end(const Eina_Bool obj_do) { Eo2_Stack_Frame *fptr; @@ -427,7 +427,7 @@ eo2_class_do_end(const Eo_Class **klass_id EINA_UNUSED) } EAPI Eina_Bool -eo2_call_resolve_internal(const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) +eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; const _Eo * obj; From bbab74320a9c0e44c11b706f9e0c89b79cba733c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 1 Aug 2013 09:47:21 +0200 Subject: [PATCH 058/169] eo2: fix eo2 custom constructors --- src/lib/eo/Eo.h | 20 ++++++++++++++++- src/lib/eo/eo.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index c2dfe3178b..77ec6a741f 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -874,7 +874,13 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ + Eo *_tmp_obj = eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + eo2_do(_tmp_obj, \ + eo2_constructor(); \ + __VA_ARGS__; \ + _tmp_obj = eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + ); \ + _tmp_obj; \ }) /** @@ -892,6 +898,16 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); const Eo_Class *_tmp_klass = klass; \ eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ }) +#define eo2_add_custom(klass, parent, ...) \ + ({ \ + const Eo_Class *_tmp_klass = klass; \ + Eo *_tmp_obj = eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + eo2_do(_tmp_obj, \ + __VA_ARGS__; \ + _tmp_obj = eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + ); \ + _tmp_obj; \ + }) /** * @brief Create a new object. @@ -906,6 +922,8 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * @see #eo_add */ EAPI Eo *eo_add_internal(const char *file, int line, const Eo_Class *klass, Eo *parent, ...); +EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id); +EAPI Eo * eo2_add_internal_end(const char *file, int line, const Eo *obj); /** * @brief Get a pointer to the data of an object for a specific class. diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8e1b1f1e84..8ff4912209 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -449,7 +449,6 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ return EINA_FALSE; } - func = _dich_func_get(klass, op); if (EINA_LIKELY(func != NULL)) { @@ -614,6 +613,64 @@ _eo2_class_funcs_set(_Eo_Class *klass) } } +EAPI Eo * +eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) +{ + _Eo_Class *klass = _eo_class_pointer_get(klass_id); + EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, NULL); + + if (parent_id) + { + EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, NULL); + } + + if (EINA_UNLIKELY(klass->desc->type != EO_CLASS_TYPE_REGULAR)) + { + ERR("in %s:%d: Class '%s' is not instantiate-able. Aborting.", file, line, klass->desc->name); + return NULL; + } + + _Eo *obj = calloc(1, klass->obj_size); + obj->refcount++; + obj->klass = klass; + +#ifndef HAVE_EO_ID + EINA_MAGIC_SET(obj, EO_EINA_MAGIC); +#endif + Eo_Id obj_id = _eo_id_allocate(obj); + obj->obj_id = obj_id; + eo_parent_set((Eo *)obj_id, parent_id); + + _eo_condtor_reset(obj); + + return (Eo *)obj_id; +} + +EAPI Eo * +eo2_add_internal_end(const char *file, int line, const Eo *obj_id) +{ + Eo2_Stack_Frame *fptr; + + fptr = eo2_call_stack.frame_ptr; + + if ((fptr == NULL) || (fptr->obj_id != obj_id)) + { + ERR("in %s:%d - Something very wrong happend to the call stack.", file, line); + return NULL; + } + + if (!fptr->obj->condtor_done) + { + ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", + file, line, fptr->klass->desc->name); + /* for the for the basic object ref. */ + _eo_unref(fptr->obj); + return NULL; + } + + return (Eo *)fptr->obj_id; +} + /*****************************************************************************/ #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \ From 4b975916346e0ee5b9d2399524e7420bf0dbba1c Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Thu, 1 Aug 2013 18:49:27 +0900 Subject: [PATCH 059/169] 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. --- src/lib/eo/Eo.h | 135 ++++++++++++++++++++++++++++-------- src/lib/eo/eo.c | 9 +++ src/lib/eo/eo2_base_class.c | 2 +- 3 files changed, 115 insertions(+), 31 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 77ec6a741f..6edc79baa1 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -621,28 +621,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) \ +#define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \ + Eo2_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) \ - op = eo2_api_op_id_get((void*)Name, EO_OP_TYPE_REGULAR); \ - 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; \ - -#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; \ - 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) \ @@ -650,41 +659,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) @@ -720,48 +787,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 8ff4912209..04c3aeeb1a 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -257,6 +257,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) { @@ -350,6 +357,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); From 7477a514320f47a80f855ccdbd6813ad3c281ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 1 Aug 2013 15:41:12 +0200 Subject: [PATCH 060/169] eo2: add EO2_HOOK_DO_PREPARE --- src/lib/eo/Eo.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 6edc79baa1..8bd3fd9a22 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -644,6 +644,10 @@ EAPI extern Eo2_Hook_Class_Do eo2_hook_class_do_post; if (Hook) \ Hook(call.klass_id, call.obj_id, call.func, __VA_ARGS__); +#define EO2_HOOK_DO_PREPARE(Hook, Var) \ + if (Hook) \ + Hook(__FILE__, __FUNCTION__, __LINE__, Var); + // cache OP id, get real fct and object data then do the call #define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \ Eo2_Op_Call_Data call; \ @@ -695,7 +699,7 @@ EAPI extern Eo2_Hook_Class_Do eo2_hook_class_do_post; void \ Name(__VA_ARGS__) \ { \ - typedef void (*__##Name##_func)(Eo *, void *obj_data, __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); \ @@ -787,56 +791,56 @@ EAPI int eo2_call_stack_depth(); do \ { \ Eo *_objid_ = objid; \ - if (eo2_hook_do_pre) eo2_hook_do_pre(__FILE__, __FUNCTION__, __LINE__, _objid_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_do_pre, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_do_post, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_do_pre, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_do_post, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_class_do_pre, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_class_do_post, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_class_do_pre, _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_); \ + EO2_HOOK_DO_PREPARE(eo2_hook_class_do_post, _clsid_); \ } while (0) /*****************************************************************************/ From 0b279b600e2937c9d69387a7c3df66417c20a0cf Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Mon, 5 Aug 2013 12:05:49 +0900 Subject: [PATCH 061/169] eo2: we can rely on LD_PRELOAD for those hook, so removing them. --- src/lib/eo/Eo.h | 30 ++++++------------------------ src/lib/eo/eo.c | 8 ++------ 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 8bd3fd9a22..fbda48971c 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -622,15 +622,9 @@ typedef struct _Eo2_Op_Call_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(...) __VA_ARGS__ @@ -644,10 +638,6 @@ EAPI extern Eo2_Hook_Class_Do eo2_hook_class_do_post; if (Hook) \ Hook(call.klass_id, call.obj_id, call.func, __VA_ARGS__); -#define EO2_HOOK_DO_PREPARE(Hook, Var) \ - if (Hook) \ - Hook(__FILE__, __FUNCTION__, __LINE__, Var); - // cache OP id, get real fct and object data then do the call #define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \ Eo2_Op_Call_Data call; \ @@ -774,8 +764,8 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj_id, const Eina_Bool do_super); -EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super); +EAPI Eina_Bool eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file, const char *func, int line); +EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(Eo **ojb); @@ -791,56 +781,48 @@ EAPI int eo2_call_stack_depth(); do \ { \ Eo *_objid_ = objid; \ - EO2_HOOK_DO_PREPARE(eo2_hook_do_pre, _objid_); \ - if (eo2_do_start(_objid_, EINA_FALSE)) \ + if (eo2_do_start(_objid_, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__)) \ { \ Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ __VA_ARGS__; \ (void) _id_clean_; \ } \ - EO2_HOOK_DO_PREPARE(eo2_hook_do_post, _objid_);\ } while (0) #define eo2_do_super(objid, ...) \ do \ { \ Eo *_objid_ = objid; \ - EO2_HOOK_DO_PREPARE(eo2_hook_do_pre, _objid_); \ - if (eo2_do_start(_objid_, EINA_TRUE)) \ + if (eo2_do_start(_objid_, EINA_TRUE, __FILE__, __FUNCTION__, __LINE__)) \ { \ Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ __VA_ARGS__; \ (void) _id_clean_; \ } \ - EO2_HOOK_DO_PREPARE(eo2_hook_do_post, _objid_);\ } while (0) #define eo2_class_do(clsid, ...) \ do \ { \ const Eo_Class *_clsid_ = clsid; \ - EO2_HOOK_DO_PREPARE(eo2_hook_class_do_pre, _clsid_); \ - if (eo2_class_do_start(_clsid_, EINA_FALSE)) \ + if (eo2_class_do_start(_clsid_, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__)) \ { \ const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ __VA_ARGS__; \ (void) _id_clean_; \ } \ - EO2_HOOK_DO_PREPARE(eo2_hook_class_do_post, _clsid_); \ } while (0) #define eo2_class_super_do(clsid, ...) \ do \ { \ const Eo_Class *_clsid_ = clsid; \ - EO2_HOOK_DO_PREPARE(eo2_hook_class_do_pre, _clsid_); \ - if (eo2_class_do_start(_clsid_, EINA_TRUE)) \ + if (eo2_class_do_start(_clsid_, EINA_TRUE, __FILE__, __FUNCTION__, __LINE__)) \ { \ const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ __VA_ARGS__; \ (void) _id_clean_; \ } \ - EO2_HOOK_DO_PREPARE(eo2_hook_class_do_post, _clsid_); \ } while (0) /*****************************************************************************/ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 04c3aeeb1a..e6928e7ded 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -259,10 +259,6 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) 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) @@ -315,7 +311,7 @@ eo2_call_stack_depth() } EAPI Eina_Bool -eo2_do_start(Eo *obj_id, const Eina_Bool do_super) +eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { _Eo * obj; const _Eo_Class *klass; @@ -363,7 +359,7 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super) } EAPI Eina_Bool -eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super) +eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { Eo2_Stack_Frame *fptr; const _Eo_Class *klass; From 8613ebe403bbb6eb63826daf755fa8e82731570d Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Mon, 5 Aug 2013 15:13:21 +0900 Subject: [PATCH 062/169] eo2: memset will be faster, still why not using NULL instead of -1 ? --- src/lib/eo/eo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index e6928e7ded..270573843c 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -408,9 +408,7 @@ _eo2_do_end(const Eina_Bool obj_do) if(obj_do) _eo_unref(fptr->obj); - fptr->obj = NULL; - fptr->obj_id = NULL; - fptr->klass = NULL; + memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; if (fptr == &eo2_call_stack.stack[0]) From fe23e26d0e64832175504b02c57fa04c0b92687d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 14 Aug 2013 13:46:06 +0200 Subject: [PATCH 063/169] eo2: add DBG msg in eo2_class_funcs_set --- src/lib/eo/eo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 270573843c..2285106c41 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -353,8 +353,6 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, fptr->klass = klass; fptr->obj_data = EO2_INVALID_DATA; - - return EINA_TRUE; } @@ -578,7 +576,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); op_id = klass->base_id; - /* printf("elaborate class '%s' \n", klass->desc->name); */ + DBG("Set functions for class '%s'", klass->desc->name); for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if(op_desc->api_func == NULL) @@ -611,7 +609,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) klass->desc->name, (unsigned long) (op_desc - op_descs)); } - /* printf(" %d %p %p %s\n", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); */ + DBG(" %4d %p %p %s", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); _dich_func_set(klass, op_desc->op, op_desc->func); } } From 94adc97efedc320d4e709335758537ba70c74d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 14 Aug 2013 13:46:49 +0200 Subject: [PATCH 064/169] eo2: rename eo2 class 'Eo Base'->'Eo2 Base' --- src/lib/eo/eo2_base_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 676540b90d..7848d2b7c8 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -811,7 +811,7 @@ static const Eo_Event_Description *event_desc[] = { static const Eo_Class_Description class_desc = { EO2_VERSION, - "Eo Base", + "Eo2 Base", EO_CLASS_TYPE_REGULAR_NO_INSTANT, EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, From 2af0764eeb00fa1a7f26d3e7f4500b1c86bc6fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 14 Aug 2013 13:48:54 +0200 Subject: [PATCH 065/169] eo2: _eo2_api_desc_get: walks in mro not in klass->parent --- src/lib/eo/eo.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 2285106c41..71fdbb1c19 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -490,14 +490,18 @@ static inline const Eo2_Op_Description * _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass) { int imin, imax, imid; + const _Eo_Class *cur_klass; + const _Eo_Class **kls_itr = NULL; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; - while (klass) + kls_itr = klass->mro; + while (*kls_itr) { + cur_klass = *kls_itr; imin = 0; - imax = klass->desc->ops.count - 1; - op_descs = klass->desc->ops.descs2; + imax = cur_klass->desc->ops.count - 1; + op_descs = cur_klass->desc->ops.descs2; while (imax >= imin) { @@ -512,7 +516,7 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass) return op_desc; } - klass = klass->parent; + kls_itr++; } return NULL; From 74f7bf363396f6cb6a11c46fcf69e7424a908ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 1 Sep 2013 23:48:57 +0200 Subject: [PATCH 066/169] eo2: eo2_call_resolve_internal support undef HAVE_EO_ID --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 71fdbb1c19..7b9e117679 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -458,7 +458,7 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ ERR("you called a pure virtual func"); return EINA_FALSE; } - call->klass_id = (Eo_Class *) klass->class_id; + call->klass_id = _eo_class_id_get(klass); call->obj_id = fptr->obj_id; call->func = func->func; From 3a86881941fc2885a54ed9c656495ff22bf97014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 6 Sep 2013 11:38:25 +0200 Subject: [PATCH 067/169] eo2: eo2_do_start use EO_OBJ_POINTER_ macros not _eo_obj_pointer_get --- src/lib/eo/eo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7b9e117679..cd145aa4f1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -329,7 +329,8 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, } else { - obj = _eo_obj_pointer_get((Eo_Id)obj_id); + EO_OBJ_POINTER_RETURN_VAL(obj_id, _obj, EINA_FALSE); + obj = _obj; if (!obj) return EINA_FALSE; if (do_super) klass = _eo2_kls_itr_next(obj->klass, obj->klass); From 796b151c27ee5c474e3f7c159e04f21f7b5e2ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 20:42:18 +0100 Subject: [PATCH 068/169] eo2: minor fixes after huge rebase indentation use _Eo_Object * instead of _Eo * use EO_CLASS_POINTER_RETURN_VAL(), _eo_id_get(), and _eo_class_id_get(). --- src/lib/eo/Eo.h | 4 ++-- src/lib/eo/eo.c | 41 +++++++++++++++++++++++------------------ src/lib/eo/eo_private.h | 10 ++++------ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index fbda48971c..95a8f870f8 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1457,7 +1457,7 @@ eo2_wref_del(Eo **wref); #define eo2_weak_ref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_add(wref)); \ - } while (0); + } while (0) /** * @def eo_weak_unref @@ -1479,7 +1479,7 @@ eo2_wref_del(Eo **wref); #define eo2_weak_unref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_del(wref)); \ - } while (0); + } while (0) /** * @def eo_wref_del_safe diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index cd145aa4f1..76afc042fc 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -268,10 +268,10 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) /* Find the kls itr. */ kls_itr = orig_kls->mro; while (*kls_itr && (*kls_itr != cur_klass)) - kls_itr++; + kls_itr++; if (*kls_itr) - return *(++kls_itr); + return *(++kls_itr); return NULL; } @@ -281,8 +281,8 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) #define EO2_CALL_STACK_DEPTH 5 typedef struct _Eo2_Stack_Frame { - Eo *obj_id; - _Eo *obj; + Eo *obj_id; + _Eo_Object *obj; const _Eo_Class *klass; void *obj_data; @@ -306,14 +306,16 @@ static Eo2_Call_Stack eo2_call_stack = { EAPI int eo2_call_stack_depth() { - return ((eo2_call_stack.frame_ptr == NULL) ? 0 : - 1 + (eo2_call_stack.frame_ptr - eo2_call_stack.stack)); + if (eo2_call_stack.frame_ptr == NULL) + return 0; + else + return (1 + (eo2_call_stack.frame_ptr - eo2_call_stack.stack)); } EAPI Eina_Bool eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { - _Eo * obj; + _Eo_Object * obj; const _Eo_Class *klass; Eo2_Stack_Frame *fptr; @@ -363,8 +365,10 @@ eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const cha Eo2_Stack_Frame *fptr; const _Eo_Class *klass; + klass = NULL; fptr = eo2_call_stack.frame_ptr; - if ((fptr != NULL) && (fptr->klass->class_id == (Eo_Class_Id) klass_id)) + + if ((fptr != NULL) && (_eo_class_id_get(fptr->klass) == (Eo *)klass_id)) { if (do_super) klass = _eo2_kls_itr_next(fptr->klass, fptr->klass); @@ -374,10 +378,11 @@ eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const cha } else { - klass = _eo_class_pointer_get(klass_id); - EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); + EO_CLASS_POINTER_RETURN_VAL(klass_id, _klass, EINA_FALSE); if (do_super) - klass = _eo2_kls_itr_next(klass, klass); + klass = _eo2_kls_itr_next(_klass, _klass); + else + klass = _klass; if (fptr == NULL) eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; else @@ -432,17 +437,18 @@ EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; - const _Eo * obj; + const _Eo_Object * obj; const _Eo_Class *klass; const op_type_funcs *func; fptr = eo2_call_stack.frame_ptr; obj = fptr->obj; + klass = NULL; if (klass_id) { - klass = _eo_class_pointer_get(klass_id); - EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); + EO_CLASS_POINTER_RETURN_VAL(klass_id, _klass, EINA_FALSE); + klass = _klass; } else { @@ -622,8 +628,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) { - _Eo_Class *klass = _eo_class_pointer_get(klass_id); - EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, NULL); + EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, NULL); if (parent_id) { @@ -636,7 +641,7 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo return NULL; } - _Eo *obj = calloc(1, klass->obj_size); + _Eo_Object *obj = calloc(1, klass->obj_size); obj->refcount++; obj->klass = klass; @@ -644,7 +649,7 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo EINA_MAGIC_SET(obj, EO_EINA_MAGIC); #endif Eo_Id obj_id = _eo_id_allocate(obj); - obj->obj_id = obj_id; + obj->header.id = obj_id; eo_parent_set((Eo *)obj_id, parent_id); _eo_condtor_reset(obj); diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 614483f9b8..96d14aac78 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -212,14 +212,12 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) /* We need that for the event callbacks that may ref/unref. */ obj->refcount++; - eo_do(_eo_id_get(obj), eo_event_callback_call(EO_EV_DEL, NULL, NULL)); - const _Eo_Class *klass = obj->klass; if (klass->desc->version == EO2_VERSION) - eo2_do((Eo *)obj->obj_id, eo2_event_callback_call(EO_EV_DEL, NULL);); + eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); else - eo_do((Eo *) obj->obj_id, eo_event_callback_call(EO_EV_DEL, NULL, NULL)); + eo_do(_eo_id_get(obj), eo_event_callback_call(EO_EV_DEL, NULL, NULL)); _eo_condtor_reset(obj); @@ -227,10 +225,10 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) { // FIXME: eo2 do_err = EINA_FALSE; - eo2_do((Eo *)obj->obj_id, eo2_destructor();); + eo2_do(_eo_id_get(obj), eo2_destructor();); } else - do_err = !eo_do((Eo *)obj->obj_id, eo_destructor()); + do_err = !eo_do(_eo_id_get(obj), eo_destructor()); if (EINA_UNLIKELY(do_err)) { From f1e65820520a026703792d2358e659f62deba77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 20:56:59 +0100 Subject: [PATCH 069/169] eo2: import cecd1980, calloc and realloc failure protections --- src/lib/eo/eo2_base_class.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 7848d2b7c8..9a96bb94f9 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -68,6 +68,7 @@ _data_set(Eo *obj, void *class_data, eo2_do(obj, eo2_base_data_del(key); ); node = malloc(sizeof(Eo_Generic_Data_Node)); + if (!node) return; node->key = eina_stringshare_add(key); node->data = (void *) data; node->free_func = free_func; @@ -149,11 +150,14 @@ _wref_add(Eo *obj, void *class_data, Eo **wref) { Private_Data *pd = (Private_Data *) class_data; size_t count; + Eo ***tmp; count = _wref_count(pd); count += 1; /* New wref. */ - pd->wrefs= realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1)); + tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1)); + if (!tmp) return; + pd->wrefs = tmp; pd->wrefs[count - 1] = wref; pd->wrefs[count] = NULL; @@ -205,8 +209,11 @@ _wref_del(Eo *obj, void *class_data, Eo **wref) if (count > 1) { + Eo ***tmp; // No count--; because of the NULL that is not included in the count. */ - pd->wrefs = realloc(pd->wrefs, sizeof(*pd->wrefs) * count); + tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * count); + if (!tmp) return; + pd->wrefs = tmp; pd->wrefs[count - 1] = NULL; } else @@ -359,6 +366,7 @@ _ev_cb_priority_add(Eo *obj, void *class_data, Private_Data *pd = (Private_Data *) class_data; cb = calloc(1, sizeof(*cb)); + if (!cb) return; cb->items.item.desc = desc; cb->items.item.func = func; cb->func_data = (void *) user_data; @@ -419,6 +427,7 @@ _ev_cb_array_priority_add(Eo *obj, void *class_data, Private_Data *pd = (Private_Data *) class_data; cb = calloc(1, sizeof(*cb)); + if (!cb) return; cb->func_data = (void *) user_data; cb->priority = priority; cb->items.item_array = array; @@ -670,7 +679,9 @@ _eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, voi { const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src; Eo_Dbg_Info **dst = _dst; + *dst = calloc(1, sizeof(Eo_Dbg_Info)); + if (!*dst) return EINA_FALSE; (*dst)->name = eina_stringshare_ref((*src)->name); eina_value_copy(&((*src)->value), &((*dst)->value)); return EINA_TRUE; From d4aad6bfc08a26b116e1fdac6e68e94b50a3220a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 21:00:23 +0100 Subject: [PATCH 070/169] eo2: formatting --- src/lib/eo/eo2_base_class.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 9a96bb94f9..68bdb531d3 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -139,7 +139,7 @@ _wref_count(Private_Data *pd) return 0; Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) + for (itr = pd->wrefs; *itr; itr++) count++; return count; @@ -190,7 +190,7 @@ _wref_del(Eo *obj, void *class_data, Eo **wref) { Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) + for (itr = pd->wrefs; *itr; itr++) { if (*itr == wref) { @@ -233,7 +233,7 @@ _wref_destruct(Private_Data *pd) if (!pd->wrefs) return; - for (itr = pd->wrefs ; *itr ; itr++) + for (itr = pd->wrefs; *itr; itr++) { **itr = NULL; } @@ -274,7 +274,7 @@ _eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) if (pd->callbacks == cb) pd->callbacks = cb->next; - for ( ; itr ; ) + for ( ; itr; ) { Eo_Callback_Description *titr = itr; itr = itr->next; @@ -321,7 +321,7 @@ _eo_callbacks_clear(Private_Data *pd) pd->deletions_waiting = EINA_FALSE; - for (cb = pd->callbacks ; cb ; ) + for (cb = pd->callbacks; cb; ) { Eo_Callback_Description *titr = cb; cb = cb->next; @@ -337,7 +337,7 @@ static void _eo_callbacks_sorted_insert(Private_Data *pd, Eo_Callback_Description *cb) { Eo_Callback_Description *itr, *itrp = NULL; - for (itr = pd->callbacks ; itr && (itr->priority < cb->priority) ; + for (itr = pd->callbacks; itr && (itr->priority < cb->priority); itr = itr->next) { itrp = itr; @@ -394,7 +394,7 @@ _ev_cb_del(Eo *obj, void *class_data, Eo_Callback_Description *cb; Private_Data *pd = (Private_Data *) class_data; - for (cb = pd->callbacks ; cb ; cb = cb->next) + for (cb = pd->callbacks; cb; cb = cb->next) { if ((cb->items.item.desc == desc) && (cb->items.item.func == func) && (cb->func_data == user_data)) @@ -452,7 +452,7 @@ _ev_cb_array_del(Eo *obj, void *class_data, Eo_Callback_Description *cb; Private_Data *pd = (Private_Data *) class_data; - for (cb = pd->callbacks ; cb ; cb = cb->next) + for (cb = pd->callbacks; cb; cb = cb->next) { if ((cb->items.item_array == array) && (cb->func_data == user_data)) { @@ -488,7 +488,7 @@ _ev_cb_call(Eo *obj_id, void *class_data, _eo_ref(obj); pd->walking_list++; - for (cb = pd->callbacks ; cb ; cb = cb->next) + for (cb = pd->callbacks; cb; cb = cb->next) { if (!cb->delete_me) { @@ -496,7 +496,7 @@ _ev_cb_call(Eo *obj_id, void *class_data, { const Eo_Callback_Array_Item *it; - for (it = cb->items.item_array ; it->func ; it++) + for (it = cb->items.item_array; it->func; it++) { if (it->desc != desc) continue; From c9ccc700fdedb6549586e5add35331f9fff51cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 21:11:48 +0100 Subject: [PATCH 071/169] eo2: add eo2_parent_set(), eo2_parent_get(), eo2_children_iterator_new() imported from eo_base_class.c as is in a7f417e 2013-12-24 23:45:30 +0900 --- src/lib/eo/Eo.h | 6 ++ src/lib/eo/eo.c | 9 +- src/lib/eo/eo2_base_class.c | 165 ++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 95a8f870f8..2de0ad7312 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1391,6 +1391,8 @@ eo2_base_data_del(const char *key); * @see eo_parent_get() */ #define eo_parent_set(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), EO_TYPECHECK(Eo *, parent) +EAPI void +eo2_parent_set(Eo *parent_id); /** * @def eo_parent_get @@ -1400,6 +1402,8 @@ eo2_base_data_del(const char *key); * @see eo_parent_set() */ #define eo_parent_get(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), EO_TYPECHECK(Eo **, parent) +EAPI Eo * +eo2_parent_get(); /** * @def eo_children_iterator_new @@ -1410,6 +1414,8 @@ eo2_base_data_del(const char *key); * @see eo_parent_set() */ #define eo_children_iterator_new(it) EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), EO_TYPECHECK(Eina_Iterator **, it) +EAPI Eina_Iterator * +eo2_children_iterator_new(); /** * @def eo_wref_add diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 76afc042fc..ec11fa4a11 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -650,10 +650,11 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo #endif Eo_Id obj_id = _eo_id_allocate(obj); obj->header.id = obj_id; - eo_parent_set((Eo *)obj_id, parent_id); _eo_condtor_reset(obj); + eo2_do((Eo *)obj_id, eo2_parent_set(parent_id)); + return (Eo *)obj_id; } @@ -1655,7 +1656,11 @@ eo_unref(const Eo *obj_id) EAPI void eo_del(const Eo *obj) { - eo_do((Eo *) obj, eo_parent_set(NULL)); + EO_OBJ_POINTER_RETURN(obj, _obj); + if (_obj->klass->desc->version == EO2_VERSION) + eo2_do((Eo *) obj, eo2_parent_set(NULL)); + else + eo_do((Eo *) obj, eo_parent_set(NULL)); eo_unref(obj); } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 68bdb531d3..1cbccef360 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -14,6 +14,9 @@ typedef struct _Eo_Callback_Description Eo_Callback_Description; typedef struct { + Eina_List *children; + Eo *parent; + Eina_Inlist *generic_data; Eo ***wrefs; @@ -101,6 +104,165 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) } EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_get, EO2_FUNC_CALL(key), const char *key); +static void +_parent_set(Eo *obj, void *class_data, Eo *parent_id) +{ + Private_Data *pd = (Private_Data *) class_data; + + if (pd->parent == parent_id) + return; + + if (eo_composite_is(obj) && pd->parent) + { + eo_composite_detach(obj, pd->parent); + } + + if (pd->parent) + { + Private_Data *old_parent_pd; + + old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); + if (old_parent_pd) + { + old_parent_pd->children = eina_list_remove(old_parent_pd->children, + obj); + } + else + { + ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.", + pd->parent, obj); + } + + eo_xunref(obj, pd->parent); + } + + /* Set new parent */ + if (parent_id) + { + Private_Data *parent_pd = NULL; + parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); + + if (EINA_LIKELY(parent_pd != NULL)) + { + pd->parent = parent_id; + parent_pd->children = eina_list_append(parent_pd->children, + obj); + eo_xref(obj, pd->parent); + } + else + { + pd->parent = NULL; + ERR("New parent %p for object %p is not a valid Eo object.", + parent_id, obj); + } + } + else + { + pd->parent = NULL; + } +} +EAPI EO2_VOID_FUNC_BODYV(eo2_parent_set, EO2_FUNC_CALL(parent_id), Eo *parent_id); + +static Eo * +_parent_get(Eo *obj EINA_UNUSED, void *class_data) +{ + Private_Data *pd = (Private_Data *) class_data; + + return pd->parent; +} +EAPI EO2_FUNC_BODY(eo2_parent_get, Eo *, NULL); + +/* Children accessor */ +typedef struct _Eo_Children_Iterator Eo_Children_Iterator; +struct _Eo_Children_Iterator +{ + Eina_Iterator iterator; + Eina_List *current; + _Eo_Object *obj; + Eo *obj_id; +}; + +static Eina_Bool +_eo_children_iterator_next(Eo_Children_Iterator *it, void **data) +{ + if (!it->current) return EINA_FALSE; + + if (data) *data = eina_list_data_get(it->current); + it->current = eina_list_next(it->current); + + return EINA_TRUE; +} + +static Eo * +_eo_children_iterator_container(Eo_Children_Iterator *it) +{ + return it->obj_id; +} + +static void +_eo_children_iterator_free(Eo_Children_Iterator *it) +{ + _Eo_Class *klass; + _Eo_Object *obj; + + klass = (_Eo_Class*) it->obj->klass; + obj = it->obj; + + eina_spinlock_take(&klass->iterators.trash_lock); + if (klass->iterators.trash_count < 8) + { + klass->iterators.trash_count++; + eina_trash_push(&klass->iterators.trash, it); + } + else + { + free(it); + } + eina_spinlock_release(&klass->iterators.trash_lock); + + _eo_unref(obj); +} + +static Eina_Iterator * +_children_iterator_new(Eo *obj_id, void *class_data) +{ + Private_Data *pd = class_data; + _Eo_Class *klass; + Eo_Children_Iterator *it; + + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + + if (!pd->children) return NULL; + + klass = (_Eo_Class *) obj->klass; + + eina_spinlock_take(&klass->iterators.trash_lock); + it = eina_trash_pop(&klass->iterators.trash); + if (it) + { + klass->iterators.trash_count--; + memset(it, 0, sizeof (Eo_Children_Iterator)); + } + else + { + it = calloc(1, sizeof (Eo_Children_Iterator)); + } + eina_spinlock_release(&klass->iterators.trash_lock); + if (!it) return NULL; + + EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); + it->current = obj->children; + it->obj = _eo_ref(obj); + it->obj_id = obj_id; + + it->iterator.next = FUNC_ITERATOR_NEXT(_eo_children_iterator_next); + it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eo_children_iterator_container); + it->iterator.free = FUNC_ITERATOR_FREE(_eo_children_iterator_free); + + return (Eina_Iterator *)it; +} +EAPI EO2_FUNC_BODY(eo2_children_iterator_new, Eina_Iterator *, NULL); + static void _dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo_Dbg_Info *root_node EINA_UNUSED) { /* No info required in the meantime */ @@ -790,6 +952,9 @@ _class_constructor(Eo_Class *klass EINA_UNUSED) Eo2_Op_Description op_descs [] = { EO2_OP_FUNC(_constructor, eo2_constructor, "Constructor."), EO2_OP_FUNC(_destructor, eo2_destructor, "Destructor."), + EO2_OP_FUNC(_parent_set, eo2_parent_set, "Set parent."), + EO2_OP_FUNC(_parent_get, eo2_parent_get, "Get parent."), + EO2_OP_FUNC(_children_iterator_new, eo2_children_iterator_new, "Get Children Iterator."), EO2_OP_FUNC(_data_set, eo2_base_data_set, "Set data for key."), EO2_OP_FUNC(_data_get, eo2_base_data_get, "Get data for key."), EO2_OP_FUNC(_data_del, eo2_base_data_del, "Del key."), From 2be91e465a9b7700e53cf37f5c48b09ab5366a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 23:46:50 +0100 Subject: [PATCH 072/169] eo2: change a few variable names in the EPAI, don't show that Eo* could be IDs. in the implementation, use klass_id and obj_id if you know or want it to be a class or an object, use eo_id in general cases. --- src/lib/eo/Eo.h | 36 +++++++++---------- src/lib/eo/eo.c | 92 ++++++++++++++++++++++++------------------------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 2de0ad7312..6d5c506845 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -615,13 +615,13 @@ EAPI Eina_Bool eo_shutdown(void); // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data { - Eo *obj_id; - Eo_Class *klass_id; + Eo *obj; + Eo_Class *klass; void *func; 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_Call)(const Eo_Class *klass_id, const Eo *obj, void *func, ...); EAPI extern Eo2_Hook_Call eo2_hook_call_pre; EAPI extern Eo2_Hook_Call eo2_hook_call_post; @@ -632,11 +632,11 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; #define EO2_HOOK_CALL_PREPARE(Hook) \ if (Hook) \ - Hook(call.klass_id, call.obj_id, call.func); + Hook(call.klass, call.obj, call.func); #define EO2_HOOK_CALL_PREPAREV(Hook, ...) \ if (Hook) \ - Hook(call.klass_id, call.obj_id, call.func, __VA_ARGS__); + Hook(call.klass, call.obj, call.func, __VA_ARGS__); // cache OP id, get real fct and object data then do the call #define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \ @@ -653,10 +653,10 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Name(void) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ - Ret _r; \ + 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); \ + _r = _func_(call.obj, call.data); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ return _r; \ } @@ -668,7 +668,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; 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); \ + _func_(call.obj, call.data); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ } @@ -677,10 +677,10 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Name(__VA_ARGS__) \ { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - Ret _r; \ + 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); \ + _r = _func_(call.obj, call.data, Arguments); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ return _r; \ } @@ -692,7 +692,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; 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); \ + _func_(call.obj, call.data, Arguments); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ } @@ -705,7 +705,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; 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); \ + _r = _func_(call.klass); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ return _r; \ } @@ -718,7 +718,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Ret _r; \ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_CLASS); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ - _func_(call.klass_id); \ + _func_(call.klass); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ return _r; \ } @@ -731,7 +731,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; 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); \ + _r = _func_(call.klass, Arguments); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ return _r; \ } @@ -743,7 +743,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; 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); \ + _func_(call.klass, Arguments); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ } @@ -764,7 +764,7 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file, const char *func, int line); +EAPI Eina_Bool eo2_do_start(Eo *obj, const Eina_Bool do_super, const char *file, const char *func, int line); EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer @@ -983,7 +983,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * @see #eo_add */ EAPI Eo *eo_add_internal(const char *file, int line, const Eo_Class *klass, Eo *parent, ...); -EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id); +EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); EAPI Eo * eo2_add_internal_end(const char *file, int line, const Eo *obj); /** @@ -1392,7 +1392,7 @@ eo2_base_data_del(const char *key); */ #define eo_parent_set(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), EO_TYPECHECK(Eo *, parent) EAPI void -eo2_parent_set(Eo *parent_id); +eo2_parent_set(Eo *parent); /** * @def eo_parent_get diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index ec11fa4a11..5f715a1ff7 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -136,15 +136,15 @@ static const Eo_Op_Description noop_desc = static inline Eina_Bool -_eo_is_a_class(const Eo *obj_id) +_eo_is_a_class(const Eo *eo_id) { Eo_Id oid; #ifdef HAVE_EO_ID - oid = (Eo_Id) obj_id; + oid = (Eo_Id) eo_id; #else - /* fortunately EO_OBJ_POINTER_RETURN* will handle NULL obj_id */ - if (!obj_id) return EINA_FALSE; - oid = ((Eo_Base *) obj_id)->id; + /* fortunately EO_OBJ_POINTER_RETURN* will handle NULL eo_id */ + if (!eo_id) return EINA_FALSE; + oid = ((Eo_Base *) eo_id)->id; #endif return (((oid >> REF_TAG_SHIFT) & 0x1) == 0x0); } @@ -281,7 +281,7 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) #define EO2_CALL_STACK_DEPTH 5 typedef struct _Eo2_Stack_Frame { - Eo *obj_id; + Eo *eo_id; _Eo_Object *obj; const _Eo_Class *klass; void *obj_data; @@ -313,14 +313,14 @@ eo2_call_stack_depth() } EAPI Eina_Bool -eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +eo2_do_start(Eo *eo_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { _Eo_Object * obj; const _Eo_Class *klass; Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; - if ((fptr != NULL) && (fptr->obj_id == obj_id)) + if ((fptr != NULL) && (fptr->eo_id == eo_id)) { obj = fptr->obj; if (do_super) @@ -331,7 +331,7 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, } else { - EO_OBJ_POINTER_RETURN_VAL(obj_id, _obj, EINA_FALSE); + EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); obj = _obj; if (!obj) return EINA_FALSE; if (do_super) @@ -352,7 +352,7 @@ eo2_do_start(Eo *obj_id, const Eina_Bool do_super, const char *file EINA_UNUSED, _eo_ref(obj); fptr->obj = obj; - fptr->obj_id = obj_id; + fptr->eo_id = eo_id; fptr->klass = klass; fptr->obj_data = EO2_INVALID_DATA; @@ -395,7 +395,7 @@ eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const cha ERR("eo2 call stack overflow !!!"); fptr->obj = NULL; - fptr->obj_id = NULL; + fptr->eo_id = NULL; fptr->klass = klass; fptr->obj_data = EO2_INVALID_DATA; @@ -422,7 +422,7 @@ _eo2_do_end(const Eina_Bool obj_do) } EAPI void -eo2_do_end(Eo **obj_id EINA_UNUSED) +eo2_do_end(Eo **eo_id EINA_UNUSED) { _eo2_do_end(EINA_TRUE); } @@ -465,8 +465,8 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ ERR("you called a pure virtual func"); return EINA_FALSE; } - call->klass_id = _eo_class_id_get(klass); - call->obj_id = fptr->obj_id; + call->klass = _eo_class_id_get(klass); + call->obj = fptr->eo_id; call->func = func->func; if (obj) @@ -648,24 +648,24 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo #ifndef HAVE_EO_ID EINA_MAGIC_SET(obj, EO_EINA_MAGIC); #endif - Eo_Id obj_id = _eo_id_allocate(obj); - obj->header.id = obj_id; + Eo_Id eo_id = _eo_id_allocate(obj); + obj->header.id = eo_id; _eo_condtor_reset(obj); - eo2_do((Eo *)obj_id, eo2_parent_set(parent_id)); + eo2_do((Eo *)eo_id, eo2_parent_set(parent_id)); - return (Eo *)obj_id; + return (Eo *)eo_id; } EAPI Eo * -eo2_add_internal_end(const char *file, int line, const Eo *obj_id) +eo2_add_internal_end(const char *file, int line, const Eo *eo_id) { Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; - if ((fptr == NULL) || (fptr->obj_id != obj_id)) + if ((fptr == NULL) || (fptr->eo_id != eo_id)) { ERR("in %s:%d - Something very wrong happend to the call stack.", file, line); return NULL; @@ -680,7 +680,7 @@ eo2_add_internal_end(const char *file, int line, const Eo *obj_id) return NULL; } - return (Eo *)fptr->obj_id; + return (Eo *)fptr->eo_id; } /*****************************************************************************/ @@ -806,25 +806,25 @@ _eo_class_dov_internal(const char *file, int line, _Eo_Class *klass, va_list *p_ } EAPI Eina_Bool -eo_do_internal(const char *file, int line, const Eo *obj_id, ...) +eo_do_internal(const char *file, int line, const Eo *eo_id, ...) { Eina_Bool ret = EINA_TRUE; va_list p_list; - Eina_Bool class_ref = _eo_is_a_class(obj_id); + Eina_Bool class_ref = _eo_is_a_class(eo_id); if (class_ref) { - EO_CLASS_POINTER_RETURN_VAL(obj_id, klass, EINA_FALSE); + EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - va_start(p_list, obj_id); + va_start(p_list, eo_id); ret = _eo_class_dov_internal(file, line, klass, &p_list); va_end(p_list); } else { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - va_start(p_list, obj_id); + va_start(p_list, eo_id); ret = _eo_obj_dov_internal(file, line, obj, &p_list); va_end(p_list); } @@ -833,24 +833,24 @@ eo_do_internal(const char *file, int line, const Eo *obj_id, ...) } EAPI Eina_Bool -eo_vdo_internal(const char *file, int line, const Eo *obj_id, va_list *ops) +eo_vdo_internal(const char *file, int line, const Eo *eo_id, va_list *ops) { - Eina_Bool class_ref = _eo_is_a_class(obj_id); + Eina_Bool class_ref = _eo_is_a_class(eo_id); if (class_ref) { - EO_CLASS_POINTER_RETURN_VAL(obj_id, klass, EINA_FALSE); + EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); return _eo_class_dov_internal(file, line, klass, ops); } else { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); return _eo_obj_dov_internal(file, line, obj, ops); } } EAPI Eina_Bool -eo_do_super_internal(const char *file, int line, const Eo *obj_id, const Eo_Class *cur_klass_id, Eo_Op op, ...) +eo_do_super_internal(const char *file, int line, const Eo *eo_id, const Eo_Class *cur_klass_id, Eo_Op op, ...) { const _Eo_Class *nklass; Eina_Bool op_ret = EINA_TRUE; @@ -859,9 +859,9 @@ eo_do_super_internal(const char *file, int line, const Eo *obj_id, const Eo_Clas EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - if (_eo_is_a_class(obj_id)) + if (_eo_is_a_class(eo_id)) { - EO_CLASS_POINTER_RETURN_VAL(obj_id, klass, EINA_FALSE); + EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); va_start(p_list, op); nklass = _eo_kls_itr_next(klass, cur_klass, op); @@ -870,7 +870,7 @@ eo_do_super_internal(const char *file, int line, const Eo *obj_id, const Eo_Clas } else { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); va_start(p_list, op); nklass = _eo_kls_itr_next(obj->klass, cur_klass, op); @@ -887,15 +887,15 @@ eo_do_super_internal(const char *file, int line, const Eo *obj_id, const Eo_Clas } EAPI const Eo_Class * -eo_class_get(const Eo *obj_id) +eo_class_get(const Eo *eo_id) { - if (_eo_is_a_class(obj_id)) + if (_eo_is_a_class(eo_id)) { - EO_CLASS_POINTER_RETURN_VAL(obj_id, _klass, NULL); + EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); return eo_class_class_get(); } - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); if (obj->klass) return _eo_class_id_get(obj->klass); @@ -903,18 +903,18 @@ eo_class_get(const Eo *obj_id) } EAPI const char * -eo_class_name_get(const Eo_Class *obj_id) +eo_class_name_get(const Eo_Class *eo_id) { const _Eo_Class *klass; - if (_eo_is_a_class(obj_id)) + if (_eo_is_a_class(eo_id)) { - EO_CLASS_POINTER_RETURN_VAL(obj_id, _klass, NULL); + EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); klass = _klass; } else { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); klass = obj->klass; } @@ -1184,7 +1184,7 @@ _eo_class_check_op_descs(const Eo_Class_Description *desc) /* Not really called, just used for the ptr... */ static void -_eo_class_isa_func(Eo *obj_id EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_eo_class_isa_func(Eo *eo_id EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { /* Do nonthing. */ } @@ -1473,9 +1473,9 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } EAPI Eina_Bool -eo_isa(const Eo *obj_id, const Eo_Class *klass_id) +eo_isa(const Eo *eo_id, const Eo_Class *klass_id) { - EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE); + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE); const op_type_funcs *func = _dich_func_get(obj->klass, klass->base_id + klass->desc->ops.count); From 93f85f095e54fc094ccca046b210ee88ab17c76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 2 Oct 2013 10:44:33 +0200 Subject: [PATCH 073/169] eo2: rewrite eo2_do_start(...) we need Eo_Class *cur_klass for eo2_do_super be sure not to update stack pointer before we can't fail anymore --- src/lib/eo/Eo.h | 8 ++--- src/lib/eo/eo.c | 92 +++++++++++++++++++++++++++---------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 6d5c506845..7924f9d048 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -764,7 +764,7 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj, const Eina_Bool do_super, const char *file, const char *func, int line); +EAPI Eina_Bool eo2_do_start(Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer @@ -781,7 +781,7 @@ EAPI int eo2_call_stack_depth(); do \ { \ Eo *_objid_ = objid; \ - if (eo2_do_start(_objid_, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__)) \ + if (eo2_do_start(_objid_, NULL, __FILE__, __FUNCTION__, __LINE__)) \ { \ Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ __VA_ARGS__; \ @@ -789,11 +789,11 @@ EAPI int eo2_call_stack_depth(); } \ } while (0) -#define eo2_do_super(objid, ...) \ +#define eo2_do_super(objid, clsid, ...) \ do \ { \ Eo *_objid_ = objid; \ - if (eo2_do_start(_objid_, EINA_TRUE, __FILE__, __FUNCTION__, __LINE__)) \ + if (eo2_do_start(_objid_, clsid, __FILE__, __FUNCTION__, __LINE__)) \ { \ Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ __VA_ARGS__; \ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 5f715a1ff7..cb5efe79bb 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -282,8 +282,8 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) typedef struct _Eo2_Stack_Frame { Eo *eo_id; - _Eo_Object *obj; - const _Eo_Class *klass; + Eo_Base *base; + const _Eo_Class *cur_klass; void *obj_data; } Eo2_Stack_Frame; @@ -313,48 +313,58 @@ eo2_call_stack_depth() } EAPI Eina_Bool -eo2_do_start(Eo *eo_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +eo2_do_start(Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { - _Eo_Object * obj; + _Eo_Object *obj; const _Eo_Class *klass; - Eo2_Stack_Frame *fptr; + Eo2_Stack_Frame *fptr, *nfptr; + Eina_Bool empty_stack = (eo2_call_stack.frame_ptr == NULL); fptr = eo2_call_stack.frame_ptr; - if ((fptr != NULL) && (fptr->eo_id == eo_id)) + if (((fptr - eo2_call_stack.stack) + 1) >= EO2_CALL_STACK_DEPTH) { - obj = fptr->obj; - if (do_super) - klass = _eo2_kls_itr_next(obj->klass, fptr->klass); - else - klass = fptr->klass; - eo2_call_stack.frame_ptr++; + ERR("eo2 call stack overflow !!!"); + return EINA_FALSE; + } + + if (empty_stack) + nfptr = &eo2_call_stack.stack[0]; + else + nfptr = fptr + 1; + + if ((!empty_stack) && (fptr->eo_id == eo_id)) + { + obj = (_Eo_Object *)fptr->base; + memcpy(nfptr, fptr, sizeof(Eo2_Stack_Frame)); } else { EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); obj = _obj; - if (!obj) return EINA_FALSE; - if (do_super) - klass = _eo2_kls_itr_next(obj->klass, obj->klass); - else - klass = obj->klass; - if (fptr == NULL) - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; - else - eo2_call_stack.frame_ptr++; + nfptr->base = (Eo_Base *)_obj; + nfptr->eo_id = eo_id; } - fptr = eo2_call_stack.frame_ptr; + if (cur_klass_id) + { + EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); + klass = _eo2_kls_itr_next(obj->klass, cur_klass); + } + else + klass = obj->klass; - if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_DEPTH) - ERR("eo2 call stack overflow !!!"); + if (klass != nfptr->cur_klass) + { + nfptr->cur_klass = klass; + nfptr->obj_data = EO2_INVALID_DATA; + } _eo_ref(obj); - fptr->obj = obj; - fptr->eo_id = eo_id; - fptr->klass = klass; - fptr->obj_data = EO2_INVALID_DATA; + if (empty_stack) + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + else + eo2_call_stack.frame_ptr++; return EINA_TRUE; } @@ -368,12 +378,12 @@ eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const cha klass = NULL; fptr = eo2_call_stack.frame_ptr; - if ((fptr != NULL) && (_eo_class_id_get(fptr->klass) == (Eo *)klass_id)) + if ((fptr != NULL) && (_eo_class_id_get(fptr->cur_klass) == (Eo *)klass_id)) { if (do_super) - klass = _eo2_kls_itr_next(fptr->klass, fptr->klass); + klass = _eo2_kls_itr_next(fptr->cur_klass, fptr->cur_klass); else - klass = fptr->klass; + klass = fptr->cur_klass; eo2_call_stack.frame_ptr++; } else @@ -394,9 +404,9 @@ eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const cha if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_DEPTH) ERR("eo2 call stack overflow !!!"); - fptr->obj = NULL; + fptr->base = NULL; fptr->eo_id = NULL; - fptr->klass = klass; + fptr->cur_klass = klass; fptr->obj_data = EO2_INVALID_DATA; return EINA_TRUE; @@ -410,7 +420,7 @@ _eo2_do_end(const Eina_Bool obj_do) fptr = eo2_call_stack.frame_ptr; if(obj_do) - _eo_unref(fptr->obj); + _eo_unref((_Eo_Object *)fptr->base); memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; @@ -442,7 +452,7 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ const op_type_funcs *func; fptr = eo2_call_stack.frame_ptr; - obj = fptr->obj; + obj = (_Eo_Object *)fptr->base; klass = NULL; if (klass_id) @@ -452,7 +462,7 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ } else { - klass = fptr->klass; + klass = fptr->cur_klass; if (!klass) return EINA_FALSE; } @@ -536,9 +546,9 @@ eo2_api_op_id_get(const void *api_func, const Eo_Op_Type op_type) const _Eo_Class *klass; if (op_type == EO_OP_TYPE_REGULAR) - klass = eo2_call_stack.frame_ptr->obj->klass; + klass = ((_Eo_Object *)eo2_call_stack.frame_ptr->base)->klass; else if (op_type == EO_OP_TYPE_CLASS) - klass = eo2_call_stack.frame_ptr->klass; + klass = eo2_call_stack.frame_ptr->cur_klass; else { ERR("api func %p, unknown op type %d", api_func, op_type); @@ -671,12 +681,12 @@ eo2_add_internal_end(const char *file, int line, const Eo *eo_id) return NULL; } - if (!fptr->obj->condtor_done) + if (!((_Eo_Object *)fptr->base)->condtor_done) { ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", - file, line, fptr->klass->desc->name); + file, line, fptr->cur_klass->desc->name); /* for the for the basic object ref. */ - _eo_unref(fptr->obj); + _eo_unref((_Eo_Object *)fptr->base); return NULL; } From 782092f7af9265b6ae4de3a71ec7bea8faf0d96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 2 Oct 2013 11:47:10 +0200 Subject: [PATCH 074/169] eo2: eo2_do() and eo2_do_super() supports objects and classes --- src/lib/eo/Eo.h | 71 +++++++--------------- src/lib/eo/eo.c | 152 +++++++++++++++++++++++------------------------- 2 files changed, 96 insertions(+), 127 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 7924f9d048..b046f1e686 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -764,65 +764,38 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); -EAPI Eina_Bool eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file, const char *func, int line); +EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer -EAPI void eo2_do_end(Eo **ojb); -EAPI void eo2_class_do_end(const Eo_Class **klass); +EAPI void eo2_do_end(const Eo **ojb); EAPI int eo2_call_stack_depth(); #define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) -#define EO2_CLASS_DO_CLEANUP __attribute__((cleanup(eo2_class_do_end))) // eo object method calls batch, -#define eo2_do(objid, ...) \ - do \ - { \ - Eo *_objid_ = objid; \ - if (eo2_do_start(_objid_, NULL, __FILE__, __FUNCTION__, __LINE__)) \ - { \ - Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ - __VA_ARGS__; \ - (void) _id_clean_; \ - } \ +#define eo2_do(eoid, ...) \ + do \ + { \ + const Eo *_eoid_ = eoid; \ + if (eo2_do_start(_eoid_, NULL, __FILE__, __FUNCTION__, __LINE__)) \ + { \ + const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ } while (0) -#define eo2_do_super(objid, clsid, ...) \ - do \ - { \ - Eo *_objid_ = objid; \ - if (eo2_do_start(_objid_, clsid, __FILE__, __FUNCTION__, __LINE__)) \ - { \ - Eo *_id_clean_ EO2_DO_CLEANUP = _objid_; \ - __VA_ARGS__; \ - (void) _id_clean_; \ - } \ - } while (0) - -#define eo2_class_do(clsid, ...) \ - do \ - { \ - const Eo_Class *_clsid_ = clsid; \ - if (eo2_class_do_start(_clsid_, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__)) \ - { \ - const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ - __VA_ARGS__; \ - (void) _id_clean_; \ - } \ - } while (0) - -#define eo2_class_super_do(clsid, ...) \ - do \ - { \ - const Eo_Class *_clsid_ = clsid; \ - if (eo2_class_do_start(_clsid_, EINA_TRUE, __FILE__, __FUNCTION__, __LINE__)) \ - { \ - const Eo_Class *_id_clean_ EO2_CLASS_DO_CLEANUP = _clsid_; \ - __VA_ARGS__; \ - (void) _id_clean_; \ - } \ +#define eo2_do_super(eoid, clsid, ...) \ + do \ + { \ + const Eo *_eoid_ = eoid; \ + if (eo2_do_start(_eoid_, clsid, __FILE__, __FUNCTION__, __LINE__)) \ + { \ + const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ + __VA_ARGS__; \ + (void) _id_clean_; \ + } \ } while (0) /*****************************************************************************/ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index cb5efe79bb..1d79bda502 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -281,7 +281,7 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) #define EO2_CALL_STACK_DEPTH 5 typedef struct _Eo2_Stack_Frame { - Eo *eo_id; + const Eo *eo_id; Eo_Base *base; const _Eo_Class *cur_klass; void *obj_data; @@ -312,27 +312,14 @@ eo2_call_stack_depth() return (1 + (eo2_call_stack.frame_ptr - eo2_call_stack.stack)); } -EAPI Eina_Bool -eo2_do_start(Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +static inline Eina_Bool +_eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, + Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *nfptr) { _Eo_Object *obj; const _Eo_Class *klass; - Eo2_Stack_Frame *fptr, *nfptr; - Eina_Bool empty_stack = (eo2_call_stack.frame_ptr == NULL); - fptr = eo2_call_stack.frame_ptr; - if (((fptr - eo2_call_stack.stack) + 1) >= EO2_CALL_STACK_DEPTH) - { - ERR("eo2 call stack overflow !!!"); - return EINA_FALSE; - } - - if (empty_stack) - nfptr = &eo2_call_stack.stack[0]; - else - nfptr = fptr + 1; - - if ((!empty_stack) && (fptr->eo_id == eo_id)) + if (same_eo_id) { obj = (_Eo_Object *)fptr->base; memcpy(nfptr, fptr, sizeof(Eo2_Stack_Frame)); @@ -341,8 +328,8 @@ eo2_do_start(Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUS { EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); obj = _obj; - nfptr->base = (Eo_Base *)_obj; nfptr->eo_id = eo_id; + nfptr->base = (Eo_Base *)_obj; } if (cur_klass_id) @@ -361,6 +348,70 @@ eo2_do_start(Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUS _eo_ref(obj); + return EINA_TRUE; +} + +static inline Eina_Bool +_eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, + Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *nfptr) +{ + const _Eo_Class *klass; + + if (same_eo_id) + { + klass = (_Eo_Class *)fptr->base; + memcpy(nfptr, fptr, sizeof(Eo2_Stack_Frame)); + } + else + { + EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); + klass = _klass; + nfptr->eo_id = eo_id; + nfptr->base = (Eo_Base *)_klass; + } + + if(cur_klass_id) + { + EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); + nfptr->cur_klass = _eo2_kls_itr_next(klass, cur_klass); + } + else + nfptr->cur_klass = klass; + + nfptr->obj_data = EO2_INVALID_DATA; + + return EINA_TRUE; +} + +EAPI Eina_Bool +eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +{ + Eo2_Stack_Frame *fptr, *nfptr; + Eina_Bool empty_stack = (eo2_call_stack.frame_ptr == NULL); + + fptr = eo2_call_stack.frame_ptr; + if (((fptr - eo2_call_stack.stack) + 1) >= EO2_CALL_STACK_DEPTH) + { + ERR("eo2 call stack overflow !!!"); + return EINA_FALSE; + } + + if (empty_stack) + nfptr = &eo2_call_stack.stack[0]; + else + nfptr = fptr + 1; + + if(_eo_is_a_class(eo_id)) + { + if (!_eo2_class_do(eo_id, cur_klass_id, ((!empty_stack) && (fptr->eo_id == eo_id)), fptr, nfptr)) + return EINA_FALSE; + } + else + { + if (!_eo2_obj_do(eo_id, cur_klass_id, ((!empty_stack) && (fptr->eo_id == eo_id)), fptr, nfptr)) + return EINA_FALSE; + } + if (empty_stack) eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; else @@ -369,57 +420,14 @@ eo2_do_start(Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUS return EINA_TRUE; } -EAPI Eina_Bool -eo2_class_do_start(const Eo_Class *klass_id, const Eina_Bool do_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) -{ - Eo2_Stack_Frame *fptr; - const _Eo_Class *klass; - - klass = NULL; - fptr = eo2_call_stack.frame_ptr; - - if ((fptr != NULL) && (_eo_class_id_get(fptr->cur_klass) == (Eo *)klass_id)) - { - if (do_super) - klass = _eo2_kls_itr_next(fptr->cur_klass, fptr->cur_klass); - else - klass = fptr->cur_klass; - eo2_call_stack.frame_ptr++; - } - else - { - EO_CLASS_POINTER_RETURN_VAL(klass_id, _klass, EINA_FALSE); - if (do_super) - klass = _eo2_kls_itr_next(_klass, _klass); - else - klass = _klass; - if (fptr == NULL) - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; - else - eo2_call_stack.frame_ptr++; - } - - fptr = eo2_call_stack.frame_ptr; - - if ((fptr - eo2_call_stack.stack) >= EO2_CALL_STACK_DEPTH) - ERR("eo2 call stack overflow !!!"); - - fptr->base = NULL; - fptr->eo_id = NULL; - fptr->cur_klass = klass; - fptr->obj_data = EO2_INVALID_DATA; - - return EINA_TRUE; -} - -static inline void -_eo2_do_end(const Eina_Bool obj_do) +EAPI void +eo2_do_end(const Eo **eo_id) { Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; - if(obj_do) + if(!_eo_is_a_class(*eo_id)) _eo_unref((_Eo_Object *)fptr->base); memset(fptr, 0, sizeof (Eo2_Stack_Frame)); @@ -431,18 +439,6 @@ _eo2_do_end(const Eina_Bool obj_do) eo2_call_stack.frame_ptr--; } -EAPI void -eo2_do_end(Eo **eo_id EINA_UNUSED) -{ - _eo2_do_end(EINA_TRUE); -} - -EAPI void -eo2_class_do_end(const Eo_Class **klass_id EINA_UNUSED) -{ - _eo2_do_end(EINA_FALSE); -} - EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_Data *call) { @@ -476,7 +472,7 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ return EINA_FALSE; } call->klass = _eo_class_id_get(klass); - call->obj = fptr->eo_id; + call->obj = (Eo *)fptr->eo_id; call->func = func->func; if (obj) From 4bbd97913d33cb8a9f0d0dcb1db90cf77e442633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 00:00:11 +0100 Subject: [PATCH 075/169] eo2: eo2_add_internal_start use trash and fix MAGIC --- src/lib/eo/eo.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 1d79bda502..db5189cb71 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -634,6 +634,8 @@ _eo2_class_funcs_set(_Eo_Class *klass) EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) { + _Eo_Object *obj; + EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, NULL); if (parent_id) @@ -647,21 +649,35 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo return NULL; } - _Eo_Object *obj = calloc(1, klass->obj_size); + eina_spinlock_take(&klass->objects.trash_lock); + obj = eina_trash_pop(&klass->objects.trash); + if (obj) + { + memset(obj, 0, klass->obj_size); + klass->objects.trash_count--; + } + else + { + obj = calloc(1, klass->obj_size); + } + eina_spinlock_release(&klass->objects.trash_lock); + obj->refcount++; obj->klass = klass; #ifndef HAVE_EO_ID - EINA_MAGIC_SET(obj, EO_EINA_MAGIC); + EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC); #endif Eo_Id eo_id = _eo_id_allocate(obj); obj->header.id = eo_id; _eo_condtor_reset(obj); - eo2_do((Eo *)eo_id, eo2_parent_set(parent_id)); + _eo_ref(obj); - return (Eo *)eo_id; + eo2_do(_eo_id_get(obj), eo2_parent_set(parent_id)); + + return _eo_id_get(obj); } EAPI Eo * @@ -681,12 +697,15 @@ eo2_add_internal_end(const char *file, int line, const Eo *eo_id) { ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", file, line, fptr->cur_klass->desc->name); - /* for the for the basic object ref. */ + /* Unref twice, once for the ref in eo2_add_internal_start, and once for the basic object ref. */ + _eo_unref((_Eo_Object *)fptr->base); _eo_unref((_Eo_Object *)fptr->base); return NULL; } - return (Eo *)fptr->eo_id; + _eo_unref((_Eo_Object *)fptr->base); + + return (Eo *)eo_id; } /*****************************************************************************/ From fc448f89af234d613a735066e92df12fba2a5e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 2 Oct 2013 14:57:45 +0200 Subject: [PATCH 076/169] eo2: clean up and speed up call stack usage --- src/lib/eo/eo.c | 108 ++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index db5189cb71..44a8d4d90f 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -278,7 +278,8 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) // FIXME: per thread stack, grow/shrink #define EO2_INVALID_DATA (void *) -1 -#define EO2_CALL_STACK_DEPTH 5 +#define EO2_CALL_STACK_DEPTH 100 + typedef struct _Eo2_Stack_Frame { const Eo *eo_id; @@ -289,47 +290,56 @@ typedef struct _Eo2_Stack_Frame } Eo2_Stack_Frame; typedef struct _Eo2_Call_Stack { - Eo2_Stack_Frame stack[EO2_CALL_STACK_DEPTH]; + Eo2_Stack_Frame *stack; Eo2_Stack_Frame *frame_ptr; } Eo2_Call_Stack; -static Eo2_Call_Stack eo2_call_stack = { - { - { NULL, NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, NULL, EO2_INVALID_DATA }, - { NULL, NULL, NULL, EO2_INVALID_DATA }, - }, - NULL }; +static Eo2_Call_Stack eo2_call_stack = { NULL, NULL }; + +static Eina_Bool +_eo2_call_stack_init() +{ + eo2_call_stack.stack = calloc(EO2_CALL_STACK_DEPTH, sizeof(Eo2_Stack_Frame)); + if (!eo2_call_stack.stack) + return EINA_FALSE; + + // first frame is never used + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + + return EINA_TRUE; +} + +static void +_eo2_call_stack_free() +{ + if (eo2_call_stack.stack) + free(eo2_call_stack.stack); +} EAPI int eo2_call_stack_depth() { - if (eo2_call_stack.frame_ptr == NULL) - return 0; - else - return (1 + (eo2_call_stack.frame_ptr - eo2_call_stack.stack)); + return (eo2_call_stack.frame_ptr - eo2_call_stack.stack); } static inline Eina_Bool -_eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, - Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *nfptr) +_eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, + Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { _Eo_Object *obj; const _Eo_Class *klass; - if (same_eo_id) + if (pfptr) { - obj = (_Eo_Object *)fptr->base; - memcpy(nfptr, fptr, sizeof(Eo2_Stack_Frame)); + obj = (_Eo_Object *)pfptr->base; + memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); } else { EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); obj = _obj; - nfptr->eo_id = eo_id; - nfptr->base = (Eo_Base *)_obj; + fptr->eo_id = eo_id; + fptr->base = (Eo_Base *)_obj; } if (cur_klass_id) @@ -340,10 +350,10 @@ _eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, else klass = obj->klass; - if (klass != nfptr->cur_klass) + if (klass != fptr->cur_klass) { - nfptr->cur_klass = klass; - nfptr->obj_data = EO2_INVALID_DATA; + fptr->cur_klass = klass; + fptr->obj_data = EO2_INVALID_DATA; } _eo_ref(obj); @@ -352,33 +362,33 @@ _eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, } static inline Eina_Bool -_eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_id, - Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *nfptr) +_eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, + Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { const _Eo_Class *klass; - if (same_eo_id) + if (pfptr) { - klass = (_Eo_Class *)fptr->base; - memcpy(nfptr, fptr, sizeof(Eo2_Stack_Frame)); + klass = (_Eo_Class *)pfptr->base; + memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); } else { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); klass = _klass; - nfptr->eo_id = eo_id; - nfptr->base = (Eo_Base *)_klass; + fptr->eo_id = eo_id; + fptr->base = (Eo_Base *)_klass; } if(cur_klass_id) { EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - nfptr->cur_klass = _eo2_kls_itr_next(klass, cur_klass); + fptr->cur_klass = _eo2_kls_itr_next(klass, cur_klass); } else - nfptr->cur_klass = klass; + fptr->cur_klass = klass; - nfptr->obj_data = EO2_INVALID_DATA; + fptr->obj_data = EO2_INVALID_DATA; return EINA_TRUE; } @@ -386,8 +396,7 @@ _eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool same_eo_i EAPI Eina_Bool eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { - Eo2_Stack_Frame *fptr, *nfptr; - Eina_Bool empty_stack = (eo2_call_stack.frame_ptr == NULL); + Eo2_Stack_Frame *fptr, *pfptr; fptr = eo2_call_stack.frame_ptr; if (((fptr - eo2_call_stack.stack) + 1) >= EO2_CALL_STACK_DEPTH) @@ -396,26 +405,19 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EIN return EINA_FALSE; } - if (empty_stack) - nfptr = &eo2_call_stack.stack[0]; - else - nfptr = fptr + 1; - + pfptr = ((fptr->eo_id == eo_id) ? fptr : NULL); if(_eo_is_a_class(eo_id)) { - if (!_eo2_class_do(eo_id, cur_klass_id, ((!empty_stack) && (fptr->eo_id == eo_id)), fptr, nfptr)) + if (!_eo2_class_do(eo_id, cur_klass_id, (fptr + 1), pfptr)) return EINA_FALSE; } else { - if (!_eo2_obj_do(eo_id, cur_klass_id, ((!empty_stack) && (fptr->eo_id == eo_id)), fptr, nfptr)) + if (!_eo2_obj_do(eo_id, cur_klass_id, (fptr + 1), pfptr)) return EINA_FALSE; } - if (empty_stack) - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; - else - eo2_call_stack.frame_ptr++; + eo2_call_stack.frame_ptr++; return EINA_TRUE; } @@ -434,7 +436,7 @@ eo2_do_end(const Eo **eo_id) fptr->obj_data = EO2_INVALID_DATA; if (fptr == &eo2_call_stack.stack[0]) - eo2_call_stack.frame_ptr = NULL; + ERR("eo2 call stack underflow !!!"); else eo2_call_stack.frame_ptr--; } @@ -1937,6 +1939,12 @@ eo_init(void) /* bootstrap EO_CLASS_CLASS */ (void) eo_class_class_get(); + if (!_eo2_call_stack_init()) + { + EINA_LOG_ERR("Could not init eo2 call stack."); + return EINA_FALSE; + } + return EINA_TRUE; } @@ -1964,6 +1972,8 @@ eo_shutdown(void) eina_spinlock_free(&_eo_class_creation_lock); + _eo2_call_stack_free(); + _eo_free_ids_tables(); eina_log_domain_unregister(_eo_log_dom); From e51e397b89d039e25b38f2339f5147b8eb3e8b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 3 Oct 2013 14:17:03 +0200 Subject: [PATCH 077/169] eo2: fix eo_base_data_get(), eo_composite_attach(), eo_composite_detach() --- src/lib/eo/Eo.h | 2 +- src/lib/eo/eo.c | 11 +++++++++-- src/lib/eo/eo2_base_class.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index b046f1e686..5a9dec3b5a 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1327,7 +1327,7 @@ eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free * @see #eo_base_data_del */ #define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data) -EAPI void +EAPI void * eo2_base_data_get(const char *key); /** diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 44a8d4d90f..b409953b32 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -2014,7 +2014,11 @@ eo_composite_attach(Eo *comp_obj_id, Eo *parent_id) comp_obj->composite = EINA_TRUE; *comp_dst = comp_obj; - eo_do(comp_obj_id, eo_parent_set(parent_id)); + + if (comp_obj->klass->desc->version == EO2_VERSION) + eo2_do(comp_obj_id, eo2_parent_set(parent_id)); + else + eo_do(comp_obj_id, eo_parent_set(parent_id)); return EINA_TRUE; } @@ -2036,7 +2040,10 @@ eo_composite_detach(Eo *comp_obj_id, Eo *parent_id) { comp_obj->composite = EINA_FALSE; *comp_itr = NULL; - eo_do(comp_obj_id, eo_parent_set(NULL)); + if (comp_obj->klass->desc->version == EO2_VERSION) + eo2_do(comp_obj_id, eo2_parent_set(NULL)); + else + eo_do(comp_obj_id, eo_parent_set(NULL)); return EINA_TRUE; } } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 1cbccef360..55ef48ebc6 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -102,7 +102,7 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) return NULL; } -EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_get, EO2_FUNC_CALL(key), const char *key); +EAPI EO2_FUNC_BODYV(eo2_base_data_get, void*, NULL, EO2_FUNC_CALL(key), const char *key); static void _parent_set(Eo *obj, void *class_data, Eo *parent_id) From 2e9ae2a571aac83d3fa94bcb164c9db899cf3c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 00:18:45 +0100 Subject: [PATCH 078/169] eo2: optimize eo2_call_resolve and call stack --- src/lib/eo/Eo.h | 3 +-- src/lib/eo/eo.c | 70 ++++++++++++++++++++++--------------------------- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 5a9dec3b5a..4cf780d662 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -760,8 +760,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); // gets the real function pointer and the object data -#define eo2_call_resolve(op, call) eo2_call_resolve_internal(NULL, op, call) -EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, const Eo_Op op, Eo2_Op_Call_Data *call); +EAPI Eina_Bool eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index b409953b32..09dcd0440b 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -283,7 +283,7 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) typedef struct _Eo2_Stack_Frame { const Eo *eo_id; - Eo_Base *base; + _Eo_Object *obj; const _Eo_Class *cur_klass; void *obj_data; @@ -331,7 +331,7 @@ _eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, if (pfptr) { - obj = (_Eo_Object *)pfptr->base; + obj = pfptr->obj; memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); } else @@ -339,7 +339,7 @@ _eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); obj = _obj; fptr->eo_id = eo_id; - fptr->base = (Eo_Base *)_obj; + fptr->obj = _obj; } if (cur_klass_id) @@ -350,7 +350,7 @@ _eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, else klass = obj->klass; - if (klass != fptr->cur_klass) + if ((!pfptr) || (klass != fptr->cur_klass)) { fptr->cur_klass = klass; fptr->obj_data = EO2_INVALID_DATA; @@ -369,7 +369,7 @@ _eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, if (pfptr) { - klass = (_Eo_Class *)pfptr->base; + klass = pfptr->cur_klass; memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); } else @@ -377,7 +377,8 @@ _eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); klass = _klass; fptr->eo_id = eo_id; - fptr->base = (Eo_Base *)_klass; + fptr->obj = NULL; + fptr->obj_data = EO2_INVALID_DATA; } if(cur_klass_id) @@ -388,8 +389,6 @@ _eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, else fptr->cur_klass = klass; - fptr->obj_data = EO2_INVALID_DATA; - return EINA_TRUE; } @@ -423,14 +422,14 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EIN } EAPI void -eo2_do_end(const Eo **eo_id) +eo2_do_end(const Eo **eo_id EINA_UNUSED) { Eo2_Stack_Frame *fptr; fptr = eo2_call_stack.frame_ptr; - if(!_eo_is_a_class(*eo_id)) - _eo_unref((_Eo_Object *)fptr->base); + if(fptr->obj) + _eo_unref(fptr->obj); memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; @@ -442,7 +441,7 @@ eo2_do_end(const Eo **eo_id) } EAPI Eina_Bool -eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_Data *call) +eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; const _Eo_Object * obj; @@ -450,31 +449,20 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ const op_type_funcs *func; fptr = eo2_call_stack.frame_ptr; - obj = (_Eo_Object *)fptr->base; - klass = NULL; - - if (klass_id) - { - EO_CLASS_POINTER_RETURN_VAL(klass_id, _klass, EINA_FALSE); - klass = _klass; - } - else - { - klass = fptr->cur_klass; - if (!klass) - return EINA_FALSE; - } + obj = fptr->obj; + klass = fptr->cur_klass; func = _dich_func_get(klass, op); - if (EINA_LIKELY(func != NULL)) + if (EINA_UNLIKELY(func == NULL)) + { + ERR("you called func %d which is unknown in class '%s'", op, klass->desc->name); + return EINA_FALSE; + } + + if (EINA_LIKELY(func->func && func->src )) { - if (func->func == NULL) - { - ERR("you called a pure virtual func"); - return EINA_FALSE; - } - call->klass = _eo_class_id_get(klass); call->obj = (Eo *)fptr->eo_id; + call->klass = _eo_class_id_get(klass); call->func = func->func; if (obj) @@ -495,6 +483,12 @@ eo2_call_resolve_internal(const Eo_Class *klass_id, const Eo_Op op, Eo2_Op_Call_ return EINA_TRUE; } + if (func->src != NULL) + { + ERR("you called a pure virtual func %d", op); + return EINA_FALSE; + } + /* Try composite objects */ /* FIXME!!! */ return EINA_FALSE; @@ -544,7 +538,7 @@ eo2_api_op_id_get(const void *api_func, const Eo_Op_Type op_type) const _Eo_Class *klass; if (op_type == EO_OP_TYPE_REGULAR) - klass = ((_Eo_Object *)eo2_call_stack.frame_ptr->base)->klass; + klass = eo2_call_stack.frame_ptr->obj->klass; else if (op_type == EO_OP_TYPE_CLASS) klass = eo2_call_stack.frame_ptr->cur_klass; else @@ -695,17 +689,17 @@ eo2_add_internal_end(const char *file, int line, const Eo *eo_id) return NULL; } - if (!((_Eo_Object *)fptr->base)->condtor_done) + if (!fptr->obj->condtor_done) { ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", file, line, fptr->cur_klass->desc->name); /* Unref twice, once for the ref in eo2_add_internal_start, and once for the basic object ref. */ - _eo_unref((_Eo_Object *)fptr->base); - _eo_unref((_Eo_Object *)fptr->base); + _eo_unref(fptr->obj); + _eo_unref(fptr->obj); return NULL; } - _eo_unref((_Eo_Object *)fptr->base); + _eo_unref(fptr->obj); return (Eo *)eo_id; } From 47d560b720f2662d4631d54e7a407018d8bb52c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 3 Oct 2013 14:30:31 +0200 Subject: [PATCH 079/169] eo2: support composites object _eo2_api_desc_get() searches extensions classes eo2_call_resolve() searches composites objects --- src/lib/eo/eo.c | 55 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 09dcd0440b..3e40e0efc2 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -490,22 +490,47 @@ eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) } /* Try composite objects */ - /* FIXME!!! */ + if (obj) + { + Eina_List *itr; + Eo *emb_eo_id; + EINA_LIST_FOREACH((obj)->composite_objects, itr, emb_eo_id) + { + /* should never return */ + EO_OBJ_POINTER_RETURN_VAL(emb_eo_id, emb_obj, EINA_FALSE); + + func = _dich_func_get(emb_obj->klass, op); + if (func == NULL) + continue; + + if (EINA_LIKELY(func->func && func->src )) + { + call->obj = _eo_id_get(emb_obj); + call->klass = _eo_class_id_get(emb_obj->klass); + call->func = func->func; + call->data = _eo_data_scope_get(emb_obj, func->src); + + return EINA_TRUE; + } + } + } + + ERR("func %d could not be resolved in class '%s'", op, klass->desc->name); + return EINA_FALSE; } static inline const Eo2_Op_Description * -_eo2_api_desc_get(const void *api_func, const _Eo_Class *klass) +_eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class **extns) { int imin, imax, imid; const _Eo_Class *cur_klass; const _Eo_Class **kls_itr = NULL; - Eo2_Op_Description *op_desc; - Eo2_Op_Description *op_descs; + const Eo2_Op_Description *op_desc; + const Eo2_Op_Description *op_descs; - kls_itr = klass->mro; - while (*kls_itr) + for (kls_itr = klass->mro ; *kls_itr ; kls_itr++) { cur_klass = *kls_itr; imin = 0; @@ -525,7 +550,19 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass) return op_desc; } - kls_itr++; + } + + if (extns) + { + for (kls_itr = extns ; *kls_itr ; kls_itr++) + { + cur_klass = *kls_itr; + if (cur_klass->desc->type == EO_CLASS_TYPE_REGULAR) + { + op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); + if (op_desc) return op_desc; + } + } } return NULL; @@ -547,7 +584,7 @@ eo2_api_op_id_get(const void *api_func, const Eo_Op_Type op_type) return EO_NOOP; } - desc = _eo2_api_desc_get(api_func, klass); + desc = _eo2_api_desc_get(api_func, klass, klass->extensions); if (desc == NULL) { @@ -607,7 +644,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) ERR("Can't inherit from a NULL parent. Class '%s', Func index: %lu", klass->desc->name, (unsigned long) (op_desc - op_descs)); - api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent); + api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent, klass->extensions); if (api_desc == NULL) ERR("Can't find api func %p description in class hierarchy. Class '%s', Func index: %lu", From 1614b9d5290def27df72a8eba2aa84e1f851753b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 13 Oct 2013 00:28:40 +0200 Subject: [PATCH 080/169] eo2: base class op_descs must be static --- src/lib/eo/eo2_base_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 55ef48ebc6..35a21b69da 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -949,7 +949,7 @@ _class_constructor(Eo_Class *klass EINA_UNUSED) event_freeze_count = 0; } -Eo2_Op_Description op_descs [] = { +static Eo2_Op_Description op_descs [] = { EO2_OP_FUNC(_constructor, eo2_constructor, "Constructor."), EO2_OP_FUNC(_destructor, eo2_destructor, "Destructor."), EO2_OP_FUNC(_parent_set, eo2_parent_set, "Set parent."), From eb01d1c3e8944256846ddc3ffb8a9fcc1112d5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 00:33:49 +0100 Subject: [PATCH 081/169] eo2: add EO2_CLASS_CLASS --- src/Makefile_Eo.am | 1 + src/lib/eo/Eo.h | 2 ++ src/lib/eo/eo.c | 5 ++++- src/lib/eo/eo2_class_class.c | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/lib/eo/eo2_class_class.c diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 6675a46d12..17d44b925b 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -13,6 +13,7 @@ lib/eo/eo_ptr_indirection.h \ lib/eo/eo_class_class.c \ lib/eo/eo_base_class.c \ lib/eo/eo2_base_class.c \ +lib/eo/eo2_class_class.c \ lib/eo/eo_private.h lib_eo_libeo_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EO_CFLAGS@ diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 4cf780d662..544cf82628 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1217,11 +1217,13 @@ EAPI Eina_Bool eo_composite_is(const Eo *comp_obj); * The class type for the Eo Class class. */ #define EO_CLASS_CLASS eo_class_class_get() +#define EO2_CLASS_CLASS eo2_class_class_get() /** * @brief Use #EO_CLASS_CLASS * @internal * */ EAPI const Eo_Class *eo_class_class_get(void); +EAPI const Eo_Class *eo2_class_class_get(void); /** * @var EO_CLASS_CLASS_BASE_ID diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 3e40e0efc2..35b92a260d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -950,7 +950,10 @@ eo_class_get(const Eo *eo_id) if (_eo_is_a_class(eo_id)) { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); - return eo_class_class_get(); + if (_klass->desc->version == EO2_VERSION) + return eo2_class_class_get(); + else + return eo_class_class_get(); } EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c new file mode 100644 index 0000000000..97f2fccaee --- /dev/null +++ b/src/lib/eo/eo2_class_class.c @@ -0,0 +1,20 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "Eo.h" + +static Eo2_Op_Description op_descs [] = {}; + +static const Eo_Class_Description class_desc = { + EO2_VERSION, + "Eo Abstract Class", + EO_CLASS_TYPE_REGULAR_NO_INSTANT, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + 0, + NULL, + NULL +}; + +EO_DEFINE_CLASS(eo2_class_class_get, &class_desc, NULL, NULL) From bd66dd49f8ec7eafcaba0c40a6955b8924e05668 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 13:56:34 +0000 Subject: [PATCH 082/169] eo2: changed Eo class names to be consistent. All the class names are now of the format: Lib_Type_Subtype_Extra. --- src/lib/eo/eo2_base_class.c | 2 +- src/lib/eo/eo2_class_class.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 35a21b69da..631e1f2459 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -987,7 +987,7 @@ static const Eo_Event_Description *event_desc[] = { static const Eo_Class_Description class_desc = { EO2_VERSION, - "Eo2 Base", + "Eo2_Base", EO_CLASS_TYPE_REGULAR_NO_INSTANT, EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c index 97f2fccaee..cda4fac830 100644 --- a/src/lib/eo/eo2_class_class.c +++ b/src/lib/eo/eo2_class_class.c @@ -8,7 +8,7 @@ static Eo2_Op_Description op_descs [] = {}; static const Eo_Class_Description class_desc = { EO2_VERSION, - "Eo Abstract Class", + "Eo_Abstract_Class", EO_CLASS_TYPE_REGULAR_NO_INSTANT, EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, From 7c0598c93020b9ff6eec5b20e3b6554772617e04 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 14:47:58 +0000 Subject: [PATCH 083/169] eo2: access tests makeup --- src/tests/eo/access/access_inherit.c | 6 +++--- src/tests/eo/access/access_simple.c | 6 +++--- src/tests/eo/access/access_simple.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tests/eo/access/access_inherit.c b/src/tests/eo/access/access_inherit.c index 676aa051fe..303f60f261 100644 --- a/src/tests/eo/access/access_inherit.c +++ b/src/tests/eo/access/access_inherit.c @@ -18,8 +18,8 @@ _prot_print(Eo *obj, void *class_data EINA_UNUSED) EAPI EO2_VOID_FUNC_BODY(inherit_prot_print); -static Eo2_Op_Description op_desc[] = { - EO2_OP_FUNC(_prot_print, inherit_prot_print, "Print protocted var x1."), +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_prot_print, inherit_prot_print, "Print protected var x1."), EO2_OP_SENTINEL }; @@ -27,7 +27,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_desc), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c index 38fcf46563..a7a14a10f7 100644 --- a/src/tests/eo/access/access_simple.c +++ b/src/tests/eo/access/access_simple.c @@ -32,8 +32,8 @@ _a_set(Eo *obj, void *class_data, int a) EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -static Eo2_Op_Description op_desc[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property A."), +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), EO2_OP_SENTINEL }; @@ -46,7 +46,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_desc), + EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), NULL, diff --git a/src/tests/eo/access/access_simple.h b/src/tests/eo/access/access_simple.h index 31a11f6106..3c92d21073 100644 --- a/src/tests/eo/access/access_simple.h +++ b/src/tests/eo/access/access_simple.h @@ -1,13 +1,13 @@ #ifndef SIMPLE_H #define SIMPLE_H +EAPI void simple_a_set(int a); + typedef struct { int public_x2; } Simple_Public_Data; -EAPI void simple_a_set(int a); - extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) From 5e92ffb1218396eedc200b5c5ba66851ff1137fc Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 15:24:20 +0000 Subject: [PATCH 084/169] eo2: improved error messages on failed resolves. --- src/lib/eo/Eo.h | 4 ++-- src/lib/eo/eo.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 544cf82628..e2dfc6dc87 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -644,7 +644,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) \ op = eo2_api_op_id_get((void*)Name, Type); \ - if (!eo2_call_resolve(op, &call)) return DefRet; \ + if (!eo2_call_resolve(#Name, op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ // to define an EAPI function @@ -760,7 +760,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); // gets the real function pointer and the object data -EAPI Eina_Bool eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call); +EAPI Eina_Bool eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 35b92a260d..c7d6530909 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -441,7 +441,7 @@ eo2_do_end(const Eo **eo_id EINA_UNUSED) } EAPI Eina_Bool -eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) +eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; const _Eo_Object * obj; @@ -455,7 +455,7 @@ eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) func = _dich_func_get(klass, op); if (EINA_UNLIKELY(func == NULL)) { - ERR("you called func %d which is unknown in class '%s'", op, klass->desc->name); + ERR("you called func '%s' (%d) which is unknown in class '%s'", func_name, op, klass->desc->name); return EINA_FALSE; } @@ -485,7 +485,7 @@ eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) if (func->src != NULL) { - ERR("you called a pure virtual func %d", op); + ERR("you called a pure virtual func '%s' (%d)", func_name, op); return EINA_FALSE; } @@ -515,7 +515,7 @@ eo2_call_resolve(const Eo_Op op, Eo2_Op_Call_Data *call) } } - ERR("func %d could not be resolved in class '%s'", op, klass->desc->name); + ERR("func '%s' (%d) could not be resolved in class '%s'", func_name, op, klass->desc->name); return EINA_FALSE; } From e5c7d666e09b2c57dfd730aeb82a2042f2a5bc71 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 15:28:55 +0000 Subject: [PATCH 085/169] eo2: migrated the composite test to eo2. --- .../composite_objects_comp.c | 47 ++++++++----------- .../composite_objects_main.c | 12 ++--- .../composite_objects_simple.c | 45 ++++++------------ .../composite_objects_simple.h | 14 +----- 4 files changed, 43 insertions(+), 75 deletions(-) diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index 7d66331400..fb874f1b86 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -8,58 +8,51 @@ #include "../eunit_tests.h" -EAPI Eo_Op COMP_BASE_ID = 0; - #define MY_CLASS COMP_CLASS -static void -_a_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_a_get(Eo *obj, void *class_data EINA_UNUSED) { - int *a; - a = va_arg(*list, int *); - eo_do_super(obj, MY_CLASS, simple_a_get(a)); + int a; + eo2_do_super(obj, MY_CLASS, a = simple_a_get()); + + return a; } static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); - Eo *simple = eo_add(SIMPLE_CLASS, obj); + Eo *simple = eo2_add(SIMPLE_CLASS, obj); eo_composite_attach(simple, obj); - eo_do(simple, eo_event_callback_forwarder_add(EV_A_CHANGED, obj)); + eo2_do(simple, eo2_event_callback_forwarder_add(EV_A_CHANGED, obj)); fail_if(eo_composite_is(obj)); fail_if(!eo_composite_is(simple)); - eo_do(obj, eo_base_data_set("simple-obj", simple, NULL)); + eo2_do(obj, eo2_base_data_set("simple-obj", simple, NULL)); eo_unref(simple); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_a_get, simple_a_get), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Comp", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS, +EO_DEFINE_CLASS(comp_class_get, &class_desc, EO2_BASE_CLASS, SIMPLE_CLASS, NULL); diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index ba96eb4a22..71b0d08090 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -31,26 +31,26 @@ main(int argc, char *argv[]) eo_init(); Eo *obj = eo_add(COMP_CLASS, NULL); - eo_do(obj, eo_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL)); + eo2_do(obj, eo2_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL)); fail_if(!eo_isa(obj, COMP_CLASS)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); int a; - eo_do(obj, simple_a_set(1)); + eo2_do(obj, simple_a_set(1)); fail_if(!cb_called); - eo_do(obj, simple_a_get(&a)); + eo2_do(obj, a = simple_a_get()); fail_if(a != 1); /* disable the callback forwarder, and fail if it's still called. */ Eo *simple; - eo_do(obj, eo_base_data_get("simple-obj", (void **) &simple)); + eo2_do(obj, simple = eo2_base_data_get("simple-obj")); eo_ref(simple); - eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj)); + eo2_do(simple, eo2_event_callback_forwarder_del(EV_A_CHANGED, obj)); cb_called = EINA_FALSE; - eo_do(obj, simple_a_set(2)); + eo2_do(obj, simple_a_set(2)); fail_if(cb_called); fail_if(!eo_composite_is(simple)); diff --git a/src/tests/eo/composite_objects/composite_objects_simple.c b/src/tests/eo/composite_objects/composite_objects_simple.c index 5420ef895d..3ccef86d27 100644 --- a/src/tests/eo/composite_objects/composite_objects_simple.c +++ b/src/tests/eo/composite_objects/composite_objects_simple.c @@ -5,50 +5,35 @@ #include "Eo.h" #include "composite_objects_simple.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - EAPI const Eo_Event_Description _EV_A_CHANGED = EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed."); #define MY_CLASS SIMPLE_CLASS static void -_a_set(Eo *obj, void *class_data, va_list *list) +_a_set(Eo *obj, void *class_data, int a) { Simple_Public_Data *pd = class_data; - int a; - a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); pd->a = a; - eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL)); + eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); } -static void -_a_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +static int +_a_get(Eo *obj EINA_UNUSED, void *class_data) { const Simple_Public_Data *pd = class_data; - int *a; - a = va_arg(*list, int *); - *a = pd->a; + return pd->a; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); +EAPI EO2_FUNC_BODY(simple_a_get, int, 0); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), + EO2_OP_FUNC(_a_get, simple_a_get, "Get property A"), + EO2_OP_SENTINEL }; static const Eo_Event_Description *event_desc[] = { @@ -57,15 +42,15 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Simple_Public_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/composite_objects/composite_objects_simple.h b/src/tests/eo/composite_objects/composite_objects_simple.h index 32a62465b8..d9dbbb272b 100644 --- a/src/tests/eo/composite_objects/composite_objects_simple.h +++ b/src/tests/eo/composite_objects/composite_objects_simple.h @@ -1,23 +1,13 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_GET, - SIMPLE_SUB_ID_LAST -}; - typedef struct { int a; } Simple_Public_Data; -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) -#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) +EAPI void simple_a_set(int a); +EAPI int simple_a_get(void); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) From cbc9a7bd305669bbf31c5b4d0116149c0427fdec Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 16:06:51 +0000 Subject: [PATCH 086/169] eo2: migrated constructors test to eo2. --- src/tests/eo/constructors/constructors_main.c | 22 +++--- .../eo/constructors/constructors_mixin.c | 46 +++++-------- .../eo/constructors/constructors_mixin.h | 11 +-- .../eo/constructors/constructors_simple.c | 69 ++++++++----------- .../eo/constructors/constructors_simple.h | 23 ++----- .../eo/constructors/constructors_simple2.c | 25 +++---- .../eo/constructors/constructors_simple3.c | 22 +++--- .../eo/constructors/constructors_simple4.c | 2 +- .../eo/constructors/constructors_simple5.c | 22 +++--- .../eo/constructors/constructors_simple6.c | 26 +++---- .../eo/constructors/constructors_simple7.c | 23 +++---- 11 files changed, 107 insertions(+), 184 deletions(-) diff --git a/src/tests/eo/constructors/constructors_main.c b/src/tests/eo/constructors/constructors_main.c index c7db62d398..94113207b8 100644 --- a/src/tests/eo/constructors/constructors_main.c +++ b/src/tests/eo/constructors/constructors_main.c @@ -24,27 +24,27 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); fail_if(my_init_count != 2); - eo_do(obj, simple_a_set(1), simple_b_set(2)); + eo2_do(obj, simple_a_set(1), simple_b_set(2)); int a, b; - eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_add_and_print(5)); + eo2_do(obj, a = simple_a_get(), b = simple_b_get(), mixin_add_and_print(5)); eo_unref(obj); fail_if(my_init_count != 0); - obj = eo_add(SIMPLE2_CLASS, NULL); + obj = eo2_add(SIMPLE2_CLASS, NULL); fail_if(obj); - obj = eo_add(SIMPLE3_CLASS, NULL); + obj = eo2_add(SIMPLE3_CLASS, NULL); fail_if(obj); my_init_count = 0; - obj = eo_add(SIMPLE4_CLASS, NULL); + obj = eo2_add(SIMPLE4_CLASS, NULL); fail_if(my_init_count != 2); @@ -52,23 +52,23 @@ main(int argc, char *argv[]) fail_if(my_init_count != 0); - obj = eo_add(SIMPLE5_CLASS, NULL); + obj = eo2_add(SIMPLE5_CLASS, NULL); fail_if(!obj); eo_unref(obj); - obj = eo_add(SIMPLE6_CLASS, NULL); + obj = eo2_add(SIMPLE6_CLASS, NULL); fail_if(!obj); eo_unref(obj); - obj = eo_add(SIMPLE7_CLASS, NULL); + obj = eo2_add(SIMPLE7_CLASS, NULL); fail_if(obj); my_init_count = 0; - obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); + obj = eo2_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); fail_if(!obj); fail_if(my_init_count != 2); - eo_do(obj, simple_a_get(&a)); + eo2_do(obj, a = simple_a_get()); fail_if(a != 7); eo_unref(obj); diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index 24f73643f3..a72911733b 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -6,65 +6,53 @@ #include "constructors_mixin.h" #include "constructors_simple.h" -EAPI Eo_Op MIXIN_BASE_ID = 0; - #define MY_CLASS MIXIN_CLASS static void -_add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +_add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, int x) { - int a, b, x; - eo_do(obj, simple_a_get(&a), simple_b_get(&b)); - x = va_arg(*list, const int); + int a, b; + eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %d\n", __func__, a + b + x); } extern int my_init_count; static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); my_init_count++; } static void -_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); my_init_count--; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODYV(mixin_add_and_print, EO2_FUNC_CALL(x), int x); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(MIXIN_SUB_ID_ADD_AND_SET, "Add A + B + param and print it"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_add_and_print_set, mixin_add_and_print, "Add A + B + param and print it"), + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL); +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_mixin.h b/src/tests/eo/constructors/constructors_mixin.h index 9998b274f4..ebf923f702 100644 --- a/src/tests/eo/constructors/constructors_mixin.h +++ b/src/tests/eo/constructors/constructors_mixin.h @@ -1,16 +1,7 @@ #ifndef MIXIN_H #define MIXIN_H -extern EAPI Eo_Op MIXIN_BASE_ID; - -enum { - MIXIN_SUB_ID_ADD_AND_SET, - MIXIN_SUB_ID_LAST -}; - -#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id) - -#define mixin_add_and_print(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EO_TYPECHECK(int, x) +EAPI void mixin_add_and_print(int x); #define MIXIN_CLASS mixin_class_get() const Eo_Class *mixin_class_get(void); diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c index 466bd85c05..768eb47e5f 100644 --- a/src/tests/eo/constructors/constructors_simple.c +++ b/src/tests/eo/constructors/constructors_simple.c @@ -19,24 +19,22 @@ typedef struct static char *class_var = NULL; #define _GET_SET_FUNC(name) \ -static void \ -_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +static int \ +_##name##_get(Eo *obj EINA_UNUSED, void *class_data) \ { \ const Private_Data *pd = class_data; \ - int *name; \ - name = va_arg(*list, int *); \ - *name = pd->name; \ printf("%s %d\n", __func__, pd->name); \ + return pd->name; \ } \ static void \ -_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +_##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ { \ Private_Data *pd = class_data; \ - int name; \ - name = va_arg(*list, int); \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ -} +} \ +EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ +EO2_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) @@ -44,13 +42,11 @@ _GET_SET_FUNC(b) extern int my_init_count; static void -_simple_constructor(Eo *obj, void *class_data, va_list *list) +_simple_constructor(Eo *obj, void *class_data, int a) { Private_Data *pd = class_data; - int a; - a = va_arg(*list, int); - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); pd->a = a; printf("%s %d\n", __func__, pd->a); @@ -59,37 +55,24 @@ _simple_constructor(Eo *obj, void *class_data, va_list *list) } static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); my_init_count++; } static void -_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); my_init_count--; } static void -_class_constructor(Eo_Class *klass) +_class_constructor(Eo_Class *klass EINA_UNUSED) { - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), _simple_constructor), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); - class_var = malloc(10); } @@ -99,26 +82,30 @@ _class_destructor(Eo_Class *klass EINA_UNUSED) free(class_var); } -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_CONSTRUCTOR, "Construct and set A."), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"), - EO_OP_DESCRIPTION_SENTINEL +EO2_VOID_FUNC_BODYV(simple_constructor, EO2_FUNC_CALL(a), int a); + +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC(_simple_constructor, simple_constructor, "Construct and set A."), + EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), + EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), + EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), _class_constructor, _class_destructor }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, MIXIN_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple.h b/src/tests/eo/constructors/constructors_simple.h index 7342d3402e..d8ab0e9d2f 100644 --- a/src/tests/eo/constructors/constructors_simple.h +++ b/src/tests/eo/constructors/constructors_simple.h @@ -1,24 +1,11 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_CONSTRUCTOR, - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_GET, - SIMPLE_SUB_ID_B_SET, - SIMPLE_SUB_ID_B_GET, - SIMPLE_SUB_ID_LAST -}; - -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -#define simple_constructor(a) SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(int, a) -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) -#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) -#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b) -#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b) +EAPI void simple_constructor(int a); +EAPI void simple_a_set(int a); +EAPI int simple_a_get(void); +EAPI void simple_b_set(int b); +EAPI int simple_b_get(void); #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c index b80b22b809..3caabd0cad 100644 --- a/src/tests/eo/constructors/constructors_simple2.c +++ b/src/tests/eo/constructors/constructors_simple2.c @@ -9,34 +9,27 @@ #define MY_CLASS SIMPLE2_CLASS static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); eo_error_set(obj); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple3.c b/src/tests/eo/constructors/constructors_simple3.c index 13453b76e3..1a8a32fac5 100644 --- a/src/tests/eo/constructors/constructors_simple3.c +++ b/src/tests/eo/constructors/constructors_simple3.c @@ -14,27 +14,21 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) (void) obj; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple3", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple4.c b/src/tests/eo/constructors/constructors_simple4.c index abce301e3a..52f17fb488 100644 --- a/src/tests/eo/constructors/constructors_simple4.c +++ b/src/tests/eo/constructors/constructors_simple4.c @@ -10,7 +10,7 @@ #define MY_CLASS SIMPLE4_CLASS static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple4", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), diff --git a/src/tests/eo/constructors/constructors_simple5.c b/src/tests/eo/constructors/constructors_simple5.c index bd2f1a5b3b..ea43291eea 100644 --- a/src/tests/eo/constructors/constructors_simple5.c +++ b/src/tests/eo/constructors/constructors_simple5.c @@ -14,27 +14,21 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) (void) obj; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple5", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple6.c b/src/tests/eo/constructors/constructors_simple6.c index c9988854df..d78cad88e0 100644 --- a/src/tests/eo/constructors/constructors_simple6.c +++ b/src/tests/eo/constructors/constructors_simple6.c @@ -9,34 +9,28 @@ #define MY_CLASS SIMPLE6_CLASS static void -_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); eo_error_set(obj); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs [] = { + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple6", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple7.c b/src/tests/eo/constructors/constructors_simple7.c index 20faba537e..90b11c4984 100644 --- a/src/tests/eo/constructors/constructors_simple7.c +++ b/src/tests/eo/constructors/constructors_simple7.c @@ -14,28 +14,23 @@ static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - fail_if(eo_do_super(obj, MY_CLASS, eo_constructor())); + /* FIXME: Actually test it. */ + eo2_do_super(obj, MY_CLASS, eo2_constructor()); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs [] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple7", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; From f481e8dc645e5472b9dad3cd40270376cf8a24bb Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 16:55:26 +0000 Subject: [PATCH 087/169] eo2: fixed EO2_VOID_CLASS_FUNC_BODY function. --- src/lib/eo/Eo.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e2dfc6dc87..0b3b70cd7b 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -714,13 +714,11 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; void \ Name(void) \ { \ - typedef Ret (*__##Name##_func)(Eo_Class *); \ - Ret _r; \ + typedef void (*__##Name##_func)(Eo_Class *); \ EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_CLASS); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ _func_(call.klass); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ - return _r; \ } #define EO2_CLASS_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ From 0ee8b33bf75aedbc803d1f4825709c4eda04605f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 17:00:09 +0000 Subject: [PATCH 088/169] eo2: migrated function_overrides test to eo2. --- .../function_overrides_inherit.c | 2 +- .../function_overrides_inherit2.c | 71 ++++++++++--------- .../function_overrides_inherit2.h | 17 ++--- .../function_overrides_inherit3.c | 22 +++--- .../function_overrides_main.c | 50 ++++++++----- .../function_overrides_simple.c | 70 +++++++++--------- .../function_overrides_simple.h | 24 +++---- 7 files changed, 124 insertions(+), 132 deletions(-) diff --git a/src/tests/eo/function_overrides/function_overrides_inherit.c b/src/tests/eo/function_overrides/function_overrides_inherit.c index e2dadbec1b..e9657be845 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit.c @@ -9,7 +9,7 @@ #define MY_CLASS INHERIT_CLASS static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index addf9fdd43..71ccaed787 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -9,72 +9,73 @@ #include "../eunit_tests.h" -EAPI Eo_Op INHERIT2_BASE_ID = 0; - #define MY_CLASS INHERIT2_CLASS static void -_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +_a_set(Eo *obj, void *class_data EINA_UNUSED, int a) { - int a; - a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); - eo_do(obj, simple_a_print()); - eo_do_super(obj, MY_CLASS, simple_a_set(a + 1)); + eo2_do(obj, simple_a_print()); + eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); - fail_if(!eo_do_super(obj, MY_CLASS, simple_a_print())); + Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); + pd->a_print_called = EINA_FALSE; + eo2_do_super(obj, MY_CLASS, simple_a_print()); + fail_if(!pd->a_print_called); } +Eina_Bool inherit_print_called = EINA_FALSE; +Eina_Bool inherit2_print_called = EINA_FALSE; + static void -_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_print(Eo *obj, void *class_data EINA_UNUSED) { printf("Hey\n"); - fail_if(eo_do_super(obj, MY_CLASS, inherit2_print())); + inherit2_print_called = EINA_FALSE; + eo2_do_super(obj, MY_CLASS, inherit2_print()); + fail_if(inherit2_print_called); + inherit_print_called = EINA_TRUE; } static void -_print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hey2\n"); + inherit2_print_called = EINA_TRUE; } static void -_class_print(Eo_Class *klass, void *data EINA_UNUSED, va_list *list) +_class_print(Eo_Class *klass, void *data EINA_UNUSED) { - (void) list; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - fail_if(!eo_do_super(klass, MY_CLASS, simple_class_print())); - fail_if(!eo_do_super(klass, MY_CLASS, simple_class_print2())); + class_print_called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, simple_class_print()); + fail_if(!class_print_called); + + class_print2_called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, simple_class_print2()); + fail_if(!class_print2_called); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print), - EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT), _class_print), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODY(inherit2_print); +EAPI EO2_VOID_FUNC_BODY(inherit2_print2); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "Print hey"), - EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "Print hey2"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_print, inherit2_print, "Print hey"), + EO2_OP_FUNC(_print2, inherit2_print2, "Print hey2"), + EO2_OP_CLASS_FUNC_OVERRIDE(_class_print, simple_class_print), + EO2_OP_FUNC_OVERRIDE(_a_set, simple_a_set), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit2", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.h b/src/tests/eo/function_overrides/function_overrides_inherit2.h index 2bc0b0d36a..ca73f23d1f 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.h +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.h @@ -1,20 +1,13 @@ #ifndef INHERIT2_H #define INHERIT2_H -extern EAPI Eo_Op INHERIT2_BASE_ID; - -enum { - INHERIT2_SUB_ID_PRINT, - INHERIT2_SUB_ID_PRINT2, - INHERIT2_SUB_ID_LAST -}; - -#define INHERIT2_ID(sub_id) (INHERIT2_BASE_ID + sub_id) - -#define inherit2_print() INHERIT2_ID(INHERIT2_SUB_ID_PRINT) -#define inherit2_print2() INHERIT2_ID(INHERIT2_SUB_ID_PRINT2) +EAPI void inherit2_print(void); +EAPI void inherit2_print2(void); #define INHERIT2_CLASS inherit2_class_get() const Eo_Class *inherit2_class_get(void); +extern Eina_Bool inherit_print_called; +extern Eina_Bool inherit2_print_called; + #endif diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.c b/src/tests/eo/function_overrides/function_overrides_inherit3.c index ba6f84a229..ed94e4edf5 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit3.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit3.c @@ -15,28 +15,22 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list) int a; a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); - eo_do_super(obj, MY_CLASS, simple_a_set(a + 1)); + eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_a_set, simple_a_set), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit3", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 4210925dfe..1caf9025ff 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -17,45 +17,61 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(INHERIT2_CLASS, NULL); + Eo *obj = eo2_add(INHERIT2_CLASS, NULL); - eo_do(obj, simple_a_set(1)); + eo2_do(obj, simple_a_set(1)); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 2); eo_unref(obj); - obj = eo_add(INHERIT3_CLASS, NULL); + obj = eo2_add(INHERIT3_CLASS, NULL); - eo_do(obj, simple_a_set(1)); + eo2_do(obj, simple_a_set(1)); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 3); eo_unref(obj); - obj = eo_add(INHERIT2_CLASS, NULL); - fail_if(!eo_do(obj, inherit2_print())); - fail_if(!eo_do(obj, inherit2_print(), inherit2_print())); + obj = eo2_add(INHERIT2_CLASS, NULL); + inherit2_print_called = EINA_FALSE; + eo2_do(obj, inherit2_print()); + eo2_do(obj, inherit2_print(), inherit2_print()); + fail_if(!inherit2_print_called); eo_unref(obj); - obj = eo_add(SIMPLE_CLASS, NULL); - fail_if(eo_do(obj, inherit2_print2())); + obj = eo2_add(SIMPLE_CLASS, NULL); + inherit2_print_called = EINA_FALSE; + eo2_do(obj, inherit2_print()); + fail_if(inherit2_print_called); #ifdef EO_DEBUG - fail_if(eo_do(obj, simple_class_print())); + class_print_called = EINA_FALSE; + eo2_do(obj, simple_class_print()); + fail_if(class_print_called); #endif - fail_if(!eo_do(SIMPLE_CLASS, simple_class_print())); - fail_if(!eo_do(INHERIT_CLASS, simple_class_print())); - fail_if(!eo_do(INHERIT2_CLASS, simple_class_print())); - fail_if(!eo_do(INHERIT3_CLASS, simple_class_print())); + class_print_called = EINA_FALSE; + eo2_do(SIMPLE_CLASS, simple_class_print()); + fail_if(!class_print_called); + class_print_called = EINA_FALSE; + eo2_do(INHERIT_CLASS, simple_class_print()); + fail_if(!class_print_called); + class_print_called = EINA_FALSE; + eo2_do(INHERIT2_CLASS, simple_class_print()); + fail_if(!class_print_called); + class_print_called = EINA_FALSE; + eo2_do(INHERIT3_CLASS, simple_class_print()); + fail_if(!class_print_called); #ifdef EO_DEBUG - fail_if(eo_do(SIMPLE_CLASS, simple_a_print())); + pd->a_print_called = EINA_FALSE; + eo2_do(SIMPLE_CLASS, simple_a_print()); + fail_if(pd->a_print_called); #endif - eo_do_super(obj, SIMPLE_CLASS, eo_constructor()); - eo_do_super(obj, SIMPLE_CLASS, eo_destructor()); + eo2_do_super(obj, SIMPLE_CLASS, eo2_constructor()); + eo2_do_super(obj, SIMPLE_CLASS, eo2_destructor()); eo_unref(obj); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index afa4fef9fb..67c36a0c31 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -7,76 +7,72 @@ #include "../eunit_tests.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - #define MY_CLASS SIMPLE_CLASS +Eina_Bool class_print_called = EINA_FALSE; +Eina_Bool class_print2_called = EINA_FALSE; + static void -_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +_a_set(Eo *obj EINA_UNUSED, void *class_data, int a) { Simple_Public_Data *pd = class_data; - int a; - a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); pd->a = a; } static void -_a_print(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +_a_print(Eo *obj EINA_UNUSED, void *class_data) { - const Simple_Public_Data *pd = class_data; - (void) list; + Simple_Public_Data *pd = class_data; printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a); + pd->a_print_called = EINA_TRUE; } static void -_class_print(Eo_Class *klass, void *data EINA_UNUSED, va_list *list) +_class_print(Eo_Class *klass) { - (void) list; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - fail_if(eo_do_super(klass, MY_CLASS, simple_class_print())); - fail_if(eo_do_super(klass, MY_CLASS, simple_class_print2())); + class_print_called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, simple_class_print()); + fail_if(class_print_called); + + class_print2_called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, simple_class_print2()); + fail_if(class_print2_called); + + class_print_called = EINA_TRUE; } static void -_class_print2(Eo_Class *klass, void *data EINA_UNUSED, va_list *list) +_class_print2(Eo_Class *klass) { - (void) list; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); + class_print2_called = EINA_TRUE; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT), _class_print), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT2), _class_print2), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); +EAPI EO2_VOID_FUNC_BODY(simple_a_print); +EAPI EO2_VOID_CLASS_FUNC_BODY(simple_class_print); +EAPI EO2_VOID_CLASS_FUNC_BODY(simple_class_print2); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "Print property A"), - EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_PRINT, "Print class name."), - EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_PRINT2, "Print2 class name."), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), + EO2_OP_FUNC(_a_print, simple_a_print, "Print property A"), + EO2_OP_CLASS_FUNC(_class_print, simple_class_print, "Print class name."), + EO2_OP_CLASS_FUNC(_class_print2, simple_class_print2, "Print2 class name."), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Simple_Public_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.h b/src/tests/eo/function_overrides/function_overrides_simple.h index 3a620fa611..29ab6512b4 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.h +++ b/src/tests/eo/function_overrides/function_overrides_simple.h @@ -1,27 +1,16 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_PRINT, - SIMPLE_SUB_ID_CLASS_PRINT, - SIMPLE_SUB_ID_CLASS_PRINT2, - SIMPLE_SUB_ID_LAST -}; - typedef struct { int a; + Eina_Bool a_print_called; } Simple_Public_Data; -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) -#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT) -#define simple_class_print() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT) -#define simple_class_print2() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT2) +EAPI void simple_a_set(int a); +EAPI void simple_a_print(void); +EAPI void simple_class_print(void); +EAPI void simple_class_print2(void); extern const Eo_Event_Description _SIG_A_CHANGED; #define SIG_A_CHANGED (&(_SIG_A_CHANGED)) @@ -29,4 +18,7 @@ extern const Eo_Event_Description _SIG_A_CHANGED; #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); +extern Eina_Bool class_print_called; +extern Eina_Bool class_print2_called; + #endif From 760a74a150eae80acf898b7388fa868aa5f0b74d Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 17:20:11 +0000 Subject: [PATCH 089/169] eo2: migrated interface test to eo2. --- src/tests/eo/interface/interface_interface.c | 14 ++-- src/tests/eo/interface/interface_interface.h | 17 +---- src/tests/eo/interface/interface_interface2.c | 14 ++-- src/tests/eo/interface/interface_interface2.h | 17 +---- src/tests/eo/interface/interface_main.c | 10 +-- src/tests/eo/interface/interface_simple.c | 74 +++++++------------ src/tests/eo/interface/interface_simple.h | 43 +---------- 7 files changed, 52 insertions(+), 137 deletions(-) diff --git a/src/tests/eo/interface/interface_interface.c b/src/tests/eo/interface/interface_interface.c index c0dec7649d..0afd136b6c 100644 --- a/src/tests/eo/interface/interface_interface.c +++ b/src/tests/eo/interface/interface_interface.c @@ -6,20 +6,20 @@ #include "interface_interface.h" #include "interface_simple.h" -EAPI Eo_Op INTERFACE_BASE_ID = 0; - #define MY_CLASS INTERFACE_CLASS -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(INTERFACE_SUB_ID_AB_SUM_GET, "Get the sum of a and b."), - EO_OP_DESCRIPTION_SENTINEL +EO2_FUNC_BODY(interface_ab_sum_get, int, 0); + +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(NULL, interface_ab_sum_get, "Get the sum of a and b."), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Interface", EO_CLASS_TYPE_INTERFACE, - EO_CLASS_DESCRIPTION_OPS(&INTERFACE_BASE_ID, op_desc, INTERFACE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/interface/interface_interface.h b/src/tests/eo/interface/interface_interface.h index 4e161b8488..9af90a75ee 100644 --- a/src/tests/eo/interface/interface_interface.h +++ b/src/tests/eo/interface/interface_interface.h @@ -1,22 +1,7 @@ #ifndef INTERFACE_H #define INTERFACE_H -extern EAPI Eo_Op INTERFACE_BASE_ID; - -enum { - INTERFACE_SUB_ID_AB_SUM_GET, - INTERFACE_SUB_ID_LAST -}; - -#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id) - - -/** - * @def interface_ab_sum_get(sum) - * @brief Get sum of a,b integer elements - * @param[out] sum integer pointer to sum - value - */ -#define interface_ab_sum_get(sum) INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum) +EAPI int interface_ab_sum_get(void); #define INTERFACE_CLASS interface_class_get() const Eo_Class *interface_class_get(void); diff --git a/src/tests/eo/interface/interface_interface2.c b/src/tests/eo/interface/interface_interface2.c index 14d3f1d0f8..27f2e3c35c 100644 --- a/src/tests/eo/interface/interface_interface2.c +++ b/src/tests/eo/interface/interface_interface2.c @@ -7,20 +7,20 @@ #include "interface_interface2.h" #include "interface_simple.h" -EAPI Eo_Op INTERFACE2_BASE_ID = 0; - #define MY_CLASS INTERFACE2_CLASS -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(INTERFACE2_SUB_ID_AB_SUM_GET2, "Print the sum of a and b."), - EO_OP_DESCRIPTION_SENTINEL +EO2_FUNC_BODY(interface2_ab_sum_get2, int, 0); + +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(NULL, interface2_ab_sum_get2, "Print the sum of a and b."), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Interface2", EO_CLASS_TYPE_INTERFACE, - EO_CLASS_DESCRIPTION_OPS(&INTERFACE2_BASE_ID, op_desc, INTERFACE2_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/interface/interface_interface2.h b/src/tests/eo/interface/interface_interface2.h index 5aa91f4fdc..f02a547d6b 100644 --- a/src/tests/eo/interface/interface_interface2.h +++ b/src/tests/eo/interface/interface_interface2.h @@ -1,22 +1,7 @@ #ifndef INTERFACE2_H #define INTERFACE2_H -extern EAPI Eo_Op INTERFACE2_BASE_ID; - -enum { - INTERFACE2_SUB_ID_AB_SUM_GET2, - INTERFACE2_SUB_ID_LAST -}; - -#define INTERFACE2_ID(sub_id) (INTERFACE2_BASE_ID + sub_id) - - -/** - * @def interface2_ab_sum_get2(sum) - * @brief Get sum of a,b integer elements - * @param[out] sum integer pointer to sum - value - */ -#define interface2_ab_sum_get2(sum) INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), EO_TYPECHECK(int *, sum) +EAPI int interface2_ab_sum_get2(void); #define INTERFACE2_CLASS interface2_class_get() const Eo_Class *interface2_class_get(void); diff --git a/src/tests/eo/interface/interface_main.c b/src/tests/eo/interface/interface_main.c index 5fa65266f6..b532f269e4 100644 --- a/src/tests/eo/interface/interface_main.c +++ b/src/tests/eo/interface/interface_main.c @@ -16,18 +16,18 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - eo_do(obj, simple_a_set(1), simple_b_set(2)); + eo2_do(obj, simple_a_set(1), simple_b_set(2)); int a, b, sum = 0; - eo_do(obj, simple_a_get(&a), simple_b_get(&b), interface_ab_sum_get(&sum)); + eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = interface_ab_sum_get()); fail_if(sum != a + b); sum = 0; - eo_do(obj, interface_ab_sum_get(&sum), interface_ab_sum_get(&sum)); + eo2_do(obj, sum = interface_ab_sum_get(), sum = interface_ab_sum_get()); fail_if(sum != a + b); - eo_do(obj, interface2_ab_sum_get2(&sum), interface2_ab_sum_get2(&sum)); + eo2_do(obj, sum = interface2_ab_sum_get2(), sum = interface2_ab_sum_get2()); fail_if(sum != a + b + 1); eo_unref(obj); diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index e6f3c156b5..998c41b4b6 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -18,83 +18,63 @@ typedef struct #define MY_CLASS SIMPLE_CLASS #define _GET_SET_FUNC(name) \ -static void \ -_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +static int \ +_##name##_get(Eo *obj EINA_UNUSED, void *class_data) \ { \ const Private_Data *pd = class_data; \ - int *name; \ - name = va_arg(*list, int *); \ - *name = pd->name; \ printf("%s %d\n", __func__, pd->name); \ + return pd->name; \ } \ static void \ -_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +_##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ { \ Private_Data *pd = class_data; \ - int name; \ - name = va_arg(*list, int); \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ -} +} \ +EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ +EO2_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) -static void -_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { int a, b; - eo_do(obj, simple_a_get(&a), simple_b_get(&b)); - int *sum = va_arg(*list, int *); - if (sum) - *sum = a + b; + eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); + return a + b; } -static void -_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED) { int a, b; - eo_do(obj, simple_a_get(&a), simple_b_get(&b)); - int *sum = va_arg(*list, int *); - if (sum) - *sum = a + b + 1; + eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); + return a + b + 1; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get), - EO_OP_FUNC(INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), _ab_sum_get), - EO_OP_FUNC(INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), _ab_sum_get2), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), + EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), + EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), + EO2_OP_FUNC_OVERRIDE(_ab_sum_get, interface_ab_sum_get), + EO2_OP_FUNC_OVERRIDE(_ab_sum_get2, interface2_ab_sum_get2), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE2_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, INTERFACE2_CLASS, NULL); diff --git a/src/tests/eo/interface/interface_simple.h b/src/tests/eo/interface/interface_simple.h index 8df8131278..c4b3d7bee5 100644 --- a/src/tests/eo/interface/interface_simple.h +++ b/src/tests/eo/interface/interface_simple.h @@ -1,45 +1,10 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_GET, - SIMPLE_SUB_ID_B_SET, - SIMPLE_SUB_ID_B_GET, - SIMPLE_SUB_ID_LAST -}; - -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -/** - * @def simple_a_set(a) - * @brief Set value to a-property - * @param[in] a integer value to set - */ -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) - -/** - * @def simple_a_get(a) - * @brief Get value of a-property - * @param[out] integer pointer to a-value - */ -#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) - -/** - * @def simple_b_set(b) - * @brief Set value to b-property - * @param[in] a integer value to set - */ -#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b) - -/** - * @def simple_b_get(b) - * @brief Get value of b-property - * @param[out] integer pointer to b-value - */ -#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b) +EAPI void simple_a_set(int a); +EAPI int simple_a_get(void); +EAPI void simple_b_set(int b); +EAPI int simple_b_get(void); #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); From 18698086b4588ebb5a7567c1a8f2836e91d9d4d1 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 17:47:34 +0000 Subject: [PATCH 090/169] eo2: migrated signals test to eo2. --- src/tests/eo/signals/signals_main.c | 110 +++++++++++++------------- src/tests/eo/signals/signals_simple.c | 46 ++++------- src/tests/eo/signals/signals_simple.h | 16 +--- 3 files changed, 73 insertions(+), 99 deletions(-) diff --git a/src/tests/eo/signals/signals_main.c b/src/tests/eo/signals/signals_main.c index 7c7b786977..17f6af1b54 100644 --- a/src/tests/eo/signals/signals_main.c +++ b/src/tests/eo/signals/signals_main.c @@ -29,8 +29,8 @@ _a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event cb_count++; - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423)); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423)); /* Stop as we reached the 3rd one. */ return (cb_count != 3); @@ -43,136 +43,136 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); /* The order of these two is undetermined. */ - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); /* This will be called afterwards. */ - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3)); /* This will never be called because the previous callback returns NULL. */ - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4)); - eo_do(obj, simple_a_set(1)); + eo2_do(obj, simple_a_set(1)); fail_if(cb_count != 3); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3)); fail_if(pd->cb_count != 3); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12)); fail_if(pd->cb_count != 3); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4)); fail_if(pd->cb_count != 2); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 0); /* Freeze/thaw. */ int fcount = 0; cb_count = 0; - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 0); - eo_do(obj, eo_event_freeze()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_freeze()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 1); - eo_do(obj, eo_event_freeze()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_freeze()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 2); - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo_do(obj, simple_a_set(2)); + eo2_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(obj, eo_event_thaw()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_thaw()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 1); - eo_do(obj, eo_event_thaw()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_thaw()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 0); - eo_do(obj, simple_a_set(3)); + eo2_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; - eo_do(obj, eo_event_thaw()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_thaw()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 0); - eo_do(obj, eo_event_freeze()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_freeze()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 1); - eo_do(obj, simple_a_set(2)); + eo2_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(obj, eo_event_thaw()); - eo_do(obj, eo_event_freeze_get(&fcount)); + eo2_do(obj, eo2_event_thaw()); + eo2_do(obj, fcount = eo2_event_freeze_get()); fail_if(fcount != 0); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 0); - eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); + eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != -1); /* Global Freeze/thaw. */ fcount = 0; cb_count = 0; pd->cb_count = 0; - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 0); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 1); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 2); - eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo_do(obj, simple_a_set(2)); + eo2_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 1); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 0); - eo_do(obj, simple_a_set(3)); + eo2_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 0); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 1); - eo_do(obj, simple_a_set(2)); + eo2_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); + eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); + eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); fail_if(fcount != 0); diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c index 1417988bbc..4b7364772a 100644 --- a/src/tests/eo/signals/signals_simple.c +++ b/src/tests/eo/signals/signals_simple.c @@ -5,8 +5,6 @@ #include "Eo.h" #include "signals_simple.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - typedef struct { Simple_Public_Data pub; @@ -19,15 +17,13 @@ EAPI const Eo_Event_Description _EV_A_CHANGED = #define MY_CLASS SIMPLE_CLASS static void -_a_set(Eo *obj, void *class_data, va_list *list) +_a_set(Eo *obj, void *class_data, int a) { Private_Data *pd = class_data; - int a; - a = va_arg(*list, int); pd->a = a; printf("%s %d\n", __func__, pd->a); - eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL)); + eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); } Eina_Bool @@ -65,48 +61,40 @@ _cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_inf } static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); - eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); - eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); + eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); + eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); - eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL)); + eo2_do(obj, eo2_base_data_set("cb_count", (intptr_t) 0, NULL)); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_SENTINEL }; + static const Eo_Event_Description *event_desc[] = { EV_A_CHANGED, NULL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); diff --git a/src/tests/eo/signals/signals_simple.h b/src/tests/eo/signals/signals_simple.h index d1f63bdd06..ba50f98b4c 100644 --- a/src/tests/eo/signals/signals_simple.h +++ b/src/tests/eo/signals/signals_simple.h @@ -1,26 +1,12 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_LAST -}; - typedef struct { int cb_count; } Simple_Public_Data; -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -/** - * @def simple_a_set(a) - * @brief Set value to a - property - * @param[in] a integer value to set - */ -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) +EAPI void simple_a_set(int a); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) From b7176a93d312d41073dc6c62634b686176abcc62 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 17:49:51 +0000 Subject: [PATCH 091/169] eo2 base class: fixed regular and class event functions confusion. --- src/lib/eo/eo2_base_class.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 631e1f2459..2da47b3122 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -788,7 +788,7 @@ _ev_global_freeze(const Eo_Class *klass EINA_UNUSED) { event_freeze_count++; } -EAPI EO2_VOID_FUNC_BODY(eo2_event_global_freeze); +EAPI EO2_VOID_CLASS_FUNC_BODY(eo2_event_global_freeze); static void _ev_global_thaw(const Eo_Class *klass EINA_UNUSED) @@ -802,14 +802,14 @@ _ev_global_thaw(const Eo_Class *klass EINA_UNUSED) ERR("Global events have already been thawed."); } } -EAPI EO2_VOID_FUNC_BODY(eo2_event_global_thaw); +EAPI EO2_VOID_CLASS_FUNC_BODY(eo2_event_global_thaw); static int _ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED) { return event_freeze_count; } -EAPI EO2_FUNC_BODY(eo2_event_global_freeze_get, int, 0); +EAPI EO2_CLASS_FUNC_BODY(eo2_event_global_freeze_get, int, 0); /* Eo_Dbg */ EAPI void @@ -967,12 +967,12 @@ static Eo2_Op_Description op_descs [] = { EO2_OP_FUNC(_ev_cb_call, eo2_event_callback_call, "Call the event callbacks for an event."), EO2_OP_FUNC(_ev_cb_forwarder_add, eo2_event_callback_forwarder_add, "Add an event forwarder."), EO2_OP_FUNC(_ev_cb_forwarder_del, eo2_event_callback_forwarder_del, "Delete an event forwarder."), - EO2_OP_CLASS_FUNC(_ev_freeze, eo2_event_freeze, "Freezes events."), - EO2_OP_CLASS_FUNC(_ev_thaw, eo2_event_thaw, "Thaws events."), - EO2_OP_CLASS_FUNC(_ev_freeze_get, eo2_event_freeze_get, "Get event freeze counter."), - EO2_OP_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), - EO2_OP_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), - EO2_OP_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), + EO2_OP_FUNC(_ev_freeze, eo2_event_freeze, "Freezes events."), + EO2_OP_FUNC(_ev_thaw, eo2_event_thaw, "Thaws events."), + EO2_OP_FUNC(_ev_freeze_get, eo2_event_freeze_get, "Get event freeze counter."), + EO2_OP_CLASS_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), + EO2_OP_CLASS_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), + EO2_OP_CLASS_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), EO2_OP_FUNC(_dbg_info_get, eo2_dbg_info_get, "Get debug info list for obj."), EO2_OP_SENTINEL }; From 9a9fdb46fe491f47238fcd6d42154f7dbd7c1043 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Nov 2013 18:00:14 +0000 Subject: [PATCH 092/169] eo2 test composite: migrated things I forgot to migrate. --- src/tests/eo/composite_objects/composite_objects_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index 71b0d08090..9141ec5f33 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -30,7 +30,7 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(COMP_CLASS, NULL); + Eo *obj = eo2_add(COMP_CLASS, NULL); eo2_do(obj, eo2_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL)); fail_if(!eo_isa(obj, COMP_CLASS)); From 23e2c29298bc0ae27d748b4388ca718d0c678a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 7 Nov 2013 23:38:36 +0100 Subject: [PATCH 093/169] eo2: remove EO2_CLASS_FUNC_* macros there is no more difference in class or regular functions prototypes and definitions - eo2_api_op_id_get() uses _eo_is_a_class() at runtime - add 'void *class_data EINA_UNUSED' parameter to eo2_base class functions - Eo2_Op_Call_Data.klass is kept only for eo2_hook_call_pre end eo2_hook_call_post, but could be removed easily --- src/lib/eo/Eo.h | 66 +++++-------------------------------- src/lib/eo/eo.c | 31 +++++++---------- src/lib/eo/eo2_base_class.c | 18 +++++----- 3 files changed, 29 insertions(+), 86 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 0b3b70cd7b..726078a312 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -616,7 +616,7 @@ EAPI Eina_Bool eo_shutdown(void); typedef struct _Eo2_Op_Call_Data { Eo *obj; - Eo_Class *klass; + Eo_Class *klass; // remove this not necessary in Eo2_Hook_Call void *func; void *data; } Eo2_Op_Call_Data; @@ -628,7 +628,6 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; // to pass the internal function call to EO2_FUNC_BODY (as Func parameter) #define EO2_FUNC_CALL(...) __VA_ARGS__ -#define EO2_CLASS_FUNC_CALL(...) __VA_ARGS__ #define EO2_HOOK_CALL_PREPARE(Hook) \ if (Hook) \ @@ -639,11 +638,11 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Hook(call.klass, call.obj, call.func, __VA_ARGS__); // cache OP id, get real fct and object data then do the call -#define EO2_FUNC_COMMON_OP(Name, DefRet, Type) \ +#define EO2_FUNC_COMMON_OP(Name, DefRet) \ Eo2_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) \ - op = eo2_api_op_id_get((void*)Name, Type); \ + op = eo2_api_op_id_get((void*)Name); \ if (!eo2_call_resolve(#Name, op, &call)) return DefRet; \ __##Name##_func _func_ = (__##Name##_func) call.func; \ @@ -654,7 +653,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ Ret _r; \ - EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_REGULAR); \ + EO2_FUNC_COMMON_OP(Name, DefRet); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ _r = _func_(call.obj, call.data); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ @@ -666,7 +665,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Name(void) \ { \ typedef void (*__##Name##_func)(Eo *, void *obj_data); \ - EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_REGULAR); \ + EO2_FUNC_COMMON_OP(Name, ); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ _func_(call.obj, call.data); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ @@ -678,7 +677,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; { \ typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ Ret _r; \ - EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_REGULAR); \ + EO2_FUNC_COMMON_OP(Name, DefRet); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ _r = _func_(call.obj, call.data, Arguments); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ @@ -690,61 +689,12 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Name(__VA_ARGS__) \ { \ typedef void (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__);\ - EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_REGULAR); \ + EO2_FUNC_COMMON_OP(Name, ); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ _func_(call.obj, 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 *); \ - Ret _r; \ - EO2_FUNC_COMMON_OP(Name, DefRet, EO_OP_TYPE_CLASS); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ - _r = _func_(call.klass); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ - return _r; \ - } - -#define EO2_VOID_CLASS_FUNC_BODY(Name) \ - void \ - Name(void) \ - { \ - typedef void (*__##Name##_func)(Eo_Class *); \ - EO2_FUNC_COMMON_OP(Name, , EO_OP_TYPE_CLASS); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ - _func_(call.klass); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ - } - -#define EO2_CLASS_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ - Ret \ - Name(__VA_ARGS__) \ - { \ - typedef Ret (*__##Name##_func)(Eo_Class *, __VA_ARGS__); \ - 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, Arguments); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ - return _r; \ - } - -#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, Arguments); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ - } - // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) @@ -755,7 +705,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_api_op_id_get(const void *api_func, const Eo_Op_Type); +EAPI Eo_Op eo2_api_op_id_get(const void *api_func); // gets the real function pointer and the object data EAPI Eina_Bool eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index c7d6530909..6a69c14eca 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -461,12 +461,12 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) if (EINA_LIKELY(func->func && func->src )) { - call->obj = (Eo *)fptr->eo_id; - call->klass = _eo_class_id_get(klass); call->func = func->func; + call->klass = _eo_class_id_get(klass); if (obj) { + call->obj = (Eo *)fptr->eo_id; if (func->src == obj->klass) { if (fptr->obj_data == EO2_INVALID_DATA) @@ -478,7 +478,10 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) call->data = _eo_data_scope_get(obj, func->src); } else - call->data = NULL; + { + call->obj = call->klass; + call->data = NULL; + } return EINA_TRUE; } @@ -569,33 +572,23 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class } EAPI Eo_Op -eo2_api_op_id_get(const void *api_func, const Eo_Op_Type op_type) +eo2_api_op_id_get(const void *api_func) { const Eo2_Op_Description *desc; const _Eo_Class *klass; - if (op_type == EO_OP_TYPE_REGULAR) - klass = eo2_call_stack.frame_ptr->obj->klass; - else if (op_type == EO_OP_TYPE_CLASS) + Eina_Bool class_ref = _eo_is_a_class(eo2_call_stack.frame_ptr->eo_id); + + if (class_ref) klass = eo2_call_stack.frame_ptr->cur_klass; else - { - ERR("api func %p, unknown op type %d", api_func, op_type); - return EO_NOOP; - } + klass = eo2_call_stack.frame_ptr->obj->klass; desc = _eo2_api_desc_get(api_func, klass, klass->extensions); if (desc == NULL) { - ERR("unable to resolve api func %p, op type %d", api_func,op_type); - return EO_NOOP; - } - - if (desc->op_type != op_type) - { - ERR("api func %p resolves to %d, op type %d instead of %d", - api_func, (int) desc->op, desc->op_type, op_type); + ERR("unable to resolve %s api func %p", (class_ref ? "class" : "regular"), api_func); return EO_NOOP; } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 2da47b3122..db257af50d 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -784,14 +784,14 @@ _ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) EAPI EO2_FUNC_BODY(eo2_event_freeze_get, int, 0); static void -_ev_global_freeze(const Eo_Class *klass EINA_UNUSED) +_ev_global_freeze(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { event_freeze_count++; } -EAPI EO2_VOID_CLASS_FUNC_BODY(eo2_event_global_freeze); +EAPI EO2_VOID_FUNC_BODY(eo2_event_global_freeze); static void -_ev_global_thaw(const Eo_Class *klass EINA_UNUSED) +_ev_global_thaw(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { if (event_freeze_count > 0) { @@ -802,14 +802,14 @@ _ev_global_thaw(const Eo_Class *klass EINA_UNUSED) ERR("Global events have already been thawed."); } } -EAPI EO2_VOID_CLASS_FUNC_BODY(eo2_event_global_thaw); +EAPI EO2_VOID_FUNC_BODY(eo2_event_global_thaw); static int -_ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED) +_ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { return event_freeze_count; } -EAPI EO2_CLASS_FUNC_BODY(eo2_event_global_freeze_get, int, 0); +EAPI EO2_FUNC_BODY(eo2_event_global_freeze_get, int, 0); /* Eo_Dbg */ EAPI void @@ -970,9 +970,9 @@ static Eo2_Op_Description op_descs [] = { EO2_OP_FUNC(_ev_freeze, eo2_event_freeze, "Freezes events."), EO2_OP_FUNC(_ev_thaw, eo2_event_thaw, "Thaws events."), EO2_OP_FUNC(_ev_freeze_get, eo2_event_freeze_get, "Get event freeze counter."), - EO2_OP_CLASS_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), - EO2_OP_CLASS_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), - EO2_OP_CLASS_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), + EO2_OP_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), + EO2_OP_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), + EO2_OP_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), EO2_OP_FUNC(_dbg_info_get, eo2_dbg_info_get, "Get debug info list for obj."), EO2_OP_SENTINEL }; From 78973fba6ce863da19a840b22adf230be7b3d942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:09:47 +0100 Subject: [PATCH 094/169] eo2: fix tests, do not use _CLASS_FUNC_, see previous commit --- .../function_overrides/function_overrides_simple.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index 67c36a0c31..0819544491 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -29,7 +29,7 @@ _a_print(Eo *obj EINA_UNUSED, void *class_data) } static void -_class_print(Eo_Class *klass) +_class_print(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); class_print_called = EINA_FALSE; @@ -44,7 +44,7 @@ _class_print(Eo_Class *klass) } static void -_class_print2(Eo_Class *klass) +_class_print2(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); class_print2_called = EINA_TRUE; @@ -52,14 +52,14 @@ _class_print2(Eo_Class *klass) EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); EAPI EO2_VOID_FUNC_BODY(simple_a_print); -EAPI EO2_VOID_CLASS_FUNC_BODY(simple_class_print); -EAPI EO2_VOID_CLASS_FUNC_BODY(simple_class_print2); +EAPI EO2_VOID_FUNC_BODY(simple_class_print); +EAPI EO2_VOID_FUNC_BODY(simple_class_print2); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), EO2_OP_FUNC(_a_print, simple_a_print, "Print property A"), - EO2_OP_CLASS_FUNC(_class_print, simple_class_print, "Print class name."), - EO2_OP_CLASS_FUNC(_class_print2, simple_class_print2, "Print2 class name."), + EO2_OP_FUNC(_class_print, simple_class_print, "Print class name."), + EO2_OP_FUNC(_class_print2, simple_class_print2, "Print2 class name."), EO2_OP_SENTINEL }; From 11595dc40c7a4a01e97f4c75a660f7730616473c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:42:42 +0100 Subject: [PATCH 095/169] eo2: fix mixim elaboration a mixin class must not inherit - _eo2_api_desc_get() accept NULL klass param EO_CLASS_TYPE_REGULAR_NO_INSTANT is an acceptable extension class type for - _eo2_class_funcs_set() do not shout if parent is NULL --- src/lib/eo/eo.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 6a69c14eca..9688662616 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -533,26 +533,29 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class const Eo2_Op_Description *op_desc; const Eo2_Op_Description *op_descs; - for (kls_itr = klass->mro ; *kls_itr ; kls_itr++) + if (klass) { - cur_klass = *kls_itr; - imin = 0; - imax = cur_klass->desc->ops.count - 1; - op_descs = cur_klass->desc->ops.descs2; - - while (imax >= imin) + for (kls_itr = klass->mro ; *kls_itr ; kls_itr++) { - imid = (imax + imin) / 2; - op_desc = op_descs + imid; + cur_klass = *kls_itr; + imin = 0; + imax = cur_klass->desc->ops.count - 1; + op_descs = cur_klass->desc->ops.descs2; + + while (imax >= imin) + { + imid = (imax + imin) / 2; + op_desc = op_descs + imid; + + if (op_desc->api_func > api_func) + imin = imid + 1; + else if (op_desc->api_func < api_func) + imax = imid - 1; + else + return op_desc; + } - if (op_desc->api_func > api_func) - imin = imid + 1; - else if (op_desc->api_func < api_func) - imax = imid - 1; - else - return op_desc; } - } if (extns) @@ -560,7 +563,8 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class for (kls_itr = extns ; *kls_itr ; kls_itr++) { cur_klass = *kls_itr; - if (cur_klass->desc->type == EO_CLASS_TYPE_REGULAR) + if (cur_klass->desc->type == EO_CLASS_TYPE_REGULAR + || cur_klass->desc->type == EO_CLASS_TYPE_REGULAR_NO_INSTANT) { op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); if (op_desc) return op_desc; @@ -633,10 +637,6 @@ _eo2_class_funcs_set(_Eo_Class *klass) } else if (op_desc->op == EO2_OP_OVERRIDE) { - if (klass->parent == NULL) - ERR("Can't inherit from a NULL parent. Class '%s', Func index: %lu", - klass->desc->name, (unsigned long) (op_desc - op_descs)); - api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent, klass->extensions); if (api_desc == NULL) From 36c5127822ed125e840192a3908b19f97a7fd866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:49:05 +0100 Subject: [PATCH 096/169] eo2: add EO2_CLASS_DESCRIPTION_NOOPS() macros --- src/lib/eo/Eo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 726078a312..b27d88a7e6 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -609,7 +609,8 @@ EAPI Eina_Bool eo_shutdown(void); // computes size of Eo2_Op_Description[] #define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) -// An helper macro to help populating #Eo_Class_Description. +// Helpers macro to help populating #Eo_Class_Description. +#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, NULL, 0} #define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } // to fetch internal function and object data at once From b8e9b14699603a3126e31f08bf41596ed55dd757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:50:05 +0100 Subject: [PATCH 097/169] eo2: fix some op descriptions in constructors tests --- src/tests/eo/constructors/constructors_simple2.c | 1 + src/tests/eo/constructors/constructors_simple4.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c index 3caabd0cad..3f6d6bdded 100644 --- a/src/tests/eo/constructors/constructors_simple2.c +++ b/src/tests/eo/constructors/constructors_simple2.c @@ -18,6 +18,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { diff --git a/src/tests/eo/constructors/constructors_simple4.c b/src/tests/eo/constructors/constructors_simple4.c index 52f17fb488..71fca13476 100644 --- a/src/tests/eo/constructors/constructors_simple4.c +++ b/src/tests/eo/constructors/constructors_simple4.c @@ -13,7 +13,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Simple4", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, From 9c1856bf820296a67fd89b05e9df0acdbb74adb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:51:00 +0100 Subject: [PATCH 098/169] eo2: support NULL op_descs --- src/lib/eo/eo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 9688662616..f5a77b692e 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -623,7 +623,8 @@ _eo2_class_funcs_set(_Eo_Class *klass) qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); op_id = klass->base_id; - DBG("Set functions for class '%s'", klass->desc->name); + DBG("Set functions for class '%s' %p", klass->desc->name, klass); + if (!op_descs) return; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if(op_desc->api_func == NULL) From 541cf257238ae30acef0f46064c201dc5a84a674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 00:51:22 +0100 Subject: [PATCH 099/169] eo2: eo2_add_internal_end() return NULL if do_error is set --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index f5a77b692e..24da48a8ae 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -720,7 +720,7 @@ eo2_add_internal_end(const char *file, int line, const Eo *eo_id) return NULL; } - if (!fptr->obj->condtor_done) + if (!fptr->obj->condtor_done || fptr->obj->do_error) { ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", file, line, fptr->cur_klass->desc->name); From ca1f24536641c45eb356a4d304d845661c528a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 03:01:04 +0000 Subject: [PATCH 100/169] eo2: _eo2_api_desc_get can look into interfaces extensions too --- src/lib/eo/eo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 24da48a8ae..942a6d49cc 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -564,7 +564,8 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class { cur_klass = *kls_itr; if (cur_klass->desc->type == EO_CLASS_TYPE_REGULAR - || cur_klass->desc->type == EO_CLASS_TYPE_REGULAR_NO_INSTANT) + || cur_klass->desc->type == EO_CLASS_TYPE_REGULAR_NO_INSTANT + || cur_klass->desc->type == EO_CLASS_TYPE_INTERFACE) { op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); if (op_desc) return op_desc; From 3a524e42010848ad91749ff8ca2259717a16b2af Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:15:22 +0000 Subject: [PATCH 101/169] eo2: fix function overrides test. --- .../eo/function_overrides/function_overrides_inherit2.c | 8 ++++---- .../eo/function_overrides/function_overrides_inherit2.h | 2 +- .../eo/function_overrides/function_overrides_inherit3.c | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index 71ccaed787..e0920313cd 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -24,8 +24,8 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) fail_if(!pd->a_print_called); } -Eina_Bool inherit_print_called = EINA_FALSE; Eina_Bool inherit2_print_called = EINA_FALSE; +Eina_Bool inherit2_print2_called = EINA_FALSE; static void _print(Eo *obj, void *class_data EINA_UNUSED) @@ -33,15 +33,15 @@ _print(Eo *obj, void *class_data EINA_UNUSED) printf("Hey\n"); inherit2_print_called = EINA_FALSE; eo2_do_super(obj, MY_CLASS, inherit2_print()); - fail_if(inherit2_print_called); - inherit_print_called = EINA_TRUE; + // FIXME fail_if(inherit2_print_called); + inherit2_print_called = EINA_TRUE; } static void _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hey2\n"); - inherit2_print_called = EINA_TRUE; + inherit2_print2_called = EINA_TRUE; } static void diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.h b/src/tests/eo/function_overrides/function_overrides_inherit2.h index ca73f23d1f..c891bd966d 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.h +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.h @@ -7,7 +7,7 @@ EAPI void inherit2_print2(void); #define INHERIT2_CLASS inherit2_class_get() const Eo_Class *inherit2_class_get(void); -extern Eina_Bool inherit_print_called; extern Eina_Bool inherit2_print_called; +extern Eina_Bool inherit2_print2_called; #endif diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.c b/src/tests/eo/function_overrides/function_overrides_inherit3.c index ed94e4edf5..ad4cb67f8c 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit3.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit3.c @@ -10,10 +10,8 @@ #define MY_CLASS INHERIT3_CLASS static void -_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +_a_set(Eo *obj, void *class_data EINA_UNUSED, int a) { - int a; - a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); } From 13b30abe56becfdd38a4cd613ae13c4eaeeac72e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:25:38 +0000 Subject: [PATCH 102/169] eo2: cleaned up the function overrides test. --- .../function_overrides_inherit2.c | 45 +++++++++--------- .../function_overrides_inherit2.h | 7 +-- .../function_overrides_main.c | 47 +++++++++---------- .../function_overrides_simple.c | 31 ++++++------ .../function_overrides_simple.h | 10 ++-- 5 files changed, 65 insertions(+), 75 deletions(-) diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index e0920313cd..f228528719 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -18,47 +18,46 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) eo2_do(obj, simple_a_print()); eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); - Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); - pd->a_print_called = EINA_FALSE; - eo2_do_super(obj, MY_CLASS, simple_a_print()); - fail_if(!pd->a_print_called); + Eina_Bool called; + eo2_do_super(obj, MY_CLASS, called = simple_a_print()); + fail_if(!called); } -Eina_Bool inherit2_print_called = EINA_FALSE; -Eina_Bool inherit2_print2_called = EINA_FALSE; - -static void +static Eina_Bool _print(Eo *obj, void *class_data EINA_UNUSED) { + Eina_Bool called; printf("Hey\n"); - inherit2_print_called = EINA_FALSE; - eo2_do_super(obj, MY_CLASS, inherit2_print()); - // FIXME fail_if(inherit2_print_called); - inherit2_print_called = EINA_TRUE; + eo2_do_super(obj, MY_CLASS, called = inherit2_print()); + fail_if(called); + + return EINA_TRUE; } -static void +static Eina_Bool _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hey2\n"); - inherit2_print2_called = EINA_TRUE; + + return EINA_TRUE; } -static void +static Eina_Bool _class_print(Eo_Class *klass, void *data EINA_UNUSED) { + Eina_Bool called; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print()); - fail_if(!class_print_called); + eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + fail_if(!called); - class_print2_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print2()); - fail_if(!class_print2_called); + eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + fail_if(!called); + + return EINA_TRUE; } -EAPI EO2_VOID_FUNC_BODY(inherit2_print); -EAPI EO2_VOID_FUNC_BODY(inherit2_print2); +EAPI EO2_FUNC_BODY(inherit2_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(inherit2_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(_print, inherit2_print, "Print hey"), diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.h b/src/tests/eo/function_overrides/function_overrides_inherit2.h index c891bd966d..48be203664 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.h +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.h @@ -1,13 +1,10 @@ #ifndef INHERIT2_H #define INHERIT2_H -EAPI void inherit2_print(void); -EAPI void inherit2_print2(void); +EAPI Eina_Bool inherit2_print(void); +EAPI Eina_Bool inherit2_print2(void); #define INHERIT2_CLASS inherit2_class_get() const Eo_Class *inherit2_class_get(void); -extern Eina_Bool inherit2_print_called; -extern Eina_Bool inherit2_print2_called; - #endif diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 1caf9025ff..11f4c8f999 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -17,6 +17,7 @@ main(int argc, char *argv[]) (void) argv; eo_init(); + Eina_Bool called; Eo *obj = eo2_add(INHERIT2_CLASS, NULL); eo2_do(obj, simple_a_set(1)); @@ -34,40 +35,36 @@ main(int argc, char *argv[]) eo_unref(obj); obj = eo2_add(INHERIT2_CLASS, NULL); - inherit2_print_called = EINA_FALSE; - eo2_do(obj, inherit2_print()); - eo2_do(obj, inherit2_print(), inherit2_print()); - fail_if(!inherit2_print_called); + eo2_do(obj, called = inherit2_print()); + fail_if(!called); + eo2_do(obj, called = inherit2_print(), called = inherit2_print()); + fail_if(!called); eo_unref(obj); obj = eo2_add(SIMPLE_CLASS, NULL); - inherit2_print_called = EINA_FALSE; - eo2_do(obj, inherit2_print()); - fail_if(inherit2_print_called); + eo2_do(obj, called = inherit2_print()); + fail_if(called); #ifdef EO_DEBUG - class_print_called = EINA_FALSE; - eo2_do(obj, simple_class_print()); - fail_if(class_print_called); + eo2_do(obj, called = simple_class_print()); + fail_if(called); #endif - class_print_called = EINA_FALSE; - eo2_do(SIMPLE_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT2_CLASS, simple_class_print()); - fail_if(!class_print_called); - class_print_called = EINA_FALSE; - eo2_do(INHERIT3_CLASS, simple_class_print()); - fail_if(!class_print_called); + eo2_do(SIMPLE_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT2_CLASS, called = simple_class_print()); + fail_if(!called); + + eo2_do(INHERIT3_CLASS, called = simple_class_print()); + fail_if(!called); #ifdef EO_DEBUG - pd->a_print_called = EINA_FALSE; - eo2_do(SIMPLE_CLASS, simple_a_print()); - fail_if(pd->a_print_called); + eo2_do(SIMPLE_CLASS, called = simple_a_print()); + fail_if(called); #endif eo2_do_super(obj, SIMPLE_CLASS, eo2_constructor()); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index 0819544491..3de5938aad 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -20,40 +20,41 @@ _a_set(Eo *obj EINA_UNUSED, void *class_data, int a) pd->a = a; } -static void +static Eina_Bool _a_print(Eo *obj EINA_UNUSED, void *class_data) { Simple_Public_Data *pd = class_data; printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a); - pd->a_print_called = EINA_TRUE; + + return EINA_TRUE; } -static void +static Eina_Bool _class_print(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print()); - fail_if(class_print_called); + Eina_Bool called = EINA_FALSE; + eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + fail_if(called); - class_print2_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print2()); - fail_if(class_print2_called); + eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + fail_if(called); - class_print_called = EINA_TRUE; + return EINA_TRUE; } -static void +static Eina_Bool _class_print2(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - class_print2_called = EINA_TRUE; + + return EINA_TRUE; } EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -EAPI EO2_VOID_FUNC_BODY(simple_a_print); -EAPI EO2_VOID_FUNC_BODY(simple_class_print); -EAPI EO2_VOID_FUNC_BODY(simple_class_print2); +EAPI EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(simple_class_print, Eina_Bool, EINA_FALSE); +EAPI EO2_FUNC_BODY(simple_class_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), diff --git a/src/tests/eo/function_overrides/function_overrides_simple.h b/src/tests/eo/function_overrides/function_overrides_simple.h index 29ab6512b4..e4739685b2 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.h +++ b/src/tests/eo/function_overrides/function_overrides_simple.h @@ -4,13 +4,12 @@ typedef struct { int a; - Eina_Bool a_print_called; } Simple_Public_Data; EAPI void simple_a_set(int a); -EAPI void simple_a_print(void); -EAPI void simple_class_print(void); -EAPI void simple_class_print2(void); +EAPI Eina_Bool simple_a_print(void); +EAPI Eina_Bool simple_class_print(void); +EAPI Eina_Bool simple_class_print2(void); extern const Eo_Event_Description _SIG_A_CHANGED; #define SIG_A_CHANGED (&(_SIG_A_CHANGED)) @@ -18,7 +17,4 @@ extern const Eo_Event_Description _SIG_A_CHANGED; #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); -extern Eina_Bool class_print_called; -extern Eina_Bool class_print2_called; - #endif From e4f0e4c410370e0be068812ebbe0392a9a7aac24 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:30:17 +0000 Subject: [PATCH 103/169] eo2: constructors test, removed obsolete Eo_Op. --- src/tests/eo/constructors/constructors_simple.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c index 768eb47e5f..f5ab9f5123 100644 --- a/src/tests/eo/constructors/constructors_simple.c +++ b/src/tests/eo/constructors/constructors_simple.c @@ -6,8 +6,6 @@ #include "constructors_mixin.h" #include "constructors_simple.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - typedef struct { int a; From f4f62e0f9fe3b799ae95bd500ff2c7c1cd01b249 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:48:55 +0000 Subject: [PATCH 104/169] eo2: migrated mixin test to eo2. --- src/tests/eo/mixin/mixin_inherit.c | 32 ++++++++---------- src/tests/eo/mixin/mixin_main.c | 13 +++---- src/tests/eo/mixin/mixin_mixin.c | 50 ++++++++++----------------- src/tests/eo/mixin/mixin_mixin.h | 17 +--------- src/tests/eo/mixin/mixin_mixin2.c | 44 +++++++++++------------- src/tests/eo/mixin/mixin_mixin3.c | 44 +++++++++++------------- src/tests/eo/mixin/mixin_mixin4.c | 2 +- src/tests/eo/mixin/mixin_simple.c | 54 +++++++++++------------------- src/tests/eo/mixin/mixin_simple.h | 43 +++--------------------- 9 files changed, 104 insertions(+), 195 deletions(-) diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c index 8f9db135df..7c8b3b568f 100644 --- a/src/tests/eo/mixin/mixin_inherit.c +++ b/src/tests/eo/mixin/mixin_inherit.c @@ -9,33 +9,29 @@ #define MY_CLASS INHERIT_CLASS -static void -_a_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_a_get(Eo *obj, void *class_data EINA_UNUSED) { - int *name = va_arg(*list, int *); - eo_do_super(obj, MY_CLASS, simple_a_get(name)); - printf("%s\n", __func__); + int ret; + eo2_do_super(obj, MY_CLASS, ret = simple_a_get()); + printf("%s %d\n", __func__, ret); + + return ret; } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_a_get, simple_a_get), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/mixin/mixin_main.c b/src/tests/eo/mixin/mixin_main.c index cde8ef984e..f6bcc15b33 100644 --- a/src/tests/eo/mixin/mixin_main.c +++ b/src/tests/eo/mixin/mixin_main.c @@ -18,15 +18,15 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - eo_do(obj, simple_a_set(1), simple_b_set(2)); + eo2_do(obj, simple_a_set(1), simple_b_set(2)); int a, b, sum = 0; - eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_ab_sum_get(&sum)); + eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = mixin_ab_sum_get()); fail_if(sum != a + b + 2); /* 2 for the two mixins... */ - eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum)); + eo2_do(obj, sum = mixin_ab_sum_get(), sum = mixin_ab_sum_get()); Mixin2_Public_Data *pd2 = eo_data_scope_get(obj, MIXIN2_CLASS); fail_if(pd2->count != 6); @@ -36,8 +36,9 @@ main(int argc, char *argv[]) eo_unref(obj); - obj = eo_add(INHERIT_CLASS, NULL); - eo_do(obj, simple_a_set(5), simple_a_get(&a)); + obj = eo2_add(INHERIT_CLASS, NULL); + eo2_do(obj, simple_a_set(5), a = simple_a_get()); + printf("%d\n", a); fail_if(a != 5); eo_unref(obj); diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index ee3342f00b..71983850d5 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -6,62 +6,48 @@ #include "mixin_mixin.h" #include "mixin_simple.h" -EAPI Eo_Op MIXIN_BASE_ID = 0; - #define MY_CLASS MIXIN_CLASS -static void -_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { int a, b; - eo_do(obj, simple_a_get(&a), simple_b_get(&b)); - int *sum = va_arg(*list, int *); - if (sum) - *sum = a + b; + eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); + return a + b; } static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); } static void -_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +_destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get), - EO_OP_FUNC_SENTINEL - }; +EAPI EO2_FUNC_BODY(mixin_ab_sum_get, int, 0); - eo_class_funcs_set(klass, func_desc); -} - - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(MIXIN_SUB_ID_AB_SUM_GET, "Get the sum of a and b."), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC(_ab_sum_get, mixin_ab_sum_get, "Get the sum of a and b."), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL) +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO2_BASE_CLASS, NULL) diff --git a/src/tests/eo/mixin/mixin_mixin.h b/src/tests/eo/mixin/mixin_mixin.h index 745e5c4683..e97b609ab0 100644 --- a/src/tests/eo/mixin/mixin_mixin.h +++ b/src/tests/eo/mixin/mixin_mixin.h @@ -1,22 +1,7 @@ #ifndef MIXIN_H #define MIXIN_H -extern EAPI Eo_Op MIXIN_BASE_ID; - -enum { - MIXIN_SUB_ID_AB_SUM_GET, - MIXIN_SUB_ID_LAST -}; - -#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id) - - -/** - * @def mixin_ab_sum_get(sum) - * @brief Get sum of a,b integer elements - * @param[out] sum integer pointer to sum - value - */ -#define mixin_ab_sum_get(sum) MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum) +EAPI int mixin_ab_sum_get(void); #define MIXIN_CLASS mixin_class_get() const Eo_Class *mixin_class_get(void); diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c index 451a8ec1ca..417321f12c 100644 --- a/src/tests/eo/mixin/mixin_mixin2.c +++ b/src/tests/eo/mixin/mixin_mixin2.c @@ -11,58 +11,54 @@ #define MY_CLASS MIXIN2_CLASS -static void -_ab_sum_get(Eo *obj, void *class_data, va_list *list) +static int +_ab_sum_get(Eo *obj, void *class_data) { /* This cast is a hack just for the tests... */ Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data; - int *sum = va_arg(*list, int *); + int sum; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); - eo_do_super(obj, MY_CLASS, mixin_ab_sum_get(sum)); + eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); - ++*sum; + ++sum; pd->count += 2; { int _a, _b; - eo_do(obj, simple_a_get(&_a), simple_b_get(&_b)); - fail_if(*sum != _a + _b + 1); + eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); + fail_if(sum != _a + _b + 1); } + + return sum; } static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); } static void _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC_OVERRIDE(_ab_sum_get, mixin_ab_sum_get), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin2", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Mixin2_Public_Data), - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c index 6ad66e1172..1a04b94be1 100644 --- a/src/tests/eo/mixin/mixin_mixin3.c +++ b/src/tests/eo/mixin/mixin_mixin3.c @@ -11,58 +11,54 @@ #define MY_CLASS MIXIN3_CLASS -static void -_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list) +static int +_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { /* This cast is just a hack for the test. */ Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data; - int *sum = va_arg(*list, int *); + int sum; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); - eo_do_super(obj, MY_CLASS, mixin_ab_sum_get(sum)); + eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); - ++*sum; + ++sum; pd->count += 3; { int _a, _b; - eo_do(obj, simple_a_get(&_a), simple_b_get(&_b)); - fail_if(*sum != _a + _b + 2); + eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); + fail_if(sum != _a + _b + 2); } + + return sum; } static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_constructor()); + eo2_do_super(obj, MY_CLASS, eo2_constructor()); } static void _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo_do_super(obj, MY_CLASS, eo_destructor()); + eo2_do_super(obj, MY_CLASS, eo2_destructor()); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC_OVERRIDE(_ab_sum_get, mixin_ab_sum_get), + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin3", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Mixin3_Public_Data), - _class_constructor, + NULL, NULL }; diff --git a/src/tests/eo/mixin/mixin_mixin4.c b/src/tests/eo/mixin/mixin_mixin4.c index cf8f16f965..0e3dc216e5 100644 --- a/src/tests/eo/mixin/mixin_mixin4.c +++ b/src/tests/eo/mixin/mixin_mixin4.c @@ -12,7 +12,7 @@ #define MY_CLASS MIXIN4_CLASS static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin4", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), diff --git a/src/tests/eo/mixin/mixin_simple.c b/src/tests/eo/mixin/mixin_simple.c index ff4600d727..8dc515bb87 100644 --- a/src/tests/eo/mixin/mixin_simple.c +++ b/src/tests/eo/mixin/mixin_simple.c @@ -8,8 +8,6 @@ #include "mixin_mixin3.h" #include "mixin_simple.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - typedef struct { int a; @@ -19,59 +17,45 @@ typedef struct #define MY_CLASS SIMPLE_CLASS #define _GET_SET_FUNC(name) \ -static void \ -_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +static int \ +_##name##_get(Eo *obj EINA_UNUSED, void *class_data) \ { \ const Private_Data *pd = class_data; \ - int *name; \ - name = va_arg(*list, int *); \ - *name = pd->name; \ printf("%s %d\n", __func__, pd->name); \ + return pd->name; \ } \ static void \ -_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \ +_##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ { \ Private_Data *pd = class_data; \ - int name; \ - name = va_arg(*list, int); \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ -} +} \ +EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ +EO2_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), + EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), + EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, + MIXIN3_CLASS, MIXIN2_CLASS, NULL); + diff --git a/src/tests/eo/mixin/mixin_simple.h b/src/tests/eo/mixin/mixin_simple.h index 8df8131278..c4b3d7bee5 100644 --- a/src/tests/eo/mixin/mixin_simple.h +++ b/src/tests/eo/mixin/mixin_simple.h @@ -1,45 +1,10 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_GET, - SIMPLE_SUB_ID_B_SET, - SIMPLE_SUB_ID_B_GET, - SIMPLE_SUB_ID_LAST -}; - -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -/** - * @def simple_a_set(a) - * @brief Set value to a-property - * @param[in] a integer value to set - */ -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) - -/** - * @def simple_a_get(a) - * @brief Get value of a-property - * @param[out] integer pointer to a-value - */ -#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) - -/** - * @def simple_b_set(b) - * @brief Set value to b-property - * @param[in] a integer value to set - */ -#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b) - -/** - * @def simple_b_get(b) - * @brief Get value of b-property - * @param[out] integer pointer to b-value - */ -#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b) +EAPI void simple_a_set(int a); +EAPI int simple_a_get(void); +EAPI void simple_b_set(int b); +EAPI int simple_b_get(void); #define SIMPLE_CLASS simple_class_get() const Eo_Class *simple_class_get(void); From 2593cb86c62e2e99d7c6d8e6da979f4e7ae8be10 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:50:16 +0000 Subject: [PATCH 105/169] eo2: interface test, removed obsolete Eo_Op. --- src/tests/eo/interface/interface_simple.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index 998c41b4b6..16e2b836a5 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -7,8 +7,6 @@ #include "interface_interface2.h" #include "interface_simple.h" -EAPI Eo_Op SIMPLE_BASE_ID = 0; - typedef struct { int a; From b08ae598a885b2966f04afa613bab8c214db2396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 8 Nov 2013 12:08:17 +0100 Subject: [PATCH 106/169] eo2: do not restrict search for api in class extensions to some class types --- src/lib/eo/eo.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 942a6d49cc..4d2f05c5ab 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -563,13 +563,8 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class for (kls_itr = extns ; *kls_itr ; kls_itr++) { cur_klass = *kls_itr; - if (cur_klass->desc->type == EO_CLASS_TYPE_REGULAR - || cur_klass->desc->type == EO_CLASS_TYPE_REGULAR_NO_INSTANT - || cur_klass->desc->type == EO_CLASS_TYPE_INTERFACE) - { - op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); - if (op_desc) return op_desc; - } + op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); + if (op_desc) return op_desc; } } From a588c7d99e7b5efacb08927b2a087d6c23e6b2ba Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 12:18:05 +0000 Subject: [PATCH 107/169] eo2: correctly handle eo2_do(NULL, ...). --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 4d2f05c5ab..c1c4aad442 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -404,7 +404,7 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EIN return EINA_FALSE; } - pfptr = ((fptr->eo_id == eo_id) ? fptr : NULL); + pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); if(_eo_is_a_class(eo_id)) { if (!_eo2_class_do(eo_id, cur_klass_id, (fptr + 1), pfptr)) From f38895abedb97842bd28b165b50ac2531304c26d Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 12:24:40 +0000 Subject: [PATCH 108/169] eo2: detach children when object is deleted. --- src/lib/eo/eo2_base_class.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index db257af50d..b032b01118 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -933,8 +933,14 @@ EAPI EO2_VOID_FUNC_BODY(eo2_constructor); static void _destructor(Eo *obj, void *class_data) { + Private_Data *pd = class_data; + Eo *child; + DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); + EINA_LIST_FREE(pd->children, child) + eo2_do(child, eo2_parent_set(NULL)); + _eo_generic_data_del_all(class_data); _wref_destruct(class_data); _eo_callback_remove_all(class_data); From ff64050a7bb8aea9dc6fef96c2d57f20bd0fadbc Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 13:02:49 +0000 Subject: [PATCH 109/169] eo2: fixed eo2_class_class. --- src/lib/eo/eo2_class_class.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c index cda4fac830..8f40cae6ec 100644 --- a/src/lib/eo/eo2_class_class.c +++ b/src/lib/eo/eo2_class_class.c @@ -4,7 +4,9 @@ #include "Eo.h" -static Eo2_Op_Description op_descs [] = {}; +static Eo2_Op_Description op_descs [] = { + EO2_OP_SENTINEL +}; static const Eo_Class_Description class_desc = { EO2_VERSION, From 08b28211b6b54b94e7b187b8cbeaf58fc337e2d1 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 12:25:39 +0000 Subject: [PATCH 110/169] eo2: migrated the eo-suite test to eo2. --- src/tests/eo/suite/eo_test_class_errors.c | 207 +---------- src/tests/eo/suite/eo_test_class_simple.c | 72 ++-- src/tests/eo/suite/eo_test_class_simple.h | 18 +- src/tests/eo/suite/eo_test_general.c | 434 +++++++++------------- src/tests/eo/suite/eo_test_value.c | 4 +- 5 files changed, 229 insertions(+), 506 deletions(-) diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index 5b1f8e6947..4193befffb 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -78,109 +78,6 @@ _eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const c ctx.did = EINA_FALSE; \ ctx.expected_level = EINA_LOG_LEVEL_ERR -START_TEST(eo_incomplete_desc) -{ - eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); - - const Eo_Class *klass; - static Eo_Op TMP_BASE_ID = EO_NOOP; - - enum { - TEST_SUB_ID_FOO, - TEST_SUB_ID_FOO2, - TEST_SUB_ID_LAST - }; - - static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"), - EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"), - EO_OP_DESCRIPTION_SENTINEL - }; - - static const Eo_Op_Description op_desc_wrong[] = { - EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"), - EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"), - EO_OP_DESCRIPTION_SENTINEL - }; - - /* XXX: In real life this should be const, this is just for testing. */ - static Eo_Class_Description class_desc = { - EO_VERSION, - "Simple", - EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1), - NULL, - 0, - NULL, - NULL - }; - - TEST_EO_ERROR("_eo_class_check_op_descs", "Class '%s' has a non-zero ops count, but base_id is NULL."); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.ops.base_op_id = &TMP_BASE_ID; - class_desc.ops.descs = NULL; - - TEST_EO_ERROR("_eo_class_check_op_descs", "Class '%s' has a non-zero ops count, but there are no descs."); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.ops.descs = op_desc; - class_desc.ops.count = TEST_SUB_ID_LAST + 1; - - TEST_EO_ERROR("_eo_class_check_op_descs", "Found too few Ops description for class '%s'. Expected 0x%lx descriptions, but found 0x%lx."); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.ops.count = 0; - - TEST_EO_ERROR("_eo_class_check_op_descs", "Found extra Ops description for class '%s'. Expected %lu descriptions, but found more."); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.ops.count = TEST_SUB_ID_LAST; - class_desc.ops.descs = op_desc_wrong; - - TEST_EO_ERROR("_eo_class_check_op_descs", "Wrong order in Ops description for class '%s'. Expected 0x%lx and got 0x%lx"); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.ops.descs = op_desc; - class_desc.name = NULL; - - eina_log_print_cb_set(_eo_test_safety_print_cb, &ctx); - - TEST_EO_ERROR("eo_class_new", "safety check failed: desc->name == NULL"); - klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - class_desc.name = "Simple"; - - - TEST_EO_ERROR("eo_class_new", "safety check failed: desc == NULL"); - klass = eo_class_new(NULL, NULL, NULL); - fail_if(klass); - fail_unless(ctx.did); - - /* Should create a class. */ - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); - fail_if(!klass); - - (void) klass; - eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); - - eo_shutdown(); -} -END_TEST - START_TEST(eo_inherit_errors) { eo_init(); @@ -191,7 +88,7 @@ START_TEST(eo_inherit_errors) const Eo_Class *klass_simple; static const Eo_Class_Description class_desc_simple = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -202,7 +99,7 @@ START_TEST(eo_inherit_errors) }; static const Eo_Class_Description class_desc_mixin = { - EO_VERSION, + EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -213,7 +110,7 @@ START_TEST(eo_inherit_errors) }; static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "General", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -226,7 +123,7 @@ START_TEST(eo_inherit_errors) klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL); fail_if(!klass_mixin); - klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL); + klass_simple = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, NULL); fail_if(!klass_simple); TEST_EO_ERROR("eo_class_new", "Non-regular classes ('%s') aren't allowed to inherit from regular classes ('%s')."); @@ -259,7 +156,7 @@ START_TEST(eo_inconsistent_mro) const Eo_Class *klass_mixin3; static const Eo_Class_Description class_desc_simple = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -270,7 +167,7 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin = { - EO_VERSION, + EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -281,7 +178,7 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin2 = { - EO_VERSION, + EO2_VERSION, "Mixin2", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -292,7 +189,7 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin3 = { - EO_VERSION, + EO2_VERSION, "Mixin3", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -312,14 +209,14 @@ START_TEST(eo_inconsistent_mro) fail_if(!klass_mixin3); TEST_EO_ERROR("_eo_class_mro_init", "Cannot create a consistent method resolution order for class '%s' because of '%s'."); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL); + klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin, klass_mixin2, NULL); fail_if(klass); fail_unless(ctx.did); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL); + klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin, NULL); fail_if(!klass); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); + klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); fail_if(!klass); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); @@ -338,7 +235,7 @@ START_TEST(eo_bad_interface) const Eo_Class *klass; static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Interface", EO_CLASS_TYPE_INTERFACE, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -376,89 +273,9 @@ START_TEST(eo_bad_interface) } END_TEST -static int _const_ops_counter = 0; - -static void -_const_ops_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list) -{ - int a = va_arg(*list, int); - (void) a; - _const_ops_counter++; -} - -static void -_const_ops_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - _const_ops_counter++; -} - -static void -_const_ops_class_hi_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - _const_ops_counter++; -} - -static void -_const_ops_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _const_ops_class_hi_print), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _const_ops_class_hi_print), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -START_TEST(eo_op_types) -{ - eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); - - const Eo_Class *klass; - - static Eo_Class_Description class_desc = { - EO_VERSION, - "Simple", - EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), - NULL, - 0, - _const_ops_class_constructor, - NULL - }; - - TEST_EO_ERROR("eo_class_funcs_set", "Set function's op type (0x%x) is different than the one in the op description (%d) for op '%s:%s'. Func index: %lu"); - klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); - fail_if(!klass); - - TEST_EO_ERROR("eo_class_name_get", NULL); -#ifdef HAVE_EO_ID - ctx.expected_level = EINA_LOG_LEVEL_ERR; -#else - ctx.expected_level = EINA_LOG_LEVEL_CRITICAL; -#endif - /* Add class checks here... */ - Eo *obj = eo_add(klass, NULL); - eo_do(obj, simple_a_set(7), simple_a_print(), simple_class_hi_print()); - - eo_unref(obj); - - eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); - - eo_shutdown(); -} -END_TEST - void eo_test_class_errors(TCase *tc) { - tcase_add_test(tc, eo_incomplete_desc); tcase_add_test(tc, eo_inherit_errors); tcase_add_test(tc, eo_inconsistent_mro); tcase_add_test(tc, eo_bad_interface); - tcase_add_test(tc, eo_op_types); } diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index cbeb18362a..9b55ffb3fa 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -7,78 +7,76 @@ #define MY_CLASS SIMPLE_CLASS -EAPI Eo_Op SIMPLE_BASE_ID = 0; - EAPI const Eo_Event_Description _EV_A_CHANGED = EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed."); static void -_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +_a_set(Eo *obj EINA_UNUSED, void *class_data, int a) { Simple_Public_Data *pd = class_data; - int a; - a = va_arg(*list, int); printf("%s %d\n", eo_class_name_get(MY_CLASS), a); pd->a = a; - eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL)); + eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); } -static void -_a_print(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +static int +_a_get(Eo *obj EINA_UNUSED, void *class_data) +{ + Simple_Public_Data *pd = class_data; + + return pd->a; +} + +static Eina_Bool +_a_print(Eo *obj EINA_UNUSED, void *class_data) { const Simple_Public_Data *pd = class_data; - (void) list; printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a); + + return EINA_TRUE; } -static void -_class_hi_print(Eo_Class *klass, void *data EINA_UNUSED, va_list *list) +static Eina_Bool +_class_hi_print(Eo_Class *klass, void *data EINA_UNUSED) { - (void) list; printf("Hi Print %s\n", eo_class_name_get(klass)); + + return EINA_TRUE; } static void -_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) +_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Eo_Dbg_Info *root) { - Eo_Dbg_Info *root = (Eo_Dbg_Info *) va_arg(*list, Eo_Dbg_Info *); - eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root)); + eo2_do_super(eo_obj, MY_CLASS, eo2_dbg_info_get(root)); Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, "Test list"); EO_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8); } -static void -_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print), - EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _class_hi_print), - EO_OP_FUNC_SENTINEL - }; +EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); +EO2_FUNC_BODY(simple_a_get, int, 0); +EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); +EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE); - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), - EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "Print property A"), - EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_HI_PRINT, "Print Hi"), - EO_OP_DESCRIPTION_SENTINEL +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_dbg_info_get, eo2_dbg_info_get), + EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), + EO2_OP_FUNC(_a_print, simple_a_print, "Print property a"), + EO2_OP_CLASS_FUNC(_class_hi_print, simple_class_hi_print, "Print property a"), + EO2_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Simple_Public_Data), - _class_constructor, + NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL) diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h index 699ddb8bbc..a82adef078 100644 --- a/src/tests/eo/suite/eo_test_class_simple.h +++ b/src/tests/eo/suite/eo_test_class_simple.h @@ -1,25 +1,15 @@ #ifndef SIMPLE_H #define SIMPLE_H -extern EAPI Eo_Op SIMPLE_BASE_ID; - -enum { - SIMPLE_SUB_ID_A_SET, - SIMPLE_SUB_ID_A_PRINT, - SIMPLE_SUB_ID_CLASS_HI_PRINT, - SIMPLE_SUB_ID_LAST -}; - typedef struct { int a; } Simple_Public_Data; -#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) - -#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) -#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT) -#define simple_class_hi_print() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT) +EAPI void simple_a_set(int a); +EAPI int simple_a_get(void); +EAPI Eina_Bool simple_a_print(void); +EAPI Eina_Bool simple_class_hi_print(void); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index 35f787918a..d2bface3e4 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -11,13 +11,13 @@ START_TEST(eo_simple) { eo_init(); - Eo *obj = eo_add(EO_BASE_CLASS, NULL); + Eo *obj = eo2_add(EO2_BASE_CLASS, NULL); fail_if(obj); - obj = eo_add(SIMPLE_CLASS, NULL); + obj = eo2_add(SIMPLE_CLASS, NULL); fail_if(!obj); - eo_do(obj, eo_constructor()); - eo_do(obj, eo_destructor()); + eo2_do(obj, eo2_constructor()); + eo2_do(obj, eo2_destructor()); eo_unref(obj); eo_shutdown(); @@ -80,23 +80,23 @@ START_TEST(eo_signals) { EO_EV_DEL, _eo_signals_eo_del_cb }, { NULL, NULL } }; - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks)); - eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks)); - eo_do(obj, eo_event_callback_array_priority_add(callbacks, -100, (void *) 1)); - eo_do(obj, eo_event_callback_array_add(callbacks, (void *) 3)); - eo_do(obj, eo_event_callback_array_priority_add(callbacks, -50, (void *) 2)); - fail_if(!eo_do(obj, simple_a_set(1))); + eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks)); + eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks)); + eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -100, (void *) 1)); + eo2_do(obj, eo2_event_callback_array_add(callbacks, (void *) 3)); + eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -50, (void *) 2)); + eo2_do(obj, simple_a_set(1)); ck_assert_int_eq(_eo_signals_cb_flag, 0x3); - eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 1)); - eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 2)); - eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 3)); + eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 1)); + eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 2)); + eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 3)); /* Try to delete something that doesn't exist. */ - eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 4)); + eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 4)); _eo_signals_cb_flag = 0; - fail_if(!eo_do(obj, simple_a_set(1))); + eo2_do(obj, simple_a_set(1)); ck_assert_int_eq(_eo_signals_cb_flag, 0x0); eo_unref(obj); @@ -111,7 +111,7 @@ START_TEST(eo_data_fetch) /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -121,10 +121,10 @@ START_TEST(eo_data_fetch) NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); fail_if(!klass); - Eo *obj = eo_add(klass, NULL); + Eo *obj = eo2_add(klass, NULL); fail_if(!obj); #ifdef EO_DEBUG fail_if(eo_data_scope_get(obj, SIMPLE_CLASS)); @@ -132,10 +132,10 @@ START_TEST(eo_data_fetch) eo_unref(obj); class_desc.data_size = 0; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); fail_if(!klass); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(eo_data_scope_get(obj, klass)); eo_unref(obj); @@ -153,7 +153,7 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Iface", EO_CLASS_TYPE_INTERFACE, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -170,7 +170,7 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -187,7 +187,7 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -197,26 +197,26 @@ START_TEST(eo_isa_tests) NULL }; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL); + klass = eo_class_new(&class_desc, EO2_BASE_CLASS, iface, mixin, NULL); fail_if(!klass); } - Eo *obj = eo_add(klass, NULL); + Eo *obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(eo_isa(obj, SIMPLE_CLASS)); fail_if(!eo_isa(obj, iface)); fail_if(!eo_isa(obj, mixin)); fail_if(!eo_isa(obj, klass)); - fail_if(!eo_isa(obj, EO_BASE_CLASS)); + fail_if(!eo_isa(obj, EO2_BASE_CLASS)); eo_unref(obj); - obj = eo_add(SIMPLE_CLASS, NULL); + obj = eo2_add(SIMPLE_CLASS, NULL); fail_if(!obj); fail_if(eo_isa(obj, klass)); fail_if(eo_isa(obj, iface)); fail_if(eo_isa(obj, mixin)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); - fail_if(!eo_isa(obj, EO_BASE_CLASS)); + fail_if(!eo_isa(obj, EO2_BASE_CLASS)); eo_unref(obj); eo_shutdown(); @@ -228,13 +228,13 @@ START_TEST(eo_composite_tests) { eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); fail_if(!obj); - Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); fail_if(!obj2); eo_composite_attach(obj2, obj); - eo_do(obj2, eo_parent_set(NULL)); + eo2_do(obj2, eo2_parent_set(NULL)); fail_if(eo_composite_is(obj2)); eo_unref(obj2); @@ -253,30 +253,22 @@ _man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED) { if (_man_should_con) eo_manual_free_set(obj, EINA_TRUE); - eo_do_super(obj, cur_klass, eo_constructor()); + eo2_do_super(obj, cur_klass, eo2_constructor()); } static void _man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo_do_super(obj, cur_klass, eo_destructor()); + eo2_do_super(obj, cur_klass, eo2_destructor()); if (_man_should_des) eo_manual_free_set(obj, EINA_FALSE); } - -static void -_man_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(_man_con, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(_man_des, eo2_destructor), + EO2_OP_SENTINEL +}; START_TEST(eo_man_free) { @@ -284,35 +276,35 @@ START_TEST(eo_man_free) /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_OPS(op_descs), NULL, 10, - _man_class_constructor, + NULL, NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); fail_if(!klass); cur_klass = klass; - Eo *obj = eo_add(klass, NULL); + Eo *obj = eo2_add(klass, NULL); fail_if(!obj); eo_unref(obj); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); eo_unref(obj); _man_should_des = EINA_FALSE; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); cur_klass = klass; fail_if(!klass); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); fail_if(eo_destructed_is(obj)); @@ -320,23 +312,23 @@ START_TEST(eo_man_free) fail_if(!eo_destructed_is(obj)); fail_if(!eo_manual_free(obj)); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); eo_unref(obj); fail_if(!eo_destructed_is(obj)); fail_if(!eo_manual_free(obj)); _man_should_con = EINA_FALSE; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); cur_klass = klass; fail_if(!klass); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); eo_unref(obj); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); eo_manual_free_set(obj, EINA_TRUE); eo_unref(obj); @@ -345,7 +337,7 @@ START_TEST(eo_man_free) eo_unref(obj); fail_if(!eo_manual_free(obj)); - obj = eo_add(klass, NULL); + obj = eo2_add(klass, NULL); fail_if(!obj); eo_manual_free_set(obj, EINA_TRUE); eo_unref(obj); @@ -363,9 +355,9 @@ END_TEST START_TEST(eo_refs) { eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); - Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); - Eo *obj3 = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj3 = eo2_add(SIMPLE_CLASS, NULL); eo_xref(obj, obj2); fail_if(eo_ref_get(obj) != 2); @@ -400,11 +392,11 @@ START_TEST(eo_refs) eo_unref(obj3); /* Check hierarchy */ - obj = eo_add(SIMPLE_CLASS, NULL); - obj2 = eo_add(SIMPLE_CLASS, obj); + obj = eo2_add(SIMPLE_CLASS, NULL); + obj2 = eo2_add(SIMPLE_CLASS, obj); Eo *wref; - eo_do(obj2, eo_wref_add(&wref)); + eo2_do(obj2, eo2_wref_add(&wref)); fail_if(!wref); eo_unref(obj2); @@ -416,13 +408,13 @@ START_TEST(eo_refs) fail_if(wref); /* Just check it doesn't seg atm. */ - obj = eo_add(SIMPLE_CLASS, NULL); + obj = eo2_add(SIMPLE_CLASS, NULL); eo_ref(obj); eo_unref(obj); eo_unref(obj); - obj = eo_add(SIMPLE_CLASS, NULL); - obj2 = eo_add(SIMPLE_CLASS, obj); + obj = eo2_add(SIMPLE_CLASS, NULL); + obj2 = eo2_add(SIMPLE_CLASS, obj); eo_unref(obj2); eo_ref(obj2); eo_del(obj2); @@ -436,17 +428,17 @@ START_TEST(eo_weak_reference) { eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); - Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); Eo *wref, *wref2, *wref3; - eo_do(obj, eo_wref_add(&wref)); + eo2_do(obj, eo2_wref_add(&wref)); fail_if(!wref); eo_unref(obj); fail_if(wref); - obj = eo_add(SIMPLE_CLASS, NULL); - eo_do(obj, eo_wref_add(&wref)); + obj = eo2_add(SIMPLE_CLASS, NULL); + eo2_do(obj, eo2_wref_add(&wref)); eo_ref(obj); fail_if(!wref); @@ -457,37 +449,37 @@ START_TEST(eo_weak_reference) eo_unref(obj); fail_if(wref); - obj = eo_add(SIMPLE_CLASS, NULL); + obj = eo2_add(SIMPLE_CLASS, NULL); - eo_do(obj, eo_wref_add(&wref)); - eo_do(obj, eo_wref_del(&wref)); + eo2_do(obj, eo2_wref_add(&wref)); + eo2_do(obj, eo2_wref_del(&wref)); fail_if(wref); - eo_do(obj, eo_wref_add(&wref)); - eo_do(obj2, eo_wref_del(&wref)); + eo2_do(obj, eo2_wref_add(&wref)); + eo2_do(obj2, eo2_wref_del(&wref)); fail_if(!wref); - eo_wref_del_safe(&wref); + eo2_wref_del_safe(&wref); fail_if(wref); wref = obj; - eo_do(obj, eo_wref_del(&wref)); + eo2_do(obj, eo2_wref_del(&wref)); fail_if(wref); wref = wref2 = wref3 = NULL; - eo_do(obj, eo_wref_add(&wref), eo_wref_add(&wref2), eo_wref_add(&wref3)); + eo2_do(obj, eo2_wref_add(&wref), eo2_wref_add(&wref2), eo2_wref_add(&wref3)); fail_if(!wref); fail_if(!wref2); fail_if(!wref3); - eo_do(obj, eo_wref_del(&wref), eo_wref_del(&wref2), eo_wref_del(&wref3)); + eo2_do(obj, eo2_wref_del(&wref), eo2_wref_del(&wref2), eo2_wref_del(&wref3)); fail_if(wref); fail_if(wref2); fail_if(wref3); - eo_do(obj, eo_wref_add(&wref2), eo_wref_add(&wref3)); + eo2_do(obj, eo2_wref_add(&wref2), eo2_wref_add(&wref3)); wref = obj; - eo_do(obj, eo_wref_del(&wref)); + eo2_do(obj, eo2_wref_del(&wref)); fail_if(wref); - eo_do(obj, eo_wref_del(&wref2), eo_wref_del(&wref3)); + eo2_do(obj, eo2_wref_del(&wref2), eo2_wref_del(&wref3)); eo_unref(obj); eo_unref(obj2); @@ -497,77 +489,6 @@ START_TEST(eo_weak_reference) } END_TEST -static void -_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - fail_if(EINA_TRUE); -} - -static void -_op_errors_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST), _a_set), - EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST + 1), _a_set), - EO_OP_FUNC(0x0F010111, _a_set), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -START_TEST(eo_op_errors) -{ - eo_init(); - - static const Eo_Class_Description class_desc = { - EO_VERSION, - "Simple", - EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), - NULL, - 0, - _op_errors_class_constructor, - NULL - }; - - const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); - fail_if(!klass); - - Eo *obj = eo_add(klass, NULL); - - /* Out of bounds op for a legal class. */ - fail_if(eo_do(obj, EO_BASE_ID(0x0111))); - - /* Ilegal class. */ - fail_if(eo_do(obj, 0x0F010111)); - - fail_if(eo_ref_get(obj) != 1); - - eo_ref(obj); - fail_if(eo_ref_get(obj) != 2); - - eo_ref(obj); - fail_if(eo_ref_get(obj) != 3); - - eo_unref(obj); - fail_if(eo_ref_get(obj) != 2); - - eo_unref(obj); - fail_if(eo_ref_get(obj) != 1); - - eo_unref(obj); - - obj = eo_add(SIMPLE_CLASS, NULL); - fail_if(!eo_do(obj, simple_a_print())); - fail_if(!eo_do(obj, simple_a_print())); - fail_if(!eo_do(obj, simple_a_set(1))); - eo_unref(obj); - - eo_shutdown(); -} -END_TEST - static void _fake_free_func(void *data) { @@ -581,59 +502,59 @@ _fake_free_func(void *data) START_TEST(eo_generic_data) { eo_init(); - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); void *data; - eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); - eo_do(obj, eo_base_data_get("test1", &data)); + eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL)); + eo2_do(obj, data = eo2_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test1")); - eo_do(obj, eo_base_data_get("test1", &data)); + eo2_do(obj, eo2_base_data_del("test1")); + eo2_do(obj, data = eo2_base_data_get("test1")); fail_if(data); - eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); - eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL)); - eo_do(obj, eo_base_data_get("test1", &data)); + eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL)); + eo2_do(obj, eo2_base_data_set("test2", (void *) 2, NULL)); + eo2_do(obj, data = eo2_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, eo_base_data_get("test2", &data)); + eo2_do(obj, data = eo2_base_data_get("test2")); fail_if(2 != (intptr_t) data); - eo_do(obj, eo_base_data_get("test2", &data)); + eo2_do(obj, data = eo2_base_data_get("test2")); fail_if(2 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test2")); - eo_do(obj, eo_base_data_get("test2", &data)); + eo2_do(obj, eo2_base_data_del("test2")); + eo2_do(obj, data = eo2_base_data_get("test2")); fail_if(data); - eo_do(obj, eo_base_data_get("test1", &data)); + eo2_do(obj, data = eo2_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test1")); - eo_do(obj, eo_base_data_get("test1", &data)); + eo2_do(obj, eo2_base_data_del("test1")); + eo2_do(obj, data = eo2_base_data_get("test1")); fail_if(data); int a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, eo_base_data_get("test3", &data)); + eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); + eo2_do(obj, data = eo2_base_data_get("test3")); fail_if(&a != data); - eo_do(obj, eo_base_data_get("test3", NULL)); - eo_do(obj, eo_base_data_del("test3")); + eo2_do(obj, eo2_base_data_get("test3")); + eo2_do(obj, eo2_base_data_del("test3")); fail_if(a != 1); a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func)); + eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); + eo2_do(obj, eo2_base_data_set("test3", NULL, _fake_free_func)); fail_if(a != 1); a = 0; data = (void *) 123; - eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func)); - eo_do(obj, eo_base_data_get(NULL, &data)); + eo2_do(obj, eo2_base_data_set(NULL, &a, _fake_free_func)); + eo2_do(obj, data = eo2_base_data_get(NULL)); fail_if(data); - eo_do(obj, eo_base_data_del(NULL)); + eo2_do(obj, eo2_base_data_del(NULL)); a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, eo_base_data_set("test3", NULL, NULL)); + eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); + eo2_do(obj, eo2_base_data_set("test3", NULL, NULL)); fail_if(a != 1); - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); + eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); eo_unref(obj); fail_if(a != 2); @@ -642,6 +563,7 @@ START_TEST(eo_generic_data) } END_TEST + START_TEST(eo_magic_checks) { char _buf[sizeof(long)]; /* Just enough to hold eina magic + a bit more. */ @@ -650,32 +572,38 @@ START_TEST(eo_magic_checks) memset(_buf, 1, sizeof(_buf)); - Eo *obj = eo_add(SIMPLE_CLASS, (Eo *) buf); + Eo *obj = eo2_add(SIMPLE_CLASS, (Eo *) buf); fail_if(obj); while (1) { + int i = 20, a = 0; Eo *parent = NULL; Eo *wref = NULL; Eo *obj2 = NULL; - obj = eo_add((Eo_Class *) buf, NULL); + obj = eo2_add((Eo_Class *) buf, NULL); fail_if(obj); - obj = eo_add(SIMPLE_CLASS, NULL); + obj = eo2_add(SIMPLE_CLASS, NULL); fail_if(!obj); - fail_if(eo_do((Eo *) buf, EO_NOOP)); - fail_if(eo_do_super((Eo *) buf, SIMPLE_CLASS, EO_NOOP)); - fail_if(eo_do_super(obj, (const Eo_Class *) buf, EO_NOOP)); + eo2_do((Eo *) buf, simple_a_set(++i), a = simple_a_get()); + ck_assert_int_ne(i, a); + eo2_do_super((Eo *) buf, SIMPLE_CLASS, simple_a_set(++i)); + eo2_do_super((Eo *) buf, SIMPLE_CLASS, a = simple_a_get()); + ck_assert_int_ne(i, a); + eo2_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i)); + eo2_do_super(obj, (const Eo_Class *) buf, a = simple_a_get()); + ck_assert_int_ne(i, a); fail_if(eo_class_get((Eo *) buf)); fail_if(eo_class_name_get((Eo_Class*) buf)); fail_if(eo_class_get(obj) != SIMPLE_CLASS); - fail_if(eo_class_get(SIMPLE_CLASS) != EO_CLASS_CLASS); + fail_if(eo_class_get(SIMPLE_CLASS) != EO2_CLASS_CLASS); eo_class_funcs_set((Eo_Class *) buf, NULL); - eo_do((Eo_Class *) buf, NULL); - eo_do_super((Eo_Class *) buf, SIMPLE_CLASS, EO_NOOP); - eo_do_super(SIMPLE_CLASS, (Eo_Class *) buf, EO_NOOP); + eo2_do((Eo_Class *) buf, NULL); + eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); + eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); // FIXME Jeremy: For some reason it tries to call the object function on the class!!! fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL); @@ -693,9 +621,9 @@ START_TEST(eo_magic_checks) fail_if(0 != eo_ref_get((Eo *) buf)); - eo_do((Eo *) buf, - eo_wref_add(&wref), - eo_parent_get(&parent)); + eo2_do((Eo *) buf, + eo2_wref_add(&wref), + eo2_parent_get(&parent)); fail_if(wref); fail_if(parent); @@ -709,8 +637,8 @@ START_TEST(eo_magic_checks) eo_composite_detach(obj, (Eo *) buf); eo_composite_is((Eo *) buf); - eo_do(obj, eo_event_callback_forwarder_add(NULL, (Eo *) buf)); - eo_do(obj, eo_event_callback_forwarder_del(NULL, (Eo *) buf)); + eo2_do(obj, eo2_event_callback_forwarder_add(NULL, (Eo *) buf)); + eo2_do(obj, eo2_event_callback_forwarder_del(NULL, (Eo *) buf)); eo_manual_free_set((Eo *) buf, EINA_TRUE); eo_manual_free((Eo *) buf); @@ -734,72 +662,63 @@ START_TEST(eo_magic_checks) END_TEST /* MULTI */ -static Eo_Op MULTI_BASE_ID; -#define MULTI_ID(sub_id) (MULTI_BASE_ID + sub_id) -#define multi_a_print() MULTI_ID(MULTI_SUB_ID_A_PRINT) -#define multi_class_hi_print() MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT) -static void -_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +static Eina_Bool +_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hey\n"); + + return EINA_TRUE; } -static void -_class_hi_print(Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +static Eina_Bool +_class_hi_print(Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { printf("Hi\n"); + + return EINA_TRUE; } -enum { - MULTI_SUB_ID_A_PRINT, - MULTI_SUB_ID_CLASS_HI_PRINT, - MULTI_SUB_ID_LAST +EO2_FUNC_BODY(multi_a_print, Eina_Bool, EINA_FALSE); +EO2_FUNC_BODY(multi_class_hi_print, Eina_Bool, EINA_FALSE); + +static Eo2_Op_Description _multi_do_op_descs[] = { + EO2_OP_FUNC(_a_print, multi_a_print, "Print property a"), + EO2_OP_FUNC(_class_hi_print, multi_class_hi_print, "Print Hi"), + EO2_OP_SENTINEL }; -static void -_eo_multiple_do_class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(MULTI_ID(MULTI_SUB_ID_A_PRINT), _a_print), - EO_OP_FUNC_CLASS(MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT), _class_hi_print), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description _eo_multiple_do_op_desc[] = { - EO_OP_DESCRIPTION(MULTI_SUB_ID_A_PRINT, "Print property A"), - EO_OP_DESCRIPTION_CLASS(MULTI_SUB_ID_CLASS_HI_PRINT, "Print Hi"), - EO_OP_DESCRIPTION_SENTINEL -}; - - START_TEST(eo_multiple_do) { eo_init(); /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&MULTI_BASE_ID, _eo_multiple_do_op_desc, MULTI_SUB_ID_LAST), + EO2_CLASS_DESCRIPTION_OPS(_multi_do_op_descs), NULL, 0, - _eo_multiple_do_class_constructor, + NULL, NULL }; const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); fail_if(!klass); - Eo *obj = eo_add(klass, NULL); + Eo *obj = eo2_add(klass, NULL); fail_if(!obj); - fail_if(!eo_do(obj, simple_a_print(), multi_a_print(), multi_a_print())); - fail_if(!eo_do(klass, simple_class_hi_print(), multi_class_hi_print(), multi_class_hi_print())); + Eina_Bool ca, cb, cc; + + ca = cb = cc = EINA_FALSE; + eo2_do(obj, ca = simple_a_print(), cb = multi_a_print(), cc = multi_a_print()); + fail_if(!(ca && cb && cc)); + + ca = cb = cc = EINA_FALSE; + eo2_do(klass, ca = simple_class_hi_print(), cb = multi_class_hi_print(), cc = multi_class_hi_print()); + fail_if(!(ca && cb && cc)); eo_unref(obj); @@ -807,23 +726,23 @@ START_TEST(eo_multiple_do) } END_TEST -START_TEST(eo_add_do_and_custom) +START_TEST(eo2_add_do_and_custom) { Simple_Public_Data *pd = NULL; Eo *obj = NULL; eo_init(); - obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor()); + obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor()); fail_if(!obj); eo_unref(obj); - obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7)); + obj = eo2_add(SIMPLE_CLASS, NULL, simple_a_set(7)); fail_if(!obj); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 7); eo_unref(obj); - obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7)); + obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor(), simple_a_set(7)); fail_if(!obj); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 7); @@ -839,7 +758,7 @@ START_TEST(eo_pointers_indirection) eo_init(); static const Eo_Class_Description class_desc = { - EO_VERSION, + EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), @@ -849,11 +768,11 @@ START_TEST(eo_pointers_indirection) NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); fail_if(!klass); /* Check simple id validity */ - Eo *obj = eo_add(klass, NULL); + Eo *obj = eo2_add(klass, NULL); fail_if(!obj); fail_if(!eo_isa(obj, klass)); obj = (Eo *)((char *)(obj) + 1); @@ -864,10 +783,10 @@ START_TEST(eo_pointers_indirection) fail_if(eo_isa(obj, klass)); /* Check id invalidity after deletion */ - Eo *obj1 = eo_add(klass, NULL); + Eo *obj1 = eo2_add(klass, NULL); fail_if(!obj1); eo_unref(obj1); - Eo *obj2 = eo_add(klass, NULL); + Eo *obj2 = eo2_add(klass, NULL); fail_if(!obj2); fail_if(!eo_isa(obj2, klass)); fail_if(eo_isa(obj1, klass)); @@ -880,7 +799,7 @@ START_TEST(eo_pointers_indirection) /* Creation of the objects */ for ( obj_id = 0; obj_id < NB_OBJS; obj_id++) { - objs[obj_id] = eo_add(klass, NULL); + objs[obj_id] = eo2_add(klass, NULL); if(!objs[obj_id]) fail_if(!objs[obj_id]); if(!eo_isa(objs[obj_id], klass)) @@ -896,7 +815,7 @@ START_TEST(eo_pointers_indirection) /* Creation of the deleted objects */ for ( obj_id = 0; obj_id < NB_OBJS; obj_id+=2000) { - objs[obj_id] = eo_add(klass, NULL); + objs[obj_id] = eo2_add(klass, NULL); if(!objs[obj_id]) fail_if(!objs[obj_id]); if(!eo_isa(objs[obj_id], klass)) @@ -916,18 +835,17 @@ END_TEST void eo_test_general(TCase *tc) { - tcase_add_test(tc, eo_generic_data); - tcase_add_test(tc, eo_op_errors); tcase_add_test(tc, eo_simple); - tcase_add_test(tc, eo_weak_reference); - tcase_add_test(tc, eo_refs); - tcase_add_test(tc, eo_magic_checks); - tcase_add_test(tc, eo_data_fetch); - tcase_add_test(tc, eo_man_free); - tcase_add_test(tc, eo_composite_tests); - tcase_add_test(tc, eo_isa_tests); - tcase_add_test(tc, eo_multiple_do); - tcase_add_test(tc, eo_add_do_and_custom); tcase_add_test(tc, eo_signals); + tcase_add_test(tc, eo_data_fetch); + tcase_add_test(tc, eo_isa_tests); + tcase_add_test(tc, eo_composite_tests); + tcase_add_test(tc, eo_man_free); + tcase_add_test(tc, eo_refs); + tcase_add_test(tc, eo_weak_reference); + tcase_add_test(tc, eo_generic_data); + tcase_add_test(tc, eo_magic_checks); + tcase_add_test(tc, eo_multiple_do); + tcase_add_test(tc, eo2_add_do_and_custom); tcase_add_test(tc, eo_pointers_indirection); } diff --git a/src/tests/eo/suite/eo_test_value.c b/src/tests/eo/suite/eo_test_value.c index 9f4965ba41..5715457657 100644 --- a/src/tests/eo/suite/eo_test_value.c +++ b/src/tests/eo/suite/eo_test_value.c @@ -16,10 +16,10 @@ START_TEST(eo_value) Eina_Value val2, eo_val; void *tmpp = NULL; Eo_Dbg_Info *eo_dbg_info; - Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "Root"); - fail_if(!eo_do(obj, eo_dbg_info_get(eo_dbg_info))); + eo2_do(obj, eo2_dbg_info_get(eo_dbg_info)); fail_if(!eo_dbg_info); ck_assert_str_eq(eo_dbg_info->name, "Root"); str = eina_value_to_string(&eo_dbg_info->value); From 7d79b10bb67296197ffe12708ce2adfd63f8cc53 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 13:56:06 +0000 Subject: [PATCH 111/169] eo2 suite: add an important FIXME. --- src/tests/eo/suite/eo_test_general.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index d2bface3e4..a942cc887c 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -595,7 +595,7 @@ START_TEST(eo_magic_checks) ck_assert_int_ne(i, a); eo2_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i)); eo2_do_super(obj, (const Eo_Class *) buf, a = simple_a_get()); - ck_assert_int_ne(i, a); + ck_assert_int_ne(i, a); // FIXME Jeremy: shouldn't happen. do_super should check for class validity and fail! fail_if(eo_class_get((Eo *) buf)); fail_if(eo_class_name_get((Eo_Class*) buf)); fail_if(eo_class_get(obj) != SIMPLE_CLASS); From d0f71a6e8b687d22cc5021a6c6d6b40136acafb9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 14:55:29 +0000 Subject: [PATCH 112/169] eo2: fix eo2_base_class function signatures. "void func(void)" != "void func()" ! The former is a func that accepts 0 parameters. The latter is a func that accepts variable number of parameters. Watch out. --- src/lib/eo/Eo.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index b27d88a7e6..433e8ab46a 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -717,7 +717,7 @@ EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, const char // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(const Eo **ojb); -EAPI int eo2_call_stack_depth(); +EAPI int eo2_call_stack_depth(void); #define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) @@ -1326,7 +1326,7 @@ eo2_parent_set(Eo *parent); */ #define eo_parent_get(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), EO_TYPECHECK(Eo **, parent) EAPI Eo * -eo2_parent_get(); +eo2_parent_get(void); /** * @def eo_children_iterator_new @@ -1338,7 +1338,7 @@ eo2_parent_get(); */ #define eo_children_iterator_new(it) EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), EO_TYPECHECK(Eina_Iterator **, it) EAPI Eina_Iterator * -eo2_children_iterator_new(); +eo2_children_iterator_new(void); /** * @def eo_wref_add @@ -1433,7 +1433,7 @@ eo2_wref_del(Eo **wref); */ #define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR) EAPI void -eo2_constructor(); +eo2_constructor(void); /** * @def eo_destructor @@ -1445,7 +1445,7 @@ eo2_constructor(); */ #define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR) EAPI void -eo2_destructor(); +eo2_destructor(void); /** * @addtogroup Eo_Events Eo's Event Handling @@ -1563,7 +1563,7 @@ eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); */ #define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE) EAPI void -eo2_event_freeze(); +eo2_event_freeze(void); /** * @def eo_event_thaw @@ -1575,7 +1575,7 @@ eo2_event_freeze(); */ #define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW) EAPI void -eo2_event_thaw(); +eo2_event_thaw(void); /** * @def eo_event_freeze_get @@ -1590,7 +1590,7 @@ eo2_event_thaw(); */ #define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount) EAPI int -eo2_event_freeze_get(); +eo2_event_freeze_get(void); /** * @def eo_event_global_freeze @@ -1603,7 +1603,7 @@ eo2_event_freeze_get(); */ #define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE) EAPI void -eo2_event_global_freeze(); +eo2_event_global_freeze(void); /** * @def eo_event_global_thaw @@ -1616,7 +1616,7 @@ eo2_event_global_freeze(); */ #define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW) EAPI void -eo2_event_global_thaw(); +eo2_event_global_thaw(void); /** * @def eo_event_global_freeze_get @@ -1632,7 +1632,7 @@ eo2_event_global_thaw(); */ #define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount) EAPI int -eo2_event_global_freeze_get(); +eo2_event_global_freeze_get(void); /** * @def eo_event_callback_add(obj, desc, cb, data) From ed14382f7c31aaa92780e3d508601c47d6334fe9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 14:57:47 +0000 Subject: [PATCH 113/169] eo2: fixed a compliation issue in test suite. --- src/tests/eo/suite/eo_test_general.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index a942cc887c..a651232617 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -623,7 +623,7 @@ START_TEST(eo_magic_checks) eo2_do((Eo *) buf, eo2_wref_add(&wref), - eo2_parent_get(&parent)); + parent = eo2_parent_get()); fail_if(wref); fail_if(parent); From c20c53752809452c8b8df971d11572e70ba22d70 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:02:06 +0000 Subject: [PATCH 114/169] eo2: use EO2_CLASS_DESCRIPTION_NOOPS everywhere. --- src/lib/eo/eo2_class_class.c | 6 +----- .../function_overrides_inherit.c | 2 +- src/tests/eo/mixin/mixin_mixin4.c | 2 +- src/tests/eo/suite/eo_test_class_errors.c | 16 ++++++++-------- src/tests/eo/suite/eo_test_general.c | 10 +++++----- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c index 8f40cae6ec..feb20dd68d 100644 --- a/src/lib/eo/eo2_class_class.c +++ b/src/lib/eo/eo2_class_class.c @@ -4,15 +4,11 @@ #include "Eo.h" -static Eo2_Op_Description op_descs [] = { - EO2_OP_SENTINEL -}; - static const Eo_Class_Description class_desc = { EO2_VERSION, "Eo_Abstract_Class", EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/function_overrides/function_overrides_inherit.c b/src/tests/eo/function_overrides/function_overrides_inherit.c index e9657be845..641c07c49e 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit.c @@ -12,7 +12,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/mixin/mixin_mixin4.c b/src/tests/eo/mixin/mixin_mixin4.c index 0e3dc216e5..efd9e42990 100644 --- a/src/tests/eo/mixin/mixin_mixin4.c +++ b/src/tests/eo/mixin/mixin_mixin4.c @@ -15,7 +15,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, "Mixin4", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index 4193befffb..9f08b5e1e7 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -91,7 +91,7 @@ START_TEST(eo_inherit_errors) EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -102,7 +102,7 @@ START_TEST(eo_inherit_errors) EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -113,7 +113,7 @@ START_TEST(eo_inherit_errors) EO2_VERSION, "General", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -159,7 +159,7 @@ START_TEST(eo_inconsistent_mro) EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -170,7 +170,7 @@ START_TEST(eo_inconsistent_mro) EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -181,7 +181,7 @@ START_TEST(eo_inconsistent_mro) EO2_VERSION, "Mixin2", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -192,7 +192,7 @@ START_TEST(eo_inconsistent_mro) EO2_VERSION, "Mixin3", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -238,7 +238,7 @@ START_TEST(eo_bad_interface) EO2_VERSION, "Interface", EO_CLASS_TYPE_INTERFACE, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index a651232617..af16aa0efc 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -114,7 +114,7 @@ START_TEST(eo_data_fetch) EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, @@ -156,7 +156,7 @@ START_TEST(eo_isa_tests) EO2_VERSION, "Iface", EO_CLASS_TYPE_INTERFACE, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -173,7 +173,7 @@ START_TEST(eo_isa_tests) EO2_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -190,7 +190,7 @@ START_TEST(eo_isa_tests) EO2_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, @@ -761,7 +761,7 @@ START_TEST(eo_pointers_indirection) EO2_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EO2_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, From 123ebca6d06ae1472f537c0fe42de43f809a1a55 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:16:47 +0000 Subject: [PATCH 115/169] eo2: don't create types starting with __, that's reserved. __ is a reserved compiler domain, prefix with _Eo2_ instead. --- src/lib/eo/Eo.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 433e8ab46a..21b070f587 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -645,14 +645,14 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; if ( op == EO_NOOP ) \ op = eo2_api_op_id_get((void*)Name); \ if (!eo2_call_resolve(#Name, op, &call)) return DefRet; \ - __##Name##_func _func_ = (__##Name##_func) call.func; \ + _Eo2_##Name##_func _func_ = (_Eo2_##Name##_func) call.func; \ // to define an EAPI function #define EO2_FUNC_BODY(Name, Ret, DefRet) \ Ret \ Name(void) \ { \ - typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \ + typedef Ret (*_Eo2_##Name##_func)(Eo *, void *obj_data); \ Ret _r; \ EO2_FUNC_COMMON_OP(Name, DefRet); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ @@ -665,7 +665,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; void \ Name(void) \ { \ - typedef void (*__##Name##_func)(Eo *, void *obj_data); \ + typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data); \ EO2_FUNC_COMMON_OP(Name, ); \ EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ _func_(call.obj, call.data); \ @@ -676,7 +676,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Ret \ Name(__VA_ARGS__) \ { \ - typedef Ret (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ + typedef Ret (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ Ret _r; \ EO2_FUNC_COMMON_OP(Name, DefRet); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ @@ -689,7 +689,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; void \ Name(__VA_ARGS__) \ { \ - typedef void (*__##Name##_func)(Eo *, void *obj_data, __VA_ARGS__);\ + typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__);\ EO2_FUNC_COMMON_OP(Name, ); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ _func_(call.obj, call.data, Arguments); \ From b8ae43b4641b46390293c719d24b130b9f0bd91b Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:20:38 +0000 Subject: [PATCH 116/169] eo2: prefix all the eo2_*internal* functions with an underscore. This prevents them from being auto-completed by IDEs which makes development nicer. --- src/lib/eo/Eo.h | 12 ++++++------ src/lib/eo/eo.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 21b070f587..50016a90a2 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -856,11 +856,11 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - Eo *_tmp_obj = eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + Eo *_tmp_obj = _eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ eo2_do(_tmp_obj, \ eo2_constructor(); \ __VA_ARGS__; \ - _tmp_obj = eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + _tmp_obj = _eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ ); \ _tmp_obj; \ }) @@ -883,10 +883,10 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add_custom(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - Eo *_tmp_obj = eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + Eo *_tmp_obj = _eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ eo2_do(_tmp_obj, \ __VA_ARGS__; \ - _tmp_obj = eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + _tmp_obj = _eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ ); \ _tmp_obj; \ }) @@ -904,8 +904,8 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * @see #eo_add */ EAPI Eo *eo_add_internal(const char *file, int line, const Eo_Class *klass, Eo *parent, ...); -EAPI Eo * eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); -EAPI Eo * eo2_add_internal_end(const char *file, int line, const Eo *obj); +EAPI Eo * _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); +EAPI Eo * _eo2_add_internal_end(const char *file, int line, const Eo *obj); /** * @brief Get a pointer to the data of an object for a specific class. diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index c1c4aad442..f68894f2ae 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -655,7 +655,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) } EAPI Eo * -eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) +_eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) { _Eo_Object *obj; @@ -704,7 +704,7 @@ eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo } EAPI Eo * -eo2_add_internal_end(const char *file, int line, const Eo *eo_id) +_eo2_add_internal_end(const char *file, int line, const Eo *eo_id) { Eo2_Stack_Frame *fptr; @@ -720,7 +720,7 @@ eo2_add_internal_end(const char *file, int line, const Eo *eo_id) { ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", file, line, fptr->cur_klass->desc->name); - /* Unref twice, once for the ref in eo2_add_internal_start, and once for the basic object ref. */ + /* Unref twice, once for the ref in _eo2_add_internal_start, and once for the basic object ref. */ _eo_unref(fptr->obj); _eo_unref(fptr->obj); return NULL; From d9ceddf63a741ae3a92fcd9146bb656055ddc987 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:30:25 +0000 Subject: [PATCH 117/169] eo2: fixed formatting. --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index f68894f2ae..ea91cf5621 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -459,7 +459,7 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) return EINA_FALSE; } - if (EINA_LIKELY(func->func && func->src )) + if (EINA_LIKELY(func->func && func->src)) { call->func = func->func; call->klass = _eo_class_id_get(klass); From a62d150c96e3b3eb71c1082a83dc63acef1f2d2f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:54:39 +0000 Subject: [PATCH 118/169] eo2: share code between eo2_do and eo2_do_super. --- src/lib/eo/Eo.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 50016a90a2..f53907d731 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -722,19 +722,8 @@ EAPI int eo2_call_stack_depth(void); #define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) // eo object method calls batch, -#define eo2_do(eoid, ...) \ - do \ - { \ - const Eo *_eoid_ = eoid; \ - if (eo2_do_start(_eoid_, NULL, __FILE__, __FUNCTION__, __LINE__)) \ - { \ - const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ - __VA_ARGS__; \ - (void) _id_clean_; \ - } \ - } while (0) -#define eo2_do_super(eoid, clsid, ...) \ +#define _eo2_do_common(eoid, clsid, ...) \ do \ { \ const Eo *_eoid_ = eoid; \ @@ -746,6 +735,11 @@ EAPI int eo2_call_stack_depth(void); } \ } while (0) + +#define eo2_do(eoid, ...) _eo2_do_common(eoid, NULL, __VA_ARGS__) + +#define eo2_do_super(eoid, clsid, ...) _eo2_do_common(eoid, clsid, __VA_ARGS__) + /*****************************************************************************/ /** From 7c3f7e9b5b80c2c7e3f52881d980fd516755215a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 16:21:01 +0000 Subject: [PATCH 119/169] eo2: eo2_do_super should only have one func. This is a limitation that must be respected as eo2_do_super, unlike eo2_do can end up with having different next class because of mixins. --- src/lib/eo/Eo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index f53907d731..011ff57158 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -738,7 +738,7 @@ EAPI int eo2_call_stack_depth(void); #define eo2_do(eoid, ...) _eo2_do_common(eoid, NULL, __VA_ARGS__) -#define eo2_do_super(eoid, clsid, ...) _eo2_do_common(eoid, clsid, __VA_ARGS__) +#define eo2_do_super(eoid, clsid, func) _eo2_do_common(eoid, clsid, func) /*****************************************************************************/ From 1890fdf27f3780e62707b8d4531c16957c9ba71e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 10:34:35 +0000 Subject: [PATCH 120/169] eo2: fixed eo2_do call order. This fixes the mixin test and general calling order. "Next class" can only be known per op. That's why super should be restricted to only one op. --- src/lib/eo/eo.c | 149 ++++++++++++++++++++++++------------------------ 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index ea91cf5621..9759febd99 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -283,10 +283,12 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) typedef struct _Eo2_Stack_Frame { const Eo *eo_id; - _Eo_Object *obj; + union { + _Eo_Object *obj; + const _Eo_Class *kls; + } o; const _Eo_Class *cur_klass; void *obj_data; - } Eo2_Stack_Frame; typedef struct _Eo2_Call_Stack { @@ -323,72 +325,32 @@ eo2_call_stack_depth() } static inline Eina_Bool -_eo2_obj_do(const Eo *eo_id, const Eo_Class *cur_klass_id, +_eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { - _Eo_Object *obj; - const _Eo_Class *klass; - + /* If we are already in the same object context, we inherit info from it. */ if (pfptr) { - obj = pfptr->obj; memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); } else { - EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); - obj = _obj; fptr->eo_id = eo_id; - fptr->obj = _obj; + fptr->obj_data = EO2_INVALID_DATA; } if (cur_klass_id) { EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - klass = _eo2_kls_itr_next(obj->klass, cur_klass); - } - else - klass = obj->klass; - - if ((!pfptr) || (klass != fptr->cur_klass)) - { - fptr->cur_klass = klass; - fptr->obj_data = EO2_INVALID_DATA; - } - - _eo_ref(obj); - - return EINA_TRUE; -} - -static inline Eina_Bool -_eo2_class_do(const Eo *eo_id, const Eo_Class *cur_klass_id, - Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) -{ - const _Eo_Class *klass; - - if (pfptr) - { - klass = pfptr->cur_klass; - memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); + if (fptr->cur_klass == cur_klass) + fptr->obj_data = EO2_INVALID_DATA; + fptr->cur_klass = cur_klass; } else { - EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); - klass = _klass; - fptr->eo_id = eo_id; - fptr->obj = NULL; - fptr->obj_data = EO2_INVALID_DATA; + fptr->cur_klass = NULL; } - if(cur_klass_id) - { - EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - fptr->cur_klass = _eo2_kls_itr_next(klass, cur_klass); - } - else - fptr->cur_klass = klass; - return EINA_TRUE; } @@ -405,16 +367,22 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EIN } pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); + fptr++; + + if (!_eo2_do_internal(eo_id, cur_klass_id, fptr, pfptr)) + return EINA_FALSE; + if(_eo_is_a_class(eo_id)) { - if (!_eo2_class_do(eo_id, cur_klass_id, (fptr + 1), pfptr)) - return EINA_FALSE; - } + EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); + fptr->o.kls = _klass; + } else { - if (!_eo2_obj_do(eo_id, cur_klass_id, (fptr + 1), pfptr)) - return EINA_FALSE; - } + EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); + fptr->o.obj = _obj; + _eo_ref(_obj); + } eo2_call_stack.frame_ptr++; @@ -428,8 +396,8 @@ eo2_do_end(const Eo **eo_id EINA_UNUSED) fptr = eo2_call_stack.frame_ptr; - if(fptr->obj) - _eo_unref(fptr->obj); + if(fptr->o.obj) + _eo_unref(fptr->o.obj); memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; @@ -444,13 +412,24 @@ EAPI Eina_Bool eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; - const _Eo_Object * obj; const _Eo_Class *klass; const op_type_funcs *func; + Eina_Bool is_obj; fptr = eo2_call_stack.frame_ptr; - obj = fptr->obj; - klass = fptr->cur_klass; + is_obj = !_eo_is_a_class(fptr->eo_id); + + klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; + + /* If we have a current class, we need to itr to the next. */ + if (fptr->cur_klass) + { + /* FIXME-2 This should actually be merged with the dich_func_get after. */ + klass = _eo_kls_itr_next(klass, fptr->cur_klass, op); + + if (!klass) + goto end; + } func = _dich_func_get(klass, op); if (EINA_UNLIKELY(func == NULL)) @@ -464,18 +443,18 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) call->func = func->func; call->klass = _eo_class_id_get(klass); - if (obj) + if (is_obj) { call->obj = (Eo *)fptr->eo_id; - if (func->src == obj->klass) + if (func->src == fptr->o.obj->klass) { if (fptr->obj_data == EO2_INVALID_DATA) - fptr->obj_data = _eo_data_scope_get(obj, func->src); + fptr->obj_data = _eo_data_scope_get(fptr->o.obj, func->src); call->data = fptr->obj_data; } else - call->data = _eo_data_scope_get(obj, func->src); + call->data = _eo_data_scope_get(fptr->o.obj, func->src); } else { @@ -492,12 +471,14 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) return EINA_FALSE; } + +end: /* Try composite objects */ - if (obj) + if (is_obj) { Eina_List *itr; Eo *emb_eo_id; - EINA_LIST_FOREACH((obj)->composite_objects, itr, emb_eo_id) + EINA_LIST_FOREACH(fptr->o.obj->composite_objects, itr, emb_eo_id) { /* should never return */ EO_OBJ_POINTER_RETURN_VAL(emb_eo_id, emb_obj, EINA_FALSE); @@ -506,7 +487,7 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) if (func == NULL) continue; - if (EINA_LIKELY(func->func && func->src )) + if (EINA_LIKELY(func->func && func->src)) { call->obj = _eo_id_get(emb_obj); call->klass = _eo_class_id_get(emb_obj->klass); @@ -518,7 +499,23 @@ eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) } } - ERR("func '%s' (%d) could not be resolved in class '%s'", func_name, op, klass->desc->name); + { + 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) + { + ERR("func '%s' (%d) could not be resolved for class '%s' for super of '%s'", + func_name, op, main_klass->desc->name, + fptr->cur_klass->desc->name); + } + else + { + ERR("func '%s' (%d) could not be resolved for class '%s'", + func_name, op, main_klass->desc->name); + } + } return EINA_FALSE; } @@ -580,9 +577,9 @@ eo2_api_op_id_get(const void *api_func) Eina_Bool class_ref = _eo_is_a_class(eo2_call_stack.frame_ptr->eo_id); if (class_ref) - klass = eo2_call_stack.frame_ptr->cur_klass; + klass = eo2_call_stack.frame_ptr->o.kls; else - klass = eo2_call_stack.frame_ptr->obj->klass; + klass = eo2_call_stack.frame_ptr->o.obj->klass; desc = _eo2_api_desc_get(api_func, klass, klass->extensions); @@ -716,17 +713,19 @@ _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) return NULL; } - if (!fptr->obj->condtor_done || fptr->obj->do_error) + if (!fptr->o.obj->condtor_done || fptr->o.obj->do_error) { + const _Eo_Class *klass = (fptr->cur_klass) ? + fptr->cur_klass : fptr->o.obj->klass; ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", - file, line, fptr->cur_klass->desc->name); + file, line, klass->desc->name); /* Unref twice, once for the ref in _eo2_add_internal_start, and once for the basic object ref. */ - _eo_unref(fptr->obj); - _eo_unref(fptr->obj); + _eo_unref(fptr->o.obj); + _eo_unref(fptr->o.obj); return NULL; } - _eo_unref(fptr->obj); + _eo_unref(fptr->o.obj); return (Eo *)eo_id; } From ebae305a9e053616cdb5ceb778e435c2c4e03d26 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 10:47:13 +0000 Subject: [PATCH 121/169] eo2: fixed validity checks for eo2_do_super. The class should be checked to be valid and non-null. This fixes the issues with eo_suite. --- src/lib/eo/Eo.h | 10 +++++----- src/lib/eo/eo.c | 8 ++++---- src/tests/eo/suite/eo_test_general.c | 5 ++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 011ff57158..432152c280 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -712,7 +712,7 @@ EAPI Eo_Op eo2_api_op_id_get(const void *api_func); EAPI Eina_Bool eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, const char *file, const char *func, int line); +EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void eo2_do_end(const Eo **ojb); @@ -723,11 +723,11 @@ EAPI int eo2_call_stack_depth(void); // eo object method calls batch, -#define _eo2_do_common(eoid, clsid, ...) \ +#define _eo2_do_common(eoid, clsid, is_super, ...) \ do \ { \ const Eo *_eoid_ = eoid; \ - if (eo2_do_start(_eoid_, clsid, __FILE__, __FUNCTION__, __LINE__)) \ + if (eo2_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \ { \ const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ __VA_ARGS__; \ @@ -736,9 +736,9 @@ EAPI int eo2_call_stack_depth(void); } while (0) -#define eo2_do(eoid, ...) _eo2_do_common(eoid, NULL, __VA_ARGS__) +#define eo2_do(eoid, ...) _eo2_do_common(eoid, NULL, EINA_FALSE, __VA_ARGS__) -#define eo2_do_super(eoid, clsid, func) _eo2_do_common(eoid, clsid, func) +#define eo2_do_super(eoid, clsid, func) _eo2_do_common(eoid, clsid, EINA_TRUE, func) /*****************************************************************************/ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 9759febd99..3bea5d4045 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -326,7 +326,7 @@ eo2_call_stack_depth() static inline Eina_Bool _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, - Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) + Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { /* If we are already in the same object context, we inherit info from it. */ if (pfptr) @@ -339,7 +339,7 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, fptr->obj_data = EO2_INVALID_DATA; } - if (cur_klass_id) + if (is_super) { EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); if (fptr->cur_klass == cur_klass) @@ -355,7 +355,7 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, } EAPI Eina_Bool -eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { Eo2_Stack_Frame *fptr, *pfptr; @@ -369,7 +369,7 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, const char *file EIN pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); fptr++; - if (!_eo2_do_internal(eo_id, cur_klass_id, fptr, pfptr)) + if (!_eo2_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) return EINA_FALSE; if(_eo_is_a_class(eo_id)) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index af16aa0efc..4cc2c2203f 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -595,7 +595,7 @@ START_TEST(eo_magic_checks) ck_assert_int_ne(i, a); eo2_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i)); eo2_do_super(obj, (const Eo_Class *) buf, a = simple_a_get()); - ck_assert_int_ne(i, a); // FIXME Jeremy: shouldn't happen. do_super should check for class validity and fail! + ck_assert_int_ne(i, a); fail_if(eo_class_get((Eo *) buf)); fail_if(eo_class_name_get((Eo_Class*) buf)); fail_if(eo_class_get(obj) != SIMPLE_CLASS); @@ -603,8 +603,7 @@ START_TEST(eo_magic_checks) eo_class_funcs_set((Eo_Class *) buf, NULL); eo2_do((Eo_Class *) buf, NULL); eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); - eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); // FIXME Jeremy: For some reason it tries to call the object function on the class!!! - + eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL); eo_xref(obj, (Eo *) buf); From 2fe10219c0a694aa8d9a1f7b3f39516ce98e2e2e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 10:51:47 +0000 Subject: [PATCH 122/169] eo2: prefixed internal functions with _. This is done to prevent code completion from picking them up. --- src/lib/eo/Eo.h | 16 ++++++++-------- src/lib/eo/eo.c | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 432152c280..24f7e3bd7e 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -643,8 +643,8 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Eo2_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ if ( op == EO_NOOP ) \ - op = eo2_api_op_id_get((void*)Name); \ - if (!eo2_call_resolve(#Name, op, &call)) return DefRet; \ + op = _eo2_api_op_id_get((void*)Name); \ + if (!_eo2_call_resolve(#Name, op, &call)) return DefRet; \ _Eo2_##Name##_func _func_ = (_Eo2_##Name##_func) call.func; \ // to define an EAPI function @@ -706,20 +706,20 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op eo2_api_op_id_get(const void *api_func); +EAPI Eo_Op _eo2_api_op_id_get(const void *api_func); // gets the real function pointer and the object data -EAPI Eina_Bool eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); +EAPI Eina_Bool _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); +EAPI Eina_Bool _eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); // end of the eo2_do barrier, unref the obj, move the stack pointer -EAPI void eo2_do_end(const Eo **ojb); +EAPI void _eo2_do_end(const Eo **ojb); EAPI int eo2_call_stack_depth(void); -#define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end))) +#define EO2_DO_CLEANUP __attribute__((cleanup(_eo2_do_end))) // eo object method calls batch, @@ -727,7 +727,7 @@ EAPI int eo2_call_stack_depth(void); do \ { \ const Eo *_eoid_ = eoid; \ - if (eo2_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \ + if (_eo2_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \ { \ const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ __VA_ARGS__; \ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 3bea5d4045..02961e3b77 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -355,7 +355,7 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, } EAPI Eina_Bool -eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +_eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { Eo2_Stack_Frame *fptr, *pfptr; @@ -390,7 +390,7 @@ eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, } EAPI void -eo2_do_end(const Eo **eo_id EINA_UNUSED) +_eo2_do_end(const Eo **eo_id EINA_UNUSED) { Eo2_Stack_Frame *fptr; @@ -409,7 +409,7 @@ eo2_do_end(const Eo **eo_id EINA_UNUSED) } EAPI Eina_Bool -eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) +_eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) { Eo2_Stack_Frame *fptr; const _Eo_Class *klass; @@ -569,7 +569,7 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class } EAPI Eo_Op -eo2_api_op_id_get(const void *api_func) +_eo2_api_op_id_get(const void *api_func) { const Eo2_Op_Description *desc; const _Eo_Class *klass; From 76dc0d99a6bed65eeae9f894a03c000f848c056e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 15:30:25 +0000 Subject: [PATCH 123/169] eo2: formatting. --- src/lib/eo/Eo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 24f7e3bd7e..1aa1c8046c 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -642,7 +642,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; #define EO2_FUNC_COMMON_OP(Name, DefRet) \ Eo2_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ - if ( op == EO_NOOP ) \ + if (op == EO_NOOP) \ op = _eo2_api_op_id_get((void*)Name); \ if (!_eo2_call_resolve(#Name, op, &call)) return DefRet; \ _Eo2_##Name##_func _func_ = (_Eo2_##Name##_func) call.func; \ @@ -689,7 +689,7 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; void \ Name(__VA_ARGS__) \ { \ - typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__);\ + typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ EO2_FUNC_COMMON_OP(Name, ); \ EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ _func_(call.obj, call.data, Arguments); \ From 08aca96bc370a71ea9d48f2fb1821e6d10a4b09c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 10:59:54 +0000 Subject: [PATCH 124/169] eo2: get rid of eo2_stack_depth_get. This is super internal, no reason why it should be exposed. We should just implement automatic stack growth. --- src/lib/eo/Eo.h | 2 -- src/lib/eo/eo.c | 6 ------ 2 files changed, 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 1aa1c8046c..8fa8ad5b0a 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -717,8 +717,6 @@ EAPI Eina_Bool _eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool // end of the eo2_do barrier, unref the obj, move the stack pointer EAPI void _eo2_do_end(const Eo **ojb); -EAPI int eo2_call_stack_depth(void); - #define EO2_DO_CLEANUP __attribute__((cleanup(_eo2_do_end))) // eo object method calls batch, diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 02961e3b77..6ffb612152 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -318,12 +318,6 @@ _eo2_call_stack_free() free(eo2_call_stack.stack); } -EAPI int -eo2_call_stack_depth() -{ - return (eo2_call_stack.frame_ptr - eo2_call_stack.stack); -} - static inline Eina_Bool _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) From 0dc70153e51833fdc66d6580055fcdf0ce8ab4b2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 13:06:51 +0000 Subject: [PATCH 125/169] eo2: optimize eo2_do_super func relove a bit. no need to call dich_func_get twice, just reuse the value previously fetched. --- src/lib/eo/eo.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 6ffb612152..f387c36db1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -210,8 +210,8 @@ _eo_op_id_name_get(Eo_Op op) return (desc) ? desc->name : NULL; } -static inline const _Eo_Class * -_eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) +static inline const op_type_funcs * +_eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) { const _Eo_Class **kls_itr = NULL; @@ -231,13 +231,22 @@ _eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op kls_itr++; continue; } - return fsrc->src; + return fsrc; } } return NULL; } +static inline const _Eo_Class * +_eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) +{ + const op_type_funcs *fsrc; + fsrc = _eo2_kls_itr_next(orig_kls, cur_klass, op); + + return (fsrc) ? fsrc->src : NULL; +} + static inline const op_type_funcs * _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) { @@ -260,22 +269,6 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL; EAPI Eo2_Hook_Call eo2_hook_call_post = NULL; -static inline const _Eo_Class * -_eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass) -{ - const _Eo_Class **kls_itr = NULL; - - /* Find the kls itr. */ - kls_itr = orig_kls->mro; - while (*kls_itr && (*kls_itr != cur_klass)) - kls_itr++; - - if (*kls_itr) - return *(++kls_itr); - - return NULL; -} - // FIXME: per thread stack, grow/shrink #define EO2_INVALID_DATA (void *) -1 #define EO2_CALL_STACK_DEPTH 100 @@ -418,14 +411,18 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) /* If we have a current class, we need to itr to the next. */ if (fptr->cur_klass) { - /* FIXME-2 This should actually be merged with the dich_func_get after. */ - klass = _eo_kls_itr_next(klass, fptr->cur_klass, op); + func = _eo2_kls_itr_next(klass, fptr->cur_klass, op); - if (!klass) + if (!func) goto end; + + klass = func->src; + } + else + { + func = _dich_func_get(klass, op); } - func = _dich_func_get(klass, op); if (EINA_UNLIKELY(func == NULL)) { ERR("you called func '%s' (%d) which is unknown in class '%s'", func_name, op, klass->desc->name); From 055dd3c521432fab291c547288a746586966946b Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Nov 2013 13:27:36 +0000 Subject: [PATCH 126/169] eo2: change the order of EO2_OP_FUNC* to put EAPI first. This looks cleaner and more aligned. Also, it makes more sense as the internal function is bound to the EAPI and not the other way around. --- src/lib/eo/Eo.h | 10 ++-- src/lib/eo/eo2_base_class.c | 48 +++++++++---------- src/tests/eo/access/access_inherit.c | 2 +- src/tests/eo/access/access_simple.c | 2 +- .../composite_objects_comp.c | 4 +- .../composite_objects_simple.c | 4 +- .../eo/constructors/constructors_mixin.c | 6 +-- .../eo/constructors/constructors_simple.c | 14 +++--- .../eo/constructors/constructors_simple2.c | 2 +- .../eo/constructors/constructors_simple3.c | 2 +- .../eo/constructors/constructors_simple5.c | 2 +- .../eo/constructors/constructors_simple6.c | 2 +- .../eo/constructors/constructors_simple7.c | 2 +- .../function_overrides_inherit2.c | 8 ++-- .../function_overrides_inherit3.c | 2 +- .../function_overrides_simple.c | 8 ++-- src/tests/eo/interface/interface_interface.c | 2 +- src/tests/eo/interface/interface_interface2.c | 2 +- src/tests/eo/interface/interface_simple.c | 12 ++--- src/tests/eo/mixin/mixin_inherit.c | 2 +- src/tests/eo/mixin/mixin_mixin.c | 6 +-- src/tests/eo/mixin/mixin_mixin2.c | 6 +-- src/tests/eo/mixin/mixin_mixin3.c | 6 +-- src/tests/eo/mixin/mixin_simple.c | 8 ++-- src/tests/eo/signals/signals_simple.c | 4 +- src/tests/eo/suite/eo_test_class_simple.c | 10 ++-- src/tests/eo/suite/eo_test_general.c | 8 ++-- 27 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 8fa8ad5b0a..f297c9297f 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -450,8 +450,8 @@ typedef struct _Eo_Op_Description Eo_Op_Description; typedef struct _Eo2_Op_Description { - void *func; /**< The static function to call for the op. */ void *api_func; /**< The EAPI function offering this op. */ + void *func; /**< The static function to call for the op. */ Eo_Op op; /**< The op. */ Eo_Op_Type op_type; /**< The type of the Op. */ const char *doc; /**< Explanation about the Op. */ @@ -699,10 +699,10 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; // OP ID of an overriding function #define EO2_OP_OVERRIDE ((Eo_Op) -1) -#define EO2_OP_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} -#define EO2_OP_CLASS_FUNC(_private, _api, _doc) {_private, _api, EO_NOOP, EO_OP_TYPE_CLASS, _doc} -#define EO2_OP_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} -#define EO2_OP_CLASS_FUNC_OVERRIDE(_private, _api) {_private, _api, EO2_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} +#define EO2_OP_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} +#define EO2_OP_CLASS_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_CLASS, _doc} +#define EO2_OP_FUNC_OVERRIDE(_api, _private) {_api, _private, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} +#define EO2_OP_CLASS_FUNC_OVERRIDE(_api, _private) {_api, _private, EO2_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index b032b01118..3cf4b8fd4c 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -956,30 +956,30 @@ _class_constructor(Eo_Class *klass EINA_UNUSED) } static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC(_constructor, eo2_constructor, "Constructor."), - EO2_OP_FUNC(_destructor, eo2_destructor, "Destructor."), - EO2_OP_FUNC(_parent_set, eo2_parent_set, "Set parent."), - EO2_OP_FUNC(_parent_get, eo2_parent_get, "Get parent."), - EO2_OP_FUNC(_children_iterator_new, eo2_children_iterator_new, "Get Children Iterator."), - EO2_OP_FUNC(_data_set, eo2_base_data_set, "Set data for key."), - EO2_OP_FUNC(_data_get, eo2_base_data_get, "Get data for key."), - EO2_OP_FUNC(_data_del, eo2_base_data_del, "Del key."), - EO2_OP_FUNC(_wref_add, eo2_wref_add, "Add a weak ref to the object."), - EO2_OP_FUNC(_wref_del, eo2_wref_del, "Delete the weak ref."), - EO2_OP_FUNC(_ev_cb_priority_add, eo2_event_callback_priority_add, "Add an event callback with a priority."), - EO2_OP_FUNC(_ev_cb_del, eo2_event_callback_del, "Delete an event callback"), - EO2_OP_FUNC(_ev_cb_array_priority_add, eo2_event_callback_array_priority_add, "Add an event callback array with a priority."), - EO2_OP_FUNC(_ev_cb_array_del, eo2_event_callback_array_del, "Delete an event callback array"), - EO2_OP_FUNC(_ev_cb_call, eo2_event_callback_call, "Call the event callbacks for an event."), - EO2_OP_FUNC(_ev_cb_forwarder_add, eo2_event_callback_forwarder_add, "Add an event forwarder."), - EO2_OP_FUNC(_ev_cb_forwarder_del, eo2_event_callback_forwarder_del, "Delete an event forwarder."), - EO2_OP_FUNC(_ev_freeze, eo2_event_freeze, "Freezes events."), - EO2_OP_FUNC(_ev_thaw, eo2_event_thaw, "Thaws events."), - EO2_OP_FUNC(_ev_freeze_get, eo2_event_freeze_get, "Get event freeze counter."), - EO2_OP_FUNC(_ev_global_freeze, eo2_event_global_freeze, "Freezes events globally."), - EO2_OP_FUNC(_ev_global_thaw, eo2_event_global_thaw, "Thaws events globally."), - EO2_OP_FUNC(_ev_global_freeze_get, eo2_event_global_freeze_get, "Get global event freeze counter."), - EO2_OP_FUNC(_dbg_info_get, eo2_dbg_info_get, "Get debug info list for obj."), + EO2_OP_FUNC(eo2_constructor, _constructor, "Constructor."), + EO2_OP_FUNC(eo2_destructor, _destructor, "Destructor."), + EO2_OP_FUNC(eo2_parent_set, _parent_set, "Set parent."), + EO2_OP_FUNC(eo2_parent_get, _parent_get, "Get parent."), + EO2_OP_FUNC(eo2_children_iterator_new, _children_iterator_new, "Get Children Iterator."), + EO2_OP_FUNC(eo2_base_data_set, _data_set, "Set data for key."), + EO2_OP_FUNC(eo2_base_data_get, _data_get, "Get data for key."), + EO2_OP_FUNC(eo2_base_data_del, _data_del, "Del key."), + EO2_OP_FUNC(eo2_wref_add, _wref_add, "Add a weak ref to the object."), + EO2_OP_FUNC(eo2_wref_del, _wref_del, "Delete the weak ref."), + EO2_OP_FUNC(eo2_event_callback_priority_add, _ev_cb_priority_add, "Add an event callback with a priority."), + EO2_OP_FUNC(eo2_event_callback_del, _ev_cb_del, "Delete an event callback"), + EO2_OP_FUNC(eo2_event_callback_array_priority_add, _ev_cb_array_priority_add, "Add an event callback array with a priority."), + EO2_OP_FUNC(eo2_event_callback_array_del, _ev_cb_array_del, "Delete an event callback array"), + EO2_OP_FUNC(eo2_event_callback_call, _ev_cb_call, "Call the event callbacks for an event."), + EO2_OP_FUNC(eo2_event_callback_forwarder_add, _ev_cb_forwarder_add, "Add an event forwarder."), + EO2_OP_FUNC(eo2_event_callback_forwarder_del, _ev_cb_forwarder_del, "Delete an event forwarder."), + EO2_OP_FUNC(eo2_event_freeze, _ev_freeze, "Freezes events."), + EO2_OP_FUNC(eo2_event_thaw, _ev_thaw, "Thaws events."), + EO2_OP_FUNC(eo2_event_freeze_get, _ev_freeze_get, "Get event freeze counter."), + EO2_OP_FUNC(eo2_event_global_freeze, _ev_global_freeze, "Freezes events globally."), + EO2_OP_FUNC(eo2_event_global_thaw, _ev_global_thaw, "Thaws events globally."), + EO2_OP_FUNC(eo2_event_global_freeze_get, _ev_global_freeze_get, "Get global event freeze counter."), + EO2_OP_FUNC(eo2_dbg_info_get, _dbg_info_get, "Get debug info list for obj."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/access/access_inherit.c b/src/tests/eo/access/access_inherit.c index 303f60f261..6db73134de 100644 --- a/src/tests/eo/access/access_inherit.c +++ b/src/tests/eo/access/access_inherit.c @@ -19,7 +19,7 @@ _prot_print(Eo *obj, void *class_data EINA_UNUSED) EAPI EO2_VOID_FUNC_BODY(inherit_prot_print); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_prot_print, inherit_prot_print, "Print protected var x1."), + EO2_OP_FUNC(inherit_prot_print, _prot_print, "Print protected var x1."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c index a7a14a10f7..59997f3a78 100644 --- a/src/tests/eo/access/access_simple.c +++ b/src/tests/eo/access/access_simple.c @@ -33,7 +33,7 @@ _a_set(Eo *obj, void *class_data, int a) EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index fb874f1b86..9d1ec64eab 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -37,8 +37,8 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_a_get, simple_a_get), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(simple_a_get, _a_get), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/composite_objects/composite_objects_simple.c b/src/tests/eo/composite_objects/composite_objects_simple.c index 3ccef86d27..e44df196fb 100644 --- a/src/tests/eo/composite_objects/composite_objects_simple.c +++ b/src/tests/eo/composite_objects/composite_objects_simple.c @@ -31,8 +31,8 @@ EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); EAPI EO2_FUNC_BODY(simple_a_get, int, 0); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), - EO2_OP_FUNC(_a_get, simple_a_get, "Get property A"), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), + EO2_OP_FUNC(simple_a_get, _a_get, "Get property A"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index a72911733b..62ebf7bb09 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -37,9 +37,9 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED) EAPI EO2_VOID_FUNC_BODYV(mixin_add_and_print, EO2_FUNC_CALL(x), int x); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_add_and_print_set, mixin_add_and_print, "Add A + B + param and print it"), - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC(mixin_add_and_print, _add_and_print_set, "Add A + B + param and print it"), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c index f5ab9f5123..dfa51bf75e 100644 --- a/src/tests/eo/constructors/constructors_simple.c +++ b/src/tests/eo/constructors/constructors_simple.c @@ -83,13 +83,13 @@ _class_destructor(Eo_Class *klass EINA_UNUSED) EO2_VOID_FUNC_BODYV(simple_constructor, EO2_FUNC_CALL(a), int a); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), - EO2_OP_FUNC(_simple_constructor, simple_constructor, "Construct and set A."), - EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), - EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), - EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), - EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), + EO2_OP_FUNC(simple_constructor, _simple_constructor, "Construct and set A."), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c index 3f6d6bdded..b7b4aaef2d 100644 --- a/src/tests/eo/constructors/constructors_simple2.c +++ b/src/tests/eo/constructors/constructors_simple2.c @@ -17,7 +17,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple3.c b/src/tests/eo/constructors/constructors_simple3.c index 1a8a32fac5..233005eecb 100644 --- a/src/tests/eo/constructors/constructors_simple3.c +++ b/src/tests/eo/constructors/constructors_simple3.c @@ -15,7 +15,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple5.c b/src/tests/eo/constructors/constructors_simple5.c index ea43291eea..b64b969819 100644 --- a/src/tests/eo/constructors/constructors_simple5.c +++ b/src/tests/eo/constructors/constructors_simple5.c @@ -15,7 +15,7 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple6.c b/src/tests/eo/constructors/constructors_simple6.c index d78cad88e0..7a23eb31d4 100644 --- a/src/tests/eo/constructors/constructors_simple6.c +++ b/src/tests/eo/constructors/constructors_simple6.c @@ -17,7 +17,7 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED) } static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/constructors/constructors_simple7.c b/src/tests/eo/constructors/constructors_simple7.c index 90b11c4984..fb4a731261 100644 --- a/src/tests/eo/constructors/constructors_simple7.c +++ b/src/tests/eo/constructors/constructors_simple7.c @@ -19,7 +19,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index f228528719..cf8b1cb0db 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -60,10 +60,10 @@ EAPI EO2_FUNC_BODY(inherit2_print, Eina_Bool, EINA_FALSE); EAPI EO2_FUNC_BODY(inherit2_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_print, inherit2_print, "Print hey"), - EO2_OP_FUNC(_print2, inherit2_print2, "Print hey2"), - EO2_OP_CLASS_FUNC_OVERRIDE(_class_print, simple_class_print), - EO2_OP_FUNC_OVERRIDE(_a_set, simple_a_set), + EO2_OP_FUNC(inherit2_print, _print, "Print hey"), + EO2_OP_FUNC(inherit2_print2, _print2, "Print hey2"), + EO2_OP_CLASS_FUNC_OVERRIDE(simple_class_print, _class_print), + EO2_OP_FUNC_OVERRIDE(simple_a_set, _a_set), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.c b/src/tests/eo/function_overrides/function_overrides_inherit3.c index ad4cb67f8c..68214b7b26 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit3.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit3.c @@ -17,7 +17,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_a_set, simple_a_set), + EO2_OP_FUNC_OVERRIDE(simple_a_set, _a_set), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index 3de5938aad..1e2ef0e6f7 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -57,10 +57,10 @@ EAPI EO2_FUNC_BODY(simple_class_print, Eina_Bool, EINA_FALSE); EAPI EO2_FUNC_BODY(simple_class_print2, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property A"), - EO2_OP_FUNC(_a_print, simple_a_print, "Print property A"), - EO2_OP_FUNC(_class_print, simple_class_print, "Print class name."), - EO2_OP_FUNC(_class_print2, simple_class_print2, "Print2 class name."), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), + EO2_OP_FUNC(simple_a_print, _a_print, "Print property A"), + EO2_OP_FUNC(simple_class_print, _class_print, "Print class name."), + EO2_OP_FUNC(simple_class_print2, _class_print2, "Print2 class name."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/interface/interface_interface.c b/src/tests/eo/interface/interface_interface.c index 0afd136b6c..eac93cd2b0 100644 --- a/src/tests/eo/interface/interface_interface.c +++ b/src/tests/eo/interface/interface_interface.c @@ -11,7 +11,7 @@ EO2_FUNC_BODY(interface_ab_sum_get, int, 0); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(NULL, interface_ab_sum_get, "Get the sum of a and b."), + EO2_OP_FUNC(interface_ab_sum_get, NULL, "Get the sum of a and b."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/interface/interface_interface2.c b/src/tests/eo/interface/interface_interface2.c index 27f2e3c35c..198850da05 100644 --- a/src/tests/eo/interface/interface_interface2.c +++ b/src/tests/eo/interface/interface_interface2.c @@ -12,7 +12,7 @@ EO2_FUNC_BODY(interface2_ab_sum_get2, int, 0); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(NULL, interface2_ab_sum_get2, "Print the sum of a and b."), + EO2_OP_FUNC(interface2_ab_sum_get2, NULL, "Print the sum of a and b."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index 16e2b836a5..8a0aa1f06b 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -55,12 +55,12 @@ _ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), - EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), - EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), - EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), - EO2_OP_FUNC_OVERRIDE(_ab_sum_get, interface_ab_sum_get), - EO2_OP_FUNC_OVERRIDE(_ab_sum_get2, interface2_ab_sum_get2), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), + EO2_OP_FUNC_OVERRIDE(interface_ab_sum_get, _ab_sum_get), + EO2_OP_FUNC_OVERRIDE(interface2_ab_sum_get2, _ab_sum_get2), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c index 7c8b3b568f..558c54cf04 100644 --- a/src/tests/eo/mixin/mixin_inherit.c +++ b/src/tests/eo/mixin/mixin_inherit.c @@ -20,7 +20,7 @@ _a_get(Eo *obj, void *class_data EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_a_get, simple_a_get), + EO2_OP_FUNC_OVERRIDE(simple_a_get, _a_get), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index 71983850d5..9b6ac802a1 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -32,9 +32,9 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED) EAPI EO2_FUNC_BODY(mixin_ab_sum_get, int, 0); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), - EO2_OP_FUNC(_ab_sum_get, mixin_ab_sum_get, "Get the sum of a and b."), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), + EO2_OP_FUNC(mixin_ab_sum_get, _ab_sum_get, "Get the sum of a and b."), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c index 417321f12c..80dfa8275b 100644 --- a/src/tests/eo/mixin/mixin_mixin2.c +++ b/src/tests/eo/mixin/mixin_mixin2.c @@ -45,9 +45,9 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), - EO2_OP_FUNC_OVERRIDE(_ab_sum_get, mixin_ab_sum_get), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), + EO2_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c index 1a04b94be1..441fd29e72 100644 --- a/src/tests/eo/mixin/mixin_mixin3.c +++ b/src/tests/eo/mixin/mixin_mixin3.c @@ -45,9 +45,9 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor), - EO2_OP_FUNC_OVERRIDE(_ab_sum_get, mixin_ab_sum_get), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), + EO2_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/mixin/mixin_simple.c b/src/tests/eo/mixin/mixin_simple.c index 8dc515bb87..879728964f 100644 --- a/src/tests/eo/mixin/mixin_simple.c +++ b/src/tests/eo/mixin/mixin_simple.c @@ -38,10 +38,10 @@ _GET_SET_FUNC(a) _GET_SET_FUNC(b) static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), - EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), - EO2_OP_FUNC(_b_set, simple_b_set, "Set property b"), - EO2_OP_FUNC(_b_get, simple_b_get, "Get property b"), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c index 4b7364772a..1de1ad9e34 100644 --- a/src/tests/eo/signals/signals_simple.c +++ b/src/tests/eo/signals/signals_simple.c @@ -74,8 +74,8 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor), - EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index 9b55ffb3fa..8690dfc540 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -59,11 +59,11 @@ EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE); static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_dbg_info_get, eo2_dbg_info_get), - EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"), - EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"), - EO2_OP_FUNC(_a_print, simple_a_print, "Print property a"), - EO2_OP_CLASS_FUNC(_class_hi_print, simple_class_hi_print, "Print property a"), + EO2_OP_FUNC_OVERRIDE(eo2_dbg_info_get, _dbg_info_get), + EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO2_OP_FUNC(simple_a_print, _a_print, "Print property a"), + EO2_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index 4cc2c2203f..c703493926 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -265,8 +265,8 @@ _man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED) } static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(_man_con, eo2_constructor), - EO2_OP_FUNC_OVERRIDE(_man_des, eo2_destructor), + EO2_OP_FUNC_OVERRIDE(eo2_constructor, _man_con), + EO2_OP_FUNC_OVERRIDE(eo2_destructor, _man_des), EO2_OP_SENTINEL }; @@ -682,8 +682,8 @@ EO2_FUNC_BODY(multi_a_print, Eina_Bool, EINA_FALSE); EO2_FUNC_BODY(multi_class_hi_print, Eina_Bool, EINA_FALSE); static Eo2_Op_Description _multi_do_op_descs[] = { - EO2_OP_FUNC(_a_print, multi_a_print, "Print property a"), - EO2_OP_FUNC(_class_hi_print, multi_class_hi_print, "Print Hi"), + EO2_OP_FUNC(multi_a_print, _a_print, "Print property a"), + EO2_OP_FUNC(multi_class_hi_print, _class_hi_print, "Print Hi"), EO2_OP_SENTINEL }; From 117aa6f2a7e82d0aac2ce02e22bf7c4c2236730e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 17:38:50 +0100 Subject: [PATCH 127/169] eo2: add TODO-eo2 merry XMas eo2 !! you've been fully rebased, without the eo2test directory, luckily without any mistake !? --- TODO-eo2 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 TODO-eo2 diff --git a/TODO-eo2 b/TODO-eo2 new file mode 100644 index 0000000000..8c62c83d4e --- /dev/null +++ b/TODO-eo2 @@ -0,0 +1,32 @@ + +- eo_composite_attach + maybe check that the class of comp_obj is part of parent extensions + +- Eo2_Call_Stack + grow/shrink + stack push and pop functions + per thread stack + +- Remove the memset in do_end? Waste of cpu... + +- cleanup EO2_VERSION specific code in eo.c and eo_private.c + +- Move the Op_Descs to be set using a function inside the class_constructor + check if it works ASIS on windows + if it does, do nothing + +- Rediscuss the whole attribute cleanup thing. I'm not sure we want that as everything breaks if that isn't there. Embedded old gcc? + +- function name from pointer + dladdr backtrace ?? + +- Get rid of some of the EO2_VOID_FUNC_BODY? + +- Add line number to errors (like in eo1...) + +- A bit annoying that we don't get type checks on the callbacks, fix that? That's really dangerous! + +- Get all the optimisations cedric has been doing to Eo1? I think that's where the children thing got lost... + - Make sure all the improvements have been migrated... + +- Fix all the FIXME From 1834e3ff121629048328c6c878cf2ce097c99b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 23:07:22 +0100 Subject: [PATCH 128/169] eo2: remove dead code --- src/lib/eo/eo.c | 3 --- src/lib/eo/eo_private.h | 1 - 2 files changed, 4 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index f387c36db1..7d8d77dca1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1590,9 +1590,6 @@ eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent _eo_parent_internal_set(obj, parent_id); - /* Run the relevant do stuff. */ - if (klass->desc->version == EO2_VERSION) - eo2_do((Eo *)obj_id, eo2_constructor()); /* Run the relevant do stuff. */ { va_list p_list; diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 96d14aac78..b398ff080f 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -60,7 +60,6 @@ typedef uintptr_t Eo_Id; typedef struct _Eo_Class _Eo_Class; typedef struct _Eo_Object _Eo_Object; typedef struct _Eo_Base Eo_Base; -typedef struct _Eo_Internal _Eo; /* Retrieves the pointer to the object from the id */ static inline _Eo_Object *_eo_obj_pointer_get(const Eo_Id obj_id); From 5f311223ad2ae7037ce1f4606c4c63e3a89b0225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2013 23:08:30 +0100 Subject: [PATCH 129/169] eo2: rename Eo_Abstract_Class->Eo2_Abstract_Class --- src/lib/eo/eo2_class_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c index feb20dd68d..a0cab0a813 100644 --- a/src/lib/eo/eo2_class_class.c +++ b/src/lib/eo/eo2_class_class.c @@ -6,7 +6,7 @@ static const Eo_Class_Description class_desc = { EO2_VERSION, - "Eo_Abstract_Class", + "Eo2_Abstract_Class", EO_CLASS_TYPE_REGULAR_NO_INSTANT, EO2_CLASS_DESCRIPTION_NOOPS(), NULL, From ae536bdd84f497ffd9cdf7ec58fc11abe8445b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 15:24:15 +0100 Subject: [PATCH 130/169] eo2: call stack grows and shrinks --- src/lib/eo/eo.c | 70 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7d8d77dca1..bdc4f4f8e3 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -269,9 +269,9 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL; EAPI Eo2_Hook_Call eo2_hook_call_post = NULL; -// FIXME: per thread stack, grow/shrink +// FIXME: Thread Local Storage #define EO2_INVALID_DATA (void *) -1 -#define EO2_CALL_STACK_DEPTH 100 +#define EO2_CALL_STACK_DEPTH 30 typedef struct _Eo2_Stack_Frame { @@ -287,9 +287,11 @@ typedef struct _Eo2_Stack_Frame typedef struct _Eo2_Call_Stack { Eo2_Stack_Frame *stack; Eo2_Stack_Frame *frame_ptr; + Eo2_Stack_Frame *last_frame; + Eo2_Stack_Frame *shrink_frame; } Eo2_Call_Stack; -static Eo2_Call_Stack eo2_call_stack = { NULL, NULL }; +static Eo2_Call_Stack eo2_call_stack = { NULL, NULL, NULL, NULL }; static Eina_Bool _eo2_call_stack_init() @@ -299,7 +301,9 @@ _eo2_call_stack_init() return EINA_FALSE; // first frame is never used - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[0]; + eo2_call_stack.frame_ptr = eo2_call_stack.stack; + eo2_call_stack.last_frame = &eo2_call_stack.stack[EO2_CALL_STACK_DEPTH - 1]; + eo2_call_stack.shrink_frame = eo2_call_stack.stack; return EINA_TRUE; } @@ -311,6 +315,40 @@ _eo2_call_stack_free() free(eo2_call_stack.stack); } + +static inline void +_eo2_call_stack_resize(Eina_Bool grow) +{ + size_t sz, next_sz; + int frame_offset; + + frame_offset = eo2_call_stack.frame_ptr - eo2_call_stack.stack; + sz = eo2_call_stack.last_frame - eo2_call_stack.stack + 1; + if (grow) + next_sz = sz << 1; + else + next_sz = sz >> 1; + + DBG("resize from %lu to %lu", sz, next_sz); + eo2_call_stack.stack = realloc(eo2_call_stack.stack, next_sz * sizeof(Eo2_Stack_Frame)); + if(!eo2_call_stack.stack) + { + CRI("unable to resize call stack, abort."); + abort(); + } + + eo2_call_stack.frame_ptr = &eo2_call_stack.stack[frame_offset]; + eo2_call_stack.last_frame = &eo2_call_stack.stack[next_sz - 1]; + + if (grow) + frame_offset = (sz >> 1); + if (next_sz == EO2_CALL_STACK_DEPTH) + frame_offset = 0; + else + frame_offset = (next_sz >> 1); + eo2_call_stack.shrink_frame = &eo2_call_stack.stack[frame_offset]; +} + static inline Eina_Bool _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) @@ -346,18 +384,16 @@ _eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, { Eo2_Stack_Frame *fptr, *pfptr; + if (eo2_call_stack.frame_ptr == eo2_call_stack.last_frame) + _eo2_call_stack_resize(EINA_TRUE); + fptr = eo2_call_stack.frame_ptr; - if (((fptr - eo2_call_stack.stack) + 1) >= EO2_CALL_STACK_DEPTH) - { - ERR("eo2 call stack overflow !!!"); - return EINA_FALSE; - } pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); fptr++; if (!_eo2_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) - return EINA_FALSE; + return EINA_FALSE; if(_eo_is_a_class(eo_id)) { @@ -389,10 +425,16 @@ _eo2_do_end(const Eo **eo_id EINA_UNUSED) memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; - if (fptr == &eo2_call_stack.stack[0]) - ERR("eo2 call stack underflow !!!"); - else - eo2_call_stack.frame_ptr--; + if (fptr == eo2_call_stack.stack) + { + CRI("call stack underflow, abort."); + abort(); + } + + eo2_call_stack.frame_ptr--; + + if (fptr == eo2_call_stack.shrink_frame) + _eo2_call_stack_resize(EINA_FALSE); } EAPI Eina_Bool From d497459f931ba829d8917c432661477f80b30011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 15:24:44 +0100 Subject: [PATCH 131/169] eo2: add tests for call stack grow and shrink --- src/tests/eo/suite/eo_test_class_simple.c | 17 +++++++++++++++++ src/tests/eo/suite/eo_test_class_simple.h | 1 + src/tests/eo/suite/eo_test_general.c | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index 8690dfc540..d6fc49d233 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -45,6 +45,22 @@ _class_hi_print(Eo_Class *klass, void *data EINA_UNUSED) return EINA_TRUE; } +EO2_VOID_FUNC_BODYV(simple_recursive, EO2_FUNC_CALL(n), int n); + +static void +_recursive(Eo *obj, void *class_data EINA_UNUSED, int n) +{ + static int count = 0; + + if (count < n) + { + count++; + eo2_do(obj, simple_recursive(n)); + } + else + count = 0; +} + static void _dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Eo_Dbg_Info *root) { @@ -64,6 +80,7 @@ static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), EO2_OP_FUNC(simple_a_print, _a_print, "Print property a"), EO2_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"), + EO2_OP_FUNC(simple_recursive, _recursive, "Recursive function"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h index a82adef078..03bbebdf43 100644 --- a/src/tests/eo/suite/eo_test_class_simple.h +++ b/src/tests/eo/suite/eo_test_class_simple.h @@ -10,6 +10,7 @@ EAPI void simple_a_set(int a); EAPI int simple_a_get(void); EAPI Eina_Bool simple_a_print(void); EAPI Eina_Bool simple_class_hi_print(void); +EAPI void simple_recursive(int n); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index c703493926..eb37585df9 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -24,6 +24,20 @@ START_TEST(eo_simple) } END_TEST +START_TEST(eo_stack) +{ + eo_init(); + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + fail_if(!obj); + + eo2_do(obj, simple_recursive(123)); + + eo_unref(obj); + + eo_shutdown(); +} +END_TEST + static int _eo_signals_cb_curent = 0; static int _eo_signals_cb_flag = 0; @@ -835,6 +849,7 @@ END_TEST void eo_test_general(TCase *tc) { tcase_add_test(tc, eo_simple); + tcase_add_test(tc, eo_stack); tcase_add_test(tc, eo_signals); tcase_add_test(tc, eo_data_fetch); tcase_add_test(tc, eo_isa_tests); From adb5b8776d9b527ed02869807a0d593b674f80f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 17:53:54 +0100 Subject: [PATCH 132/169] eo2: no need to resolve eo_id when we reuse previous stack frame --- src/lib/eo/eo.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index bdc4f4f8e3..fdd0665927 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -353,15 +353,30 @@ static inline Eina_Bool _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { + Eina_Bool is_klass = _eo_is_a_class(eo_id); + /* If we are already in the same object context, we inherit info from it. */ if (pfptr) { memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); + if (!is_klass) + _eo_ref(fptr->o.obj); } else { fptr->eo_id = eo_id; fptr->obj_data = EO2_INVALID_DATA; + if (is_klass) + { + EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); + fptr->o.kls = _klass; + } + else + { + EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); + fptr->o.obj = _obj; + _eo_ref(_obj); + } } if (is_super) @@ -395,18 +410,6 @@ _eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, if (!_eo2_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) return EINA_FALSE; - if(_eo_is_a_class(eo_id)) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); - fptr->o.kls = _klass; - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); - fptr->o.obj = _obj; - _eo_ref(_obj); - } - eo2_call_stack.frame_ptr++; return EINA_TRUE; From 56ae6cf32e0e15080bf8c9478bf5ebb960ad18d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 20:12:00 +0100 Subject: [PATCH 133/169] eo2: remove memset() in _eo2_do_end() as all stack fields are set in _eo2_do_start() --- src/lib/eo/eo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index fdd0665927..3a5e99559d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -425,7 +425,6 @@ _eo2_do_end(const Eo **eo_id EINA_UNUSED) if(fptr->o.obj) _eo_unref(fptr->o.obj); - memset(fptr, 0, sizeof (Eo2_Stack_Frame)); fptr->obj_data = EO2_INVALID_DATA; if (fptr == eo2_call_stack.stack) From d3cd7cd63c633b544e4772d496252fc3694a139e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 20:23:22 +0100 Subject: [PATCH 134/169] eo2: do not try to unref classes in eo2_do_end() --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 3a5e99559d..d7dea5ed19 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -422,7 +422,7 @@ _eo2_do_end(const Eo **eo_id EINA_UNUSED) fptr = eo2_call_stack.frame_ptr; - if(fptr->o.obj) + if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj) _eo_unref(fptr->o.obj); fptr->obj_data = EO2_INVALID_DATA; From 63c271dc5e81b9f7d81fcfb4ef06e7cbd2791330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 20:31:40 +0100 Subject: [PATCH 135/169] eo2: fix indentation --- src/lib/eo/eo.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index d7dea5ed19..943f2e4130 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -351,7 +351,7 @@ _eo2_call_stack_resize(Eina_Bool grow) static inline Eina_Bool _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, - Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) + Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) { Eina_Bool is_klass = _eo_is_a_class(eo_id); @@ -383,7 +383,7 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, { EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); if (fptr->cur_klass == cur_klass) - fptr->obj_data = EO2_INVALID_DATA; + fptr->obj_data = EO2_INVALID_DATA; fptr->cur_klass = cur_klass; } else @@ -458,7 +458,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) func = _eo2_kls_itr_next(klass, fptr->cur_klass, op); if (!func) - goto end; + goto end; klass = func->src; } @@ -542,13 +542,13 @@ end: if (fptr->cur_klass) { ERR("func '%s' (%d) could not be resolved for class '%s' for super of '%s'", - func_name, op, main_klass->desc->name, - fptr->cur_klass->desc->name); + func_name, op, main_klass->desc->name, + fptr->cur_klass->desc->name); } else { ERR("func '%s' (%d) could not be resolved for class '%s'", - func_name, op, main_klass->desc->name); + func_name, op, main_klass->desc->name); } } @@ -606,15 +606,15 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class EAPI Eo_Op _eo2_api_op_id_get(const void *api_func) { - const Eo2_Op_Description *desc; - const _Eo_Class *klass; + const Eo2_Op_Description *desc; + const _Eo_Class *klass; Eina_Bool class_ref = _eo_is_a_class(eo2_call_stack.frame_ptr->eo_id); if (class_ref) - klass = eo2_call_stack.frame_ptr->o.kls; + klass = eo2_call_stack.frame_ptr->o.kls; else - klass = eo2_call_stack.frame_ptr->o.obj->klass; + klass = eo2_call_stack.frame_ptr->o.obj->klass; desc = _eo2_api_desc_get(api_func, klass, klass->extensions); @@ -624,7 +624,7 @@ _eo2_api_op_id_get(const void *api_func) return EO_NOOP; } - return desc->op; + return desc->op; } static int @@ -642,7 +642,7 @@ EAPI void _eo2_class_funcs_set(_Eo_Class *klass) { int op_id; - const Eo2_Op_Description *api_desc; + const Eo2_Op_Description *api_desc; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; From 914dde776ff22fc1c5ba3d2ed1859bb2b1e993e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 30 Dec 2013 22:16:55 +0100 Subject: [PATCH 136/169] eo2: fix uninitialized vars in tests because of conditional execution of eo2_do() fct calls these vars could end up not initialized. --- src/tests/eo/composite_objects/composite_objects_comp.c | 2 +- src/tests/eo/composite_objects/composite_objects_main.c | 4 ++-- src/tests/eo/constructors/constructors_main.c | 4 +++- src/tests/eo/constructors/constructors_mixin.c | 2 +- .../eo/function_overrides/function_overrides_inherit2.c | 6 +++--- src/tests/eo/function_overrides/function_overrides_main.c | 2 +- src/tests/eo/interface/interface_main.c | 2 +- src/tests/eo/interface/interface_simple.c | 4 ++-- src/tests/eo/mixin/mixin_inherit.c | 2 +- src/tests/eo/mixin/mixin_main.c | 2 +- src/tests/eo/mixin/mixin_mixin.c | 2 +- src/tests/eo/mixin/mixin_mixin2.c | 4 ++-- src/tests/eo/mixin/mixin_mixin3.c | 4 ++-- src/tests/eo/suite/eo_test_general.c | 8 ++++---- 14 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index 9d1ec64eab..32f22da68a 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -13,7 +13,7 @@ static int _a_get(Eo *obj, void *class_data EINA_UNUSED) { - int a; + int a = 0; eo2_do_super(obj, MY_CLASS, a = simple_a_get()); return a; diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index 9141ec5f33..b71c4cd585 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -36,7 +36,7 @@ main(int argc, char *argv[]) fail_if(!eo_isa(obj, COMP_CLASS)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); - int a; + int a = 0; eo2_do(obj, simple_a_set(1)); fail_if(!cb_called); @@ -44,7 +44,7 @@ main(int argc, char *argv[]) fail_if(a != 1); /* disable the callback forwarder, and fail if it's still called. */ - Eo *simple; + Eo *simple = NULL; eo2_do(obj, simple = eo2_base_data_get("simple-obj")); eo_ref(simple); eo2_do(simple, eo2_event_callback_forwarder_del(EV_A_CHANGED, obj)); diff --git a/src/tests/eo/constructors/constructors_main.c b/src/tests/eo/constructors/constructors_main.c index 94113207b8..e40ec915a4 100644 --- a/src/tests/eo/constructors/constructors_main.c +++ b/src/tests/eo/constructors/constructors_main.c @@ -30,8 +30,10 @@ main(int argc, char *argv[]) eo2_do(obj, simple_a_set(1), simple_b_set(2)); - int a, b; + int a = 0, b = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get(), mixin_add_and_print(5)); + fail_if(a != 1); + fail_if(b != 2); eo_unref(obj); diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index 62ebf7bb09..69a957aee2 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -11,7 +11,7 @@ static void _add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, int x) { - int a, b; + int a = 0, b = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %d\n", __func__, a + b + x); } diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index cf8b1cb0db..6a2369a6fc 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -18,7 +18,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) eo2_do(obj, simple_a_print()); eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); - Eina_Bool called; + Eina_Bool called = EINA_FALSE; eo2_do_super(obj, MY_CLASS, called = simple_a_print()); fail_if(!called); } @@ -26,7 +26,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) static Eina_Bool _print(Eo *obj, void *class_data EINA_UNUSED) { - Eina_Bool called; + Eina_Bool called = EINA_FALSE; printf("Hey\n"); eo2_do_super(obj, MY_CLASS, called = inherit2_print()); fail_if(called); @@ -45,7 +45,7 @@ _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED) static Eina_Bool _class_print(Eo_Class *klass, void *data EINA_UNUSED) { - Eina_Bool called; + Eina_Bool called = EINA_FALSE; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); eo2_do_super(klass, MY_CLASS, called = simple_class_print()); fail_if(!called); diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 11f4c8f999..17aab2910d 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -17,7 +17,7 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eina_Bool called; + Eina_Bool called = EINA_FALSE; Eo *obj = eo2_add(INHERIT2_CLASS, NULL); eo2_do(obj, simple_a_set(1)); diff --git a/src/tests/eo/interface/interface_main.c b/src/tests/eo/interface/interface_main.c index b532f269e4..6fe9de131f 100644 --- a/src/tests/eo/interface/interface_main.c +++ b/src/tests/eo/interface/interface_main.c @@ -20,7 +20,7 @@ main(int argc, char *argv[]) eo2_do(obj, simple_a_set(1), simple_b_set(2)); - int a, b, sum = 0; + int a = 0, b = 0, sum = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = interface_ab_sum_get()); fail_if(sum != a + b); diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index 8a0aa1f06b..32cd9cb31b 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -39,7 +39,7 @@ _GET_SET_FUNC(b) static int _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { - int a, b; + int a = 0, b = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b; @@ -48,7 +48,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) static int _ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED) { - int a, b; + int a = 0, b = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b + 1; diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c index 558c54cf04..4578b54039 100644 --- a/src/tests/eo/mixin/mixin_inherit.c +++ b/src/tests/eo/mixin/mixin_inherit.c @@ -12,7 +12,7 @@ static int _a_get(Eo *obj, void *class_data EINA_UNUSED) { - int ret; + int ret = 0; eo2_do_super(obj, MY_CLASS, ret = simple_a_get()); printf("%s %d\n", __func__, ret); diff --git a/src/tests/eo/mixin/mixin_main.c b/src/tests/eo/mixin/mixin_main.c index f6bcc15b33..a0221b3bf0 100644 --- a/src/tests/eo/mixin/mixin_main.c +++ b/src/tests/eo/mixin/mixin_main.c @@ -22,7 +22,7 @@ main(int argc, char *argv[]) eo2_do(obj, simple_a_set(1), simple_b_set(2)); - int a, b, sum = 0; + int a = 0, b = 0, sum = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = mixin_ab_sum_get()); fail_if(sum != a + b + 2); /* 2 for the two mixins... */ diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index 9b6ac802a1..0392e9099c 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -11,7 +11,7 @@ static int _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { - int a, b; + int a = 0, b = 0; eo2_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b; diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c index 80dfa8275b..621715ea86 100644 --- a/src/tests/eo/mixin/mixin_mixin2.c +++ b/src/tests/eo/mixin/mixin_mixin2.c @@ -16,7 +16,7 @@ _ab_sum_get(Eo *obj, void *class_data) { /* This cast is a hack just for the tests... */ Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data; - int sum; + int sum = 0; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); @@ -24,7 +24,7 @@ _ab_sum_get(Eo *obj, void *class_data) pd->count += 2; { - int _a, _b; + int _a = 0, _b = 0; eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); fail_if(sum != _a + _b + 1); } diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c index 441fd29e72..1a90847e1f 100644 --- a/src/tests/eo/mixin/mixin_mixin3.c +++ b/src/tests/eo/mixin/mixin_mixin3.c @@ -16,7 +16,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { /* This cast is just a hack for the test. */ Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data; - int sum; + int sum = 0; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); @@ -24,7 +24,7 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) pd->count += 3; { - int _a, _b; + int _a = 0, _b = 0; eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); fail_if(sum != _a + _b + 2); } diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index eb37585df9..e0a95c6cc8 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -409,7 +409,7 @@ START_TEST(eo_refs) obj = eo2_add(SIMPLE_CLASS, NULL); obj2 = eo2_add(SIMPLE_CLASS, obj); - Eo *wref; + Eo *wref = NULL; eo2_do(obj2, eo2_wref_add(&wref)); fail_if(!wref); @@ -444,7 +444,7 @@ START_TEST(eo_weak_reference) Eo *obj = eo2_add(SIMPLE_CLASS, NULL); Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); - Eo *wref, *wref2, *wref3; + Eo *wref = NULL, *wref2 = NULL, *wref3 = NULL; eo2_do(obj, eo2_wref_add(&wref)); fail_if(!wref); @@ -517,7 +517,7 @@ START_TEST(eo_generic_data) { eo_init(); Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - void *data; + void *data = NULL; eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL)); eo2_do(obj, data = eo2_base_data_get("test1")); @@ -615,7 +615,7 @@ START_TEST(eo_magic_checks) fail_if(eo_class_get(obj) != SIMPLE_CLASS); fail_if(eo_class_get(SIMPLE_CLASS) != EO2_CLASS_CLASS); eo_class_funcs_set((Eo_Class *) buf, NULL); - eo2_do((Eo_Class *) buf, NULL); + eo2_do((Eo_Class *) buf,(void) NULL); eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL); From e41f2804b42e8a4cab965ba5f5670941eaa37904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Jan 2014 15:54:18 +0100 Subject: [PATCH 137/169] eo2: improve err msg in _eo2_api_op_id_get() and _eo2_call_resolve() --- src/lib/eo/Eo.h | 8 ++++---- src/lib/eo/eo.c | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index f297c9297f..ffd2d7ded5 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -643,8 +643,8 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; Eo2_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ if (op == EO_NOOP) \ - op = _eo2_api_op_id_get((void*)Name); \ - if (!_eo2_call_resolve(#Name, op, &call)) return DefRet; \ + op = _eo2_api_op_id_get((void*) Name, __FILE__, __LINE__); \ + if (!_eo2_call_resolve(#Name, op, &call, __FILE__, __LINE__)) return DefRet; \ _Eo2_##Name##_func _func_ = (_Eo2_##Name##_func) call.func; \ // to define an EAPI function @@ -706,10 +706,10 @@ EAPI extern Eo2_Hook_Call eo2_hook_call_post; #define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op _eo2_api_op_id_get(const void *api_func); +EAPI Eo_Op _eo2_api_op_id_get(const void *api_func, const char *file, int line); // gets the real function pointer and the object data -EAPI Eina_Bool _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call); +EAPI Eina_Bool _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, const char *file, int line); // start of eo2_do barrier, gets the object pointer and ref it, put it on the stask EAPI Eina_Bool _eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 943f2e4130..70d91185b7 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -440,7 +440,7 @@ _eo2_do_end(const Eo **eo_id EINA_UNUSED) } EAPI Eina_Bool -_eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) +_eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, const char *file, int line) { Eo2_Stack_Frame *fptr; const _Eo_Class *klass; @@ -469,7 +469,8 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) if (EINA_UNLIKELY(func == NULL)) { - ERR("you called func '%s' (%d) which is unknown in class '%s'", func_name, op, klass->desc->name); + ERR("in %s:%d: you called func '%s' (%d) which is unknown in class '%s'", + file, line, func_name, op, klass->desc->name); return EINA_FALSE; } @@ -502,7 +503,8 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call) if (func->src != NULL) { - ERR("you called a pure virtual func '%s' (%d)", func_name, op); + ERR("in %s:%d: you called a pure virtual func '%s' (%d)", + file, line, func_name, op); return EINA_FALSE; } @@ -541,14 +543,14 @@ end: /* If it's a do_super call. */ if (fptr->cur_klass) { - ERR("func '%s' (%d) could not be resolved for class '%s' for super of '%s'", - func_name, op, main_klass->desc->name, + ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'", + file, line, func_name, op, main_klass->desc->name, fptr->cur_klass->desc->name); } else { - ERR("func '%s' (%d) could not be resolved for class '%s'", - func_name, op, main_klass->desc->name); + ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s'", + file, line, func_name, op, main_klass->desc->name); } } @@ -604,7 +606,7 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class } EAPI Eo_Op -_eo2_api_op_id_get(const void *api_func) +_eo2_api_op_id_get(const void *api_func, const char *file, int line) { const Eo2_Op_Description *desc; const _Eo_Class *klass; @@ -620,7 +622,8 @@ _eo2_api_op_id_get(const void *api_func) if (desc == NULL) { - ERR("unable to resolve %s api func %p", (class_ref ? "class" : "regular"), api_func); + ERR("in %s:%d: unable to resolve %s api func %p", + file, line, (class_ref ? "class" : "regular"), api_func); return EO_NOOP; } From 19245b48f8d7d643f8da089768302fa433525be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Jan 2014 16:00:24 +0100 Subject: [PATCH 138/169] eo2: add _eo2_op_id_desc_get() --- src/lib/eo/eo.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 70d91185b7..d77b3a1830 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -203,6 +203,32 @@ _eo_op_id_desc_get(Eo_Op op) return NULL; } +static const Eo2_Op_Description * +_eo2_op_id_desc_get(Eo_Op op) +{ + unsigned int i; + const _Eo_Class *klass; + const Eo2_Op_Description *op_descs; + + if (op == EO_NOOP) + return NULL; + + klass = _eo_op_class_get(op); + DBG("klass %p %s", klass, klass->desc->name); + + if (klass) + { + op_descs = klass->desc->ops.descs2; + for (i = 0; i < klass->desc->ops.count; i++) + { + if (op_descs[i].op == op) + return &op_descs[i]; + } + } + + return NULL; +} + static const char * _eo_op_id_name_get(Eo_Op op) { From 82af591b83d3ef19fcf9668ce1143d658fe4e9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Jan 2014 16:01:27 +0100 Subject: [PATCH 139/169] eo2: improve _eo_op_id_name_get() to support eo1/2 --- src/lib/eo/eo.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index d77b3a1830..cc64203e01 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -29,6 +29,7 @@ static inline void *_eo_data_xref_internal(const char *file, int line, _Eo_Objec static inline void _eo_data_xunref_internal(_Eo_Object *obj, void *data, const _Eo_Object *ref_obj); static const _Eo_Class *_eo_op_class_get(Eo_Op op); static const Eo_Op_Description *_eo_op_id_desc_get(Eo_Op op); +static const char * _eo_op_id_name_get(Eo_Op op, int version); /* Start of Dich */ @@ -230,10 +231,18 @@ _eo2_op_id_desc_get(Eo_Op op) } static const char * -_eo_op_id_name_get(Eo_Op op) +_eo_op_id_name_get(Eo_Op op, int version) { - const Eo_Op_Description *desc = _eo_op_id_desc_get(op); - return (desc) ? desc->name : NULL; + if (version == EO2_VERSION) + { + const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); + return (desc) ? desc->doc : NULL; + } + else + { + const Eo_Op_Description *desc = _eo_op_id_desc_get(op); + return (desc) ? desc->name : NULL; + } } static inline const op_type_funcs * @@ -802,7 +811,7 @@ _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) const _Eo_Class *op_klass = _eo_op_class_get(op); \ const char *_dom_name = (op_klass) ? op_klass->desc->name : NULL; \ ERR("in %s:%d: Can't execute function %s:%s (op 0x%x) for class '%s'. Aborting.", \ - file, line, _dom_name, _eo_op_id_name_get(op), op, \ + file, line, _dom_name, _eo_op_id_name_get(op, op_klass->desc->version), op, \ (klass) ? klass->desc->name : NULL); \ } \ while (0) From c506ce2e1fe7c10f9ca08203b1e146f9501269c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Jan 2014 16:02:00 +0100 Subject: [PATCH 140/169] eo2: fix err msg in _dich_func_set() --- src/lib/eo/eo.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index cc64203e01..35225d13c5 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -100,19 +100,21 @@ _dich_func_get(const _Eo_Class *klass, Eo_Op op) static inline void _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) { + op_type_funcs *fsrc; size_t idx1 = DICH_CHAIN1(op); Dich_Chain1 *chain1 = &klass->chain[idx1]; _dich_chain_alloc(chain1); - if (chain1->funcs[DICH_CHAIN_LAST(op)].src == klass) + fsrc = &chain1->funcs[DICH_CHAIN_LAST(op)]; + if (fsrc->src == klass) { const _Eo_Class *op_kls = _eo_op_class_get(op); - const Eo_Op_Description *op_desc = _eo_op_id_desc_get(op); - ERR("Already set function for op 0x%x (%s:%s). Overriding with func %p", - op, op_kls->desc->name, op_desc->name, func); + const char *op_name = _eo_op_id_name_get(op, op_kls->desc->version); + ERR("Already set function for op %d (%s:'%s'). Overriding %p with %p", + op, op_kls->desc->name, op_name, fsrc->func, func); } - chain1->funcs[DICH_CHAIN_LAST(op)].func = func; - chain1->funcs[DICH_CHAIN_LAST(op)].src = klass; + fsrc->func = func; + fsrc->src = klass; } static inline void From a9c325c124710d526e8d1f523fde3daae7c1efca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 11:10:48 +0100 Subject: [PATCH 141/169] eo2: normalize ERR msgs --- src/lib/eo/eo.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 35225d13c5..7eb310a2f1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -109,7 +109,7 @@ _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) { const _Eo_Class *op_kls = _eo_op_class_get(op); const char *op_name = _eo_op_id_name_get(op, op_kls->desc->version); - ERR("Already set function for op %d (%s:'%s'). Overriding %p with %p", + ERR("Already set function for op %d (%s:'%s'). Overriding %p with %p.", op, op_kls->desc->name, op_name, fsrc->func, func); } @@ -506,7 +506,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, if (EINA_UNLIKELY(func == NULL)) { - ERR("in %s:%d: you called func '%s' (%d) which is unknown in class '%s'", + ERR("in %s:%d: you called func '%s' (%d) which is unknown in class '%s'.", file, line, func_name, op, klass->desc->name); return EINA_FALSE; } @@ -540,7 +540,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, if (func->src != NULL) { - ERR("in %s:%d: you called a pure virtual func '%s' (%d)", + ERR("in %s:%d: you called a pure virtual func '%s' (%d).", file, line, func_name, op); return EINA_FALSE; } @@ -580,13 +580,13 @@ end: /* If it's a do_super call. */ if (fptr->cur_klass) { - ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'", + ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'.", file, line, func_name, op, main_klass->desc->name, fptr->cur_klass->desc->name); } else { - ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s'", + ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s'.", file, line, func_name, op, main_klass->desc->name); } } @@ -659,7 +659,7 @@ _eo2_api_op_id_get(const void *api_func, const char *file, int line) if (desc == NULL) { - ERR("in %s:%d: unable to resolve %s api func %p", + ERR("in %s:%d: unable to resolve %s api func %p.", file, line, (class_ref ? "class" : "regular"), api_func); return EO_NOOP; } @@ -1799,7 +1799,7 @@ eo_error_set_internal(const Eo *obj_id, const char *file, int line) { EO_OBJ_POINTER_RETURN(obj_id, obj); - ERR("Error with obj '%p' at %s:%d", obj, file, line); + ERR("Error with obj '%p' at %s:%d.", obj, file, line); obj->do_error = EINA_TRUE; } @@ -1939,7 +1939,7 @@ eo_data_scope_get(const Eo *obj_id, const Eo_Class *klass_id) #ifdef EO_DEBUG if (!ret && (klass->desc->data_size == 0)) { - ERR("Tried getting data of class '%s', but it has none..", klass->desc->name); + ERR("Tried getting data of class '%s', but it has none.", klass->desc->name); } #endif @@ -1972,7 +1972,7 @@ eo_data_xref_internal(const char *file, int line, const Eo *obj_id, const Eo_Cla #ifdef EO_DEBUG if (klass && !ret && (klass->desc->data_size == 0)) { - ERR("Tried getting data of class '%s', but it has none..", klass->desc->name); + ERR("Tried getting data of class '%s', but it has none.", klass->desc->name); } #endif @@ -2005,7 +2005,7 @@ eo_init(void) _eo_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE); if (_eo_log_dom < 0) { - EINA_LOG_ERR("Could not register log domain: %s", log_dom); + EINA_LOG_ERR("Could not register log domain: %s.", log_dom); return EINA_FALSE; } From 9d2eeb7a8b58e8862c265911be23a2a8e2c6d7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 11:13:34 +0100 Subject: [PATCH 142/169] eo2: improve _eo2_class_funcs_set() errors support as op descs are sorted, we can't output fct indexes in error msgs, but as they are sorted using api_fct as key, we can detect multiple usage of the same api_fct which leads to an unpredictable call to whatever is returned by _eo2_api_op_id_get()->_eo2_api_desc_get(). it is still possible to instanciate an object of a not well defined class. --- src/lib/eo/eo.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7eb310a2f1..2e053bd1e2 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -682,25 +682,37 @@ EAPI void _eo2_class_funcs_set(_Eo_Class *klass) { int op_id; + const void *last_api_func; const Eo2_Op_Description *api_desc; Eo2_Op_Description *op_desc; Eo2_Op_Description *op_descs; + op_id = klass->base_id; op_descs = klass->desc->ops.descs2; qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); - op_id = klass->base_id; - DBG("Set functions for class '%s' %p", klass->desc->name, klass); + DBG("Set functions for class '%s':%p", klass->desc->name, klass); + if (!op_descs) return; + + last_api_func = NULL; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if(op_desc->api_func == NULL) - ERR("Setting implementation for NULL API. Class '%s', Func index: %lu", - klass->desc->name, (unsigned long) (op_desc - op_descs)); + { + ERR("Ignore %d NULL->%p '%s'. Can't set implementation for NULL API.", + op_desc->op, op_desc->func, op_desc->doc); + continue; + } if (op_desc->op == EO_NOOP) { + if (op_desc->api_func == last_api_func) + { + ERR("API already defined %d %p->%p '%s'. Expect undefined behaviour.", + op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); + } op_desc->op = op_id; op_id++; } @@ -709,20 +721,20 @@ _eo2_class_funcs_set(_Eo_Class *klass) api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent, klass->extensions); if (api_desc == NULL) - ERR("Can't find api func %p description in class hierarchy. Class '%s', Func index: %lu", - op_desc->api_func, klass->desc->name, (unsigned long) (op_desc - op_descs)); + { + ERR("Ignore override %p->%p. Can't find api func description in class hierarchy.", + op_desc->api_func, op_desc->func); + continue; + } op_desc->op = api_desc->op; op_desc->doc = api_desc->doc; - - if (op_desc->op == EO_NOOP) - ERR("API func %p, not found in direct parent '%s'. Class '%s', Func index: %lu", - op_desc->api_func, klass->parent->desc->name, - klass->desc->name, (unsigned long) (op_desc - op_descs)); } - DBG(" %4d %p %p %s", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); + DBG(" %4d %p->%p '%s'", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); + _dich_func_set(klass, op_desc->op, op_desc->func); + last_api_func = op_desc->api_func; } } From 5dc95bb50ca8bb387a1a9516f288dd56c61147d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 11:30:44 +0100 Subject: [PATCH 143/169] eo2: add test cases for class construction errors it covers: NULL API func, overriding non-existing fct, API redefined, dich func override. --- src/tests/eo/suite/eo_test_class_errors.c | 141 ++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index 9f08b5e1e7..abc839eacd 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -273,9 +273,150 @@ START_TEST(eo_bad_interface) } END_TEST +static void _null_fct(Eo *eo_obj EINA_UNUSED, void *d EINA_UNUSED) { } +void null_fct (void) {} + +START_TEST(eo_null_api) +{ + eo_init(); + eina_log_print_cb_set(_eo_test_print_cb, &ctx); + + const Eo_Class *klass; + + static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(NULL, _null_fct, "NULL API function"), + EO2_OP_SENTINEL + }; + static Eo_Class_Description class_desc = { + EO2_VERSION, + "Simple", + EO_CLASS_TYPE_REGULAR, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + 0, + NULL, + NULL + }; + + TEST_EO_ERROR("_eo2_class_funcs_set", "Ignore %d NULL->%p '%s'. Can't set implementation for NULL API."); + klass = eo_class_new(&class_desc, NULL, NULL); + fail_if(!klass); + fail_unless(ctx.did); + + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + + eo_shutdown(); +} +END_TEST + +START_TEST(eo_wrong_override) +{ + eo_init(); + eina_log_print_cb_set(_eo_test_print_cb, &ctx); + + const Eo_Class *klass; + + static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(null_fct, _null_fct), + EO2_OP_SENTINEL + }; + static Eo_Class_Description class_desc = { + EO2_VERSION, + "Simple", + EO_CLASS_TYPE_REGULAR, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + 0, + NULL, + NULL + }; + + TEST_EO_ERROR("_eo2_class_funcs_set", "Ignore override %p->%p. Can't find api func description in class hierarchy."); + klass = eo_class_new(&class_desc, NULL, NULL); + fail_if(!klass); + fail_unless(ctx.did); + + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + + eo_shutdown(); +} +END_TEST + +START_TEST(eo_api_redefined) +{ + eo_init(); + eina_log_print_cb_set(_eo_test_print_cb, &ctx); + + const Eo_Class *klass; + + static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(null_fct, _null_fct, "API function"), + EO2_OP_FUNC(null_fct, NULL, "Redefining API function"), + EO2_OP_SENTINEL + }; + static Eo_Class_Description class_desc = { + EO2_VERSION, + "Simple", + EO_CLASS_TYPE_REGULAR, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + 0, + NULL, + NULL + }; + + TEST_EO_ERROR("_eo2_class_funcs_set", "API already defined %d %p->%p '%s'. Expect undefined behaviour."); + klass = eo_class_new(&class_desc, NULL, NULL); + fail_if(!klass); + fail_unless(ctx.did); + + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + + eo_shutdown(); +} +END_TEST + +START_TEST(eo_dich_func_override) +{ + eo_init(); + eina_log_print_cb_set(_eo_test_print_cb, &ctx); + + const Eo_Class *klass; + + static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC_OVERRIDE(simple_a_set, _null_fct), + EO2_OP_FUNC_OVERRIDE(simple_a_set, NULL), + EO2_OP_SENTINEL + }; + static Eo_Class_Description class_desc = { + EO2_VERSION, + "Simple", + EO_CLASS_TYPE_REGULAR, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + 0, + NULL, + NULL + }; + + TEST_EO_ERROR("_dich_func_set", "Already set function for op %d (%s:'%s'). Overriding %p with %p."); + klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); + fail_if(!klass); + fail_unless(ctx.did); + + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + + eo_shutdown(); +} +END_TEST + void eo_test_class_errors(TCase *tc) { tcase_add_test(tc, eo_inherit_errors); tcase_add_test(tc, eo_inconsistent_mro); tcase_add_test(tc, eo_bad_interface); + tcase_add_test(tc, eo_null_api); + tcase_add_test(tc, eo_wrong_override); + tcase_add_test(tc, eo_api_redefined); + tcase_add_test(tc, eo_dich_func_override); } From a0d761cfa9bd182449b2c4cf483c07e71821f1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 12:11:20 +0100 Subject: [PATCH 144/169] eo2: _eo2_call_resolve() fails if op is EO_NOOP --- src/lib/eo/eo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 2e053bd1e2..4d264782e1 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -484,6 +484,8 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, const op_type_funcs *func; Eina_Bool is_obj; + if (op == EO_NOOP) return EINA_FALSE; + fptr = eo2_call_stack.frame_ptr; is_obj = !_eo_is_a_class(fptr->eo_id); @@ -586,6 +588,7 @@ end: } else { + /* we should not be able to take this branch */ ERR("in %s:%d: func '%s' (%d) could not be resolved for class '%s'.", file, line, func_name, op, main_klass->desc->name); } From d23b9ffd236e68a08d9d7c2a119f0a3da2a4b116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 14:10:39 +0100 Subject: [PATCH 145/169] eo2: tests: extract mgs checks into eo_error_msgs.c|h --- src/Makefile_Eo.am | 2 + src/tests/eo/suite/eo_error_msgs.c | 53 +++++++++++++++ src/tests/eo/suite/eo_error_msgs.h | 30 ++++++++ src/tests/eo/suite/eo_test_class_errors.c | 83 +++-------------------- 4 files changed, 93 insertions(+), 75 deletions(-) create mode 100644 src/tests/eo/suite/eo_error_msgs.c create mode 100644 src/tests/eo/suite/eo_error_msgs.h diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 17d44b925b..0d210be5e6 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -93,6 +93,8 @@ tests/eo/suite/eo_test_class_simple.c \ tests/eo/suite/eo_test_class_simple.h \ tests/eo/suite/eo_suite.c \ tests/eo/suite/eo_suite.h \ +tests/eo/suite/eo_error_msgs.h \ +tests/eo/suite/eo_error_msgs.c \ tests/eo/suite/eo_test_class_errors.c \ tests/eo/suite/eo_test_general.c \ tests/eo/suite/eo_test_value.c \ diff --git a/src/tests/eo/suite/eo_error_msgs.c b/src/tests/eo/suite/eo_error_msgs.c new file mode 100644 index 0000000000..ae5b5d0ddc --- /dev/null +++ b/src/tests/eo/suite/eo_error_msgs.c @@ -0,0 +1,53 @@ +#include "eo_error_msgs.h" + +void +eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED) +{ + struct log_ctx *myctx = data; + + if (level > _EINA_LOG_MAX) + return; + + ck_assert_int_eq(level, myctx->expected_level); + if (myctx->msg) + ck_assert_str_eq(myctx->msg, fmt); + ck_assert_str_eq(myctx->fnc, fnc); + myctx->did = EINA_TRUE; + +#ifdef SHOW_LOG + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +#else + (void)d; + (void)file; + (void)line; +#endif +} + +void +eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED) +{ + struct log_ctx *myctx = data; + va_list cp_args; + const char *str; + + if (level > _EINA_LOG_MAX) + return; + + va_copy(cp_args, args); + str = va_arg(cp_args, const char *); + va_end(cp_args); + + ck_assert_int_eq(level, myctx->expected_level); + ck_assert_str_eq(fmt, "%s"); + ck_assert_str_eq(myctx->msg, str); + ck_assert_str_eq(myctx->fnc, fnc); + myctx->did = EINA_TRUE; + +#ifdef SHOW_LOG + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +#else + (void)d; + (void)file; + (void)line; +#endif +} diff --git a/src/tests/eo/suite/eo_error_msgs.h b/src/tests/eo/suite/eo_error_msgs.h new file mode 100644 index 0000000000..c3690fd345 --- /dev/null +++ b/src/tests/eo/suite/eo_error_msgs.h @@ -0,0 +1,30 @@ +#ifndef _EO_ERROR_MSGS_H +#define _EO_ERROR_MSGS_H + +#include "Eo.h" +#include "eo_suite.h" + +/* The Max level to consider when working with the print cb. */ +#define _EINA_LOG_MAX 2 +/* #define SHOW_LOG 1 */ + +struct log_ctx { + const char *msg; + const char *fnc; + Eina_Bool did; + int expected_level; +}; + +void +eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED); + +void +eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED); + +#define TEST_EO_ERROR(fn, _msg) \ + ctx.msg = _msg; \ + ctx.fnc = fn; \ + ctx.did = EINA_FALSE; \ + ctx.expected_level = EINA_LOG_LEVEL_ERR + +#endif /* _EO_ERROR_MSGS_H */ diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index abc839eacd..24a07f47e9 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -6,82 +6,15 @@ #include "Eo.h" #include "eo_suite.h" +#include "eo_error_msgs.h" #include "eo_test_class_simple.h" -/* The Max level to consider when working with the print cb. */ -#define _EINA_LOG_MAX 2 - -struct log_ctx { - const char *msg; - const char *fnc; - Eina_Bool did; - int expected_level; -}; - static struct log_ctx ctx; -static void -_eo_test_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED) -{ - struct log_ctx *myctx = data; - - if (level > _EINA_LOG_MAX) - return; - - ck_assert_int_eq(level, myctx->expected_level); - if (myctx->msg) - ck_assert_str_eq(myctx->msg, fmt); - ck_assert_str_eq(myctx->fnc, fnc); - myctx->did = EINA_TRUE; - -#ifdef SHOW_LOG - eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); -#else - (void)d; - (void)file; - (void)line; -#endif -} - -static void -_eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args EINA_UNUSED) -{ - struct log_ctx *myctx = data; - va_list cp_args; - const char *str; - - if (level > _EINA_LOG_MAX) - return; - - va_copy(cp_args, args); - str = va_arg(cp_args, const char *); - va_end(cp_args); - - ck_assert_int_eq(level, myctx->expected_level); - ck_assert_str_eq(fmt, "%s"); - ck_assert_str_eq(myctx->msg, str); - ck_assert_str_eq(myctx->fnc, fnc); - myctx->did = EINA_TRUE; - -#ifdef SHOW_LOG - eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); -#else - (void)d; - (void)file; - (void)line; -#endif -} - -#define TEST_EO_ERROR(fn, _msg) \ - ctx.msg = _msg; \ - ctx.fnc = fn; \ - ctx.did = EINA_FALSE; \ - ctx.expected_level = EINA_LOG_LEVEL_ERR - START_TEST(eo_inherit_errors) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; const Eo_Class *klass_mixin; @@ -148,7 +81,7 @@ END_TEST START_TEST(eo_inconsistent_mro) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; const Eo_Class *klass_mixin; @@ -230,7 +163,7 @@ static void _stub_class_constructor(Eo_Class *klass EINA_UNUSED) {} START_TEST(eo_bad_interface) { eo_init(); - eina_log_print_cb_set(_eo_test_safety_print_cb, &ctx); + eina_log_print_cb_set(eo_test_safety_print_cb, &ctx); const Eo_Class *klass; @@ -279,7 +212,7 @@ void null_fct (void) {} START_TEST(eo_null_api) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; @@ -312,7 +245,7 @@ END_TEST START_TEST(eo_wrong_override) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; @@ -345,7 +278,7 @@ END_TEST START_TEST(eo_api_redefined) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; @@ -379,7 +312,7 @@ END_TEST START_TEST(eo_dich_func_override) { eo_init(); - eina_log_print_cb_set(_eo_test_print_cb, &ctx); + eina_log_print_cb_set(eo_test_print_cb, &ctx); const Eo_Class *klass; From 2fb5a5461097808791b17da04aa8ca74c0e2bc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jan 2014 14:48:36 +0100 Subject: [PATCH 146/169] eo2: add tests for method call error msgs --- src/Makefile_Eo.am | 1 + src/tests/eo/suite/eo_suite.c | 1 + src/tests/eo/suite/eo_suite.h | 1 + src/tests/eo/suite/eo_test_call_errors.c | 73 +++++++++++++++++++++++ src/tests/eo/suite/eo_test_class_simple.c | 3 + src/tests/eo/suite/eo_test_class_simple.h | 2 + 6 files changed, 81 insertions(+) create mode 100644 src/tests/eo/suite/eo_test_call_errors.c diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 0d210be5e6..9b1cb117c2 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -96,6 +96,7 @@ tests/eo/suite/eo_suite.h \ tests/eo/suite/eo_error_msgs.h \ tests/eo/suite/eo_error_msgs.c \ tests/eo/suite/eo_test_class_errors.c \ +tests/eo/suite/eo_test_call_errors.c \ tests/eo/suite/eo_test_general.c \ tests/eo/suite/eo_test_value.c \ tests/eo/suite/eo_test_init.c diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c index 9d040d32cc..db303cfebb 100644 --- a/src/tests/eo/suite/eo_suite.c +++ b/src/tests/eo/suite/eo_suite.c @@ -20,6 +20,7 @@ static const Eo_Test_Case etc[] = { { "Eo init", eo_test_init }, { "Eo general", eo_test_general }, { "Eo class errors", eo_test_class_errors }, + { "Eo call errors", eo_test_call_errors }, { "Eo eina value", eo_test_value }, { NULL, NULL } }; diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h index c26db968be..4a3c3b0f21 100644 --- a/src/tests/eo/suite/eo_suite.h +++ b/src/tests/eo/suite/eo_suite.h @@ -6,6 +6,7 @@ void eo_test_init(TCase *tc); void eo_test_general(TCase *tc); void eo_test_class_errors(TCase *tc); +void eo_test_call_errors(TCase *tc); void eo_test_value(TCase *tc); #endif /* _EO_SUITE_H */ diff --git a/src/tests/eo/suite/eo_test_call_errors.c b/src/tests/eo/suite/eo_test_call_errors.c new file mode 100644 index 0000000000..76a60ffc53 --- /dev/null +++ b/src/tests/eo/suite/eo_test_call_errors.c @@ -0,0 +1,73 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include "Eo.h" +#include "eo_suite.h" +#include "eo_error_msgs.h" +#include "eo_test_class_simple.h" + +static struct log_ctx ctx; + +START_TEST(eo_pure_virtual_fct_call) +{ + eo_init(); + eina_log_print_cb_set(eo_test_print_cb, &ctx); + + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + fail_if(!obj); + + TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: you called a pure virtual func '%s' (%d)."); + eo2_do(obj, simple_pure_virtual()); + fail_unless(ctx.did); + + eo_unref(obj); + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + eo_shutdown(); +} +END_TEST + +START_TEST(eo_api_not_implemented_call) +{ + eo_init(); + eina_log_print_cb_set(eo_test_print_cb, &ctx); + + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + fail_if(!obj); + + TEST_EO_ERROR("_eo2_api_op_id_get", "in %s:%d: unable to resolve %s api func %p."); + eo2_do(obj, simple_no_implementation()); + fail_unless(ctx.did); + + eo_unref(obj); + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + eo_shutdown(); +} +END_TEST + +START_TEST(eo_op_not_found_in_super) +{ + eo_init(); + eina_log_print_cb_set(eo_test_print_cb, &ctx); + + Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + fail_if(!obj); + + TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'."); + eo2_do_super(obj, SIMPLE_CLASS, simple_a_set(10)); + fail_unless(ctx.did); + + eo_unref(obj); + eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); + eo_shutdown(); +} +END_TEST + +void eo_test_call_errors(TCase *tc) +{ + tcase_add_test(tc, eo_pure_virtual_fct_call); + tcase_add_test(tc, eo_api_not_implemented_call); + tcase_add_test(tc, eo_op_not_found_in_super); +} diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index d6fc49d233..89cd14e073 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -73,6 +73,8 @@ EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); EO2_FUNC_BODY(simple_a_get, int, 0); EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE); +EO2_VOID_FUNC_BODY(simple_pure_virtual); +EO2_VOID_FUNC_BODY(simple_no_implementation); static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC_OVERRIDE(eo2_dbg_info_get, _dbg_info_get), @@ -81,6 +83,7 @@ static Eo2_Op_Description op_descs[] = { EO2_OP_FUNC(simple_a_print, _a_print, "Print property a"), EO2_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"), EO2_OP_FUNC(simple_recursive, _recursive, "Recursive function"), + EO2_OP_FUNC(simple_pure_virtual, NULL, "Pure Virtual function"), EO2_OP_SENTINEL }; diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h index 03bbebdf43..7d774b761f 100644 --- a/src/tests/eo/suite/eo_test_class_simple.h +++ b/src/tests/eo/suite/eo_test_class_simple.h @@ -11,6 +11,8 @@ EAPI int simple_a_get(void); EAPI Eina_Bool simple_a_print(void); EAPI Eina_Bool simple_class_hi_print(void); EAPI void simple_recursive(int n); +EAPI void simple_pure_virtual(void); +EAPI void simple_no_implementation(void); extern const Eo_Event_Description _EV_A_CHANGED; #define EV_A_CHANGED (&(_EV_A_CHANGED)) From 70fe1398fdbf6bc5c086c6afeb0ba396fced2f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 9 Jan 2014 14:42:17 +0100 Subject: [PATCH 147/169] eo2: if _eo2_class_funcs_set() fails eo_class_new() returns NULL call to _eo2_class_funcs_set() is moved out of _eo_class_constructor() into eo_class_new(). --- src/lib/eo/eo.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 4d264782e1..1be10ea694 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -681,7 +681,7 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) else return 0; } -EAPI void +EAPI Eina_Bool _eo2_class_funcs_set(_Eo_Class *klass) { int op_id; @@ -697,7 +697,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) DBG("Set functions for class '%s':%p", klass->desc->name, klass); - if (!op_descs) return; + if (!op_descs) return EINA_TRUE; last_api_func = NULL; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) @@ -739,6 +739,8 @@ _eo2_class_funcs_set(_Eo_Class *klass) _dich_func_set(klass, op_desc->op, op_desc->func); last_api_func = op_desc->api_func; } + + return EINA_TRUE; } EAPI Eo * @@ -1206,9 +1208,6 @@ _eo_class_constructor(_Eo_Class *klass) klass->constructed = EINA_TRUE; - if (klass->desc->version == EO2_VERSION) - _eo2_class_funcs_set(klass); - if (klass->desc->class_constructor) klass->desc->class_constructor(_eo_class_id_get(klass)); } @@ -1340,13 +1339,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(desc->name, NULL); - if (desc->version == EO2_VERSION) - { - // FIXME: eo2 - /* if (!_eo2_class_check_op_descs(desc)) */ - /* return NULL; */ - } - else + if (desc->version != EO2_VERSION) { if (!_eo_class_check_op_descs(desc)) return NULL; @@ -1552,6 +1545,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } _eo_class_base_op_init(klass); + /* Flatten the function array */ { const _Eo_Class **mro_itr = klass->mro; @@ -1588,6 +1582,18 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } } + if (desc->version == EO2_VERSION) + { + if (!_eo2_class_funcs_set(klass)) + { + eina_spinlock_free(&klass->objects.trash_lock); + eina_spinlock_free(&klass->iterators.trash_lock); + _dich_func_clean_all(klass); + free(klass); + return NULL; + } + } + eina_spinlock_take(&_eo_class_creation_lock); klass->header.id = ++_eo_classes_last_id | MASK_CLASS_TAG; { From f812b38a665d5793fe2c7fbeb9297954e1a0b3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 9 Jan 2014 14:43:26 +0100 Subject: [PATCH 148/169] eo2: do not allow ill formed class creation eo_class_new() returns NULL on error in _eo2_class_funcs_set(). it covers: NULL API func, API redefined, dich func override, overriding non-existing fct. --- src/lib/eo/eo.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 1be10ea694..463794b994 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -97,7 +97,7 @@ _dich_func_get(const _Eo_Class *klass, Eo_Op op) return &chain1->funcs[DICH_CHAIN_LAST(op)]; } -static inline void +static inline Eina_Bool _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) { op_type_funcs *fsrc; @@ -109,12 +109,15 @@ _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) { const _Eo_Class *op_kls = _eo_op_class_get(op); const char *op_name = _eo_op_id_name_get(op, op_kls->desc->version); - ERR("Already set function for op %d (%s:'%s'). Overriding %p with %p.", - op, op_kls->desc->name, op_name, fsrc->func, func); + ERR("Class '%s': Overriding func %p for op %d (%s:'%s') with %p.", + klass->desc->name, fsrc->func, op, op_kls->desc->name, op_name, func); + return EINA_FALSE; } fsrc->func = func; fsrc->src = klass; + + return EINA_TRUE; } static inline void @@ -693,28 +696,29 @@ _eo2_class_funcs_set(_Eo_Class *klass) op_id = klass->base_id; op_descs = klass->desc->ops.descs2; - qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); - DBG("Set functions for class '%s':%p", klass->desc->name, klass); if (!op_descs) return EINA_TRUE; + qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + last_api_func = NULL; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if(op_desc->api_func == NULL) { - ERR("Ignore %d NULL->%p '%s'. Can't set implementation for NULL API.", - op_desc->op, op_desc->func, op_desc->doc); - continue; + ERR("Class '%s': NULL API not allowed (%d NULL->%p '%s').", + klass->desc->name, op_desc->op, op_desc->func, op_desc->doc); + return EINA_FALSE; } if (op_desc->op == EO_NOOP) { if (op_desc->api_func == last_api_func) { - ERR("API already defined %d %p->%p '%s'. Expect undefined behaviour.", - op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); + ERR("Class '%s': API previously defined (%d %p->%p '%s').", + klass->desc->name, op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); + return EINA_FALSE; } op_desc->op = op_id; op_id++; @@ -725,9 +729,9 @@ _eo2_class_funcs_set(_Eo_Class *klass) if (api_desc == NULL) { - ERR("Ignore override %p->%p. Can't find api func description in class hierarchy.", - op_desc->api_func, op_desc->func); - continue; + ERR("Class '%s': Can't find api func description in class hierarchy (%p->%p).", + klass->desc->name, op_desc->api_func, op_desc->func); + return EINA_FALSE; } op_desc->op = api_desc->op; @@ -736,7 +740,9 @@ _eo2_class_funcs_set(_Eo_Class *klass) DBG(" %4d %p->%p '%s'", op_desc->op, op_desc->api_func, op_desc->func, op_desc->doc); - _dich_func_set(klass, op_desc->op, op_desc->func); + if (!_dich_func_set(klass, op_desc->op, op_desc->func)) + return EINA_FALSE; + last_api_func = op_desc->api_func; } From 64aa007caf13db318cfed25b074ea4b0f2fdfe98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 9 Jan 2014 14:43:52 +0100 Subject: [PATCH 149/169] eo2: update class creation tests, follow new error policy see previous commit --- src/tests/eo/suite/eo_test_class_errors.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index 24a07f47e9..cbea8e1b2d 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -231,9 +231,9 @@ START_TEST(eo_null_api) NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "Ignore %d NULL->%p '%s'. Can't set implementation for NULL API."); + TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': NULL API not allowed (%d NULL->%p '%s')."); klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(!klass); + fail_if(klass); fail_unless(ctx.did); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); @@ -264,9 +264,9 @@ START_TEST(eo_wrong_override) NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "Ignore override %p->%p. Can't find api func description in class hierarchy."); + TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': Can't find api func description in class hierarchy (%p->%p)."); klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(!klass); + fail_if(klass); fail_unless(ctx.did); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); @@ -298,9 +298,9 @@ START_TEST(eo_api_redefined) NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "API already defined %d %p->%p '%s'. Expect undefined behaviour."); + TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': API previously defined (%d %p->%p '%s')."); klass = eo_class_new(&class_desc, NULL, NULL); - fail_if(!klass); + fail_if(klass); fail_unless(ctx.did); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); @@ -332,9 +332,9 @@ START_TEST(eo_dich_func_override) NULL }; - TEST_EO_ERROR("_dich_func_set", "Already set function for op %d (%s:'%s'). Overriding %p with %p."); + TEST_EO_ERROR("_dich_func_set", "Class '%s': Overriding func %p for op %d (%s:'%s') with %p."); klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); - fail_if(!klass); + fail_if(klass); fail_unless(ctx.did); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); From 4b9c37501c86d0c906406bc4d234e5bbb5550cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 21 Jan 2014 17:42:07 +0100 Subject: [PATCH 150/169] eo2: add tests for thread safe call stack Summary: 2 threads run 'eo2_do(o, a(), b());' - A goes first, creates an object, enters 'eo2_do(o, a(), b());' in a() call, it blocks, releases B and waits for it. - B when released, creates an object, enters 'eo2_do(o, a(), b());' in a() call, it joins and releases A, then blocks. - A returns from a(); and enters b() using current call stack frame, which is the one pushed by B! then pop the frame and releases B. - B does as above using the stack pushed by A! --- src/Makefile_Eo.am | 1 + src/tests/eo/suite/eo_suite.c | 1 + src/tests/eo/suite/eo_suite.h | 1 + src/tests/eo/suite/eo_test_threaded_calls.c | 130 ++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 src/tests/eo/suite/eo_test_threaded_calls.c diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 9b1cb117c2..bfefd27d73 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -99,6 +99,7 @@ tests/eo/suite/eo_test_class_errors.c \ tests/eo/suite/eo_test_call_errors.c \ tests/eo/suite/eo_test_general.c \ tests/eo/suite/eo_test_value.c \ +tests/eo/suite/eo_test_threaded_calls.c \ tests/eo/suite/eo_test_init.c tests_eo_eo_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eo\" \ diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c index db303cfebb..42c6645156 100644 --- a/src/tests/eo/suite/eo_suite.c +++ b/src/tests/eo/suite/eo_suite.c @@ -22,6 +22,7 @@ static const Eo_Test_Case etc[] = { { "Eo class errors", eo_test_class_errors }, { "Eo call errors", eo_test_call_errors }, { "Eo eina value", eo_test_value }, + { "Eo threaded eo calls", eo_test_threaded_calls }, { NULL, NULL } }; diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h index 4a3c3b0f21..94d88bd1fe 100644 --- a/src/tests/eo/suite/eo_suite.h +++ b/src/tests/eo/suite/eo_suite.h @@ -8,5 +8,6 @@ void eo_test_general(TCase *tc); void eo_test_class_errors(TCase *tc); void eo_test_call_errors(TCase *tc); void eo_test_value(TCase *tc); +void eo_test_threaded_calls(TCase *tc); #endif /* _EO_SUITE_H */ diff --git a/src/tests/eo/suite/eo_test_threaded_calls.c b/src/tests/eo/suite/eo_test_threaded_calls.c new file mode 100644 index 0000000000..a954463e46 --- /dev/null +++ b/src/tests/eo/suite/eo_test_threaded_calls.c @@ -0,0 +1,130 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include "Eo.h" +#include "eo_suite.h" + +static Eina_Barrier barrier; +static Eina_Spinlock locks[2]; + +typedef struct +{ + int v; +} Thread_Test_Public_Data; + +#define THREAD_TEST_CLASS thread_test_class_get() +const Eo_Class *thread_test_class_get(void); + +EO2_FUNC_BODY(thread_test_v_get, int, 0); +EO2_VOID_FUNC_BODY(thread_test_try_swap_stack); +EO2_VOID_FUNC_BODYV(thread_test_constructor, EO2_FUNC_CALL(v), int v); + +static int +_v_get(Eo *obj EINA_UNUSED, void *class_data) +{ + Thread_Test_Public_Data *pd = class_data; + + return pd->v; +} + +static void +_try_swap_stack(Eo *obj EINA_UNUSED, void *class_data) +{ + Thread_Test_Public_Data *pd = class_data; + + if (pd->v == 0 ) + { + eina_spinlock_release(&locks[0]); + eina_spinlock_take(&locks[1]); + eina_barrier_wait(&barrier); + } + else if (pd->v == 1 ) + { + eina_barrier_wait(&barrier); + eina_spinlock_take(&locks[1]); + } +} + +static void +_constructor(Eo *obj, void *class_data EINA_UNUSED, int v) +{ + Thread_Test_Public_Data *pd = class_data; + + eo2_do_super(obj, THREAD_TEST_CLASS, eo2_constructor()); + + pd->v = v; +} + +static Eo2_Op_Description op_descs[] = { + EO2_OP_FUNC(thread_test_constructor, _constructor, "Constructor."), + EO2_OP_FUNC(thread_test_v_get, _v_get, "Get property v."), + EO2_OP_FUNC(thread_test_try_swap_stack, _try_swap_stack, "Swap call stack frames if it is not thread safe."), + EO2_OP_SENTINEL +}; + +static const Eo_Class_Description class_desc = { + EO2_VERSION, + "Thread Test", + EO_CLASS_TYPE_REGULAR, + EO2_CLASS_DESCRIPTION_OPS(op_descs), + NULL, + sizeof(Thread_Test_Public_Data), + NULL, + NULL +}; + +EO_DEFINE_CLASS(thread_test_class_get, &class_desc, EO2_BASE_CLASS, NULL) + +static void * +_thread_job(void *data, Eina_Thread t EINA_UNUSED) +{ + Eo *obj; + int v = (int) (uintptr_t) data; + + if (v == 1) + eina_spinlock_take(&locks[0]); + + obj = eo2_add_custom(THREAD_TEST_CLASS, NULL, thread_test_constructor(v)); + + eo2_do(obj, thread_test_try_swap_stack(), v = thread_test_v_get()); + + eina_spinlock_release(&locks[1]); + + eo_unref(obj); + + return (void *) (uintptr_t) v; +} + +START_TEST(eo_threaded_calls_test) +{ + Eina_Thread threads[2]; + + eo_init(); + + fail_if(!eina_spinlock_new(&locks[0])); + fail_if(!eina_spinlock_new(&locks[1])); + fail_if(!eina_barrier_new(&barrier, 2)); + + eina_spinlock_take(&locks[0]); + + fail_if(!eina_thread_create(&threads[0], EINA_THREAD_NORMAL, 0, _thread_job, (void *) (uintptr_t)0)); + fail_if(!eina_thread_create(&threads[1], EINA_THREAD_NORMAL, 0, _thread_job, (void *) (uintptr_t)1)); + + fail_if(0 != (int)(uintptr_t)eina_thread_join(threads[0])); + fail_if(1 != (int)(uintptr_t)eina_thread_join(threads[1])); + + eina_spinlock_free(&locks[0]); + eina_spinlock_free(&locks[1]); + eina_barrier_free(&barrier); + + eo_shutdown(); +} +END_TEST + +void eo_test_threaded_calls(TCase *tc) +{ + tcase_add_test(tc, eo_threaded_calls_test); +} From d39d705087af123f4e5948bfef48bde08517dfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 22 Jan 2014 11:18:31 +0100 Subject: [PATCH 151/169] eo2: call stack is now thread safe create/destroy tls key (_eo2_call_stack_key) at eo_init()/eo_shutdown(). use _eo2_call_stack_get() to allocate the stack when required. register _eo2_call_stack_free() as eina_tls_cb_new() delete callback. --- src/lib/eo/eo.c | 130 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 41 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 463794b994..c629e6be0e 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -324,61 +324,98 @@ typedef struct _Eo2_Stack_Frame void *obj_data; } Eo2_Stack_Frame; +static Eina_TLS _eo2_call_stack_key = 0; + typedef struct _Eo2_Call_Stack { - Eo2_Stack_Frame *stack; + Eo2_Stack_Frame *frames; Eo2_Stack_Frame *frame_ptr; Eo2_Stack_Frame *last_frame; Eo2_Stack_Frame *shrink_frame; } Eo2_Call_Stack; -static Eo2_Call_Stack eo2_call_stack = { NULL, NULL, NULL, NULL }; - -static Eina_Bool -_eo2_call_stack_init() +static Eo2_Call_Stack * +_eo2_call_stack_create() { - eo2_call_stack.stack = calloc(EO2_CALL_STACK_DEPTH, sizeof(Eo2_Stack_Frame)); - if (!eo2_call_stack.stack) - return EINA_FALSE; + Eo2_Call_Stack *stack; + + stack = calloc(1, sizeof(Eo2_Call_Stack)); + if (!stack) + return NULL; + + stack->frames = calloc(EO2_CALL_STACK_DEPTH, sizeof(Eo2_Stack_Frame)); + if (!stack->frames) + { + free(stack); + return NULL; + } // first frame is never used - eo2_call_stack.frame_ptr = eo2_call_stack.stack; - eo2_call_stack.last_frame = &eo2_call_stack.stack[EO2_CALL_STACK_DEPTH - 1]; - eo2_call_stack.shrink_frame = eo2_call_stack.stack; + stack->frame_ptr = stack->frames; + stack->last_frame = &stack->frames[EO2_CALL_STACK_DEPTH - 1]; + stack->shrink_frame = stack->frames; - return EINA_TRUE; + return stack; } static void -_eo2_call_stack_free() +_eo2_call_stack_free(void *ptr) { - if (eo2_call_stack.stack) - free(eo2_call_stack.stack); + Eo2_Call_Stack *stack = (Eo2_Call_Stack *) ptr; + + if (!stack) return; + + if (stack->frames) + free(stack->frames); + free(stack); } +static inline Eo2_Call_Stack * +_eo2_call_stack_get() +{ + Eo2_Call_Stack *stack = eina_tls_get(_eo2_call_stack_key); + + if (stack) return stack; + + stack = _eo2_call_stack_create(); + if (!stack) + { + EINA_LOG_ERR("Could not alloc eo2 call stack."); + return NULL; + } + + if (!eina_tls_set(_eo2_call_stack_key, stack)) + { + EINA_LOG_ERR("Could not set eo2 call stack in TLS key."); + _eo2_call_stack_free(stack); + return NULL; + } + + return stack; +} static inline void -_eo2_call_stack_resize(Eina_Bool grow) +_eo2_call_stack_resize(Eo2_Call_Stack *stack, Eina_Bool grow) { size_t sz, next_sz; int frame_offset; - frame_offset = eo2_call_stack.frame_ptr - eo2_call_stack.stack; - sz = eo2_call_stack.last_frame - eo2_call_stack.stack + 1; + frame_offset = stack->frame_ptr - stack->frames; + sz = stack->last_frame - stack->frames + 1; if (grow) next_sz = sz << 1; else next_sz = sz >> 1; DBG("resize from %lu to %lu", sz, next_sz); - eo2_call_stack.stack = realloc(eo2_call_stack.stack, next_sz * sizeof(Eo2_Stack_Frame)); - if(!eo2_call_stack.stack) + stack->frames = realloc(stack->frames, next_sz * sizeof(Eo2_Stack_Frame)); + if(!stack->frames) { CRI("unable to resize call stack, abort."); abort(); } - eo2_call_stack.frame_ptr = &eo2_call_stack.stack[frame_offset]; - eo2_call_stack.last_frame = &eo2_call_stack.stack[next_sz - 1]; + stack->frame_ptr = &stack->frames[frame_offset]; + stack->last_frame = &stack->frames[next_sz - 1]; if (grow) frame_offset = (sz >> 1); @@ -386,7 +423,7 @@ _eo2_call_stack_resize(Eina_Bool grow) frame_offset = 0; else frame_offset = (next_sz >> 1); - eo2_call_stack.shrink_frame = &eo2_call_stack.stack[frame_offset]; + stack->shrink_frame = &stack->frames[frame_offset]; } static inline Eina_Bool @@ -438,11 +475,12 @@ EAPI Eina_Bool _eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { Eo2_Stack_Frame *fptr, *pfptr; + Eo2_Call_Stack *stack = _eo2_call_stack_get(); - if (eo2_call_stack.frame_ptr == eo2_call_stack.last_frame) - _eo2_call_stack_resize(EINA_TRUE); + if (stack->frame_ptr == stack->last_frame) + _eo2_call_stack_resize(stack, EINA_TRUE); - fptr = eo2_call_stack.frame_ptr; + fptr = stack->frame_ptr; pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); fptr++; @@ -450,7 +488,7 @@ _eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, if (!_eo2_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) return EINA_FALSE; - eo2_call_stack.frame_ptr++; + stack->frame_ptr++; return EINA_TRUE; } @@ -459,24 +497,25 @@ EAPI void _eo2_do_end(const Eo **eo_id EINA_UNUSED) { Eo2_Stack_Frame *fptr; + Eo2_Call_Stack *stack = _eo2_call_stack_get(); - fptr = eo2_call_stack.frame_ptr; + fptr = stack->frame_ptr; if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj) _eo_unref(fptr->o.obj); fptr->obj_data = EO2_INVALID_DATA; - if (fptr == eo2_call_stack.stack) + if (fptr == stack->frames) { CRI("call stack underflow, abort."); abort(); } - eo2_call_stack.frame_ptr--; + stack->frame_ptr--; - if (fptr == eo2_call_stack.shrink_frame) - _eo2_call_stack_resize(EINA_FALSE); + if (fptr == stack->shrink_frame) + _eo2_call_stack_resize(stack, EINA_FALSE); } EAPI Eina_Bool @@ -489,7 +528,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, if (op == EO_NOOP) return EINA_FALSE; - fptr = eo2_call_stack.frame_ptr; + fptr = _eo2_call_stack_get()->frame_ptr; is_obj = !_eo_is_a_class(fptr->eo_id); klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; @@ -653,13 +692,14 @@ _eo2_api_op_id_get(const void *api_func, const char *file, int line) { const Eo2_Op_Description *desc; const _Eo_Class *klass; + Eo2_Call_Stack *stack = _eo2_call_stack_get(); - Eina_Bool class_ref = _eo_is_a_class(eo2_call_stack.frame_ptr->eo_id); + Eina_Bool class_ref = _eo_is_a_class(stack->frame_ptr->eo_id); if (class_ref) - klass = eo2_call_stack.frame_ptr->o.kls; + klass = stack->frame_ptr->o.kls; else - klass = eo2_call_stack.frame_ptr->o.obj->klass; + klass = stack->frame_ptr->o.obj->klass; desc = _eo2_api_desc_get(api_func, klass, klass->extensions); @@ -802,8 +842,9 @@ EAPI Eo * _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) { Eo2_Stack_Frame *fptr; + Eo2_Call_Stack *stack = _eo2_call_stack_get(); - fptr = eo2_call_stack.frame_ptr; + fptr = stack->frame_ptr; if ((fptr == NULL) || (fptr->eo_id != eo_id)) { @@ -2061,10 +2102,16 @@ eo_init(void) /* bootstrap EO_CLASS_CLASS */ (void) eo_class_class_get(); - if (!_eo2_call_stack_init()) + if (_eo2_call_stack_key != 0) + WRN("_eo2_call_stack_key already set, this should not happen."); + else { - EINA_LOG_ERR("Could not init eo2 call stack."); - return EINA_FALSE; + if (!eina_tls_cb_new(&_eo2_call_stack_key, _eo2_call_stack_free)) + { + EINA_LOG_ERR("Could not create TLS key for call stack."); + return EINA_FALSE; + + } } return EINA_TRUE; @@ -2094,7 +2141,8 @@ eo_shutdown(void) eina_spinlock_free(&_eo_class_creation_lock); - _eo2_call_stack_free(); + if (_eo2_call_stack_key != 0) + eina_tls_free(_eo2_call_stack_key); _eo_free_ids_tables(); From 2b34ab4cf7e8115a7868e35e34b7557a98d8fa81 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 10 Apr 2014 02:47:56 +0100 Subject: [PATCH 152/169] Eolian: Generate Eo2. --- src/bin/eolian/common_funcs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/eolian/common_funcs.h b/src/bin/eolian/common_funcs.h index c8a800eefb..ace92e6fca 100644 --- a/src/bin/eolian/common_funcs.h +++ b/src/bin/eolian/common_funcs.h @@ -3,7 +3,7 @@ #include -//#define EO +#define EO extern int _eolian_gen_log_dom; From 9d332da1f8c269487a82592da1f3c58101d1c224 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 1 Apr 2014 14:07:53 +0100 Subject: [PATCH 153/169] Eo2: Adjust to composite object changes. --- src/lib/eo/eo.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index c629e6be0e..1687090a17 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -594,12 +594,12 @@ end: /* Try composite objects */ if (is_obj) { - Eina_List *itr; - Eo *emb_eo_id; - EINA_LIST_FOREACH(fptr->o.obj->composite_objects, itr, emb_eo_id) + const _Eo_Object **comp_itr = fptr->o.obj->composites; + if (!comp_itr) goto end2; + + for (unsigned int i = 0; i < fptr->o.obj->klass->composites_count; i++, comp_itr++) { - /* should never return */ - EO_OBJ_POINTER_RETURN_VAL(emb_eo_id, emb_obj, EINA_FALSE); + const _Eo_Object *emb_obj = *comp_itr; func = _dich_func_get(emb_obj->klass, op); if (func == NULL) @@ -617,6 +617,7 @@ end: } } +end2: { const _Eo_Class *main_klass; main_klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; @@ -822,6 +823,11 @@ _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo obj->refcount++; obj->klass = klass; + if (klass->composites_count == 0) + obj->composites = NULL; + else + obj->composites = (const _Eo_Object **) + ((char *) obj + klass->obj_size - (klass->composites_count * sizeof(_Eo_Object *))); #ifndef HAVE_EO_ID EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC); From 3c46e7dab884b7e1278c14e4c78d1a394d6bf94c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 1 Apr 2014 16:21:13 +0100 Subject: [PATCH 154/169] Eo2: Removed a lot of Eo1 code. --- src/Makefile_Eo.am | 2 - src/lib/eo/Eo.h | 323 ++--------- src/lib/eo/eo.c | 483 +---------------- src/lib/eo/eo2_base_class.c | 6 +- src/lib/eo/eo_base_class.c | 1013 ----------------------------------- src/lib/eo/eo_class_class.c | 20 - src/lib/eo/eo_private.h | 15 +- 7 files changed, 55 insertions(+), 1807 deletions(-) delete mode 100644 src/lib/eo/eo_base_class.c delete mode 100644 src/lib/eo/eo_class_class.c diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index bfefd27d73..c34b54b58c 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -10,8 +10,6 @@ lib_eo_libeo_la_SOURCES = \ lib/eo/eo.c \ lib/eo/eo_ptr_indirection.c \ lib/eo/eo_ptr_indirection.h \ -lib/eo/eo_class_class.c \ -lib/eo/eo_base_class.c \ lib/eo/eo2_base_class.c \ lib/eo/eo2_class_class.c \ lib/eo/eo_private.h diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index ffd2d7ded5..bd71f21257 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -229,20 +229,6 @@ EAPI void eo_dbg_info_free(Eo_Dbg_Info *info); * @} */ -/** - * @def EO_TYPECHECK(type, x) - * - * Checks x is castable to type "type" and casts it to it. - * @param type The C type to check against. - * @param x the variable to test and cast. - */ -#define EO_TYPECHECK(type, x) \ - ({ \ - type __x; \ - __x = x; \ - (type) __x; \ - }) - /** * @typedef Eo_Op * The Eo operation type id. @@ -446,7 +432,7 @@ typedef struct _Eo_Op_Description Eo_Op_Description; * @def EO_VERSION * The current version of EO. */ -#define EO_VERSION 1 +#define EO_VERSION 2 typedef struct _Eo2_Op_Description { @@ -470,8 +456,7 @@ struct _Eo_Class_Description Eo_Class_Type type; /**< The type of the class. */ struct { Eo_Op *base_op_id; - const Eo_Op_Description *descs; - Eo2_Op_Description *descs2; /**< EO2 */ + Eo2_Op_Description *descs2; size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ const Eo_Event_Description **events; /**< The event descriptions for this class. */ @@ -564,15 +549,6 @@ EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Cla */ EAPI Eina_Bool eo_isa(const Eo *obj, const Eo_Class *klass); -/** - * @brief Sets the OP functions for a class. - * @param klass the class to set the functions to. - * @param func_descs a NULL terminated array of #Eo_Op_Func_Description - * - * Should be called from within the class constructor. - */ -EAPI void eo_class_funcs_set(Eo_Class *klass, const Eo_Op_Func_Description *func_descs); - /** * @brief Gets the name of the passed class. * @param klass the class to work on. @@ -604,14 +580,14 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ -#define EO2_VERSION 2 +#define EO2_VERSION EO_VERSION // computes size of Eo2_Op_Description[] #define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) // Helpers macro to help populating #Eo_Class_Description. -#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, NULL, 0} -#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } +#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, 0} +#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data @@ -740,74 +716,6 @@ EAPI void _eo2_do_end(const Eo **ojb); /*****************************************************************************/ -/** - * @def eo_do - * A convenience wrapper around eo_do_internal() - * @see eo_do_internal - */ -#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, args) - -/** - * @brief Calls op functions of an object - * @param obj The object 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_do - */ -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 ops 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_vdo instead of this function. - * - * @see #eo_vdo - */ -EAPI Eina_Bool eo_vdo_internal(const char *file, int line, const Eo *obj, va_list *ops); - -/** - * @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 ... list of parameters. - * @return @c EINA_TRUE on success. - * - * Unlike eo_do(), this function only accepts one op. - * - * @see #eo_do - */ -#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. - * @param obj The object 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_do - * @see #eo_do_super - */ -EAPI Eina_Bool eo_do_super_internal(const char *file, int line, const Eo *obj, const Eo_Class *cur_klass, Eo_Op op, ...); - /** * @brief Gets the class of the object. * @param obj The object to work on @@ -840,11 +748,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add_custom */ -#define eo_add(klass, parent, ...) \ - ({ \ - const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo_constructor(), ## __VA_ARGS__, EO_NOOP); \ - }) #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ @@ -867,11 +770,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add */ -#define eo_add_custom(klass, parent, ...) \ - ({ \ - const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ - }) #define eo2_add_custom(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ @@ -883,19 +781,6 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); _tmp_obj; \ }) -/** - * @brief Create a new object. - * @param klass the class of the object to create. - * @param parent the parent to set to the object. - * @param ... The ops to run. With the constructor being first. - * @return An handle to the new object on success, NULL otherwise. - * - * Use the helper macros, don't pass the parameters manually. - * Use #eo_add or #eo_add_custom instead of this function. - * - * @see #eo_add - */ -EAPI Eo *eo_add_internal(const char *file, int line, const Eo_Class *klass, Eo *parent, ...); EAPI Eo * _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); EAPI Eo * _eo2_add_internal_end(const char *file, int line, const Eo *obj); @@ -1157,25 +1042,13 @@ EAPI Eina_Bool eo_composite_is(const Eo *comp_obj); * @def EO_CLASS_CLASS * The class type for the Eo Class class. */ -#define EO_CLASS_CLASS eo_class_class_get() #define EO2_CLASS_CLASS eo2_class_class_get() /** * @brief Use #EO_CLASS_CLASS * @internal * */ -EAPI const Eo_Class *eo_class_class_get(void); EAPI const Eo_Class *eo2_class_class_get(void); -/** - * @var EO_CLASS_CLASS_BASE_ID - * #EO_CLASS_CLASS 's base id. - */ -extern EAPI Eo_Op EO_CLASS_CLASS_BASE_ID; - -enum { - EO_CLASS_CLASS_SUB_ID_LAST -}; - /** * @} */ @@ -1189,13 +1062,11 @@ enum { * @def EO_BASE_CLASS * The class type for the Eo base class. */ -#define EO_BASE_CLASS eo_base_class_get() #define EO2_BASE_CLASS eo2_base_class_get() /** * @brief Use #EO_BASE_CLASS * @internal * */ -EAPI const Eo_Class *eo_base_class_get(void); EAPI const Eo_Class *eo2_base_class_get(void); /** @@ -1205,49 +1076,7 @@ EAPI const Eo_Class *eo2_base_class_get(void); typedef void (*eo_base_data_free_func)(void *); /** - * @var EO_BASE_BASE_ID - * #EO_BASE_CLASS 's base id. - */ -extern EAPI Eo_Op EO_BASE_BASE_ID; - -enum { - EO_BASE_SUB_ID_CONSTRUCTOR, - EO_BASE_SUB_ID_DESTRUCTOR, - EO_BASE_SUB_ID_PARENT_SET, - EO_BASE_SUB_ID_PARENT_GET, - EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW, - EO_BASE_SUB_ID_DATA_SET, - EO_BASE_SUB_ID_DATA_GET, - EO_BASE_SUB_ID_DATA_DEL, - EO_BASE_SUB_ID_WREF_ADD, - EO_BASE_SUB_ID_WREF_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL, - EO_BASE_SUB_ID_EVENT_CALLBACK_CALL, - EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD, - EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL, - EO_BASE_SUB_ID_EVENT_FREEZE, - EO_BASE_SUB_ID_EVENT_THAW, - EO_BASE_SUB_ID_EVENT_FREEZE_GET, - EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE, - EO_BASE_SUB_ID_EVENT_GLOBAL_THAW, - EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET, - EO_BASE_SUB_ID_DBG_INFO_GET, - EO_BASE_SUB_ID_LAST -}; - -/** - * @def EO_BASE_ID(sub_id) - * Helper macro to get the full Op ID out of the sub_id for EO_BASE. - * @param sub_id the sub id inside EO_BASE. - */ -#define EO_BASE_ID(sub_id) (EO_BASE_BASE_ID + (sub_id)) - -/** - * @def eo_base_data_set(key, data, free_func) - * Set generic data to object. + * @brief Set generic data to object. * @param[in] key the key associated with the data * @param[in] data the data to set. * @param[in] free_func the func to free data with (NULL means "do nothing"). @@ -1255,46 +1084,34 @@ enum { * @see #eo_base_data_get * @see #eo_base_data_del */ -#define eo_base_data_set(key, data, free_func) EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(const void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func) -EAPI void -eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); +EAPI void eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); /** - * @def eo_base_data_get(key, data) - * Get generic data from object. + * @brief Get generic data from object. * @param[in] key the key associated with the data * @param[out] data the data for the key * * @see #eo_base_data_set * @see #eo_base_data_del */ -#define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data) -EAPI void * -eo2_base_data_get(const char *key); +EAPI void *eo2_base_data_get(const char *key); /** - * @def eo_dbg_info_get(root_node) - * Get dbg information from the object. + * @brief Get dbg information from the object. * @param[in] root node of the tree */ -#define eo_dbg_info_get(root_node) EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), EO_TYPECHECK(Eo_Dbg_Info *, root_node) -EAPI void -eo2_dbg_info_get(Eo_Dbg_Info *root_node); +EAPI void eo2_dbg_info_get(Eo_Dbg_Info *root_node); /** - * @def eo_base_data_del(key) - * Del generic data from object. + * @brief Del generic data from object. * @param[in] key the key associated with the data * * @see #eo_base_data_set * @see #eo_base_data_get */ -#define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key) -EAPI void -eo2_base_data_del(const char *key); +EAPI void eo2_base_data_del(const char *key); /** - * @def eo_parent_set * @brief Set the parent of an object * @param[in] parent the new parent. * @@ -1305,35 +1122,26 @@ eo2_base_data_del(const char *key); * @see eo_del() * @see eo_parent_get() */ -#define eo_parent_set(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), EO_TYPECHECK(Eo *, parent) -EAPI void -eo2_parent_set(Eo *parent); +EAPI void eo2_parent_set(Eo *parent); /** - * @def eo_parent_get * @brief Get the parent of an object * @param[out] a pointer to the parent object. * * @see eo_parent_set() */ -#define eo_parent_get(parent) EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), EO_TYPECHECK(Eo **, parent) -EAPI Eo * -eo2_parent_get(void); +EAPI Eo *eo2_parent_get(void); /** - * @def eo_children_iterator_new * @brief Get an iterator on all childrens * @param obj the object to get the childrens from. * @return a pointer to an Eina_Iterator containing all the childrens. * * @see eo_parent_set() */ -#define eo_children_iterator_new(it) EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), EO_TYPECHECK(Eina_Iterator **, it) -EAPI Eina_Iterator * -eo2_children_iterator_new(void); +EAPI Eina_Iterator *eo2_children_iterator_new(void); /** - * @def eo_wref_add * @brief Add a new weak reference to obj. * @param wref The pointer to use for the weak ref. * @@ -1344,20 +1152,15 @@ eo2_children_iterator_new(void); * * @see #eo_wref_del */ -#define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref) -EAPI void -eo2_wref_add(Eo **wref); +EAPI void eo2_wref_add(Eo **wref); /** - * @def eo_wref_del * @brief Delete the weak reference passed. * @param wref the weak reference to free. * * @see #eo_wref_add */ -#define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref) -EAPI void -eo2_wref_del(Eo **wref); +EAPI void eo2_wref_del(Eo **wref); /** * @def eo_weak_ref @@ -1371,10 +1174,6 @@ eo2_wref_del(Eo **wref); * @see eo_weak_unref * @see eo_wref_add */ -#define eo_weak_ref(wref) \ - do { \ - if (*wref) eo_do(*wref, eo_wref_add(wref)); \ - } while (0) #define eo2_weak_ref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_add(wref)); \ @@ -1393,10 +1192,6 @@ eo2_wref_del(Eo **wref); * @see eo_wref_del * @see eo_wref_del_safe */ -#define eo_weak_unref(wref) \ - do { \ - if (*wref) eo_do(*wref, eo_wref_del(wref)); \ - } while (0) #define eo2_weak_unref(wref) \ do { \ if (*wref) eo2_do(*wref, eo2_wref_del(wref)); \ @@ -1412,32 +1207,25 @@ eo2_wref_del(Eo **wref); * * @see #eo_wref_del */ -#define eo_wref_del_safe(wref) eo_weak_unref(wref) #define eo2_wref_del_safe(wref) eo2_weak_unref(wref) /** - * @def eo_constructor * @brief Call the object's constructor. * * Should not be used with #eo_do. Only use it with #eo_do_super. * * @see #eo_destructor */ -#define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR) -EAPI void -eo2_constructor(void); +EAPI void eo2_constructor(void); /** - * @def eo_destructor * @brief Call the object's destructor. * * Should not be used with #eo_do. Only use it with #eo_do_super. * * @see #eo_constructor */ -#define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR) -EAPI void -eo2_destructor(void); +EAPI void eo2_destructor(void); /** * @addtogroup Eo_Events Eo's Event Handling @@ -1522,55 +1310,42 @@ struct _Eo_Callback_Array_Item } /** - * @def eo_event_callback_forwarder_add * @brief Add an event callback forwarder for an event and an object. * @param[in] desc The description of the event to listen to. * @param[in] new_obj The object to emit events from. * * @see eo_event_callback_forwarder_del() */ -#define eo_event_callback_forwarder_add(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) -EAPI void -eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); /** - * @def eo_event_callback_forwarder_del * @brief Remove an event callback forwarder for an event and an object. * @param[in] desc The description of the event to listen to. * @param[in] new_obj The object to emit events from. * * @see eo_event_callback_forwarder_add() */ -#define eo_event_callback_forwarder_del(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj) -EAPI void -eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); /** - * @def eo_event_freeze * @brief freeze events of object. * * Prevents event callbacks from being called for the object. * * @see #eo_event_thaw */ -#define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE) -EAPI void -eo2_event_freeze(void); +EAPI void eo2_event_freeze(void); /** - * @def eo_event_thaw * @brief thaw events of object. * * Lets event callbacks be called for the object. * * @see #eo_event_freeze */ -#define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW) -EAPI void -eo2_event_thaw(void); +EAPI void eo2_event_thaw(void); /** - * @def eo_event_freeze_get * @brief return freeze events of object. * * @param[out] fcount The event freeze count of the object. @@ -1580,12 +1355,9 @@ eo2_event_thaw(void); * @see #eo_event_freeze * @see #eo_event_thaw */ -#define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount) -EAPI int -eo2_event_freeze_get(void); +EAPI int eo2_event_freeze_get(void); /** - * @def eo_event_global_freeze * @brief freeze events of object. * * Prevents event callbacks from being called for the object. @@ -1593,12 +1365,9 @@ eo2_event_freeze_get(void); * @see #eo_event_freeze * @see #eo_event_global_thaw */ -#define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE) -EAPI void -eo2_event_global_freeze(void); +EAPI void eo2_event_global_freeze(void); /** - * @def eo_event_global_thaw * @brief thaw events of object. * * Lets event callbacks be called for the object. @@ -1606,12 +1375,9 @@ eo2_event_global_freeze(void); * @see #eo_event_thaw * @see #eo_event_global_freeze */ -#define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW) -EAPI void -eo2_event_global_thaw(void); +EAPI void eo2_event_global_thaw(void); /** - * @def eo_event_global_freeze_get * @brief return freeze events of object. * * @param[out] fcount The event freeze count of the object. @@ -1622,9 +1388,7 @@ eo2_event_global_thaw(void); * @see #eo_event_global_freeze * @see #eo_event_global_thaw */ -#define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount) -EAPI int -eo2_event_global_freeze_get(void); +EAPI int eo2_event_global_freeze_get(void); /** * @def eo_event_callback_add(obj, desc, cb, data) @@ -1637,15 +1401,11 @@ eo2_event_global_freeze_get(void); * * @see eo_event_callback_priority_add() */ -#define eo_event_callback_add(desc, cb, data) \ - eo_event_callback_priority_add(desc, \ - EO_CALLBACK_PRIORITY_DEFAULT, cb, data) #define eo2_event_callback_add(desc, cb, data) \ eo2_event_callback_priority_add(desc, \ EO_CALLBACK_PRIORITY_DEFAULT, cb, data) /** - * @def eo_event_callback_priority_add * @brief Add a callback for an event with a specific priority. * @param[in] desc The description of the event to listen to. * @param[in] priority The priority of the callback. @@ -1656,24 +1416,19 @@ eo2_event_global_freeze_get(void); * * @see #eo_event_callback_add */ -#define eo_event_callback_priority_add(desc, priority, cb, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(Eo_Event_Cb, cb), EO_TYPECHECK(const void *, data) -EAPI void -eo2_event_callback_priority_add(const Eo_Event_Description *desc, +EAPI void eo2_event_callback_priority_add(const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb func, const void *user_data); /** - * @def eo_event_callback_del * @brief Del a callback with a specific data associated to it for an event. * @param[in] desc The description of the event to listen to. * @param[in] func the callback to delete. * @param[in] user_data The data to compare. * */ -#define eo_event_callback_del(desc, func, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Event_Cb, func), EO_TYPECHECK(const void *, user_data) -EAPI void -eo2_event_callback_del(const Eo_Event_Description *desc, +EAPI void eo2_event_callback_del(const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data); @@ -1687,15 +1442,11 @@ eo2_event_callback_del(const Eo_Event_Description *desc, * * @see eo_event_callback_array_priority_add() */ -#define eo_event_callback_array_add(array, data) \ - eo_event_callback_array_priority_add(array, \ - EO_CALLBACK_PRIORITY_DEFAULT, data) #define eo2_event_callback_array_add(array, data) \ eo2_event_callback_array_priority_add(array, \ EO_CALLBACK_PRIORITY_DEFAULT, data) /** - * @def eo_event_callback_array_priority_add * @brief Add a callback array for an event with a specific priority. * @param[in] array an #Eo_Callback_Array_Item of events to listen to. * @param[in] priority The priority of the callback. @@ -1705,34 +1456,26 @@ eo2_event_callback_del(const Eo_Event_Description *desc, * * @see #eo_event_callback_add */ -#define eo_event_callback_array_priority_add(array, priority, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(const void *, data) -EAPI void -eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, +EAPI void eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, const void *user_data); /** - * @def eo_event_callback_array_del * @brief Del a callback array with a specific data associated to it for an event. * @param[in] array an #Eo_Callback_Array_Item of events to listen to. * @param[in] user_data The data to compare. * */ -#define eo_event_callback_array_del(array, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL), EO_TYPECHECK(const Eo_Callback_Array_Item *, array), EO_TYPECHECK(const void *, user_data) -EAPI void -eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, +EAPI void eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, const void *user_data); /** - * @def eo_event_callback_call * @brief Call the callbacks for an event of an object. * @param[in] desc The description of the event to call. * @param[in] event_info Extra event info to pass to the callbacks. * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise. */ -#define eo_event_callback_call(desc, event_info, aborted) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(const void *, event_info), EO_TYPECHECK(Eina_Bool *, aborted) -EAPI Eina_Bool -eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); +EAPI Eina_Bool eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); /** * @} diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 1687090a17..24b515f2fe 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -28,8 +28,7 @@ static inline void *_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *k static inline void *_eo_data_xref_internal(const char *file, int line, _Eo_Object *obj, const _Eo_Class *klass, const _Eo_Object *ref_obj); static inline void _eo_data_xunref_internal(_Eo_Object *obj, void *data, const _Eo_Object *ref_obj); static const _Eo_Class *_eo_op_class_get(Eo_Op op); -static const Eo_Op_Description *_eo_op_id_desc_get(Eo_Op op); -static const char * _eo_op_id_name_get(Eo_Op op, int version); +static const char * _eo_op_id_name_get(Eo_Op op); /* Start of Dich */ @@ -108,7 +107,7 @@ _dich_func_set(_Eo_Class *klass, Eo_Op op, eo_op_func_type func) if (fsrc->src == klass) { const _Eo_Class *op_kls = _eo_op_class_get(op); - const char *op_name = _eo_op_id_name_get(op, op_kls->desc->version); + const char *op_name = _eo_op_id_name_get(op); ERR("Class '%s': Overriding func %p for op %d (%s:'%s') with %p.", klass->desc->name, fsrc->func, op, op_kls->desc->name, op_name, func); return EINA_FALSE; @@ -137,10 +136,6 @@ _dich_func_clean_all(_Eo_Class *klass) /* END OF DICH */ -static const Eo_Op_Description noop_desc = - EO_OP_DESCRIPTION(EO_NOOP, "No operation."); - - static inline Eina_Bool _eo_is_a_class(const Eo *eo_id) { @@ -189,26 +184,6 @@ _eo_op_class_get(Eo_Op op) return NULL; } -static const Eo_Op_Description * -_eo_op_id_desc_get(Eo_Op op) -{ - const _Eo_Class *klass; - - if (op == EO_NOOP) - return &noop_desc; - - klass = _eo_op_class_get(op); - - if (klass) - { - Eo_Op sub_id = op - klass->base_id; - if (sub_id < klass->desc->ops.count) - return klass->desc->ops.descs + sub_id; - } - - return NULL; -} - static const Eo2_Op_Description * _eo2_op_id_desc_get(Eo_Op op) { @@ -236,18 +211,10 @@ _eo2_op_id_desc_get(Eo_Op op) } static const char * -_eo_op_id_name_get(Eo_Op op, int version) +_eo_op_id_name_get(Eo_Op op) { - if (version == EO2_VERSION) - { - const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); - return (desc) ? desc->doc : NULL; - } - else - { - const Eo_Op_Description *desc = _eo_op_id_desc_get(op); - return (desc) ? desc->name : NULL; - } + const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); + return (desc) ? desc->doc : NULL; } static inline const op_type_funcs * @@ -278,32 +245,6 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op o return NULL; } -static inline const _Eo_Class * -_eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) -{ - const op_type_funcs *fsrc; - fsrc = _eo2_kls_itr_next(orig_kls, cur_klass, op); - - return (fsrc) ? fsrc->src : NULL; -} - -static inline const op_type_funcs * -_eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) -{ - const _Eo_Class *klass = cur_klass; - if (klass) - { - const op_type_funcs *func = _dich_func_get(klass, op); - - if (func && func->func) - { - return func; - } - } - - return NULL; -} - /************************************ EO2 ************************************/ EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL; @@ -883,211 +824,18 @@ _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) const _Eo_Class *op_klass = _eo_op_class_get(op); \ const char *_dom_name = (op_klass) ? op_klass->desc->name : NULL; \ ERR("in %s:%d: Can't execute function %s:%s (op 0x%x) for class '%s'. Aborting.", \ - file, line, _dom_name, _eo_op_id_name_get(op, op_klass->desc->version), op, \ + file, line, _dom_name, _eo_op_id_name_get(op), op, \ (klass) ? klass->desc->name : NULL); \ } \ while (0) -static inline Eina_Bool -_eo_op_internal(const char *file, int line, Eo_Base *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 && (op_type != op_desc->op_type)) - { - 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->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 - - { - const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op); - if (EINA_LIKELY(func != NULL)) - { - void *func_data = NULL; - Eo *calling_obj; - if (op_type == EO_OP_TYPE_REGULAR) - { - func_data = _eo_data_scope_get((_Eo_Object *) eo_ptr, func->src); - calling_obj = _eo_id_get((_Eo_Object *) eo_ptr); - } - else - { - calling_obj = _eo_class_id_get(cur_klass); - } - func->func(calling_obj, func_data, p_list); - return EINA_TRUE; - } - } - - /* Try composite objects */ - if (op_type == EO_OP_TYPE_REGULAR) - { - const _Eo_Object **comp_itr = ((_Eo_Object *) eo_ptr)->composites; - if (!comp_itr) return EINA_FALSE; - - for (unsigned int i = 0; i < ((_Eo_Object *) eo_ptr)->klass->composites_count; i++, comp_itr++) - if (*comp_itr) - { - if (_eo_op_internal(file, line, (Eo_Base *) (*comp_itr), (*comp_itr)->klass, op_type, op, p_list)) - { - return EINA_TRUE; - } - } - } - - return EINA_FALSE; -} - -static inline Eina_Bool -_eo_dov_internal(const char *file, int line, Eo_Base *obj, const _Eo_Class *klass, Eo_Op_Type op_type, va_list *p_list) -{ - Eina_Bool ret = EINA_TRUE; - Eo_Op op = EO_NOOP; - - op = va_arg(*p_list, Eo_Op); - while (op) - { - if (!_eo_op_internal(file, line, obj, klass, op_type, op, p_list)) - { - _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass); - ret = EINA_FALSE; - break; - } - op = va_arg(*p_list, Eo_Op); - } - - return ret; -} - -static inline Eina_Bool -_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; - - prev_error = obj->do_error; - _eo_ref(obj); - - ret = _eo_dov_internal(file, line, (Eo_Base *) obj, obj->klass, EO_OP_TYPE_REGULAR, p_list); - - if (obj->do_error) - ret = EINA_FALSE; - - obj->do_error = prev_error; - _eo_unref(obj); - - return ret; -} - -static inline Eina_Bool -_eo_class_dov_internal(const char *file, int line, _Eo_Class *klass, va_list *p_list) -{ - return _eo_dov_internal(file, line, (Eo_Base *) klass, klass, EO_OP_TYPE_CLASS, p_list); -} - -EAPI Eina_Bool -eo_do_internal(const char *file, int line, const Eo *eo_id, ...) -{ - Eina_Bool ret = EINA_TRUE; - va_list p_list; - Eina_Bool class_ref = _eo_is_a_class(eo_id); - - if (class_ref) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - - va_start(p_list, eo_id); - ret = _eo_class_dov_internal(file, line, klass, &p_list); - va_end(p_list); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - - va_start(p_list, eo_id); - ret = _eo_obj_dov_internal(file, line, obj, &p_list); - va_end(p_list); - } - - return ret; -} - -EAPI Eina_Bool -eo_vdo_internal(const char *file, int line, const Eo *eo_id, va_list *ops) -{ - Eina_Bool class_ref = _eo_is_a_class(eo_id); - - if (class_ref) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - return _eo_class_dov_internal(file, line, klass, ops); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - return _eo_obj_dov_internal(file, line, obj, ops); - } -} - -EAPI Eina_Bool -eo_do_super_internal(const char *file, int line, const Eo *eo_id, const Eo_Class *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_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); - - if (_eo_is_a_class(eo_id)) - { - EO_CLASS_POINTER_RETURN_VAL(eo_id, klass, EINA_FALSE); - - va_start(p_list, op); - nklass = _eo_kls_itr_next(klass, cur_klass, op); - op_ret = _eo_op_internal(file, line, (Eo_Base *) klass, nklass, EO_OP_TYPE_CLASS, op, &p_list); - va_end(p_list); - } - else - { - EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); - - va_start(p_list, op); - nklass = _eo_kls_itr_next(obj->klass, cur_klass, op); - op_ret = _eo_op_internal(file, line, (Eo_Base *) obj, nklass, EO_OP_TYPE_REGULAR, op, &p_list); - if (obj->do_error) - ret = EINA_FALSE; - va_end(p_list); - } - - if (!op_ret) - _EO_OP_ERR_NO_OP_PRINT(file, line, op, nklass); - - return (ret & op_ret); -} - EAPI const Eo_Class * eo_class_get(const Eo *eo_id) { if (_eo_is_a_class(eo_id)) { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); - if (_klass->desc->version == EO2_VERSION) - return eo2_class_class_get(); - else - return eo_class_class_get(); + return eo2_class_class_get(); } EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); @@ -1265,40 +1013,6 @@ _eo_class_constructor(_Eo_Class *klass) klass->desc->class_constructor(_eo_class_id_get(klass)); } -EAPI void -eo_class_funcs_set(Eo_Class *klass_id, const Eo_Op_Func_Description *func_descs) -{ - EO_CLASS_POINTER_RETURN(klass_id, klass); - - const Eo_Op_Func_Description *itr; - itr = func_descs; - if (itr) - { - for ( ; itr->op_type != EO_OP_TYPE_INVALID ; itr++) - { - const Eo_Op_Description *op_desc = _eo_op_id_desc_get(itr->op); - - if (EINA_UNLIKELY(!op_desc || (itr->op == EO_NOOP))) - { - ERR("Setting implementation for non-existent op 0x%x for class '%s'. Func index: %lu", itr->op, klass->desc->name, (unsigned long) (itr - func_descs)); - } - else if (EINA_LIKELY(itr->op_type == op_desc->op_type)) - { - _dich_func_set(klass, itr->op, itr->func); - } - else - { - ERR("Set function's op type (0x%x) is different than the one in the op description (%d) for op '%s:%s'. Func index: %lu", - itr->op_type, - (op_desc) ? op_desc->op_type : EO_OP_TYPE_REGULAR, - klass->desc->name, - (op_desc) ? op_desc->name : NULL, - (unsigned long) (itr - func_descs)); - } - } - } -} - static void eo_class_free(_Eo_Class *klass) { @@ -1324,56 +1038,6 @@ eo_class_free(_Eo_Class *klass) free(klass); } -/* DEVCHECK */ -static Eina_Bool -_eo_class_check_op_descs(const Eo_Class_Description *desc) -{ - const Eo_Op_Description *itr; - size_t i; - - if (desc->ops.count > 0) - { - if (!desc->ops.base_op_id) - { - ERR("Class '%s' has a non-zero ops count, but base_id is NULL.", - desc->name); - return EINA_FALSE; - } - - if (!desc->ops.descs) - { - ERR("Class '%s' has a non-zero ops count, but there are no descs.", - desc->name); - return EINA_FALSE; - } - } - - itr = desc->ops.descs; - for (i = 0 ; i < desc->ops.count ; i++, itr++) - { - if (itr->sub_op != i) - { - if (itr->name) - { - ERR("Wrong order in Ops description for class '%s'. Expected 0x%lx and got 0x%lx", desc->name, (unsigned long) i, (unsigned long) itr->sub_op); - } - else - { - ERR("Found too few Ops description for class '%s'. Expected 0x%lx descriptions, but found 0x%lx.", desc->name, (unsigned long) desc->ops.count, (unsigned long) i); - } - return EINA_FALSE; - } - } - - if (itr && itr->name) - { - ERR("Found extra Ops description for class '%s'. Expected %lu descriptions, but found more.", desc->name, (unsigned long) desc->ops.count); - return EINA_FALSE; - } - - return EINA_TRUE; -} - /* Not really called, just used for the ptr... */ static void _eo_class_isa_func(Eo *eo_id EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) @@ -1392,12 +1056,6 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(desc->name, NULL); - if (desc->version != EO2_VERSION) - { - if (!_eo_class_check_op_descs(desc)) - return NULL; - } - _Eo_Class *parent = _eo_class_pointer_get(parent_id); #ifndef HAVE_EO_ID if (parent && !EINA_MAGIC_CHECK((Eo_Base *) parent, EO_CLASS_EINA_MAGIC)) @@ -1635,16 +1293,13 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } } - if (desc->version == EO2_VERSION) + if (!_eo2_class_funcs_set(klass)) { - if (!_eo2_class_funcs_set(klass)) - { - eina_spinlock_free(&klass->objects.trash_lock); - eina_spinlock_free(&klass->iterators.trash_lock); - _dich_func_clean_all(klass); - free(klass); + eina_spinlock_free(&klass->objects.trash_lock); + eina_spinlock_free(&klass->iterators.trash_lock); + _dich_func_clean_all(klass); + free(klass); return NULL; - } } eina_spinlock_take(&_eo_class_creation_lock); @@ -1684,103 +1339,6 @@ eo_isa(const Eo *eo_id, const Eo_Class *klass_id) return (func && (func->func == _eo_class_isa_func)); } -// A little bit hacky, but does the job -static void -_eo_parent_internal_set(_Eo_Object *obj, ...) -{ - va_list p_list; - - va_start(p_list, obj); - _eo_op_internal(__FILE__, __LINE__, (Eo_Base *) obj, obj->klass, - EO_OP_TYPE_REGULAR, EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), - &p_list); - va_end(p_list); -} - -EAPI Eo * -eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id, ...) -{ - Eina_Bool do_err; - _Eo_Object *obj; - EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, NULL); - - if (parent_id) - { - EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, NULL); - } - - if (EINA_UNLIKELY(klass->desc->type != EO_CLASS_TYPE_REGULAR)) - { - ERR("in %s:%d: Class '%s' is not instantiate-able. Aborting.", file, line, klass->desc->name); - return NULL; - } - - eina_spinlock_take(&klass->objects.trash_lock); - obj = eina_trash_pop(&klass->objects.trash); - if (obj) - { - memset(obj, 0, klass->obj_size); - klass->objects.trash_count--; - } - else - { - obj = calloc(1, klass->obj_size); - } - eina_spinlock_release(&klass->objects.trash_lock); - - obj->refcount++; - obj->klass = klass; - if (klass->composites_count == 0) - obj->composites = NULL; - else - obj->composites = (const _Eo_Object **) - ((char *) obj + klass->obj_size - (klass->composites_count * sizeof(_Eo_Object *))); - -#ifndef HAVE_EO_ID - EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC); -#endif - Eo_Id obj_id = _eo_id_allocate(obj); - obj->header.id = obj_id; - - _eo_condtor_reset(obj); - - _eo_ref(obj); - - _eo_parent_internal_set(obj, parent_id); - - /* Run the relevant do stuff. */ - { - va_list p_list; - va_start(p_list, parent_id); - do_err = !_eo_obj_dov_internal(file, line, obj, &p_list); - va_end(p_list); - } - - if (EINA_UNLIKELY(do_err)) - { - ERR("in %s:%d, Object of class '%s' - One of the object constructors have failed.", - file, line, klass->desc->name); - goto fail; - } - - if (!obj->condtor_done) - { - ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", - file, line, klass->desc->name); - goto fail; - } - - _eo_unref(obj); - - return _eo_id_get(obj); - -fail: - /* Unref twice, once for the ref above, and once for the basic object ref. */ - _eo_unref(obj); - _eo_unref(obj); - return NULL; -} - EAPI Eo * eo_xref_internal(const char *file, int line, Eo *obj_id, const Eo *ref_obj_id) { @@ -1853,10 +1411,7 @@ EAPI void eo_del(const Eo *obj) { EO_OBJ_POINTER_RETURN(obj, _obj); - if (_obj->klass->desc->version == EO2_VERSION) - eo2_do((Eo *) obj, eo2_parent_set(NULL)); - else - eo_do((Eo *) obj, eo_parent_set(NULL)); + eo2_do((Eo *) obj, eo2_parent_set(NULL)); eo_unref(obj); } @@ -2106,7 +1661,7 @@ eo_init(void) EINA_LOG_STATE_INIT); /* bootstrap EO_CLASS_CLASS */ - (void) eo_class_class_get(); + (void) eo2_class_class_get(); if (_eo2_call_stack_key != 0) WRN("_eo2_call_stack_key already set, this should not happen."); @@ -2191,10 +1746,7 @@ eo_composite_attach(Eo *comp_obj_id, Eo *parent_id) comp_obj->composite = EINA_TRUE; *comp_dst = comp_obj; - if (comp_obj->klass->desc->version == EO2_VERSION) - eo2_do(comp_obj_id, eo2_parent_set(parent_id)); - else - eo_do(comp_obj_id, eo_parent_set(parent_id)); + eo2_do(comp_obj_id, eo2_parent_set(parent_id)); return EINA_TRUE; } @@ -2216,10 +1768,7 @@ eo_composite_detach(Eo *comp_obj_id, Eo *parent_id) { comp_obj->composite = EINA_FALSE; *comp_itr = NULL; - if (comp_obj->klass->desc->version == EO2_VERSION) - eo2_do(comp_obj_id, eo2_parent_set(NULL)); - else - eo_do(comp_obj_id, eo_parent_set(NULL)); + eo2_do(comp_obj_id, eo2_parent_set(NULL)); return EINA_TRUE; } } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 3cf4b8fd4c..936cabedbb 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -121,7 +121,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) { Private_Data *old_parent_pd; - old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); + old_parent_pd = eo_data_scope_get(pd->parent, EO2_BASE_CLASS); if (old_parent_pd) { old_parent_pd->children = eina_list_remove(old_parent_pd->children, @@ -140,7 +140,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) if (parent_id) { Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); + parent_pd = eo_data_scope_get(parent_id, EO2_BASE_CLASS); if (EINA_LIKELY(parent_pd != NULL)) { @@ -910,7 +910,7 @@ EAPI const Eina_Value_Type *EO2_DBG_INFO_TYPE = &_EO2_DBG_INFO_TYPE; /* EO_BASE_CLASS stuff */ -#define MY_CLASS EO_BASE_CLASS +#define MY_CLASS EO2_BASE_CLASS /* FIXME: Set proper type descriptions. */ // FIXME: eo2 multiple definition diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c deleted file mode 100644 index c83b19bb23..0000000000 --- a/src/lib/eo/eo_base_class.c +++ /dev/null @@ -1,1013 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "Eo.h" -#include "eo_ptr_indirection.h" -#include "eo_private.h" - -EAPI Eo_Op EO_BASE_BASE_ID = 0; - -static int event_freeze_count = 0; - -typedef struct _Eo_Callback_Description Eo_Callback_Description; - -typedef struct -{ - Eina_List *children; - Eo *parent; - - Eina_Inlist *generic_data; - Eo ***wrefs; - - Eo_Callback_Description *callbacks; - unsigned short walking_list; - unsigned short event_freeze_count; - Eina_Bool deletions_waiting : 1; -} Private_Data; - -typedef struct -{ - EINA_INLIST; - Eina_Stringshare *key; - void *data; - eo_base_data_free_func free_func; -} Eo_Generic_Data_Node; - -static void -_eo_generic_data_node_free(Eo_Generic_Data_Node *node) -{ - eina_stringshare_del(node->key); - if (node->free_func) - node->free_func(node->data); - free(node); -} - -static void -_eo_generic_data_del_all(Private_Data *pd) -{ - Eina_Inlist *nnode; - Eo_Generic_Data_Node *node = NULL; - - EINA_INLIST_FOREACH_SAFE(pd->generic_data, nnode, node) - { - pd->generic_data = eina_inlist_remove(pd->generic_data, - EINA_INLIST_GET(node)); - - _eo_generic_data_node_free(node); - } -} - -static void -_data_set(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = class_data; - - EO_PARAMETER_GET(const char *, key, list); - EO_PARAMETER_GET(const void *, data, list); - EO_PARAMETER_GET(eo_base_data_free_func, free_func, list); - - Eo_Generic_Data_Node *node; - - if (!key) return; - - eo_do(obj, eo_base_data_del(key)); - - node = malloc(sizeof(Eo_Generic_Data_Node)); - if (!node) return; - node->key = eina_stringshare_add(key); - node->data = (void *) data; - node->free_func = free_func; - pd->generic_data = eina_inlist_prepend(pd->generic_data, - EINA_INLIST_GET(node)); -} - -static void -_data_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - /* We don't really change it... */ - Eo_Generic_Data_Node *node; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const char *, key, list); - EO_PARAMETER_GET(void **, data, list); - - if (!data) return; - *data = NULL; - - if (!key) return; - - EINA_INLIST_FOREACH(pd->generic_data, node) - { - if (!strcmp(node->key, key)) - { - pd->generic_data = - eina_inlist_promote(pd->generic_data, EINA_INLIST_GET(node)); - *data = node->data; - return; - } - } -} - -static void -_parent_set(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(Eo *, parent_id, list); - - if (pd->parent == parent_id) - return ; - - if (eo_composite_is(obj) && pd->parent) - { - eo_composite_detach(obj, pd->parent); - } - - if (pd->parent) - { - Private_Data *old_parent_pd; - - old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); - if (old_parent_pd) - { - old_parent_pd->children = eina_list_remove(old_parent_pd->children, - obj); - } - else - { - ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.", - pd->parent, obj); - } - - eo_xunref(obj, pd->parent); - } - - /* Set new parent */ - if (parent_id) - { - Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); - - if (EINA_LIKELY(parent_pd != NULL)) - { - pd->parent = parent_id; - parent_pd->children = eina_list_append(parent_pd->children, - obj); - eo_xref(obj, pd->parent); - } - else - { - pd->parent = NULL; - ERR("New parent %p for object %p is not a valid Eo object.", - parent_id, obj); - } - } - else - { - pd->parent = NULL; - } -} - -static void -_parent_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(Eo **, parent_id, list); - - if (!parent_id) return ; - *parent_id = pd->parent; -} - - -/* Children accessor */ -typedef struct _Eo_Children_Iterator Eo_Children_Iterator; -struct _Eo_Children_Iterator -{ - Eina_Iterator iterator; - Eina_List *current; - _Eo_Object *obj; - Eo *obj_id; - -}; - -static Eina_Bool -_eo_children_iterator_next(Eo_Children_Iterator *it, void **data) -{ - if (!it->current) return EINA_FALSE; - - if (data) *data = eina_list_data_get(it->current); - it->current = eina_list_next(it->current); - - return EINA_TRUE; -} - -static Eo * -_eo_children_iterator_container(Eo_Children_Iterator *it) -{ - return it->obj_id; -} - -static void -_eo_children_iterator_free(Eo_Children_Iterator *it) -{ - _Eo_Class *klass; - _Eo_Object *obj; - - klass = (_Eo_Class*) it->obj->klass; - obj = it->obj; - - eina_spinlock_take(&klass->iterators.trash_lock); - if (klass->iterators.trash_count < 8) - { - klass->iterators.trash_count++; - eina_trash_push(&klass->iterators.trash, it); - } - else - { - free(it); - } - eina_spinlock_release(&klass->iterators.trash_lock); - - _eo_unref(obj); -} - -static void -_children_iterator_new(Eo *obj_id, void *class_data, va_list *list) -{ - Private_Data *pd = class_data; - _Eo_Class *klass; - - EO_PARAMETER_GET(Eo_Children_Iterator **, it, list); - EO_OBJ_POINTER_RETURN(obj_id, obj); - - if (!it) return ; - *it = NULL; - - if (!pd->children) return ; - - klass = (_Eo_Class *) obj->klass; - - eina_spinlock_take(&klass->iterators.trash_lock); - *it = eina_trash_pop(&klass->iterators.trash); - if (*it) - { - klass->iterators.trash_count--; - memset(*it, 0, sizeof (Eo_Children_Iterator)); - } - else - { - *it = calloc(1, sizeof (Eo_Children_Iterator)); - } - eina_spinlock_release(&klass->iterators.trash_lock); - if (!*it) return ; - - EINA_MAGIC_SET(&(*it)->iterator, EINA_MAGIC_ITERATOR); - (*it)->current = obj->children; - (*it)->obj = _eo_ref(obj); - (*it)->obj_id = obj_id; - - (*it)->iterator.next = FUNC_ITERATOR_NEXT(_eo_children_iterator_next); - (*it)->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eo_children_iterator_container); - (*it)->iterator.free = FUNC_ITERATOR_FREE(_eo_children_iterator_free); -} - -static void -_dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, - va_list *data EINA_UNUSED) -{ /* No info required in the meantime */ - return; -} - -static void -_data_del(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Eo_Generic_Data_Node *node; - Private_Data *pd = class_data; - - EO_PARAMETER_GET(const char *, key, list); - - if (!key) return; - - EINA_INLIST_FOREACH(pd->generic_data, node) - { - if (!strcmp(node->key, key)) - { - pd->generic_data = eina_inlist_remove(pd->generic_data, - EINA_INLIST_GET(node)); - _eo_generic_data_node_free(node); - return; - } - } -} - -/* Weak reference. */ - -static inline size_t -_wref_count(Private_Data *pd) -{ - size_t count = 0; - if (!pd->wrefs) - return 0; - - Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) - count++; - - return count; -} - -static void -_wref_add(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - size_t count; - Eo ***tmp; - - EO_PARAMETER_GET(Eo **, wref, list); - - count = _wref_count(pd); - count += 1; /* New wref. */ - - tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1)); - if (!tmp) return ; - pd->wrefs = tmp; - - pd->wrefs[count - 1] = wref; - pd->wrefs[count] = NULL; - *wref = obj; -} - -static void -_wref_del(Eo *obj, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - size_t count; - - EO_PARAMETER_GET(Eo **, wref, list); - - if (*wref != obj) - { - ERR("Wref is a weak ref to %p, while this function was called on %p.", - *wref, obj); - return; - } - - if (!pd->wrefs) - { - ERR("There are no weak refs for object %p", obj); - *wref = NULL; - return; - } - - /* Move the last item in the array instead of the current wref. */ - count = _wref_count(pd); - - { - Eo ***itr; - for (itr = pd->wrefs ; *itr ; itr++) - { - if (*itr == wref) - { - *itr = pd->wrefs[count - 1]; - break; - } - } - - if (!*itr) - { - ERR("Wref %p is not associated with object %p", wref, obj); - *wref = NULL; - return; - } - } - - if (count > 1) - { - Eo ***tmp; - // No count--; because of the NULL that is not included in the count. */ - tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * count); - if (!tmp) return ; - pd->wrefs = tmp; - pd->wrefs[count - 1] = NULL; - } - else - { - free(pd->wrefs); - pd->wrefs = NULL; - } - - *wref = NULL; -} - -static inline void -_wref_destruct(Private_Data *pd) -{ - Eo ***itr; - if (!pd->wrefs) - return; - - for (itr = pd->wrefs ; *itr ; itr++) - { - **itr = NULL; - } - - free(pd->wrefs); -} - -/* EOF Weak reference. */ - -/* Event callbacks */ - -/* Callbacks */ - -struct _Eo_Callback_Description -{ - Eo_Callback_Description *next; - - union - { - Eo_Callback_Array_Item item; - const Eo_Callback_Array_Item *item_array; - } items; - - void *func_data; - Eo_Callback_Priority priority; - - Eina_Bool delete_me : 1; - Eina_Bool func_array : 1; -}; - -/* Actually remove, doesn't care about walking list, or delete_me */ -static void -_eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) -{ - Eo_Callback_Description *itr, *pitr = NULL; - - itr = pd->callbacks; - - for ( ; itr ; ) - { - Eo_Callback_Description *titr = itr; - itr = itr->next; - - if (titr == cb) - { - if (pitr) - { - pitr->next = titr->next; - } - else - { - pd->callbacks = titr->next; - } - free(titr); - } - else - { - pitr = titr; - } - } -} - -/* Actually remove, doesn't care about walking list, or delete_me */ -static void -_eo_callback_remove_all(Private_Data *pd) -{ - while (pd->callbacks) - { - Eo_Callback_Description *next = pd->callbacks->next; - free(pd->callbacks); - pd->callbacks = next; - } -} - -static inline void -_eo_callbacks_clear(Private_Data *pd) -{ - Eo_Callback_Description *cb = NULL; - - /* If there are no deletions waiting. */ - if (!pd->deletions_waiting) - return; - - /* Abort if we are currently walking the list. */ - if (pd->walking_list > 0) - return; - - pd->deletions_waiting = EINA_FALSE; - - for (cb = pd->callbacks ; cb ; ) - { - Eo_Callback_Description *titr = cb; - cb = cb->next; - - if (titr->delete_me) - { - _eo_callback_remove(pd, titr); - } - } -} - -static void -_eo_callbacks_sorted_insert(Private_Data *pd, Eo_Callback_Description *cb) -{ - Eo_Callback_Description *itr, *itrp = NULL; - for (itr = pd->callbacks ; itr && (itr->priority < cb->priority) ; - itr = itr->next) - { - itrp = itr; - } - - if (itrp) - { - cb->next = itrp->next; - itrp->next = cb; - } - else - { - cb->next = pd->callbacks; - pd->callbacks = cb; - } -} - -static void -_ev_cb_priority_add(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_ENUM_GET(Eo_Callback_Priority, priority, list); - EO_PARAMETER_GET(Eo_Event_Cb, func, list); - EO_PARAMETER_GET(const void *, data, list); - - cb = calloc(1, sizeof(*cb)); - if (!cb) return ; - cb->items.item.desc = desc; - cb->items.item.func = func; - cb->func_data = (void *) data; - cb->priority = priority; - _eo_callbacks_sorted_insert(pd, cb); - - { - const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, arr, NULL)); - } -} - -static void -_ev_cb_del(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo_Event_Cb, func, list); - EO_PARAMETER_GET(void *, user_data, list); - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if ((cb->items.item.desc == desc) && (cb->items.item.func == func) && - (cb->func_data == user_data)) - { - const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - - cb->delete_me = EINA_TRUE; - pd->deletions_waiting = EINA_TRUE; - _eo_callbacks_clear(pd); - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, arr, NULL)); - return; - } - } - - DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); -} - -static void -_ev_cb_array_priority_add(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Callback_Array_Item *, array, list); - EO_PARAMETER_ENUM_GET(Eo_Callback_Priority, priority, list); - EO_PARAMETER_GET(const void *, data, list); - - cb = calloc(1, sizeof(*cb)); - if (!cb) return ; - cb->func_data = (void *) data; - cb->priority = priority; - cb->items.item_array = array; - cb->func_array = EINA_TRUE; - _eo_callbacks_sorted_insert(pd, cb); - - { - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, array, NULL)); - } -} - -static void -_ev_cb_array_del(Eo *obj, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Callback_Array_Item *, array, list); - EO_PARAMETER_GET(void *, user_data, list); - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if ((cb->items.item_array == array) && (cb->func_data == user_data)) - { - cb->delete_me = EINA_TRUE; - pd->deletions_waiting = EINA_TRUE; - _eo_callbacks_clear(pd); - - eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, array, NULL)); - return; - } - } - - DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data); -} - -static void -_ev_cb_call(Eo *obj_id, void *class_data, va_list *list) -{ - Eo_Callback_Description *cb; - Private_Data *pd = (Private_Data *) class_data; - - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(void *, event_info, list); - EO_PARAMETER_GET(Eina_Bool *, ret, list); - - EO_OBJ_POINTER_RETURN(obj_id, obj); - - if (ret) *ret = EINA_TRUE; - - _eo_ref(obj); - pd->walking_list++; - - for (cb = pd->callbacks ; cb ; cb = cb->next) - { - if (!cb->delete_me) - { - if (cb->func_array) - { - const Eo_Callback_Array_Item *it; - - for (it = cb->items.item_array ; it->func ; it++) - { - if (it->desc != desc) - continue; - if (!it->desc->unfreezable && - (event_freeze_count || pd->event_freeze_count)) - continue; - - /* Abort callback calling if the func says so. */ - if (!it->func((void *) cb->func_data, obj_id, desc, - (void *) event_info)) - { - if (ret) *ret = EINA_FALSE; - goto end; - } - } - } - else - { - if (cb->items.item.desc != desc) - continue; - if ((!cb->items.item.desc - || !cb->items.item.desc->unfreezable) && - (event_freeze_count || pd->event_freeze_count)) - continue; - - /* Abort callback calling if the func says so. */ - if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, - (void *) event_info)) - { - if (ret) *ret = EINA_FALSE; - goto end; - } - } - } - } - -end: - pd->walking_list--; - _eo_callbacks_clear(pd); - _eo_unref(obj); -} - -static Eina_Bool -_eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) -{ - (void) obj; - Eo *new_obj = (Eo *) data; - Eina_Bool ret; - - eo_do(new_obj, eo_event_callback_call(desc, event_info, &ret)); - - return ret; -} - -/* FIXME: Change default priority? Maybe call later? */ -static void -_ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo *, new_obj, list); - - /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - - eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj)); -} - -static void -_ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); - EO_PARAMETER_GET(Eo *, new_obj, list); - - /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - - eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj)); -} - -static void -_ev_freeze(Eo *obj EINA_UNUSED, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = (Private_Data *) class_data; - pd->event_freeze_count++; -} - -static void -_ev_thaw(Eo *obj, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = (Private_Data *) class_data; - if (pd->event_freeze_count > 0) - { - pd->event_freeze_count--; - } - else - { - ERR("Events for object %p have already been thawed.", obj); - } -} - -static void -_ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) -{ - Private_Data *pd = (Private_Data *) class_data; - EO_PARAMETER_GET(int *, ret, list); - - *ret = pd->event_freeze_count; -} - -static void -_ev_global_freeze(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - event_freeze_count++; -} - -static void -_ev_global_thaw(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - if (event_freeze_count > 0) - { - event_freeze_count--; - } - else - { - ERR("Global events have already been thawed."); - } -} - -static void -_ev_global_freeze_get(Eo_Class *klass EINA_UNUSED, void *data EINA_UNUSED, va_list *list) -{ - EO_PARAMETER_GET(int *, ret, list); - - *ret = event_freeze_count; -} - -/* Eo_Dbg */ -EAPI void -eo_dbg_info_free(Eo_Dbg_Info *info) -{ - eina_value_flush(&(info->value)); - free(info); -} - -static Eina_Bool -_eo_dbg_info_setup(const Eina_Value_Type *type, void *mem) -{ - memset(mem, 0, type->value_size); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_flush(const Eina_Value_Type *type EINA_UNUSED, void *_mem) -{ - Eo_Dbg_Info *mem = *(Eo_Dbg_Info **) _mem; - eina_stringshare_del(mem->name); - eina_value_flush(&(mem->value)); - free(mem); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, void *_dst) -{ - const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src; - Eo_Dbg_Info **dst = _dst; - - *dst = calloc(1, sizeof(Eo_Dbg_Info)); - if (!*dst) return EINA_FALSE; - (*dst)->name = eina_stringshare_ref((*src)->name); - eina_value_copy(&((*src)->value), &((*dst)->value)); - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem) -{ - /* FIXME: For the meanwhile, just use the inner type for the value. */ - const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) type_mem; - if (convert == EINA_VALUE_TYPE_STRINGSHARE || - convert == EINA_VALUE_TYPE_STRING) - { - Eina_Bool ret; - const char *other_mem; - char *inner_val = eina_value_to_string(&(*src)->value); - other_mem = inner_val; - ret = eina_value_type_pset(convert, convert_mem, &other_mem); - free(inner_val); - return ret; - } - return EINA_FALSE; -} - -static Eina_Bool -_eo_dbg_info_pset(const Eina_Value_Type *type EINA_UNUSED, void *_mem, const void *_ptr) -{ - Eo_Dbg_Info **mem = _mem; - if (*mem) - free(*mem); - *mem = (void *) _ptr; - return EINA_TRUE; -} - -static Eina_Bool -_eo_dbg_info_pget(const Eina_Value_Type *type EINA_UNUSED, const void *_mem, void *_ptr) -{ - Eo_Dbg_Info **ptr = _ptr; - *ptr = (void *) _mem; - return EINA_TRUE; -} - -static const Eina_Value_Type _EO_DBG_INFO_TYPE = { - EINA_VALUE_TYPE_VERSION, - sizeof(Eo_Dbg_Info *), - "Eo_Dbg_Info_Ptr", - _eo_dbg_info_setup, - _eo_dbg_info_flush, - _eo_dbg_info_copy, - NULL, - _eo_dbg_info_convert_to, - NULL, - NULL, - _eo_dbg_info_pset, - _eo_dbg_info_pget -}; - -EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE; - - -/* EOF event callbacks */ - - -/* EO_BASE_CLASS stuff */ -#define MY_CLASS EO_BASE_CLASS - -/* FIXME: Set proper type descriptions. */ -EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = - EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); -EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = - EO_EVENT_DESCRIPTION("callback,del", "A callback was deleted."); -EAPI const Eo_Event_Description _EO_EV_DEL = - EO_HOT_EVENT_DESCRIPTION("del", "Obj is being deleted."); - -static void -_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) -{ - DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); - - _eo_condtor_done(obj); -} - -static void -_destructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED) -{ - Private_Data *pd = class_data; - Eo *child; - - DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); - - EINA_LIST_FREE(pd->children, child) - eo_do(child, eo_parent_set(NULL)); - - _eo_generic_data_del_all(class_data); - _wref_destruct(class_data); - _eo_callback_remove_all(class_data); - - _eo_condtor_done(obj); -} - -static void -_class_constructor(Eo_Class *klass) -{ - event_freeze_count = 0; - - const Eo_Op_Func_Description func_desc[] = { - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_PARENT_SET), _parent_set), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_PARENT_GET), _parent_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW), _children_iterator_new), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), _data_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), _wref_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), _wref_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), _ev_cb_priority_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), _ev_cb_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD), _ev_cb_array_priority_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL), _ev_cb_array_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), _ev_cb_call), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), _ev_cb_forwarder_add), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), _ev_cb_forwarder_del), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE), _ev_freeze), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW), _ev_thaw), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), _ev_freeze_get), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE), _ev_global_freeze), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW), _ev_global_thaw), - EO_OP_FUNC_CLASS(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), _ev_global_freeze_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get), - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_CONSTRUCTOR, "Constructor"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DESTRUCTOR, "Destructor"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_PARENT_SET, "Set parent"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_PARENT_GET, "Get parent"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_CHILDREN_ITERATOR_NEW, "Children Iterator"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_SET, "Set data for key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_GET, "Get data for key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_DEL, "Del key."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_WREF_ADD, "Add a weak ref to the object."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_WREF_DEL, "Delete the weak ref."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD, "Add an event callback with a priority."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL, "Delete an event callback"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_PRIORITY_ADD, "Add an event callback array with a priority."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_ARRAY_DEL, "Delete an event callback array"), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL, "Call the event callbacks for an event."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD, "Add an event forwarder."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL, "Delete an event forwarder."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_FREEZE, "Freezes events."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_THAW, "Thaws events."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_EVENT_FREEZE_GET, "Get event freeze counter."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE, "Freezes events globally."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW, "Thaws events globally."), - EO_OP_DESCRIPTION_CLASS(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET, "Get global event freeze counter."), - EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DBG_INFO_GET, "Get debug info list for obj."), - EO_OP_DESCRIPTION_SENTINEL -}; - -static const Eo_Event_Description *event_desc[] = { - EO_EV_CALLBACK_ADD, - EO_EV_CALLBACK_DEL, - EO_EV_DEL, - NULL -}; - -static const Eo_Class_Description class_desc = { - EO_VERSION, - "Eo_Base", - EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO_CLASS_DESCRIPTION_OPS(&EO_BASE_BASE_ID, op_desc, EO_BASE_SUB_ID_LAST), - event_desc, - sizeof(Private_Data), - _class_constructor, - NULL -}; - -EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo_class_class.c b/src/lib/eo/eo_class_class.c deleted file mode 100644 index 654e2efcca..0000000000 --- a/src/lib/eo/eo_class_class.c +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "Eo.h" - -EAPI Eo_Op EO_CLASS_CLASS_BASE_ID = 0; - -static const Eo_Class_Description class_desc = { - EO_VERSION, - "Eo_Abstract_Class", - EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO_CLASS_DESCRIPTION_OPS(&EO_CLASS_CLASS_BASE_ID, NULL, EO_CLASS_CLASS_SUB_ID_LAST), - NULL, - 0, - NULL, - NULL -}; - -EO_DEFINE_CLASS(eo_class_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index b398ff080f..17b3e8aedb 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -213,21 +213,12 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) const _Eo_Class *klass = obj->klass; - if (klass->desc->version == EO2_VERSION) - eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); - else - eo_do(_eo_id_get(obj), eo_event_callback_call(EO_EV_DEL, NULL, NULL)); + eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); _eo_condtor_reset(obj); - if (klass->desc->version == EO2_VERSION) - { - // FIXME: eo2 - do_err = EINA_FALSE; - eo2_do(_eo_id_get(obj), eo2_destructor();); - } - else - do_err = !eo_do(_eo_id_get(obj), eo_destructor()); + do_err = EINA_FALSE; + eo2_do(_eo_id_get(obj), eo2_destructor();); if (EINA_UNLIKELY(do_err)) { From 80faa56ed3399fb10dafa0a88831f52e6769a7d4 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 09:26:45 +0100 Subject: [PATCH 155/169] Eo2: Removed more Eo1 code. --- src/lib/eo/Eo.h | 128 +--------------------------------------- src/lib/eo/eo.c | 3 - src/lib/eo/eo_private.h | 3 + 3 files changed, 5 insertions(+), 129 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index bd71f21257..bef8f915b0 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -241,15 +241,6 @@ typedef unsigned int Eo_Op; */ #define EO_NOOP ((Eo_Op) 0) -/** - * @typedef eo_op_func_type - * The type of the Op functions. This is the type of the functions used by - * Eo. - * - * @see eo_op_func_type_class - */ -typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list); - /** * @addtogroup Eo_Events Eo's Event Handling * @{ @@ -368,66 +359,6 @@ enum _Eo_Class_Type */ typedef enum _Eo_Class_Type Eo_Class_Type; -/** - * @struct _Eo_Op_Func_Description - * Used to associate an Op with a func. - * @see eo_class_funcs_set - */ -struct _Eo_Op_Func_Description -{ - Eo_Op op; /**< The op */ - eo_op_func_type func; /**< The function to call for the op. */ - Eo_Op_Type op_type; /**< The type of the op */ -}; - -/** - * @typedef Eo_Op_Func_Description - * A convenience typedef for #_Eo_Op_Func_Description - */ -typedef struct _Eo_Op_Func_Description Eo_Op_Func_Description; - -/** - * @def EO_OP_FUNC(op, func) - * A convenience macro to be used when populating the #Eo_Op_Func_Description - * array. - */ -#define EO_OP_FUNC(op, func) { op, EO_TYPECHECK(eo_op_func_type, func), EO_OP_TYPE_REGULAR } - -/** - * @def EO_OP_FUNC_CLASS(op, func) - * A convenience macro to be used when populating the #Eo_Op_Func_Description - * array. - * The same as #EO_OP_FUNC but for class functions. - * - * @see EO_OP_FUNC - */ -#define EO_OP_FUNC_CLASS(op, func) { op, EO_TYPECHECK(eo_op_func_type, func), EO_OP_TYPE_CLASS } - -/** - * @def EO_OP_FUNC_SENTINEL - * A convenience macro to be used when populating the #Eo_Op_Func_Description - * array. It must appear at the end of the ARRAY. - */ -#define EO_OP_FUNC_SENTINEL { 0, NULL, EO_OP_TYPE_INVALID } - -/** - * @struct _Eo_Op_Description - * This struct holds the description of a specific op. - */ -struct _Eo_Op_Description -{ - Eo_Op sub_op; /**< The sub_id of the op in it's class. */ - const char *name; /**< The name of the op. */ - const char *doc; /**< Explanation about the Op. */ - Eo_Op_Type op_type; /**< The type of the Op. */ -}; - -/** - * @typedef Eo_Op_Description - * A convenience typedef for #_Eo_Op_Description - */ -typedef struct _Eo_Op_Description Eo_Op_Description; - /** * @def EO_VERSION * The current version of EO. @@ -455,7 +386,6 @@ struct _Eo_Class_Description const char *name; /**< The name of the class. */ Eo_Class_Type type; /**< The type of the class. */ struct { - Eo_Op *base_op_id; Eo2_Op_Description *descs2; size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ @@ -471,60 +401,6 @@ struct _Eo_Class_Description */ typedef struct _Eo_Class_Description Eo_Class_Description; -/** - * @def EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) - * An helper macro to help populating #Eo_Class_Description. - * @param base_op_id A pointer to the base op id of the class. - * @param op_descs the op descriptions array. - * @param count the number of ops in the op descriptions array. - */ -#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, NULL, count } - -/** - * @def EO_OP_DESCRIPTION(op, doc) - * An helper macro to help populating #Eo_Op_Description - * @param sub_id The sub id of the op being described. - * @param doc Additional doc for the op. - * @see Eo_Op_Description - * @see EO_OP_DESCRIPTION_CLASS - * @see EO_OP_DESCRIPTION_SENTINEL - */ -#define EO_OP_DESCRIPTION(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_REGULAR } - -/** - * @def EO_OP_DESCRIPTION_CLASS(op, doc) - * An helper macro to help populating #Eo_Op_Description - * This macro is the same as EO_OP_DESCRIPTION but indicates that the op's - * implementation is of type CLASS. - * @param sub_id The sub id of the op being described. - * @param doc Additional doc for the op. - * @see Eo_Op_Description - * @see EO_OP_DESCRIPTION - * @see EO_OP_DESCRIPTION_SENTINEL - */ -#define EO_OP_DESCRIPTION_CLASS(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_CLASS } - -/** - * @def EO_OP_DESCRIPTION_SENTINEL - * An helper macro to help populating #Eo_Op_Description - * Should be placed at the end of the array. - * @see Eo_Op_Description - * @see EO_OP_DESCRIPTION - */ -#define EO_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, EO_OP_TYPE_INVALID } - -/** - * @def EO_PARAMETER_GET - * An helper macro to get parameter with less mistake - */ -#define EO_PARAMETER_GET(Type, Name, List) Type Name = va_arg(*List, Type); - -/** - * @def EO_PARAMETER_ENUM_GET - * An helper macro to get parameter that are enum with less mistake (require to ask an int) - */ -#define EO_PARAMETER_ENUM_GET(Type, Name, List) Type Name = va_arg(*List, int); - /** * @brief Create a new class. * @param desc the class description to create the class with. @@ -586,8 +462,8 @@ EAPI Eina_Bool eo_shutdown(void); #define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) // Helpers macro to help populating #Eo_Class_Description. -#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, NULL, 0} -#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { NULL, op_descs, EO2_OP_DESC_SIZE(op_descs) } +#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, 0} +#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { op_descs, EO2_OP_DESC_SIZE(op_descs) } // to fetch internal function and object data at once typedef struct _Eo2_Op_Call_Data diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 24b515f2fe..9f4222a789 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -871,9 +871,6 @@ _eo_class_base_op_init(_Eo_Class *klass) klass->base_id = _eo_ops_last_id; - if (desc->ops.base_op_id) - *(desc->ops.base_op_id) = klass->base_id; - _eo_ops_last_id += desc->ops.count + 1; klass->chain_size = DICH_CHAIN1(_eo_ops_last_id) + 1; diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 17b3e8aedb..ebe16682f4 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -109,6 +109,9 @@ struct _Eo_Object /* [composite*] */ }; +/* FIXME: Change the type to something generic that makes sense for eo2 */ +typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list); + typedef struct _Dich_Chain1 Dich_Chain1; typedef struct From c32bb4fe958cca857f7f74171bc1be6b53c4fe99 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 09:46:34 +0100 Subject: [PATCH 156/169] Eo2: Updated naming Eo2->Eo. --- src/lib/eo/Eo.h | 220 +++++++------ src/lib/eo/eo.c | 190 +++++------ src/lib/eo/eo2_base_class.c | 156 ++++----- src/lib/eo/eo2_class_class.c | 8 +- src/lib/eo/eo_private.h | 6 +- src/tests/eo/access/access_inherit.c | 12 +- src/tests/eo/access/access_main.c | 4 +- src/tests/eo/access/access_simple.c | 16 +- .../composite_objects_comp.c | 24 +- .../composite_objects_main.c | 14 +- .../composite_objects_simple.c | 20 +- src/tests/eo/constructors/constructors_main.c | 22 +- .../eo/constructors/constructors_mixin.c | 24 +- .../eo/constructors/constructors_simple.c | 36 +-- .../eo/constructors/constructors_simple2.c | 14 +- .../eo/constructors/constructors_simple3.c | 12 +- .../eo/constructors/constructors_simple4.c | 4 +- .../eo/constructors/constructors_simple5.c | 12 +- .../eo/constructors/constructors_simple6.c | 14 +- .../eo/constructors/constructors_simple7.c | 12 +- .../function_overrides_inherit.c | 4 +- .../function_overrides_inherit2.c | 32 +- .../function_overrides_inherit3.c | 12 +- .../function_overrides_main.c | 34 +- .../function_overrides_simple.c | 30 +- src/tests/eo/interface/interface_interface.c | 12 +- src/tests/eo/interface/interface_interface2.c | 12 +- src/tests/eo/interface/interface_main.c | 10 +- src/tests/eo/interface/interface_simple.c | 30 +- src/tests/eo/mixin/mixin_inherit.c | 12 +- src/tests/eo/mixin/mixin_main.c | 12 +- src/tests/eo/mixin/mixin_mixin.c | 24 +- src/tests/eo/mixin/mixin_mixin2.c | 22 +- src/tests/eo/mixin/mixin_mixin3.c | 22 +- src/tests/eo/mixin/mixin_mixin4.c | 4 +- src/tests/eo/mixin/mixin_simple.c | 22 +- src/tests/eo/signals/signals_main.c | 110 +++---- src/tests/eo/signals/signals_simple.c | 26 +- src/tests/eo/suite/eo_test_call_errors.c | 18 +- src/tests/eo/suite/eo_test_class_errors.c | 90 +++--- src/tests/eo/suite/eo_test_class_simple.c | 44 +-- src/tests/eo/suite/eo_test_general.c | 300 +++++++++--------- src/tests/eo/suite/eo_test_threaded_calls.c | 28 +- src/tests/eo/suite/eo_test_value.c | 4 +- 44 files changed, 865 insertions(+), 869 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index bef8f915b0..6258960f9f 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -365,14 +365,14 @@ typedef enum _Eo_Class_Type Eo_Class_Type; */ #define EO_VERSION 2 -typedef struct _Eo2_Op_Description +typedef struct _Eo_Op_Description { void *api_func; /**< The EAPI function offering this op. */ void *func; /**< The static function to call for the op. */ Eo_Op op; /**< The op. */ Eo_Op_Type op_type; /**< The type of the Op. */ const char *doc; /**< Explanation about the Op. */ -} Eo2_Op_Description; +} Eo_Op_Description; /** * @struct _Eo_Class_Description @@ -386,7 +386,7 @@ struct _Eo_Class_Description const char *name; /**< The name of the class. */ Eo_Class_Type type; /**< The type of the class. */ struct { - Eo2_Op_Description *descs2; + Eo_Op_Description *descs2; size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ const Eo_Event_Description **events; /**< The event descriptions for this class. */ @@ -454,141 +454,137 @@ EAPI Eina_Bool eo_init(void); */ EAPI Eina_Bool eo_shutdown(void); -/************************************ EO2 ************************************/ - -#define EO2_VERSION EO_VERSION - -// computes size of Eo2_Op_Description[] -#define EO2_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) +// computes size of Eo_Op_Description[] +#define EO_OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(*desc) - 1) // Helpers macro to help populating #Eo_Class_Description. -#define EO2_CLASS_DESCRIPTION_NOOPS() { NULL, 0} -#define EO2_CLASS_DESCRIPTION_OPS(op_descs) { op_descs, EO2_OP_DESC_SIZE(op_descs) } +#define EO_CLASS_DESCRIPTION_NOOPS() { NULL, 0} +#define EO_CLASS_DESCRIPTION_OPS(op_descs) { op_descs, EO_OP_DESC_SIZE(op_descs) } // to fetch internal function and object data at once -typedef struct _Eo2_Op_Call_Data +typedef struct _Eo_Op_Call_Data { Eo *obj; - Eo_Class *klass; // remove this not necessary in Eo2_Hook_Call + Eo_Class *klass; // remove this not necessary in Eo_Hook_Call void *func; void *data; -} Eo2_Op_Call_Data; +} Eo_Op_Call_Data; -typedef void (*Eo2_Hook_Call)(const Eo_Class *klass_id, const Eo *obj, void *func, ...); +typedef void (*Eo_Hook_Call)(const Eo_Class *klass_id, const Eo *obj, void *func, ...); -EAPI extern Eo2_Hook_Call eo2_hook_call_pre; -EAPI extern Eo2_Hook_Call eo2_hook_call_post; +EAPI extern Eo_Hook_Call eo_hook_call_pre; +EAPI extern Eo_Hook_Call eo_hook_call_post; -// to pass the internal function call to EO2_FUNC_BODY (as Func parameter) -#define EO2_FUNC_CALL(...) __VA_ARGS__ +// to pass the internal function call to EO_FUNC_BODY (as Func parameter) +#define EO_FUNC_CALL(...) __VA_ARGS__ -#define EO2_HOOK_CALL_PREPARE(Hook) \ +#define EO_HOOK_CALL_PREPARE(Hook) \ if (Hook) \ Hook(call.klass, call.obj, call.func); -#define EO2_HOOK_CALL_PREPAREV(Hook, ...) \ +#define EO_HOOK_CALL_PREPAREV(Hook, ...) \ if (Hook) \ Hook(call.klass, call.obj, call.func, __VA_ARGS__); // cache OP id, get real fct and object data then do the call -#define EO2_FUNC_COMMON_OP(Name, DefRet) \ - Eo2_Op_Call_Data call; \ +#define EO_FUNC_COMMON_OP(Name, DefRet) \ + Eo_Op_Call_Data call; \ static Eo_Op op = EO_NOOP; \ if (op == EO_NOOP) \ - op = _eo2_api_op_id_get((void*) Name, __FILE__, __LINE__); \ - if (!_eo2_call_resolve(#Name, op, &call, __FILE__, __LINE__)) return DefRet; \ - _Eo2_##Name##_func _func_ = (_Eo2_##Name##_func) call.func; \ + op = _eo_api_op_id_get((void*) Name, __FILE__, __LINE__); \ + if (!_eo_call_resolve(#Name, op, &call, __FILE__, __LINE__)) return DefRet; \ + _Eo_##Name##_func _func_ = (_Eo_##Name##_func) call.func; \ // to define an EAPI function -#define EO2_FUNC_BODY(Name, Ret, DefRet) \ +#define EO_FUNC_BODY(Name, Ret, DefRet) \ Ret \ Name(void) \ { \ - typedef Ret (*_Eo2_##Name##_func)(Eo *, void *obj_data); \ + typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data); \ Ret _r; \ - EO2_FUNC_COMMON_OP(Name, DefRet); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ + EO_FUNC_COMMON_OP(Name, DefRet); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_pre); \ _r = _func_(call.obj, call.data); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_post); \ return _r; \ } -#define EO2_VOID_FUNC_BODY(Name) \ +#define EO_VOID_FUNC_BODY(Name) \ void \ Name(void) \ { \ - typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data); \ - EO2_FUNC_COMMON_OP(Name, ); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_pre); \ + typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data); \ + EO_FUNC_COMMON_OP(Name, ); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_pre); \ _func_(call.obj, call.data); \ - EO2_HOOK_CALL_PREPARE(eo2_hook_call_post); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_post); \ } -#define EO2_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ +#define EO_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ Ret \ Name(__VA_ARGS__) \ { \ - typedef Ret (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ + typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ Ret _r; \ - EO2_FUNC_COMMON_OP(Name, DefRet); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ + EO_FUNC_COMMON_OP(Name, DefRet); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, Arguments); \ _r = _func_(call.obj, call.data, Arguments); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_post, Arguments); \ return _r; \ } -#define EO2_VOID_FUNC_BODYV(Name, Arguments, ...) \ +#define EO_VOID_FUNC_BODYV(Name, Arguments, ...) \ void \ Name(__VA_ARGS__) \ { \ - typedef void (*_Eo2_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - EO2_FUNC_COMMON_OP(Name, ); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_pre, Arguments); \ + typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ + EO_FUNC_COMMON_OP(Name, ); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, Arguments); \ _func_(call.obj, call.data, Arguments); \ - EO2_HOOK_CALL_PREPAREV(eo2_hook_call_post, Arguments); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_post, Arguments); \ } // OP ID of an overriding function -#define EO2_OP_OVERRIDE ((Eo_Op) -1) +#define EO_OP_OVERRIDE ((Eo_Op) -1) -#define EO2_OP_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} -#define EO2_OP_CLASS_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_CLASS, _doc} -#define EO2_OP_FUNC_OVERRIDE(_api, _private) {_api, _private, EO2_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} -#define EO2_OP_CLASS_FUNC_OVERRIDE(_api, _private) {_api, _private, EO2_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} -#define EO2_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} +#define EO_OP_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_REGULAR, _doc} +#define EO_OP_CLASS_FUNC(_api, _private, _doc) {_api, _private, EO_NOOP, EO_OP_TYPE_CLASS, _doc} +#define EO_OP_FUNC_OVERRIDE(_api, _private) {_api, _private, EO_OP_OVERRIDE, EO_OP_TYPE_REGULAR, NULL} +#define EO_OP_CLASS_FUNC_OVERRIDE(_api, _private) {_api, _private, EO_OP_OVERRIDE, EO_OP_TYPE_CLASS, NULL} +#define EO_OP_SENTINEL { NULL, NULL, 0, EO_OP_TYPE_INVALID, NULL} // returns the OP id corresponding to the given api_func -EAPI Eo_Op _eo2_api_op_id_get(const void *api_func, const char *file, int line); +EAPI Eo_Op _eo_api_op_id_get(const void *api_func, const char *file, int line); // gets the real function pointer and the object data -EAPI Eina_Bool _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, const char *file, int line); +EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, const char *file, int line); -// start of eo2_do barrier, gets the object pointer and ref it, put it on the stask -EAPI Eina_Bool _eo2_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, 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 *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); -// end of the eo2_do barrier, unref the obj, move the stack pointer -EAPI void _eo2_do_end(const Eo **ojb); +// end of the eo_do barrier, unref the obj, move the stack pointer +EAPI void _eo_do_end(const Eo **ojb); -#define EO2_DO_CLEANUP __attribute__((cleanup(_eo2_do_end))) +#define EO_DO_CLEANUP __attribute__((cleanup(_eo_do_end))) // eo object method calls batch, -#define _eo2_do_common(eoid, clsid, is_super, ...) \ +#define _eo_do_common(eoid, clsid, is_super, ...) \ do \ { \ const Eo *_eoid_ = eoid; \ - if (_eo2_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \ + if (_eo_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \ { \ - const Eo *_id_clean_ EO2_DO_CLEANUP = _eoid_; \ + const Eo *_id_clean_ EO_DO_CLEANUP = _eoid_; \ __VA_ARGS__; \ (void) _id_clean_; \ } \ } while (0) -#define eo2_do(eoid, ...) _eo2_do_common(eoid, NULL, EINA_FALSE, __VA_ARGS__) +#define eo_do(eoid, ...) _eo_do_common(eoid, NULL, EINA_FALSE, __VA_ARGS__) -#define eo2_do_super(eoid, clsid, func) _eo2_do_common(eoid, clsid, EINA_TRUE, func) +#define eo_do_super(eoid, clsid, func) _eo_do_common(eoid, clsid, EINA_TRUE, func) /*****************************************************************************/ @@ -624,14 +620,14 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add_custom */ -#define eo2_add(klass, parent, ...) \ +#define eo_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - Eo *_tmp_obj = _eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ - eo2_do(_tmp_obj, \ - eo2_constructor(); \ + Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + eo_do(_tmp_obj, \ + eo_constructor(); \ __VA_ARGS__; \ - _tmp_obj = _eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + _tmp_obj = _eo_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ ); \ _tmp_obj; \ }) @@ -646,19 +642,19 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); * * @see #eo_add */ -#define eo2_add_custom(klass, parent, ...) \ +#define eo_add_custom(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - Eo *_tmp_obj = _eo2_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ - eo2_do(_tmp_obj, \ + Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent); \ + eo_do(_tmp_obj, \ __VA_ARGS__; \ - _tmp_obj = _eo2_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ + _tmp_obj = _eo_add_internal_end(__FILE__, __LINE__, _tmp_obj); \ ); \ _tmp_obj; \ }) -EAPI Eo * _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); -EAPI Eo * _eo2_add_internal_end(const char *file, int line, const Eo *obj); +EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); +EAPI Eo * _eo_add_internal_end(const char *file, int line, const Eo *obj); /** * @brief Get a pointer to the data of an object for a specific class. @@ -918,12 +914,12 @@ EAPI Eina_Bool eo_composite_is(const Eo *comp_obj); * @def EO_CLASS_CLASS * The class type for the Eo Class class. */ -#define EO2_CLASS_CLASS eo2_class_class_get() +#define EO_CLASS_CLASS eo_class_class_get() /** * @brief Use #EO_CLASS_CLASS * @internal * */ -EAPI const Eo_Class *eo2_class_class_get(void); +EAPI const Eo_Class *eo_class_class_get(void); /** * @} @@ -938,12 +934,12 @@ EAPI const Eo_Class *eo2_class_class_get(void); * @def EO_BASE_CLASS * The class type for the Eo base class. */ -#define EO2_BASE_CLASS eo2_base_class_get() +#define EO_BASE_CLASS eo_base_class_get() /** * @brief Use #EO_BASE_CLASS * @internal * */ -EAPI const Eo_Class *eo2_base_class_get(void); +EAPI const Eo_Class *eo_base_class_get(void); /** * @typedef eo_base_data_free_func @@ -960,7 +956,7 @@ typedef void (*eo_base_data_free_func)(void *); * @see #eo_base_data_get * @see #eo_base_data_del */ -EAPI void eo2_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); +EAPI void eo_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); /** * @brief Get generic data from object. @@ -970,13 +966,13 @@ EAPI void eo2_base_data_set(const char *key, const void *data, eo_base_data_free * @see #eo_base_data_set * @see #eo_base_data_del */ -EAPI void *eo2_base_data_get(const char *key); +EAPI void *eo_base_data_get(const char *key); /** * @brief Get dbg information from the object. * @param[in] root node of the tree */ -EAPI void eo2_dbg_info_get(Eo_Dbg_Info *root_node); +EAPI void eo_dbg_info_get(Eo_Dbg_Info *root_node); /** * @brief Del generic data from object. @@ -985,7 +981,7 @@ EAPI void eo2_dbg_info_get(Eo_Dbg_Info *root_node); * @see #eo_base_data_set * @see #eo_base_data_get */ -EAPI void eo2_base_data_del(const char *key); +EAPI void eo_base_data_del(const char *key); /** * @brief Set the parent of an object @@ -998,7 +994,7 @@ EAPI void eo2_base_data_del(const char *key); * @see eo_del() * @see eo_parent_get() */ -EAPI void eo2_parent_set(Eo *parent); +EAPI void eo_parent_set(Eo *parent); /** * @brief Get the parent of an object @@ -1006,7 +1002,7 @@ EAPI void eo2_parent_set(Eo *parent); * * @see eo_parent_set() */ -EAPI Eo *eo2_parent_get(void); +EAPI Eo *eo_parent_get(void); /** * @brief Get an iterator on all childrens @@ -1015,7 +1011,7 @@ EAPI Eo *eo2_parent_get(void); * * @see eo_parent_set() */ -EAPI Eina_Iterator *eo2_children_iterator_new(void); +EAPI Eina_Iterator *eo_children_iterator_new(void); /** * @brief Add a new weak reference to obj. @@ -1028,7 +1024,7 @@ EAPI Eina_Iterator *eo2_children_iterator_new(void); * * @see #eo_wref_del */ -EAPI void eo2_wref_add(Eo **wref); +EAPI void eo_wref_add(Eo **wref); /** * @brief Delete the weak reference passed. @@ -1036,7 +1032,7 @@ EAPI void eo2_wref_add(Eo **wref); * * @see #eo_wref_add */ -EAPI void eo2_wref_del(Eo **wref); +EAPI void eo_wref_del(Eo **wref); /** * @def eo_weak_ref @@ -1050,9 +1046,9 @@ EAPI void eo2_wref_del(Eo **wref); * @see eo_weak_unref * @see eo_wref_add */ -#define eo2_weak_ref(wref) \ +#define eo_weak_ref(wref) \ do { \ - if (*wref) eo2_do(*wref, eo2_wref_add(wref)); \ + if (*wref) eo_do(*wref, eo_wref_add(wref)); \ } while (0) /** @@ -1068,9 +1064,9 @@ EAPI void eo2_wref_del(Eo **wref); * @see eo_wref_del * @see eo_wref_del_safe */ -#define eo2_weak_unref(wref) \ +#define eo_weak_unref(wref) \ do { \ - if (*wref) eo2_do(*wref, eo2_wref_del(wref)); \ + if (*wref) eo_do(*wref, eo_wref_del(wref)); \ } while (0) /** @@ -1083,7 +1079,7 @@ EAPI void eo2_wref_del(Eo **wref); * * @see #eo_wref_del */ -#define eo2_wref_del_safe(wref) eo2_weak_unref(wref) +#define eo_wref_del_safe(wref) eo_weak_unref(wref) /** * @brief Call the object's constructor. @@ -1092,7 +1088,7 @@ EAPI void eo2_wref_del(Eo **wref); * * @see #eo_destructor */ -EAPI void eo2_constructor(void); +EAPI void eo_constructor(void); /** * @brief Call the object's destructor. @@ -1101,7 +1097,7 @@ EAPI void eo2_constructor(void); * * @see #eo_constructor */ -EAPI void eo2_destructor(void); +EAPI void eo_destructor(void); /** * @addtogroup Eo_Events Eo's Event Handling @@ -1192,7 +1188,7 @@ struct _Eo_Callback_Array_Item * * @see eo_event_callback_forwarder_del() */ -EAPI void eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo *new_obj); /** * @brief Remove an event callback forwarder for an event and an object. @@ -1201,7 +1197,7 @@ EAPI void eo2_event_callback_forwarder_add(const Eo_Event_Description *desc, Eo * * @see eo_event_callback_forwarder_add() */ -EAPI void eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); +EAPI void eo_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo *new_obj); /** * @brief freeze events of object. @@ -1210,7 +1206,7 @@ EAPI void eo2_event_callback_forwarder_del(const Eo_Event_Description *desc, Eo * * @see #eo_event_thaw */ -EAPI void eo2_event_freeze(void); +EAPI void eo_event_freeze(void); /** * @brief thaw events of object. @@ -1219,7 +1215,7 @@ EAPI void eo2_event_freeze(void); * * @see #eo_event_freeze */ -EAPI void eo2_event_thaw(void); +EAPI void eo_event_thaw(void); /** * @brief return freeze events of object. @@ -1231,7 +1227,7 @@ EAPI void eo2_event_thaw(void); * @see #eo_event_freeze * @see #eo_event_thaw */ -EAPI int eo2_event_freeze_get(void); +EAPI int eo_event_freeze_get(void); /** * @brief freeze events of object. @@ -1241,7 +1237,7 @@ EAPI int eo2_event_freeze_get(void); * @see #eo_event_freeze * @see #eo_event_global_thaw */ -EAPI void eo2_event_global_freeze(void); +EAPI void eo_event_global_freeze(void); /** * @brief thaw events of object. @@ -1251,7 +1247,7 @@ EAPI void eo2_event_global_freeze(void); * @see #eo_event_thaw * @see #eo_event_global_freeze */ -EAPI void eo2_event_global_thaw(void); +EAPI void eo_event_global_thaw(void); /** * @brief return freeze events of object. @@ -1264,7 +1260,7 @@ EAPI void eo2_event_global_thaw(void); * @see #eo_event_global_freeze * @see #eo_event_global_thaw */ -EAPI int eo2_event_global_freeze_get(void); +EAPI int eo_event_global_freeze_get(void); /** * @def eo_event_callback_add(obj, desc, cb, data) @@ -1277,8 +1273,8 @@ EAPI int eo2_event_global_freeze_get(void); * * @see eo_event_callback_priority_add() */ -#define eo2_event_callback_add(desc, cb, data) \ - eo2_event_callback_priority_add(desc, \ +#define eo_event_callback_add(desc, cb, data) \ + eo_event_callback_priority_add(desc, \ EO_CALLBACK_PRIORITY_DEFAULT, cb, data) /** @@ -1292,7 +1288,7 @@ EAPI int eo2_event_global_freeze_get(void); * * @see #eo_event_callback_add */ -EAPI void eo2_event_callback_priority_add(const Eo_Event_Description *desc, +EAPI void eo_event_callback_priority_add(const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb func, const void *user_data); @@ -1304,7 +1300,7 @@ EAPI void eo2_event_callback_priority_add(const Eo_Event_Description *desc, * @param[in] user_data The data to compare. * */ -EAPI void eo2_event_callback_del(const Eo_Event_Description *desc, +EAPI void eo_event_callback_del(const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data); @@ -1318,8 +1314,8 @@ EAPI void eo2_event_callback_del(const Eo_Event_Description *desc, * * @see eo_event_callback_array_priority_add() */ -#define eo2_event_callback_array_add(array, data) \ - eo2_event_callback_array_priority_add(array, \ +#define eo_event_callback_array_add(array, data) \ + eo_event_callback_array_priority_add(array, \ EO_CALLBACK_PRIORITY_DEFAULT, data) /** @@ -1332,7 +1328,7 @@ EAPI void eo2_event_callback_del(const Eo_Event_Description *desc, * * @see #eo_event_callback_add */ -EAPI void eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, +EAPI void eo_event_callback_array_priority_add(const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, const void *user_data); @@ -1342,7 +1338,7 @@ EAPI void eo2_event_callback_array_priority_add(const Eo_Callback_Array_Item *ar * @param[in] user_data The data to compare. * */ -EAPI void eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, +EAPI void eo_event_callback_array_del(const Eo_Callback_Array_Item *array, const void *user_data); /** @@ -1351,7 +1347,7 @@ EAPI void eo2_event_callback_array_del(const Eo_Callback_Array_Item *array, * @param[in] event_info Extra event info to pass to the callbacks. * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise. */ -EAPI Eina_Bool eo2_event_callback_call(const Eo_Event_Description *desc, void *event_info); +EAPI Eina_Bool eo_event_callback_call(const Eo_Event_Description *desc, void *event_info); /** * @} diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 9f4222a789..70e88efa02 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -184,12 +184,12 @@ _eo_op_class_get(Eo_Op op) return NULL; } -static const Eo2_Op_Description * -_eo2_op_id_desc_get(Eo_Op op) +static const Eo_Op_Description * +_eo_op_id_desc_get(Eo_Op op) { unsigned int i; const _Eo_Class *klass; - const Eo2_Op_Description *op_descs; + const Eo_Op_Description *op_descs; if (op == EO_NOOP) return NULL; @@ -213,12 +213,12 @@ _eo2_op_id_desc_get(Eo_Op op) static const char * _eo_op_id_name_get(Eo_Op op) { - const Eo2_Op_Description *desc = _eo2_op_id_desc_get(op); + const Eo_Op_Description *desc = _eo_op_id_desc_get(op); return (desc) ? desc->doc : NULL; } static inline const op_type_funcs * -_eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) +_eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op) { const _Eo_Class **kls_itr = NULL; @@ -245,16 +245,16 @@ _eo2_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op o return NULL; } -/************************************ EO2 ************************************/ +/************************************ EO ************************************/ -EAPI Eo2_Hook_Call eo2_hook_call_pre = NULL; -EAPI Eo2_Hook_Call eo2_hook_call_post = NULL; +EAPI Eo_Hook_Call eo_hook_call_pre = NULL; +EAPI Eo_Hook_Call eo_hook_call_post = NULL; // FIXME: Thread Local Storage -#define EO2_INVALID_DATA (void *) -1 -#define EO2_CALL_STACK_DEPTH 30 +#define EO_INVALID_DATA (void *) -1 +#define EO_CALL_STACK_DEPTH 30 -typedef struct _Eo2_Stack_Frame +typedef struct _Eo_Stack_Frame { const Eo *eo_id; union { @@ -263,27 +263,27 @@ typedef struct _Eo2_Stack_Frame } o; const _Eo_Class *cur_klass; void *obj_data; -} Eo2_Stack_Frame; +} Eo_Stack_Frame; -static Eina_TLS _eo2_call_stack_key = 0; +static Eina_TLS _eo_call_stack_key = 0; -typedef struct _Eo2_Call_Stack { - Eo2_Stack_Frame *frames; - Eo2_Stack_Frame *frame_ptr; - Eo2_Stack_Frame *last_frame; - Eo2_Stack_Frame *shrink_frame; -} Eo2_Call_Stack; +typedef struct _Eo_Call_Stack { + Eo_Stack_Frame *frames; + Eo_Stack_Frame *frame_ptr; + Eo_Stack_Frame *last_frame; + Eo_Stack_Frame *shrink_frame; +} Eo_Call_Stack; -static Eo2_Call_Stack * -_eo2_call_stack_create() +static Eo_Call_Stack * +_eo_call_stack_create() { - Eo2_Call_Stack *stack; + Eo_Call_Stack *stack; - stack = calloc(1, sizeof(Eo2_Call_Stack)); + stack = calloc(1, sizeof(Eo_Call_Stack)); if (!stack) return NULL; - stack->frames = calloc(EO2_CALL_STACK_DEPTH, sizeof(Eo2_Stack_Frame)); + stack->frames = calloc(EO_CALL_STACK_DEPTH, sizeof(Eo_Stack_Frame)); if (!stack->frames) { free(stack); @@ -292,16 +292,16 @@ _eo2_call_stack_create() // first frame is never used stack->frame_ptr = stack->frames; - stack->last_frame = &stack->frames[EO2_CALL_STACK_DEPTH - 1]; + stack->last_frame = &stack->frames[EO_CALL_STACK_DEPTH - 1]; stack->shrink_frame = stack->frames; return stack; } static void -_eo2_call_stack_free(void *ptr) +_eo_call_stack_free(void *ptr) { - Eo2_Call_Stack *stack = (Eo2_Call_Stack *) ptr; + Eo_Call_Stack *stack = (Eo_Call_Stack *) ptr; if (!stack) return; @@ -310,24 +310,24 @@ _eo2_call_stack_free(void *ptr) free(stack); } -static inline Eo2_Call_Stack * -_eo2_call_stack_get() +static inline Eo_Call_Stack * +_eo_call_stack_get() { - Eo2_Call_Stack *stack = eina_tls_get(_eo2_call_stack_key); + Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key); if (stack) return stack; - stack = _eo2_call_stack_create(); + stack = _eo_call_stack_create(); if (!stack) { - EINA_LOG_ERR("Could not alloc eo2 call stack."); + EINA_LOG_ERR("Could not alloc eo call stack."); return NULL; } - if (!eina_tls_set(_eo2_call_stack_key, stack)) + if (!eina_tls_set(_eo_call_stack_key, stack)) { - EINA_LOG_ERR("Could not set eo2 call stack in TLS key."); - _eo2_call_stack_free(stack); + EINA_LOG_ERR("Could not set eo call stack in TLS key."); + _eo_call_stack_free(stack); return NULL; } @@ -335,7 +335,7 @@ _eo2_call_stack_get() } static inline void -_eo2_call_stack_resize(Eo2_Call_Stack *stack, Eina_Bool grow) +_eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow) { size_t sz, next_sz; int frame_offset; @@ -348,7 +348,7 @@ _eo2_call_stack_resize(Eo2_Call_Stack *stack, Eina_Bool grow) next_sz = sz >> 1; DBG("resize from %lu to %lu", sz, next_sz); - stack->frames = realloc(stack->frames, next_sz * sizeof(Eo2_Stack_Frame)); + stack->frames = realloc(stack->frames, next_sz * sizeof(Eo_Stack_Frame)); if(!stack->frames) { CRI("unable to resize call stack, abort."); @@ -360,7 +360,7 @@ _eo2_call_stack_resize(Eo2_Call_Stack *stack, Eina_Bool grow) if (grow) frame_offset = (sz >> 1); - if (next_sz == EO2_CALL_STACK_DEPTH) + if (next_sz == EO_CALL_STACK_DEPTH) frame_offset = 0; else frame_offset = (next_sz >> 1); @@ -368,22 +368,22 @@ _eo2_call_stack_resize(Eo2_Call_Stack *stack, Eina_Bool grow) } static inline Eina_Bool -_eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, - Eina_Bool is_super, Eo2_Stack_Frame *fptr, Eo2_Stack_Frame *pfptr) +_eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, + Eina_Bool is_super, Eo_Stack_Frame *fptr, Eo_Stack_Frame *pfptr) { Eina_Bool is_klass = _eo_is_a_class(eo_id); /* If we are already in the same object context, we inherit info from it. */ if (pfptr) { - memcpy(fptr, pfptr, sizeof(Eo2_Stack_Frame)); + memcpy(fptr, pfptr, sizeof(Eo_Stack_Frame)); if (!is_klass) _eo_ref(fptr->o.obj); } else { fptr->eo_id = eo_id; - fptr->obj_data = EO2_INVALID_DATA; + fptr->obj_data = EO_INVALID_DATA; if (is_klass) { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); @@ -401,7 +401,7 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, { EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); if (fptr->cur_klass == cur_klass) - fptr->obj_data = EO2_INVALID_DATA; + fptr->obj_data = EO_INVALID_DATA; fptr->cur_klass = cur_klass; } else @@ -413,20 +413,20 @@ _eo2_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, } EAPI Eina_Bool -_eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) +_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) { - Eo2_Stack_Frame *fptr, *pfptr; - Eo2_Call_Stack *stack = _eo2_call_stack_get(); + Eo_Stack_Frame *fptr, *pfptr; + Eo_Call_Stack *stack = _eo_call_stack_get(); if (stack->frame_ptr == stack->last_frame) - _eo2_call_stack_resize(stack, EINA_TRUE); + _eo_call_stack_resize(stack, EINA_TRUE); fptr = stack->frame_ptr; pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL); fptr++; - if (!_eo2_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) + if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) return EINA_FALSE; stack->frame_ptr++; @@ -435,17 +435,17 @@ _eo2_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, } EAPI void -_eo2_do_end(const Eo **eo_id EINA_UNUSED) +_eo_do_end(const Eo **eo_id EINA_UNUSED) { - Eo2_Stack_Frame *fptr; - Eo2_Call_Stack *stack = _eo2_call_stack_get(); + Eo_Stack_Frame *fptr; + Eo_Call_Stack *stack = _eo_call_stack_get(); fptr = stack->frame_ptr; if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj) _eo_unref(fptr->o.obj); - fptr->obj_data = EO2_INVALID_DATA; + fptr->obj_data = EO_INVALID_DATA; if (fptr == stack->frames) { @@ -456,20 +456,20 @@ _eo2_do_end(const Eo **eo_id EINA_UNUSED) stack->frame_ptr--; if (fptr == stack->shrink_frame) - _eo2_call_stack_resize(stack, EINA_FALSE); + _eo_call_stack_resize(stack, EINA_FALSE); } EAPI Eina_Bool -_eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, const char *file, int line) +_eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, const char *file, int line) { - Eo2_Stack_Frame *fptr; + Eo_Stack_Frame *fptr; const _Eo_Class *klass; const op_type_funcs *func; Eina_Bool is_obj; if (op == EO_NOOP) return EINA_FALSE; - fptr = _eo2_call_stack_get()->frame_ptr; + fptr = _eo_call_stack_get()->frame_ptr; is_obj = !_eo_is_a_class(fptr->eo_id); klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; @@ -477,7 +477,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, /* If we have a current class, we need to itr to the next. */ if (fptr->cur_klass) { - func = _eo2_kls_itr_next(klass, fptr->cur_klass, op); + func = _eo_kls_itr_next(klass, fptr->cur_klass, op); if (!func) goto end; @@ -506,7 +506,7 @@ _eo2_call_resolve(const char *func_name, const Eo_Op op, Eo2_Op_Call_Data *call, call->obj = (Eo *)fptr->eo_id; if (func->src == fptr->o.obj->klass) { - if (fptr->obj_data == EO2_INVALID_DATA) + if (fptr->obj_data == EO_INVALID_DATA) fptr->obj_data = _eo_data_scope_get(fptr->o.obj, func->src); call->data = fptr->obj_data; @@ -582,14 +582,14 @@ end2: } -static inline const Eo2_Op_Description * -_eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class **extns) +static inline const Eo_Op_Description * +_eo_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class **extns) { int imin, imax, imid; const _Eo_Class *cur_klass; const _Eo_Class **kls_itr = NULL; - const Eo2_Op_Description *op_desc; - const Eo2_Op_Description *op_descs; + const Eo_Op_Description *op_desc; + const Eo_Op_Description *op_descs; if (klass) { @@ -621,7 +621,7 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class for (kls_itr = extns ; *kls_itr ; kls_itr++) { cur_klass = *kls_itr; - op_desc = _eo2_api_desc_get(api_func, cur_klass, NULL); + op_desc = _eo_api_desc_get(api_func, cur_klass, NULL); if (op_desc) return op_desc; } } @@ -630,11 +630,11 @@ _eo2_api_desc_get(const void *api_func, const _Eo_Class *klass, const _Eo_Class } EAPI Eo_Op -_eo2_api_op_id_get(const void *api_func, const char *file, int line) +_eo_api_op_id_get(const void *api_func, const char *file, int line) { - const Eo2_Op_Description *desc; + const Eo_Op_Description *desc; const _Eo_Class *klass; - Eo2_Call_Stack *stack = _eo2_call_stack_get(); + Eo_Call_Stack *stack = _eo_call_stack_get(); Eina_Bool class_ref = _eo_is_a_class(stack->frame_ptr->eo_id); @@ -643,7 +643,7 @@ _eo2_api_op_id_get(const void *api_func, const char *file, int line) else klass = stack->frame_ptr->o.obj->klass; - desc = _eo2_api_desc_get(api_func, klass, klass->extensions); + desc = _eo_api_desc_get(api_func, klass, klass->extensions); if (desc == NULL) { @@ -656,24 +656,24 @@ _eo2_api_op_id_get(const void *api_func, const char *file, int line) } static int -eo2_api_funcs_cmp(const void *p1, const void *p2) +eo_api_funcs_cmp(const void *p1, const void *p2) { - const Eo2_Op_Description *op1, *op2; - op1 = (Eo2_Op_Description *) p1; - op2 = (Eo2_Op_Description *) p2; + const Eo_Op_Description *op1, *op2; + op1 = (Eo_Op_Description *) p1; + op2 = (Eo_Op_Description *) p2; if (op1->api_func > op2->api_func) return -1; else if (op1->api_func < op2->api_func) return 1; else return 0; } EAPI Eina_Bool -_eo2_class_funcs_set(_Eo_Class *klass) +_eo_class_funcs_set(_Eo_Class *klass) { int op_id; const void *last_api_func; - const Eo2_Op_Description *api_desc; - Eo2_Op_Description *op_desc; - Eo2_Op_Description *op_descs; + const Eo_Op_Description *api_desc; + Eo_Op_Description *op_desc; + Eo_Op_Description *op_descs; op_id = klass->base_id; op_descs = klass->desc->ops.descs2; @@ -682,7 +682,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) if (!op_descs) return EINA_TRUE; - qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + qsort((void*)op_descs, klass->desc->ops.count, sizeof(Eo_Op_Description), eo_api_funcs_cmp); last_api_func = NULL; for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) @@ -705,9 +705,9 @@ _eo2_class_funcs_set(_Eo_Class *klass) op_desc->op = op_id; op_id++; } - else if (op_desc->op == EO2_OP_OVERRIDE) + else if (op_desc->op == EO_OP_OVERRIDE) { - api_desc = _eo2_api_desc_get(op_desc->api_func, klass->parent, klass->extensions); + api_desc = _eo_api_desc_get(op_desc->api_func, klass->parent, klass->extensions); if (api_desc == NULL) { @@ -732,7 +732,7 @@ _eo2_class_funcs_set(_Eo_Class *klass) } EAPI Eo * -_eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) +_eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id) { _Eo_Object *obj; @@ -780,16 +780,16 @@ _eo2_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo _eo_ref(obj); - eo2_do(_eo_id_get(obj), eo2_parent_set(parent_id)); + eo_do(_eo_id_get(obj), eo_parent_set(parent_id)); return _eo_id_get(obj); } EAPI Eo * -_eo2_add_internal_end(const char *file, int line, const Eo *eo_id) +_eo_add_internal_end(const char *file, int line, const Eo *eo_id) { - Eo2_Stack_Frame *fptr; - Eo2_Call_Stack *stack = _eo2_call_stack_get(); + Eo_Stack_Frame *fptr; + Eo_Call_Stack *stack = _eo_call_stack_get(); fptr = stack->frame_ptr; @@ -805,7 +805,7 @@ _eo2_add_internal_end(const char *file, int line, const Eo *eo_id) fptr->cur_klass : fptr->o.obj->klass; ERR("in %s:%d: Object of class '%s' - Not all of the object constructors have been executed.", file, line, klass->desc->name); - /* Unref twice, once for the ref in _eo2_add_internal_start, and once for the basic object ref. */ + /* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */ _eo_unref(fptr->o.obj); _eo_unref(fptr->o.obj); return NULL; @@ -835,7 +835,7 @@ eo_class_get(const Eo *eo_id) if (_eo_is_a_class(eo_id)) { EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, NULL); - return eo2_class_class_get(); + return eo_class_class_get(); } EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, NULL); @@ -1290,7 +1290,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) } } - if (!_eo2_class_funcs_set(klass)) + if (!_eo_class_funcs_set(klass)) { eina_spinlock_free(&klass->objects.trash_lock); eina_spinlock_free(&klass->iterators.trash_lock); @@ -1408,7 +1408,7 @@ EAPI void eo_del(const Eo *obj) { EO_OBJ_POINTER_RETURN(obj, _obj); - eo2_do((Eo *) obj, eo2_parent_set(NULL)); + eo_do((Eo *) obj, eo_parent_set(NULL)); eo_unref(obj); } @@ -1658,13 +1658,13 @@ eo_init(void) EINA_LOG_STATE_INIT); /* bootstrap EO_CLASS_CLASS */ - (void) eo2_class_class_get(); + (void) eo_class_class_get(); - if (_eo2_call_stack_key != 0) - WRN("_eo2_call_stack_key already set, this should not happen."); + if (_eo_call_stack_key != 0) + WRN("_eo_call_stack_key already set, this should not happen."); else { - if (!eina_tls_cb_new(&_eo2_call_stack_key, _eo2_call_stack_free)) + if (!eina_tls_cb_new(&_eo_call_stack_key, _eo_call_stack_free)) { EINA_LOG_ERR("Could not create TLS key for call stack."); return EINA_FALSE; @@ -1699,8 +1699,8 @@ eo_shutdown(void) eina_spinlock_free(&_eo_class_creation_lock); - if (_eo2_call_stack_key != 0) - eina_tls_free(_eo2_call_stack_key); + if (_eo_call_stack_key != 0) + eina_tls_free(_eo_call_stack_key); _eo_free_ids_tables(); @@ -1743,7 +1743,7 @@ eo_composite_attach(Eo *comp_obj_id, Eo *parent_id) comp_obj->composite = EINA_TRUE; *comp_dst = comp_obj; - eo2_do(comp_obj_id, eo2_parent_set(parent_id)); + eo_do(comp_obj_id, eo_parent_set(parent_id)); return EINA_TRUE; } @@ -1765,7 +1765,7 @@ eo_composite_detach(Eo *comp_obj_id, Eo *parent_id) { comp_obj->composite = EINA_FALSE; *comp_itr = NULL; - eo2_do(comp_obj_id, eo2_parent_set(NULL)); + eo_do(comp_obj_id, eo_parent_set(NULL)); return EINA_TRUE; } } diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 936cabedbb..e41433d538 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -68,7 +68,7 @@ _data_set(Eo *obj, void *class_data, if (!key) return; - eo2_do(obj, eo2_base_data_del(key); ); + eo_do(obj, eo_base_data_del(key); ); node = malloc(sizeof(Eo_Generic_Data_Node)); if (!node) return; @@ -78,7 +78,7 @@ _data_set(Eo *obj, void *class_data, pd->generic_data = eina_inlist_prepend(pd->generic_data, EINA_INLIST_GET(node)); } -EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_set, EO2_FUNC_CALL(key, data, free_func), +EAPI EO_VOID_FUNC_BODYV(eo_base_data_set, EO_FUNC_CALL(key, data, free_func), const char *key, const void *data, eo_base_data_free_func free_func); static void * @@ -102,7 +102,7 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) return NULL; } -EAPI EO2_FUNC_BODYV(eo2_base_data_get, void*, NULL, EO2_FUNC_CALL(key), const char *key); +EAPI EO_FUNC_BODYV(eo_base_data_get, void*, NULL, EO_FUNC_CALL(key), const char *key); static void _parent_set(Eo *obj, void *class_data, Eo *parent_id) @@ -121,7 +121,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) { Private_Data *old_parent_pd; - old_parent_pd = eo_data_scope_get(pd->parent, EO2_BASE_CLASS); + old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); if (old_parent_pd) { old_parent_pd->children = eina_list_remove(old_parent_pd->children, @@ -140,7 +140,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) if (parent_id) { Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO2_BASE_CLASS); + parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); if (EINA_LIKELY(parent_pd != NULL)) { @@ -161,7 +161,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) pd->parent = NULL; } } -EAPI EO2_VOID_FUNC_BODYV(eo2_parent_set, EO2_FUNC_CALL(parent_id), Eo *parent_id); +EAPI EO_VOID_FUNC_BODYV(eo_parent_set, EO_FUNC_CALL(parent_id), Eo *parent_id); static Eo * _parent_get(Eo *obj EINA_UNUSED, void *class_data) @@ -170,7 +170,7 @@ _parent_get(Eo *obj EINA_UNUSED, void *class_data) return pd->parent; } -EAPI EO2_FUNC_BODY(eo2_parent_get, Eo *, NULL); +EAPI EO_FUNC_BODY(eo_parent_get, Eo *, NULL); /* Children accessor */ typedef struct _Eo_Children_Iterator Eo_Children_Iterator; @@ -261,14 +261,14 @@ _children_iterator_new(Eo *obj_id, void *class_data) return (Eina_Iterator *)it; } -EAPI EO2_FUNC_BODY(eo2_children_iterator_new, Eina_Iterator *, NULL); +EAPI EO_FUNC_BODY(eo_children_iterator_new, Eina_Iterator *, NULL); static void _dbg_info_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo_Dbg_Info *root_node EINA_UNUSED) { /* No info required in the meantime */ return; } -EAPI EO2_VOID_FUNC_BODYV(eo2_dbg_info_get, EO2_FUNC_CALL(root_node), Eo_Dbg_Info *root_node); +EAPI EO_VOID_FUNC_BODYV(eo_dbg_info_get, EO_FUNC_CALL(root_node), Eo_Dbg_Info *root_node); static void _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) @@ -289,7 +289,7 @@ _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) } } } -EAPI EO2_VOID_FUNC_BODYV(eo2_base_data_del, EO2_FUNC_CALL(key), const char *key); +EAPI EO_VOID_FUNC_BODYV(eo_base_data_del, EO_FUNC_CALL(key), const char *key); /* Weak reference. */ @@ -325,7 +325,7 @@ _wref_add(Eo *obj, void *class_data, Eo **wref) pd->wrefs[count] = NULL; *wref = obj; } -EAPI EO2_VOID_FUNC_BODYV(eo2_wref_add, EO2_FUNC_CALL(wref), Eo **wref); +EAPI EO_VOID_FUNC_BODYV(eo_wref_add, EO_FUNC_CALL(wref), Eo **wref); static void _wref_del(Eo *obj, void *class_data, Eo **wref) @@ -386,7 +386,7 @@ _wref_del(Eo *obj, void *class_data, Eo **wref) *wref = NULL; } -EAPI EO2_VOID_FUNC_BODYV(eo2_wref_del, EO2_FUNC_CALL(wref), Eo **wref); +EAPI EO_VOID_FUNC_BODYV(eo_wref_del, EO_FUNC_CALL(wref), Eo **wref); static inline void _wref_destruct(Private_Data *pd) @@ -537,11 +537,11 @@ _ev_cb_priority_add(Eo *obj, void *class_data, { const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}}; - eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_ADD, (void *)arr)); + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)arr)); } } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_priority_add, - EO2_FUNC_CALL(desc, priority, func, user_data), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_priority_add, + EO_FUNC_CALL(desc, priority, func, user_data), const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb func, @@ -566,15 +566,15 @@ _ev_cb_del(Eo *obj, void *class_data, cb->delete_me = EINA_TRUE; pd->deletions_waiting = EINA_TRUE; _eo_callbacks_clear(pd); - eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_DEL, (void *)arr); ); + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, (void *)arr); ); return; } } DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data); } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_del, - EO2_FUNC_CALL(desc, func, user_data), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_del, + EO_FUNC_CALL(desc, func, user_data), const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data); @@ -597,11 +597,11 @@ _ev_cb_array_priority_add(Eo *obj, void *class_data, _eo_callbacks_sorted_insert(pd, cb); { - eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_ADD, (void *)array); ); + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_ADD, (void *)array); ); } } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_array_priority_add, - EO2_FUNC_CALL(array, priority, user_data), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_array_priority_add, + EO_FUNC_CALL(array, priority, user_data), const Eo_Callback_Array_Item *array, Eo_Callback_Priority priority, const void *user_data); @@ -622,15 +622,15 @@ _ev_cb_array_del(Eo *obj, void *class_data, pd->deletions_waiting = EINA_TRUE; _eo_callbacks_clear(pd); - eo2_do(obj, eo2_event_callback_call(EO_EV_CALLBACK_DEL, (void *)array); ); + eo_do(obj, eo_event_callback_call(EO_EV_CALLBACK_DEL, (void *)array); ); return; } } DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data); } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_array_del, - EO2_FUNC_CALL(array, user_data), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_array_del, + EO_FUNC_CALL(array, user_data), const Eo_Callback_Array_Item *array, const void *user_data); @@ -702,9 +702,9 @@ end: return ret; } -EAPI EO2_FUNC_BODYV(eo2_event_callback_call, Eina_Bool, +EAPI EO_FUNC_BODYV(eo_event_callback_call, Eina_Bool, EINA_FALSE, - EO2_FUNC_CALL(desc, event_info), + EO_FUNC_CALL(desc, event_info), const Eo_Event_Description *desc, void *event_info); @@ -715,7 +715,7 @@ _eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *de Eo *new_obj = (Eo *) data; Eina_Bool ret = EINA_FALSE; - eo2_do(new_obj, ret = eo2_event_callback_call(desc, (void *)event_info); ); + eo_do(new_obj, ret = eo_event_callback_call(desc, (void *)event_info); ); return ret; } @@ -729,10 +729,10 @@ _ev_cb_forwarder_add(Eo *obj, void *class_data EINA_UNUSED, /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - eo2_do(obj, eo2_event_callback_add(desc, _eo_event_forwarder_callback, new_obj); ); + eo_do(obj, eo_event_callback_add(desc, _eo_event_forwarder_callback, new_obj); ); } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_add, - EO2_FUNC_CALL(desc, new_obj), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_forwarder_add, + EO_FUNC_CALL(desc, new_obj), const Eo_Event_Description *desc, Eo *new_obj); @@ -744,10 +744,10 @@ _ev_cb_forwarder_del(Eo *obj, void *class_data EINA_UNUSED, /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */ - eo2_do(obj, eo2_event_callback_del(desc, _eo_event_forwarder_callback, new_obj); ); + eo_do(obj, eo_event_callback_del(desc, _eo_event_forwarder_callback, new_obj); ); } -EAPI EO2_VOID_FUNC_BODYV(eo2_event_callback_forwarder_del, - EO2_FUNC_CALL(desc, new_obj), +EAPI EO_VOID_FUNC_BODYV(eo_event_callback_forwarder_del, + EO_FUNC_CALL(desc, new_obj), const Eo_Event_Description *desc, Eo *new_obj); @@ -757,7 +757,7 @@ _ev_freeze(Eo *obj EINA_UNUSED, void *class_data) Private_Data *pd = (Private_Data *) class_data; pd->event_freeze_count++; } -EAPI EO2_VOID_FUNC_BODY(eo2_event_freeze); +EAPI EO_VOID_FUNC_BODY(eo_event_freeze); static void _ev_thaw(Eo *obj, void *class_data) @@ -772,7 +772,7 @@ _ev_thaw(Eo *obj, void *class_data) ERR("Events for object %p have already been thawed.", obj); } } -EAPI EO2_VOID_FUNC_BODY(eo2_event_thaw); +EAPI EO_VOID_FUNC_BODY(eo_event_thaw); static int _ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) @@ -781,14 +781,14 @@ _ev_freeze_get(Eo *obj EINA_UNUSED, void *class_data) return pd->event_freeze_count; } -EAPI EO2_FUNC_BODY(eo2_event_freeze_get, int, 0); +EAPI EO_FUNC_BODY(eo_event_freeze_get, int, 0); static void _ev_global_freeze(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { event_freeze_count++; } -EAPI EO2_VOID_FUNC_BODY(eo2_event_global_freeze); +EAPI EO_VOID_FUNC_BODY(eo_event_global_freeze); static void _ev_global_thaw(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) @@ -802,18 +802,18 @@ _ev_global_thaw(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) ERR("Global events have already been thawed."); } } -EAPI EO2_VOID_FUNC_BODY(eo2_event_global_thaw); +EAPI EO_VOID_FUNC_BODY(eo_event_global_thaw); static int _ev_global_freeze_get(const Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) { return event_freeze_count; } -EAPI EO2_FUNC_BODY(eo2_event_global_freeze_get, int, 0); +EAPI EO_FUNC_BODY(eo_event_global_freeze_get, int, 0); /* Eo_Dbg */ EAPI void -eo2_dbg_info_free(Eo_Dbg_Info *info) +eo_dbg_info_free(Eo_Dbg_Info *info) { eina_value_flush(&(info->value)); free(info); @@ -888,7 +888,7 @@ _eo_dbg_info_pget(const Eina_Value_Type *type EINA_UNUSED, const void *_mem, voi return EINA_TRUE; } -static const Eina_Value_Type _EO2_DBG_INFO_TYPE = { +static const Eina_Value_Type _EO_DBG_INFO_TYPE = { EINA_VALUE_TYPE_VERSION, sizeof(Eo_Dbg_Info *), "Eo_Dbg_Info_Ptr", @@ -903,17 +903,17 @@ static const Eina_Value_Type _EO2_DBG_INFO_TYPE = { _eo_dbg_info_pget }; -EAPI const Eina_Value_Type *EO2_DBG_INFO_TYPE = &_EO2_DBG_INFO_TYPE; +EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE; /* EOF event callbacks */ /* EO_BASE_CLASS stuff */ -#define MY_CLASS EO2_BASE_CLASS +#define MY_CLASS EO_BASE_CLASS /* FIXME: Set proper type descriptions. */ -// FIXME: eo2 multiple definition +// FIXME: eo multiple definition /* EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = */ /* EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); */ /* EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = */ @@ -928,7 +928,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) _eo_condtor_done(obj); } -EAPI EO2_VOID_FUNC_BODY(eo2_constructor); +EAPI EO_VOID_FUNC_BODY(eo_constructor); static void _destructor(Eo *obj, void *class_data) @@ -939,7 +939,7 @@ _destructor(Eo *obj, void *class_data) DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); EINA_LIST_FREE(pd->children, child) - eo2_do(child, eo2_parent_set(NULL)); + eo_do(child, eo_parent_set(NULL)); _eo_generic_data_del_all(class_data); _wref_destruct(class_data); @@ -947,7 +947,7 @@ _destructor(Eo *obj, void *class_data) _eo_condtor_done(obj); } -EAPI EO2_VOID_FUNC_BODY(eo2_destructor); +EAPI EO_VOID_FUNC_BODY(eo_destructor); static void _class_constructor(Eo_Class *klass EINA_UNUSED) @@ -955,35 +955,35 @@ _class_constructor(Eo_Class *klass EINA_UNUSED) event_freeze_count = 0; } -static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC(eo2_constructor, _constructor, "Constructor."), - EO2_OP_FUNC(eo2_destructor, _destructor, "Destructor."), - EO2_OP_FUNC(eo2_parent_set, _parent_set, "Set parent."), - EO2_OP_FUNC(eo2_parent_get, _parent_get, "Get parent."), - EO2_OP_FUNC(eo2_children_iterator_new, _children_iterator_new, "Get Children Iterator."), - EO2_OP_FUNC(eo2_base_data_set, _data_set, "Set data for key."), - EO2_OP_FUNC(eo2_base_data_get, _data_get, "Get data for key."), - EO2_OP_FUNC(eo2_base_data_del, _data_del, "Del key."), - EO2_OP_FUNC(eo2_wref_add, _wref_add, "Add a weak ref to the object."), - EO2_OP_FUNC(eo2_wref_del, _wref_del, "Delete the weak ref."), - EO2_OP_FUNC(eo2_event_callback_priority_add, _ev_cb_priority_add, "Add an event callback with a priority."), - EO2_OP_FUNC(eo2_event_callback_del, _ev_cb_del, "Delete an event callback"), - EO2_OP_FUNC(eo2_event_callback_array_priority_add, _ev_cb_array_priority_add, "Add an event callback array with a priority."), - EO2_OP_FUNC(eo2_event_callback_array_del, _ev_cb_array_del, "Delete an event callback array"), - EO2_OP_FUNC(eo2_event_callback_call, _ev_cb_call, "Call the event callbacks for an event."), - EO2_OP_FUNC(eo2_event_callback_forwarder_add, _ev_cb_forwarder_add, "Add an event forwarder."), - EO2_OP_FUNC(eo2_event_callback_forwarder_del, _ev_cb_forwarder_del, "Delete an event forwarder."), - EO2_OP_FUNC(eo2_event_freeze, _ev_freeze, "Freezes events."), - EO2_OP_FUNC(eo2_event_thaw, _ev_thaw, "Thaws events."), - EO2_OP_FUNC(eo2_event_freeze_get, _ev_freeze_get, "Get event freeze counter."), - EO2_OP_FUNC(eo2_event_global_freeze, _ev_global_freeze, "Freezes events globally."), - EO2_OP_FUNC(eo2_event_global_thaw, _ev_global_thaw, "Thaws events globally."), - EO2_OP_FUNC(eo2_event_global_freeze_get, _ev_global_freeze_get, "Get global event freeze counter."), - EO2_OP_FUNC(eo2_dbg_info_get, _dbg_info_get, "Get debug info list for obj."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs [] = { + EO_OP_FUNC(eo_constructor, _constructor, "Constructor."), + EO_OP_FUNC(eo_destructor, _destructor, "Destructor."), + EO_OP_FUNC(eo_parent_set, _parent_set, "Set parent."), + EO_OP_FUNC(eo_parent_get, _parent_get, "Get parent."), + EO_OP_FUNC(eo_children_iterator_new, _children_iterator_new, "Get Children Iterator."), + EO_OP_FUNC(eo_base_data_set, _data_set, "Set data for key."), + EO_OP_FUNC(eo_base_data_get, _data_get, "Get data for key."), + EO_OP_FUNC(eo_base_data_del, _data_del, "Del key."), + EO_OP_FUNC(eo_wref_add, _wref_add, "Add a weak ref to the object."), + EO_OP_FUNC(eo_wref_del, _wref_del, "Delete the weak ref."), + EO_OP_FUNC(eo_event_callback_priority_add, _ev_cb_priority_add, "Add an event callback with a priority."), + EO_OP_FUNC(eo_event_callback_del, _ev_cb_del, "Delete an event callback"), + EO_OP_FUNC(eo_event_callback_array_priority_add, _ev_cb_array_priority_add, "Add an event callback array with a priority."), + EO_OP_FUNC(eo_event_callback_array_del, _ev_cb_array_del, "Delete an event callback array"), + EO_OP_FUNC(eo_event_callback_call, _ev_cb_call, "Call the event callbacks for an event."), + EO_OP_FUNC(eo_event_callback_forwarder_add, _ev_cb_forwarder_add, "Add an event forwarder."), + EO_OP_FUNC(eo_event_callback_forwarder_del, _ev_cb_forwarder_del, "Delete an event forwarder."), + EO_OP_FUNC(eo_event_freeze, _ev_freeze, "Freezes events."), + EO_OP_FUNC(eo_event_thaw, _ev_thaw, "Thaws events."), + EO_OP_FUNC(eo_event_freeze_get, _ev_freeze_get, "Get event freeze counter."), + EO_OP_FUNC(eo_event_global_freeze, _ev_global_freeze, "Freezes events globally."), + EO_OP_FUNC(eo_event_global_thaw, _ev_global_thaw, "Thaws events globally."), + EO_OP_FUNC(eo_event_global_freeze_get, _ev_global_freeze_get, "Get global event freeze counter."), + EO_OP_FUNC(eo_dbg_info_get, _dbg_info_get, "Get debug info list for obj."), + EO_OP_SENTINEL }; -// FIXME: eo2 +// FIXME: eo static const Eo_Event_Description *event_desc[] = { EO_EV_CALLBACK_ADD, EO_EV_CALLBACK_DEL, @@ -992,14 +992,14 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO2_VERSION, - "Eo2_Base", + EO_VERSION, + "Eo_Base", EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), _class_constructor, NULL }; -EO_DEFINE_CLASS(eo2_base_class_get, &class_desc, NULL, NULL) +EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo2_class_class.c index a0cab0a813..43c2ffeb8f 100644 --- a/src/lib/eo/eo2_class_class.c +++ b/src/lib/eo/eo2_class_class.c @@ -5,14 +5,14 @@ #include "Eo.h" static const Eo_Class_Description class_desc = { - EO2_VERSION, - "Eo2_Abstract_Class", + EO_VERSION, + "Eo_Abstract_Class", EO_CLASS_TYPE_REGULAR_NO_INSTANT, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(eo2_class_class_get, &class_desc, NULL, NULL) +EO_DEFINE_CLASS(eo_class_class_get, &class_desc, NULL, NULL) diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index ebe16682f4..dd486b4fa0 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -109,7 +109,7 @@ struct _Eo_Object /* [composite*] */ }; -/* FIXME: Change the type to something generic that makes sense for eo2 */ +/* FIXME: Change the type to something generic that makes sense for eo */ typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list); typedef struct _Dich_Chain1 Dich_Chain1; @@ -216,12 +216,12 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) const _Eo_Class *klass = obj->klass; - eo2_do(_eo_id_get(obj), eo2_event_callback_call(EO_EV_DEL, NULL)); + eo_do(_eo_id_get(obj), eo_event_callback_call(EO_EV_DEL, NULL)); _eo_condtor_reset(obj); do_err = EINA_FALSE; - eo2_do(_eo_id_get(obj), eo2_destructor();); + eo_do(_eo_id_get(obj), eo_destructor();); if (EINA_UNLIKELY(do_err)) { diff --git a/src/tests/eo/access/access_inherit.c b/src/tests/eo/access/access_inherit.c index 6db73134de..46db0c22ad 100644 --- a/src/tests/eo/access/access_inherit.c +++ b/src/tests/eo/access/access_inherit.c @@ -16,18 +16,18 @@ _prot_print(Eo *obj, void *class_data EINA_UNUSED) printf("%s %d\n", __func__, pd->protected_x1); } -EAPI EO2_VOID_FUNC_BODY(inherit_prot_print); +EAPI EO_VOID_FUNC_BODY(inherit_prot_print); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(inherit_prot_print, _prot_print, "Print protected var x1."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(inherit_prot_print, _prot_print, "Print protected var x1."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/access/access_main.c b/src/tests/eo/access/access_main.c index 3f624f9acd..61cd381167 100644 --- a/src/tests/eo/access/access_main.c +++ b/src/tests/eo/access/access_main.c @@ -13,9 +13,9 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(INHERIT_CLASS, NULL); + Eo *obj = eo_add(INHERIT_CLASS, NULL); - eo2_do(obj, simple_a_set(1), inherit_prot_print()); + eo_do(obj, simple_a_set(1), inherit_prot_print()); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); printf("Pub: %d\n", pd->public_x2); diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c index 59997f3a78..2eeb8cc570 100644 --- a/src/tests/eo/access/access_simple.c +++ b/src/tests/eo/access/access_simple.c @@ -27,14 +27,14 @@ _a_set(Eo *obj, void *class_data, int a) pd->protected.protected_x1 = a + 1; pd->protected.public.public_x2 = a + 2; - eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); + eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a)); } -EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); +EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(simple_a_set, _a_set, "Set property A"), + EO_OP_SENTINEL }; static const Eo_Event_Description *event_desc[] = { @@ -43,15 +43,15 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index 32f22da68a..c711ffe28f 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -14,7 +14,7 @@ static int _a_get(Eo *obj, void *class_data EINA_UNUSED) { int a = 0; - eo2_do_super(obj, MY_CLASS, a = simple_a_get()); + eo_do_super(obj, MY_CLASS, a = simple_a_get()); return a; } @@ -22,37 +22,37 @@ _a_get(Eo *obj, void *class_data EINA_UNUSED) static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); - Eo *simple = eo2_add(SIMPLE_CLASS, obj); + Eo *simple = eo_add(SIMPLE_CLASS, obj); eo_composite_attach(simple, obj); - eo2_do(simple, eo2_event_callback_forwarder_add(EV_A_CHANGED, obj)); + eo_do(simple, eo_event_callback_forwarder_add(EV_A_CHANGED, obj)); fail_if(eo_composite_is(obj)); fail_if(!eo_composite_is(simple)); - eo2_do(obj, eo2_base_data_set("simple-obj", simple, NULL)); + eo_do(obj, eo_base_data_set("simple-obj", simple, NULL)); eo_unref(simple); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(simple_a_get, _a_get), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(simple_a_get, _a_get), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Comp", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(comp_class_get, &class_desc, EO2_BASE_CLASS, +EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS, SIMPLE_CLASS, NULL); diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index b71c4cd585..ecf5983cb0 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -30,27 +30,27 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(COMP_CLASS, NULL); - eo2_do(obj, eo2_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL)); + Eo *obj = eo_add(COMP_CLASS, NULL); + eo_do(obj, eo_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL)); fail_if(!eo_isa(obj, COMP_CLASS)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); int a = 0; - eo2_do(obj, simple_a_set(1)); + eo_do(obj, simple_a_set(1)); fail_if(!cb_called); - eo2_do(obj, a = simple_a_get()); + eo_do(obj, a = simple_a_get()); fail_if(a != 1); /* disable the callback forwarder, and fail if it's still called. */ Eo *simple = NULL; - eo2_do(obj, simple = eo2_base_data_get("simple-obj")); + eo_do(obj, simple = eo_base_data_get("simple-obj")); eo_ref(simple); - eo2_do(simple, eo2_event_callback_forwarder_del(EV_A_CHANGED, obj)); + eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj)); cb_called = EINA_FALSE; - eo2_do(obj, simple_a_set(2)); + eo_do(obj, simple_a_set(2)); fail_if(cb_called); fail_if(!eo_composite_is(simple)); diff --git a/src/tests/eo/composite_objects/composite_objects_simple.c b/src/tests/eo/composite_objects/composite_objects_simple.c index e44df196fb..c4490da8c0 100644 --- a/src/tests/eo/composite_objects/composite_objects_simple.c +++ b/src/tests/eo/composite_objects/composite_objects_simple.c @@ -17,7 +17,7 @@ _a_set(Eo *obj, void *class_data, int a) printf("%s %d\n", eo_class_name_get(MY_CLASS), a); pd->a = a; - eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); + eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a)); } static int @@ -27,13 +27,13 @@ _a_get(Eo *obj EINA_UNUSED, void *class_data) return pd->a; } -EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -EAPI EO2_FUNC_BODY(simple_a_get, int, 0); +EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); +EAPI EO_FUNC_BODY(simple_a_get, int, 0); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), - EO2_OP_FUNC(simple_a_get, _a_get, "Get property A"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(simple_a_set, _a_set, "Set property A"), + EO_OP_FUNC(simple_a_get, _a_get, "Get property A"), + EO_OP_SENTINEL }; static const Eo_Event_Description *event_desc[] = { @@ -42,15 +42,15 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Simple_Public_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_main.c b/src/tests/eo/constructors/constructors_main.c index e40ec915a4..7b7da023f1 100644 --- a/src/tests/eo/constructors/constructors_main.c +++ b/src/tests/eo/constructors/constructors_main.c @@ -24,14 +24,14 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(my_init_count != 2); - eo2_do(obj, simple_a_set(1), simple_b_set(2)); + eo_do(obj, simple_a_set(1), simple_b_set(2)); int a = 0, b = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get(), mixin_add_and_print(5)); + eo_do(obj, a = simple_a_get(), b = simple_b_get(), mixin_add_and_print(5)); fail_if(a != 1); fail_if(b != 2); @@ -39,14 +39,14 @@ main(int argc, char *argv[]) fail_if(my_init_count != 0); - obj = eo2_add(SIMPLE2_CLASS, NULL); + obj = eo_add(SIMPLE2_CLASS, NULL); fail_if(obj); - obj = eo2_add(SIMPLE3_CLASS, NULL); + obj = eo_add(SIMPLE3_CLASS, NULL); fail_if(obj); my_init_count = 0; - obj = eo2_add(SIMPLE4_CLASS, NULL); + obj = eo_add(SIMPLE4_CLASS, NULL); fail_if(my_init_count != 2); @@ -54,23 +54,23 @@ main(int argc, char *argv[]) fail_if(my_init_count != 0); - obj = eo2_add(SIMPLE5_CLASS, NULL); + obj = eo_add(SIMPLE5_CLASS, NULL); fail_if(!obj); eo_unref(obj); - obj = eo2_add(SIMPLE6_CLASS, NULL); + obj = eo_add(SIMPLE6_CLASS, NULL); fail_if(!obj); eo_unref(obj); - obj = eo2_add(SIMPLE7_CLASS, NULL); + obj = eo_add(SIMPLE7_CLASS, NULL); fail_if(obj); my_init_count = 0; - obj = eo2_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); + obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); fail_if(!obj); fail_if(my_init_count != 2); - eo2_do(obj, a = simple_a_get()); + eo_do(obj, a = simple_a_get()); fail_if(a != 7); eo_unref(obj); diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index 69a957aee2..3076802143 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -12,7 +12,7 @@ static void _add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, int x) { int a = 0, b = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %d\n", __func__, a + b + x); } @@ -21,7 +21,7 @@ extern int my_init_count; static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); my_init_count++; } @@ -29,30 +29,30 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) static void _destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); my_init_count--; } -EAPI EO2_VOID_FUNC_BODYV(mixin_add_and_print, EO2_FUNC_CALL(x), int x); +EAPI EO_VOID_FUNC_BODYV(mixin_add_and_print, EO_FUNC_CALL(x), int x); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(mixin_add_and_print, _add_and_print_set, "Add A + B + param and print it"), - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(mixin_add_and_print, _add_and_print_set, "Add A + B + param and print it"), + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c index dfa51bf75e..3441d44451 100644 --- a/src/tests/eo/constructors/constructors_simple.c +++ b/src/tests/eo/constructors/constructors_simple.c @@ -31,8 +31,8 @@ _##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ } \ -EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ -EO2_FUNC_BODY(simple_##name##_get, int, 0); +EO_VOID_FUNC_BODYV(simple_##name##_set, EO_FUNC_CALL(name), int name); \ +EO_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) @@ -44,7 +44,7 @@ _simple_constructor(Eo *obj, void *class_data, int a) { Private_Data *pd = class_data; - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); pd->a = a; printf("%s %d\n", __func__, pd->a); @@ -55,7 +55,7 @@ _simple_constructor(Eo *obj, void *class_data, int a) static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); my_init_count++; } @@ -63,7 +63,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) static void _destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); my_init_count--; } @@ -80,30 +80,30 @@ _class_destructor(Eo_Class *klass EINA_UNUSED) free(class_var); } -EO2_VOID_FUNC_BODYV(simple_constructor, EO2_FUNC_CALL(a), int a); +EO_VOID_FUNC_BODYV(simple_constructor, EO_FUNC_CALL(a), int a); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_FUNC(simple_constructor, _simple_constructor, "Construct and set A."), - EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), - EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), - EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), - EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_FUNC(simple_constructor, _simple_constructor, "Construct and set A."), + EO_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO_OP_FUNC(simple_b_get, _b_get, "Get property b"), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), _class_constructor, _class_destructor }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c index b7b4aaef2d..06c9e1d87a 100644 --- a/src/tests/eo/constructors/constructors_simple2.c +++ b/src/tests/eo/constructors/constructors_simple2.c @@ -11,26 +11,26 @@ static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); eo_error_set(obj); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple3.c b/src/tests/eo/constructors/constructors_simple3.c index 233005eecb..79ef940c8c 100644 --- a/src/tests/eo/constructors/constructors_simple3.c +++ b/src/tests/eo/constructors/constructors_simple3.c @@ -14,21 +14,21 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) (void) obj; } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple3", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple4.c b/src/tests/eo/constructors/constructors_simple4.c index 71fca13476..a7f627b09f 100644 --- a/src/tests/eo/constructors/constructors_simple4.c +++ b/src/tests/eo/constructors/constructors_simple4.c @@ -10,10 +10,10 @@ #define MY_CLASS SIMPLE4_CLASS static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple4", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/constructors/constructors_simple5.c b/src/tests/eo/constructors/constructors_simple5.c index b64b969819..bbfbafd00e 100644 --- a/src/tests/eo/constructors/constructors_simple5.c +++ b/src/tests/eo/constructors/constructors_simple5.c @@ -14,21 +14,21 @@ _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) (void) obj; } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple5", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple6.c b/src/tests/eo/constructors/constructors_simple6.c index 7a23eb31d4..71e29953f4 100644 --- a/src/tests/eo/constructors/constructors_simple6.c +++ b/src/tests/eo/constructors/constructors_simple6.c @@ -11,26 +11,26 @@ static void _destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); eo_error_set(obj); } -static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs [] = { + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple6", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple7.c b/src/tests/eo/constructors/constructors_simple7.c index fb4a731261..cd0298948d 100644 --- a/src/tests/eo/constructors/constructors_simple7.c +++ b/src/tests/eo/constructors/constructors_simple7.c @@ -15,19 +15,19 @@ static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { /* FIXME: Actually test it. */ - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); } -static Eo2_Op_Description op_descs [] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs [] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple7", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/function_overrides/function_overrides_inherit.c b/src/tests/eo/function_overrides/function_overrides_inherit.c index 641c07c49e..3a767f9e1a 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit.c @@ -9,10 +9,10 @@ #define MY_CLASS INHERIT_CLASS static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c index 6a2369a6fc..a892aaf96e 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit2.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c @@ -15,11 +15,11 @@ static void _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) { printf("%s %d\n", eo_class_name_get(MY_CLASS), a); - eo2_do(obj, simple_a_print()); - eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); + eo_do(obj, simple_a_print()); + eo_do_super(obj, MY_CLASS, simple_a_set(a + 1)); Eina_Bool called = EINA_FALSE; - eo2_do_super(obj, MY_CLASS, called = simple_a_print()); + eo_do_super(obj, MY_CLASS, called = simple_a_print()); fail_if(!called); } @@ -28,7 +28,7 @@ _print(Eo *obj, void *class_data EINA_UNUSED) { Eina_Bool called = EINA_FALSE; printf("Hey\n"); - eo2_do_super(obj, MY_CLASS, called = inherit2_print()); + eo_do_super(obj, MY_CLASS, called = inherit2_print()); fail_if(called); return EINA_TRUE; @@ -47,31 +47,31 @@ _class_print(Eo_Class *klass, void *data EINA_UNUSED) { Eina_Bool called = EINA_FALSE; printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); - eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + eo_do_super(klass, MY_CLASS, called = simple_class_print()); fail_if(!called); - eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + eo_do_super(klass, MY_CLASS, called = simple_class_print2()); fail_if(!called); return EINA_TRUE; } -EAPI EO2_FUNC_BODY(inherit2_print, Eina_Bool, EINA_FALSE); -EAPI EO2_FUNC_BODY(inherit2_print2, Eina_Bool, EINA_FALSE); +EAPI EO_FUNC_BODY(inherit2_print, Eina_Bool, EINA_FALSE); +EAPI EO_FUNC_BODY(inherit2_print2, Eina_Bool, EINA_FALSE); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(inherit2_print, _print, "Print hey"), - EO2_OP_FUNC(inherit2_print2, _print2, "Print hey2"), - EO2_OP_CLASS_FUNC_OVERRIDE(simple_class_print, _class_print), - EO2_OP_FUNC_OVERRIDE(simple_a_set, _a_set), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(inherit2_print, _print, "Print hey"), + EO_OP_FUNC(inherit2_print2, _print2, "Print hey2"), + EO_OP_CLASS_FUNC_OVERRIDE(simple_class_print, _class_print), + EO_OP_FUNC_OVERRIDE(simple_a_set, _a_set), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit2", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.c b/src/tests/eo/function_overrides/function_overrides_inherit3.c index 68214b7b26..d8b6190098 100644 --- a/src/tests/eo/function_overrides/function_overrides_inherit3.c +++ b/src/tests/eo/function_overrides/function_overrides_inherit3.c @@ -13,19 +13,19 @@ static void _a_set(Eo *obj, void *class_data EINA_UNUSED, int a) { printf("%s %d\n", eo_class_name_get(MY_CLASS), a); - eo2_do_super(obj, MY_CLASS, simple_a_set(a + 1)); + eo_do_super(obj, MY_CLASS, simple_a_set(a + 1)); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(simple_a_set, _a_set), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(simple_a_set, _a_set), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit3", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c index 17aab2910d..920595c077 100644 --- a/src/tests/eo/function_overrides/function_overrides_main.c +++ b/src/tests/eo/function_overrides/function_overrides_main.c @@ -18,57 +18,57 @@ main(int argc, char *argv[]) eo_init(); Eina_Bool called = EINA_FALSE; - Eo *obj = eo2_add(INHERIT2_CLASS, NULL); + Eo *obj = eo_add(INHERIT2_CLASS, NULL); - eo2_do(obj, simple_a_set(1)); + eo_do(obj, simple_a_set(1)); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 2); eo_unref(obj); - obj = eo2_add(INHERIT3_CLASS, NULL); + obj = eo_add(INHERIT3_CLASS, NULL); - eo2_do(obj, simple_a_set(1)); + eo_do(obj, simple_a_set(1)); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 3); eo_unref(obj); - obj = eo2_add(INHERIT2_CLASS, NULL); - eo2_do(obj, called = inherit2_print()); + obj = eo_add(INHERIT2_CLASS, NULL); + eo_do(obj, called = inherit2_print()); fail_if(!called); - eo2_do(obj, called = inherit2_print(), called = inherit2_print()); + eo_do(obj, called = inherit2_print(), called = inherit2_print()); fail_if(!called); eo_unref(obj); - obj = eo2_add(SIMPLE_CLASS, NULL); - eo2_do(obj, called = inherit2_print()); + obj = eo_add(SIMPLE_CLASS, NULL); + eo_do(obj, called = inherit2_print()); fail_if(called); #ifdef EO_DEBUG - eo2_do(obj, called = simple_class_print()); + eo_do(obj, called = simple_class_print()); fail_if(called); #endif - eo2_do(SIMPLE_CLASS, called = simple_class_print()); + eo_do(SIMPLE_CLASS, called = simple_class_print()); fail_if(!called); - eo2_do(INHERIT_CLASS, called = simple_class_print()); + eo_do(INHERIT_CLASS, called = simple_class_print()); fail_if(!called); - eo2_do(INHERIT2_CLASS, called = simple_class_print()); + eo_do(INHERIT2_CLASS, called = simple_class_print()); fail_if(!called); - eo2_do(INHERIT3_CLASS, called = simple_class_print()); + eo_do(INHERIT3_CLASS, called = simple_class_print()); fail_if(!called); #ifdef EO_DEBUG - eo2_do(SIMPLE_CLASS, called = simple_a_print()); + eo_do(SIMPLE_CLASS, called = simple_a_print()); fail_if(called); #endif - eo2_do_super(obj, SIMPLE_CLASS, eo2_constructor()); - eo2_do_super(obj, SIMPLE_CLASS, eo2_destructor()); + eo_do_super(obj, SIMPLE_CLASS, eo_constructor()); + eo_do_super(obj, SIMPLE_CLASS, eo_destructor()); eo_unref(obj); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index 1e2ef0e6f7..ce6590b143 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -34,10 +34,10 @@ _class_print(Eo_Class *klass, void *class_data EINA_UNUSED) { printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); Eina_Bool called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, called = simple_class_print()); + eo_do_super(klass, MY_CLASS, called = simple_class_print()); fail_if(called); - eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + eo_do_super(klass, MY_CLASS, called = simple_class_print2()); fail_if(called); return EINA_TRUE; @@ -51,29 +51,29 @@ _class_print2(Eo_Class *klass, void *class_data EINA_UNUSED) return EINA_TRUE; } -EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -EAPI EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); -EAPI EO2_FUNC_BODY(simple_class_print, Eina_Bool, EINA_FALSE); -EAPI EO2_FUNC_BODY(simple_class_print2, Eina_Bool, EINA_FALSE); +EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); +EAPI EO_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); +EAPI EO_FUNC_BODY(simple_class_print, Eina_Bool, EINA_FALSE); +EAPI EO_FUNC_BODY(simple_class_print2, Eina_Bool, EINA_FALSE); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(simple_a_set, _a_set, "Set property A"), - EO2_OP_FUNC(simple_a_print, _a_print, "Print property A"), - EO2_OP_FUNC(simple_class_print, _class_print, "Print class name."), - EO2_OP_FUNC(simple_class_print2, _class_print2, "Print2 class name."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(simple_a_set, _a_set, "Set property A"), + EO_OP_FUNC(simple_a_print, _a_print, "Print property A"), + EO_OP_FUNC(simple_class_print, _class_print, "Print class name."), + EO_OP_FUNC(simple_class_print2, _class_print2, "Print2 class name."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Simple_Public_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/interface/interface_interface.c b/src/tests/eo/interface/interface_interface.c index eac93cd2b0..7a58a3b8fa 100644 --- a/src/tests/eo/interface/interface_interface.c +++ b/src/tests/eo/interface/interface_interface.c @@ -8,18 +8,18 @@ #define MY_CLASS INTERFACE_CLASS -EO2_FUNC_BODY(interface_ab_sum_get, int, 0); +EO_FUNC_BODY(interface_ab_sum_get, int, 0); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(interface_ab_sum_get, NULL, "Get the sum of a and b."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(interface_ab_sum_get, NULL, "Get the sum of a and b."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Interface", EO_CLASS_TYPE_INTERFACE, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/interface/interface_interface2.c b/src/tests/eo/interface/interface_interface2.c index 198850da05..5e29c1712b 100644 --- a/src/tests/eo/interface/interface_interface2.c +++ b/src/tests/eo/interface/interface_interface2.c @@ -9,18 +9,18 @@ #define MY_CLASS INTERFACE2_CLASS -EO2_FUNC_BODY(interface2_ab_sum_get2, int, 0); +EO_FUNC_BODY(interface2_ab_sum_get2, int, 0); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(interface2_ab_sum_get2, NULL, "Print the sum of a and b."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(interface2_ab_sum_get2, NULL, "Print the sum of a and b."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Interface2", EO_CLASS_TYPE_INTERFACE, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/interface/interface_main.c b/src/tests/eo/interface/interface_main.c index 6fe9de131f..40936d42e7 100644 --- a/src/tests/eo/interface/interface_main.c +++ b/src/tests/eo/interface/interface_main.c @@ -16,18 +16,18 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); - eo2_do(obj, simple_a_set(1), simple_b_set(2)); + eo_do(obj, simple_a_set(1), simple_b_set(2)); int a = 0, b = 0, sum = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = interface_ab_sum_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get(), sum = interface_ab_sum_get()); fail_if(sum != a + b); sum = 0; - eo2_do(obj, sum = interface_ab_sum_get(), sum = interface_ab_sum_get()); + eo_do(obj, sum = interface_ab_sum_get(), sum = interface_ab_sum_get()); fail_if(sum != a + b); - eo2_do(obj, sum = interface2_ab_sum_get2(), sum = interface2_ab_sum_get2()); + eo_do(obj, sum = interface2_ab_sum_get2(), sum = interface2_ab_sum_get2()); fail_if(sum != a + b + 1); eo_unref(obj); diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index 32cd9cb31b..e4bd477357 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -30,8 +30,8 @@ _##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ } \ -EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ -EO2_FUNC_BODY(simple_##name##_get, int, 0); +EO_VOID_FUNC_BODYV(simple_##name##_set, EO_FUNC_CALL(name), int name); \ +EO_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) @@ -40,7 +40,7 @@ static int _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { int a = 0, b = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b; } @@ -49,30 +49,30 @@ static int _ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED) { int a = 0, b = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b + 1; } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), - EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), - EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), - EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), - EO2_OP_FUNC_OVERRIDE(interface_ab_sum_get, _ab_sum_get), - EO2_OP_FUNC_OVERRIDE(interface2_ab_sum_get2, _ab_sum_get2), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO_OP_FUNC(simple_b_get, _b_get, "Get property b"), + EO_OP_FUNC_OVERRIDE(interface_ab_sum_get, _ab_sum_get), + EO_OP_FUNC_OVERRIDE(interface2_ab_sum_get2, _ab_sum_get2), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, INTERFACE2_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE2_CLASS, NULL); diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c index 4578b54039..521acbe721 100644 --- a/src/tests/eo/mixin/mixin_inherit.c +++ b/src/tests/eo/mixin/mixin_inherit.c @@ -13,22 +13,22 @@ static int _a_get(Eo *obj, void *class_data EINA_UNUSED) { int ret = 0; - eo2_do_super(obj, MY_CLASS, ret = simple_a_get()); + eo_do_super(obj, MY_CLASS, ret = simple_a_get()); printf("%s %d\n", __func__, ret); return ret; } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(simple_a_get, _a_get), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(simple_a_get, _a_get), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/mixin/mixin_main.c b/src/tests/eo/mixin/mixin_main.c index a0221b3bf0..6ab6af288e 100644 --- a/src/tests/eo/mixin/mixin_main.c +++ b/src/tests/eo/mixin/mixin_main.c @@ -18,15 +18,15 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); - eo2_do(obj, simple_a_set(1), simple_b_set(2)); + eo_do(obj, simple_a_set(1), simple_b_set(2)); int a = 0, b = 0, sum = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get(), sum = mixin_ab_sum_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get(), sum = mixin_ab_sum_get()); fail_if(sum != a + b + 2); /* 2 for the two mixins... */ - eo2_do(obj, sum = mixin_ab_sum_get(), sum = mixin_ab_sum_get()); + eo_do(obj, sum = mixin_ab_sum_get(), sum = mixin_ab_sum_get()); Mixin2_Public_Data *pd2 = eo_data_scope_get(obj, MIXIN2_CLASS); fail_if(pd2->count != 6); @@ -36,8 +36,8 @@ main(int argc, char *argv[]) eo_unref(obj); - obj = eo2_add(INHERIT_CLASS, NULL); - eo2_do(obj, simple_a_set(5), a = simple_a_get()); + obj = eo_add(INHERIT_CLASS, NULL); + eo_do(obj, simple_a_set(5), a = simple_a_get()); printf("%d\n", a); fail_if(a != 5); diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index 0392e9099c..073ad3b988 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -12,7 +12,7 @@ static int _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) { int a = 0, b = 0; - eo2_do(obj, a = simple_a_get(), b = simple_b_get()); + eo_do(obj, a = simple_a_get(), b = simple_b_get()); printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); return a + b; } @@ -20,34 +20,34 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); } static void _destructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); } -EAPI EO2_FUNC_BODY(mixin_ab_sum_get, int, 0); +EAPI EO_FUNC_BODY(mixin_ab_sum_get, int, 0); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_FUNC(mixin_ab_sum_get, _ab_sum_get, "Get the sum of a and b."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_FUNC(mixin_ab_sum_get, _ab_sum_get, "Get the sum of a and b."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO2_BASE_CLASS, NULL) +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_BASE_CLASS, NULL) diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c index 621715ea86..6df0a85fec 100644 --- a/src/tests/eo/mixin/mixin_mixin2.c +++ b/src/tests/eo/mixin/mixin_mixin2.c @@ -18,14 +18,14 @@ _ab_sum_get(Eo *obj, void *class_data) Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data; int sum = 0; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); - eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); + eo_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); ++sum; pd->count += 2; { int _a = 0, _b = 0; - eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); + eo_do(obj, _a = simple_a_get(), _b = simple_b_get()); fail_if(sum != _a + _b + 1); } @@ -35,27 +35,27 @@ _ab_sum_get(Eo *obj, void *class_data) static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); } static void _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin2", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Mixin2_Public_Data), NULL, diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c index 1a90847e1f..6d0d99d4f8 100644 --- a/src/tests/eo/mixin/mixin_mixin3.c +++ b/src/tests/eo/mixin/mixin_mixin3.c @@ -18,14 +18,14 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data; int sum = 0; printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); - eo2_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); + eo_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get()); ++sum; pd->count += 3; { int _a = 0, _b = 0; - eo2_do(obj, _a = simple_a_get(), _b = simple_b_get()); + eo_do(obj, _a = simple_a_get(), _b = simple_b_get()); fail_if(sum != _a + _b + 2); } @@ -35,27 +35,27 @@ _ab_sum_get(Eo *obj, void *class_data EINA_UNUSED) static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); } static void _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_destructor()); + eo_do_super(obj, MY_CLASS, eo_destructor()); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _destructor), - EO2_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor), + EO_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin3", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Mixin3_Public_Data), NULL, diff --git a/src/tests/eo/mixin/mixin_mixin4.c b/src/tests/eo/mixin/mixin_mixin4.c index efd9e42990..f4e312f77b 100644 --- a/src/tests/eo/mixin/mixin_mixin4.c +++ b/src/tests/eo/mixin/mixin_mixin4.c @@ -12,10 +12,10 @@ #define MY_CLASS MIXIN4_CLASS static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin4", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, diff --git a/src/tests/eo/mixin/mixin_simple.c b/src/tests/eo/mixin/mixin_simple.c index 879728964f..5da36be987 100644 --- a/src/tests/eo/mixin/mixin_simple.c +++ b/src/tests/eo/mixin/mixin_simple.c @@ -31,31 +31,31 @@ _##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \ pd->name = name; \ printf("%s %d\n", __func__, pd->name); \ } \ -EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \ -EO2_FUNC_BODY(simple_##name##_get, int, 0); +EO_VOID_FUNC_BODYV(simple_##name##_set, EO_FUNC_CALL(name), int name); \ +EO_FUNC_BODY(simple_##name##_get, int, 0); _GET_SET_FUNC(a) _GET_SET_FUNC(b) -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), - EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), - EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"), - EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO_OP_FUNC(simple_b_set, _b_set, "Set property b"), + EO_OP_FUNC(simple_b_get, _b_get, "Get property b"), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Private_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL); diff --git a/src/tests/eo/signals/signals_main.c b/src/tests/eo/signals/signals_main.c index 17f6af1b54..eb0784febd 100644 --- a/src/tests/eo/signals/signals_main.c +++ b/src/tests/eo/signals/signals_main.c @@ -29,8 +29,8 @@ _a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event cb_count++; - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423)); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423)); /* Stop as we reached the 3rd one. */ return (cb_count != 3); @@ -43,136 +43,136 @@ main(int argc, char *argv[]) (void) argv; eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); /* The order of these two is undetermined. */ - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); /* This will be called afterwards. */ - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3)); /* This will never be called because the previous callback returns NULL. */ - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4)); - eo2_do(obj, simple_a_set(1)); + eo_do(obj, simple_a_set(1)); fail_if(cb_count != 3); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3)); fail_if(pd->cb_count != 3); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12)); fail_if(pd->cb_count != 3); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4)); fail_if(pd->cb_count != 2); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 0); /* Freeze/thaw. */ int fcount = 0; cb_count = 0; - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 0); - eo2_do(obj, eo2_event_freeze()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_freeze()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 1); - eo2_do(obj, eo2_event_freeze()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_freeze()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 2); - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo2_do(obj, simple_a_set(2)); + eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo2_do(obj, eo2_event_thaw()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_thaw()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 1); - eo2_do(obj, eo2_event_thaw()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_thaw()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 0); - eo2_do(obj, simple_a_set(3)); + eo_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; - eo2_do(obj, eo2_event_thaw()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_thaw()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 0); - eo2_do(obj, eo2_event_freeze()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_freeze()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 1); - eo2_do(obj, simple_a_set(2)); + eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo2_do(obj, eo2_event_thaw()); - eo2_do(obj, fcount = eo2_event_freeze_get()); + eo_do(obj, eo_event_thaw()); + eo_do(obj, fcount = eo_event_freeze_get()); fail_if(fcount != 0); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 0); - eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); + eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != -1); /* Global Freeze/thaw. */ fcount = 0; cb_count = 0; pd->cb_count = 0; - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); - eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_freeze()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); - eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_freeze()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 2); - eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); + eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); - eo2_do(obj, simple_a_set(2)); + eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_thaw()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); - eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_thaw()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); - eo2_do(obj, simple_a_set(3)); + eo_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; - eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_thaw()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); - eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_freeze()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); - eo2_do(obj, simple_a_set(2)); + eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw()); - eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get()); + eo_do(EO_BASE_CLASS, eo_event_global_thaw()); + eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c index 1de1ad9e34..6786aae8fb 100644 --- a/src/tests/eo/signals/signals_simple.c +++ b/src/tests/eo/signals/signals_simple.c @@ -23,7 +23,7 @@ _a_set(Eo *obj, void *class_data, int a) pd->a = a; printf("%s %d\n", __func__, pd->a); - eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); + eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a)); } Eina_Bool @@ -63,20 +63,20 @@ _cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_inf static void _constructor(Eo *obj, void *class_data EINA_UNUSED) { - eo2_do_super(obj, MY_CLASS, eo2_constructor()); + eo_do_super(obj, MY_CLASS, eo_constructor()); - eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); - eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); + eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); + eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); - eo2_do(obj, eo2_base_data_set("cb_count", (intptr_t) 0, NULL)); + eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL)); } -EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); +EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _constructor), - EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor), + EO_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO_OP_SENTINEL }; @@ -86,15 +86,15 @@ static const Eo_Event_Description *event_desc[] = { }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), event_desc, sizeof(Private_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); diff --git a/src/tests/eo/suite/eo_test_call_errors.c b/src/tests/eo/suite/eo_test_call_errors.c index 76a60ffc53..08e1635a7d 100644 --- a/src/tests/eo/suite/eo_test_call_errors.c +++ b/src/tests/eo/suite/eo_test_call_errors.c @@ -16,11 +16,11 @@ START_TEST(eo_pure_virtual_fct_call) eo_init(); eina_log_print_cb_set(eo_test_print_cb, &ctx); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: you called a pure virtual func '%s' (%d)."); - eo2_do(obj, simple_pure_virtual()); + TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: you called a pure virtual func '%s' (%d)."); + eo_do(obj, simple_pure_virtual()); fail_unless(ctx.did); eo_unref(obj); @@ -34,11 +34,11 @@ START_TEST(eo_api_not_implemented_call) eo_init(); eina_log_print_cb_set(eo_test_print_cb, &ctx); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - TEST_EO_ERROR("_eo2_api_op_id_get", "in %s:%d: unable to resolve %s api func %p."); - eo2_do(obj, simple_no_implementation()); + TEST_EO_ERROR("_eo_api_op_id_get", "in %s:%d: unable to resolve %s api func %p."); + eo_do(obj, simple_no_implementation()); fail_unless(ctx.did); eo_unref(obj); @@ -52,11 +52,11 @@ START_TEST(eo_op_not_found_in_super) eo_init(); eina_log_print_cb_set(eo_test_print_cb, &ctx); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - TEST_EO_ERROR("_eo2_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'."); - eo2_do_super(obj, SIMPLE_CLASS, simple_a_set(10)); + TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'."); + eo_do_super(obj, SIMPLE_CLASS, simple_a_set(10)); fail_unless(ctx.did); eo_unref(obj); diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index cbea8e1b2d..36a85151cc 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -21,10 +21,10 @@ START_TEST(eo_inherit_errors) const Eo_Class *klass_simple; static const Eo_Class_Description class_desc_simple = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -32,10 +32,10 @@ START_TEST(eo_inherit_errors) }; static const Eo_Class_Description class_desc_mixin = { - EO2_VERSION, + EO_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -43,10 +43,10 @@ START_TEST(eo_inherit_errors) }; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "General", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -56,7 +56,7 @@ START_TEST(eo_inherit_errors) klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL); fail_if(!klass_mixin); - klass_simple = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, NULL); + klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL); fail_if(!klass_simple); TEST_EO_ERROR("eo_class_new", "Non-regular classes ('%s') aren't allowed to inherit from regular classes ('%s')."); @@ -89,10 +89,10 @@ START_TEST(eo_inconsistent_mro) const Eo_Class *klass_mixin3; static const Eo_Class_Description class_desc_simple = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -100,10 +100,10 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin = { - EO2_VERSION, + EO_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -111,10 +111,10 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin2 = { - EO2_VERSION, + EO_VERSION, "Mixin2", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -122,10 +122,10 @@ START_TEST(eo_inconsistent_mro) }; static const Eo_Class_Description class_desc_mixin3 = { - EO2_VERSION, + EO_VERSION, "Mixin3", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -142,14 +142,14 @@ START_TEST(eo_inconsistent_mro) fail_if(!klass_mixin3); TEST_EO_ERROR("_eo_class_mro_init", "Cannot create a consistent method resolution order for class '%s' because of '%s'."); - klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin, klass_mixin2, NULL); + klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL); fail_if(klass); fail_unless(ctx.did); - klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin, NULL); + klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL); fail_if(!klass); - klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); + klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); fail_if(!klass); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); @@ -168,10 +168,10 @@ START_TEST(eo_bad_interface) const Eo_Class *klass; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Interface", EO_CLASS_TYPE_INTERFACE, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, @@ -216,22 +216,22 @@ START_TEST(eo_null_api) const Eo_Class *klass; - static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(NULL, _null_fct, "NULL API function"), - EO2_OP_SENTINEL + static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(NULL, _null_fct, "NULL API function"), + EO_OP_SENTINEL }; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': NULL API not allowed (%d NULL->%p '%s')."); + TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': NULL API not allowed (%d NULL->%p '%s')."); klass = eo_class_new(&class_desc, NULL, NULL); fail_if(klass); fail_unless(ctx.did); @@ -249,22 +249,22 @@ START_TEST(eo_wrong_override) const Eo_Class *klass; - static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(null_fct, _null_fct), - EO2_OP_SENTINEL + static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(null_fct, _null_fct), + EO_OP_SENTINEL }; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': Can't find api func description in class hierarchy (%p->%p)."); + TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': Can't find api func description in class hierarchy (%p->%p)."); klass = eo_class_new(&class_desc, NULL, NULL); fail_if(klass); fail_unless(ctx.did); @@ -282,23 +282,23 @@ START_TEST(eo_api_redefined) const Eo_Class *klass; - static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(null_fct, _null_fct, "API function"), - EO2_OP_FUNC(null_fct, NULL, "Redefining API function"), - EO2_OP_SENTINEL + static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(null_fct, _null_fct, "API function"), + EO_OP_FUNC(null_fct, NULL, "Redefining API function"), + EO_OP_SENTINEL }; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, NULL }; - TEST_EO_ERROR("_eo2_class_funcs_set", "Class '%s': API previously defined (%d %p->%p '%s')."); + TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': API previously defined (%d %p->%p '%s')."); klass = eo_class_new(&class_desc, NULL, NULL); fail_if(klass); fail_unless(ctx.did); @@ -316,16 +316,16 @@ START_TEST(eo_dich_func_override) const Eo_Class *klass; - static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(simple_a_set, _null_fct), - EO2_OP_FUNC_OVERRIDE(simple_a_set, NULL), - EO2_OP_SENTINEL + static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(simple_a_set, _null_fct), + EO_OP_FUNC_OVERRIDE(simple_a_set, NULL), + EO_OP_SENTINEL }; static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 0, NULL, diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index 89cd14e073..5b8c2e06ac 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -17,7 +17,7 @@ _a_set(Eo *obj EINA_UNUSED, void *class_data, int a) printf("%s %d\n", eo_class_name_get(MY_CLASS), a); pd->a = a; - eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a)); + eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a)); } static int @@ -45,7 +45,7 @@ _class_hi_print(Eo_Class *klass, void *data EINA_UNUSED) return EINA_TRUE; } -EO2_VOID_FUNC_BODYV(simple_recursive, EO2_FUNC_CALL(n), int n); +EO_VOID_FUNC_BODYV(simple_recursive, EO_FUNC_CALL(n), int n); static void _recursive(Eo *obj, void *class_data EINA_UNUSED, int n) @@ -55,7 +55,7 @@ _recursive(Eo *obj, void *class_data EINA_UNUSED, int n) if (count < n) { count++; - eo2_do(obj, simple_recursive(n)); + eo_do(obj, simple_recursive(n)); } else count = 0; @@ -64,39 +64,39 @@ _recursive(Eo *obj, void *class_data EINA_UNUSED, int n) static void _dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Eo_Dbg_Info *root) { - eo2_do_super(eo_obj, MY_CLASS, eo2_dbg_info_get(root)); + eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root)); Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, "Test list"); EO_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8); } -EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a); -EO2_FUNC_BODY(simple_a_get, int, 0); -EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); -EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE); -EO2_VOID_FUNC_BODY(simple_pure_virtual); -EO2_VOID_FUNC_BODY(simple_no_implementation); +EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); +EO_FUNC_BODY(simple_a_get, int, 0); +EO_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE); +EO_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE); +EO_VOID_FUNC_BODY(simple_pure_virtual); +EO_VOID_FUNC_BODY(simple_no_implementation); -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_dbg_info_get, _dbg_info_get), - EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"), - EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"), - EO2_OP_FUNC(simple_a_print, _a_print, "Print property a"), - EO2_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"), - EO2_OP_FUNC(simple_recursive, _recursive, "Recursive function"), - EO2_OP_FUNC(simple_pure_virtual, NULL, "Pure Virtual function"), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_dbg_info_get, _dbg_info_get), + EO_OP_FUNC(simple_a_set, _a_set, "Set property a"), + EO_OP_FUNC(simple_a_get, _a_get, "Get property a"), + EO_OP_FUNC(simple_a_print, _a_print, "Print property a"), + EO_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print property a"), + EO_OP_FUNC(simple_recursive, _recursive, "Recursive function"), + EO_OP_FUNC(simple_pure_virtual, NULL, "Pure Virtual function"), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Simple_Public_Data), NULL, NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index e0a95c6cc8..a5e9f3340c 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -11,13 +11,13 @@ START_TEST(eo_simple) { eo_init(); - Eo *obj = eo2_add(EO2_BASE_CLASS, NULL); + Eo *obj = eo_add(EO_BASE_CLASS, NULL); fail_if(obj); - obj = eo2_add(SIMPLE_CLASS, NULL); + obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - eo2_do(obj, eo2_constructor()); - eo2_do(obj, eo2_destructor()); + eo_do(obj, eo_constructor()); + eo_do(obj, eo_destructor()); eo_unref(obj); eo_shutdown(); @@ -27,10 +27,10 @@ END_TEST START_TEST(eo_stack) { eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - eo2_do(obj, simple_recursive(123)); + eo_do(obj, simple_recursive(123)); eo_unref(obj); @@ -94,23 +94,23 @@ START_TEST(eo_signals) { EO_EV_DEL, _eo_signals_eo_del_cb }, { NULL, NULL } }; - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); - eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks)); - eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks)); - eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -100, (void *) 1)); - eo2_do(obj, eo2_event_callback_array_add(callbacks, (void *) 3)); - eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -50, (void *) 2)); - eo2_do(obj, simple_a_set(1)); + eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks)); + eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks)); + eo_do(obj, eo_event_callback_array_priority_add(callbacks, -100, (void *) 1)); + eo_do(obj, eo_event_callback_array_add(callbacks, (void *) 3)); + eo_do(obj, eo_event_callback_array_priority_add(callbacks, -50, (void *) 2)); + eo_do(obj, simple_a_set(1)); ck_assert_int_eq(_eo_signals_cb_flag, 0x3); - eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 1)); - eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 2)); - eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 3)); + eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 1)); + eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 2)); + eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 3)); /* Try to delete something that doesn't exist. */ - eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 4)); + eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 4)); _eo_signals_cb_flag = 0; - eo2_do(obj, simple_a_set(1)); + eo_do(obj, simple_a_set(1)); ck_assert_int_eq(_eo_signals_cb_flag, 0x0); eo_unref(obj); @@ -125,20 +125,20 @@ START_TEST(eo_data_fetch) /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); fail_if(!klass); - Eo *obj = eo2_add(klass, NULL); + Eo *obj = eo_add(klass, NULL); fail_if(!obj); #ifdef EO_DEBUG fail_if(eo_data_scope_get(obj, SIMPLE_CLASS)); @@ -146,10 +146,10 @@ START_TEST(eo_data_fetch) eo_unref(obj); class_desc.data_size = 0; - klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); fail_if(!klass); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); fail_if(eo_data_scope_get(obj, klass)); eo_unref(obj); @@ -167,10 +167,10 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Iface", EO_CLASS_TYPE_INTERFACE, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -184,10 +184,10 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Mixin", EO_CLASS_TYPE_MIXIN, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, @@ -201,36 +201,36 @@ START_TEST(eo_isa_tests) { /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 10, NULL, NULL }; - klass = eo_class_new(&class_desc, EO2_BASE_CLASS, iface, mixin, NULL); + klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL); fail_if(!klass); } - Eo *obj = eo2_add(klass, NULL); + Eo *obj = eo_add(klass, NULL); fail_if(!obj); fail_if(eo_isa(obj, SIMPLE_CLASS)); fail_if(!eo_isa(obj, iface)); fail_if(!eo_isa(obj, mixin)); fail_if(!eo_isa(obj, klass)); - fail_if(!eo_isa(obj, EO2_BASE_CLASS)); + fail_if(!eo_isa(obj, EO_BASE_CLASS)); eo_unref(obj); - obj = eo2_add(SIMPLE_CLASS, NULL); + obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); fail_if(eo_isa(obj, klass)); fail_if(eo_isa(obj, iface)); fail_if(eo_isa(obj, mixin)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); - fail_if(!eo_isa(obj, EO2_BASE_CLASS)); + fail_if(!eo_isa(obj, EO_BASE_CLASS)); eo_unref(obj); eo_shutdown(); @@ -242,13 +242,13 @@ START_TEST(eo_composite_tests) { eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj2); eo_composite_attach(obj2, obj); - eo2_do(obj2, eo2_parent_set(NULL)); + eo_do(obj2, eo_parent_set(NULL)); fail_if(eo_composite_is(obj2)); eo_unref(obj2); @@ -267,21 +267,21 @@ _man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED) { if (_man_should_con) eo_manual_free_set(obj, EINA_TRUE); - eo2_do_super(obj, cur_klass, eo2_constructor()); + eo_do_super(obj, cur_klass, eo_constructor()); } static void _man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED) { - eo2_do_super(obj, cur_klass, eo2_destructor()); + eo_do_super(obj, cur_klass, eo_destructor()); if (_man_should_des) eo_manual_free_set(obj, EINA_FALSE); } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC_OVERRIDE(eo2_constructor, _man_con), - EO2_OP_FUNC_OVERRIDE(eo2_destructor, _man_des), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _man_con), + EO_OP_FUNC_OVERRIDE(eo_destructor, _man_des), + EO_OP_SENTINEL }; START_TEST(eo_man_free) @@ -290,35 +290,35 @@ START_TEST(eo_man_free) /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple2", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, 10, NULL, NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); fail_if(!klass); cur_klass = klass; - Eo *obj = eo2_add(klass, NULL); + Eo *obj = eo_add(klass, NULL); fail_if(!obj); eo_unref(obj); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); eo_unref(obj); _man_should_des = EINA_FALSE; - klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); cur_klass = klass; fail_if(!klass); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); fail_if(eo_destructed_is(obj)); @@ -326,23 +326,23 @@ START_TEST(eo_man_free) fail_if(!eo_destructed_is(obj)); fail_if(!eo_manual_free(obj)); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); eo_unref(obj); fail_if(!eo_destructed_is(obj)); fail_if(!eo_manual_free(obj)); _man_should_con = EINA_FALSE; - klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); cur_klass = klass; fail_if(!klass); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); fail_if(eo_manual_free(obj)); eo_unref(obj); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); eo_manual_free_set(obj, EINA_TRUE); eo_unref(obj); @@ -351,7 +351,7 @@ START_TEST(eo_man_free) eo_unref(obj); fail_if(!eo_manual_free(obj)); - obj = eo2_add(klass, NULL); + obj = eo_add(klass, NULL); fail_if(!obj); eo_manual_free_set(obj, EINA_TRUE); eo_unref(obj); @@ -369,9 +369,9 @@ END_TEST START_TEST(eo_refs) { eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); - Eo *obj3 = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); + Eo *obj3 = eo_add(SIMPLE_CLASS, NULL); eo_xref(obj, obj2); fail_if(eo_ref_get(obj) != 2); @@ -406,11 +406,11 @@ START_TEST(eo_refs) eo_unref(obj3); /* Check hierarchy */ - obj = eo2_add(SIMPLE_CLASS, NULL); - obj2 = eo2_add(SIMPLE_CLASS, obj); + obj = eo_add(SIMPLE_CLASS, NULL); + obj2 = eo_add(SIMPLE_CLASS, obj); Eo *wref = NULL; - eo2_do(obj2, eo2_wref_add(&wref)); + eo_do(obj2, eo_wref_add(&wref)); fail_if(!wref); eo_unref(obj2); @@ -422,13 +422,13 @@ START_TEST(eo_refs) fail_if(wref); /* Just check it doesn't seg atm. */ - obj = eo2_add(SIMPLE_CLASS, NULL); + obj = eo_add(SIMPLE_CLASS, NULL); eo_ref(obj); eo_unref(obj); eo_unref(obj); - obj = eo2_add(SIMPLE_CLASS, NULL); - obj2 = eo2_add(SIMPLE_CLASS, obj); + obj = eo_add(SIMPLE_CLASS, NULL); + obj2 = eo_add(SIMPLE_CLASS, obj); eo_unref(obj2); eo_ref(obj2); eo_del(obj2); @@ -442,17 +442,17 @@ START_TEST(eo_weak_reference) { eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); - Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); + Eo *obj2 = eo_add(SIMPLE_CLASS, NULL); Eo *wref = NULL, *wref2 = NULL, *wref3 = NULL; - eo2_do(obj, eo2_wref_add(&wref)); + eo_do(obj, eo_wref_add(&wref)); fail_if(!wref); eo_unref(obj); fail_if(wref); - obj = eo2_add(SIMPLE_CLASS, NULL); - eo2_do(obj, eo2_wref_add(&wref)); + obj = eo_add(SIMPLE_CLASS, NULL); + eo_do(obj, eo_wref_add(&wref)); eo_ref(obj); fail_if(!wref); @@ -463,37 +463,37 @@ START_TEST(eo_weak_reference) eo_unref(obj); fail_if(wref); - obj = eo2_add(SIMPLE_CLASS, NULL); + obj = eo_add(SIMPLE_CLASS, NULL); - eo2_do(obj, eo2_wref_add(&wref)); - eo2_do(obj, eo2_wref_del(&wref)); + eo_do(obj, eo_wref_add(&wref)); + eo_do(obj, eo_wref_del(&wref)); fail_if(wref); - eo2_do(obj, eo2_wref_add(&wref)); - eo2_do(obj2, eo2_wref_del(&wref)); + eo_do(obj, eo_wref_add(&wref)); + eo_do(obj2, eo_wref_del(&wref)); fail_if(!wref); - eo2_wref_del_safe(&wref); + eo_wref_del_safe(&wref); fail_if(wref); wref = obj; - eo2_do(obj, eo2_wref_del(&wref)); + eo_do(obj, eo_wref_del(&wref)); fail_if(wref); wref = wref2 = wref3 = NULL; - eo2_do(obj, eo2_wref_add(&wref), eo2_wref_add(&wref2), eo2_wref_add(&wref3)); + eo_do(obj, eo_wref_add(&wref), eo_wref_add(&wref2), eo_wref_add(&wref3)); fail_if(!wref); fail_if(!wref2); fail_if(!wref3); - eo2_do(obj, eo2_wref_del(&wref), eo2_wref_del(&wref2), eo2_wref_del(&wref3)); + eo_do(obj, eo_wref_del(&wref), eo_wref_del(&wref2), eo_wref_del(&wref3)); fail_if(wref); fail_if(wref2); fail_if(wref3); - eo2_do(obj, eo2_wref_add(&wref2), eo2_wref_add(&wref3)); + eo_do(obj, eo_wref_add(&wref2), eo_wref_add(&wref3)); wref = obj; - eo2_do(obj, eo2_wref_del(&wref)); + eo_do(obj, eo_wref_del(&wref)); fail_if(wref); - eo2_do(obj, eo2_wref_del(&wref2), eo2_wref_del(&wref3)); + eo_do(obj, eo_wref_del(&wref2), eo_wref_del(&wref3)); eo_unref(obj); eo_unref(obj2); @@ -516,59 +516,59 @@ _fake_free_func(void *data) START_TEST(eo_generic_data) { eo_init(); - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); void *data = NULL; - eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL)); - eo2_do(obj, data = eo2_base_data_get("test1")); + eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); + eo_do(obj, data = eo_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo2_do(obj, eo2_base_data_del("test1")); - eo2_do(obj, data = eo2_base_data_get("test1")); + eo_do(obj, eo_base_data_del("test1")); + eo_do(obj, data = eo_base_data_get("test1")); fail_if(data); - eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL)); - eo2_do(obj, eo2_base_data_set("test2", (void *) 2, NULL)); - eo2_do(obj, data = eo2_base_data_get("test1")); + eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); + eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL)); + eo_do(obj, data = eo_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo2_do(obj, data = eo2_base_data_get("test2")); + eo_do(obj, data = eo_base_data_get("test2")); fail_if(2 != (intptr_t) data); - eo2_do(obj, data = eo2_base_data_get("test2")); + eo_do(obj, data = eo_base_data_get("test2")); fail_if(2 != (intptr_t) data); - eo2_do(obj, eo2_base_data_del("test2")); - eo2_do(obj, data = eo2_base_data_get("test2")); + eo_do(obj, eo_base_data_del("test2")); + eo_do(obj, data = eo_base_data_get("test2")); fail_if(data); - eo2_do(obj, data = eo2_base_data_get("test1")); + eo_do(obj, data = eo_base_data_get("test1")); fail_if(1 != (intptr_t) data); - eo2_do(obj, eo2_base_data_del("test1")); - eo2_do(obj, data = eo2_base_data_get("test1")); + eo_do(obj, eo_base_data_del("test1")); + eo_do(obj, data = eo_base_data_get("test1")); fail_if(data); int a = 0; - eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); - eo2_do(obj, data = eo2_base_data_get("test3")); + eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); + eo_do(obj, data = eo_base_data_get("test3")); fail_if(&a != data); - eo2_do(obj, eo2_base_data_get("test3")); - eo2_do(obj, eo2_base_data_del("test3")); + eo_do(obj, eo_base_data_get("test3")); + eo_do(obj, eo_base_data_del("test3")); fail_if(a != 1); a = 0; - eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); - eo2_do(obj, eo2_base_data_set("test3", NULL, _fake_free_func)); + eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func)); fail_if(a != 1); a = 0; data = (void *) 123; - eo2_do(obj, eo2_base_data_set(NULL, &a, _fake_free_func)); - eo2_do(obj, data = eo2_base_data_get(NULL)); + eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func)); + eo_do(obj, data = eo_base_data_get(NULL)); fail_if(data); - eo2_do(obj, eo2_base_data_del(NULL)); + eo_do(obj, eo_base_data_del(NULL)); a = 0; - eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); - eo2_do(obj, eo2_base_data_set("test3", NULL, NULL)); + eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_base_data_set("test3", NULL, NULL)); fail_if(a != 1); - eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); eo_unref(obj); fail_if(a != 2); @@ -586,7 +586,7 @@ START_TEST(eo_magic_checks) memset(_buf, 1, sizeof(_buf)); - Eo *obj = eo2_add(SIMPLE_CLASS, (Eo *) buf); + Eo *obj = eo_add(SIMPLE_CLASS, (Eo *) buf); fail_if(obj); while (1) @@ -596,28 +596,28 @@ START_TEST(eo_magic_checks) Eo *wref = NULL; Eo *obj2 = NULL; - obj = eo2_add((Eo_Class *) buf, NULL); + obj = eo_add((Eo_Class *) buf, NULL); fail_if(obj); - obj = eo2_add(SIMPLE_CLASS, NULL); + obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); - eo2_do((Eo *) buf, simple_a_set(++i), a = simple_a_get()); + eo_do((Eo *) buf, simple_a_set(++i), a = simple_a_get()); ck_assert_int_ne(i, a); - eo2_do_super((Eo *) buf, SIMPLE_CLASS, simple_a_set(++i)); - eo2_do_super((Eo *) buf, SIMPLE_CLASS, a = simple_a_get()); + eo_do_super((Eo *) buf, SIMPLE_CLASS, simple_a_set(++i)); + eo_do_super((Eo *) buf, SIMPLE_CLASS, a = simple_a_get()); ck_assert_int_ne(i, a); - eo2_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i)); - eo2_do_super(obj, (const Eo_Class *) buf, a = simple_a_get()); + eo_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i)); + eo_do_super(obj, (const Eo_Class *) buf, a = simple_a_get()); ck_assert_int_ne(i, a); fail_if(eo_class_get((Eo *) buf)); fail_if(eo_class_name_get((Eo_Class*) buf)); fail_if(eo_class_get(obj) != SIMPLE_CLASS); - fail_if(eo_class_get(SIMPLE_CLASS) != EO2_CLASS_CLASS); + fail_if(eo_class_get(SIMPLE_CLASS) != EO_CLASS_CLASS); eo_class_funcs_set((Eo_Class *) buf, NULL); - eo2_do((Eo_Class *) buf,(void) NULL); - eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); - eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); + eo_do((Eo_Class *) buf,(void) NULL); + eo_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); + eo_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL); eo_xref(obj, (Eo *) buf); @@ -634,9 +634,9 @@ START_TEST(eo_magic_checks) fail_if(0 != eo_ref_get((Eo *) buf)); - eo2_do((Eo *) buf, - eo2_wref_add(&wref), - parent = eo2_parent_get()); + eo_do((Eo *) buf, + eo_wref_add(&wref), + parent = eo_parent_get()); fail_if(wref); fail_if(parent); @@ -650,8 +650,8 @@ START_TEST(eo_magic_checks) eo_composite_detach(obj, (Eo *) buf); eo_composite_is((Eo *) buf); - eo2_do(obj, eo2_event_callback_forwarder_add(NULL, (Eo *) buf)); - eo2_do(obj, eo2_event_callback_forwarder_del(NULL, (Eo *) buf)); + eo_do(obj, eo_event_callback_forwarder_add(NULL, (Eo *) buf)); + eo_do(obj, eo_event_callback_forwarder_del(NULL, (Eo *) buf)); eo_manual_free_set((Eo *) buf, EINA_TRUE); eo_manual_free((Eo *) buf); @@ -692,13 +692,13 @@ _class_hi_print(Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED) return EINA_TRUE; } -EO2_FUNC_BODY(multi_a_print, Eina_Bool, EINA_FALSE); -EO2_FUNC_BODY(multi_class_hi_print, Eina_Bool, EINA_FALSE); +EO_FUNC_BODY(multi_a_print, Eina_Bool, EINA_FALSE); +EO_FUNC_BODY(multi_class_hi_print, Eina_Bool, EINA_FALSE); -static Eo2_Op_Description _multi_do_op_descs[] = { - EO2_OP_FUNC(multi_a_print, _a_print, "Print property a"), - EO2_OP_FUNC(multi_class_hi_print, _class_hi_print, "Print Hi"), - EO2_OP_SENTINEL +static Eo_Op_Description _multi_do_op_descs[] = { + EO_OP_FUNC(multi_a_print, _a_print, "Print property a"), + EO_OP_FUNC(multi_class_hi_print, _class_hi_print, "Print Hi"), + EO_OP_SENTINEL }; START_TEST(eo_multiple_do) @@ -707,10 +707,10 @@ START_TEST(eo_multiple_do) /* Usually should be const, not const only for the test... */ static Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Inherit", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(_multi_do_op_descs), + EO_CLASS_DESCRIPTION_OPS(_multi_do_op_descs), NULL, 0, NULL, @@ -720,17 +720,17 @@ START_TEST(eo_multiple_do) const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL); fail_if(!klass); - Eo *obj = eo2_add(klass, NULL); + Eo *obj = eo_add(klass, NULL); fail_if(!obj); Eina_Bool ca, cb, cc; ca = cb = cc = EINA_FALSE; - eo2_do(obj, ca = simple_a_print(), cb = multi_a_print(), cc = multi_a_print()); + eo_do(obj, ca = simple_a_print(), cb = multi_a_print(), cc = multi_a_print()); fail_if(!(ca && cb && cc)); ca = cb = cc = EINA_FALSE; - eo2_do(klass, ca = simple_class_hi_print(), cb = multi_class_hi_print(), cc = multi_class_hi_print()); + eo_do(klass, ca = simple_class_hi_print(), cb = multi_class_hi_print(), cc = multi_class_hi_print()); fail_if(!(ca && cb && cc)); eo_unref(obj); @@ -739,23 +739,23 @@ START_TEST(eo_multiple_do) } END_TEST -START_TEST(eo2_add_do_and_custom) +START_TEST(eo_add_do_and_custom) { Simple_Public_Data *pd = NULL; Eo *obj = NULL; eo_init(); - obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor()); + obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor()); fail_if(!obj); eo_unref(obj); - obj = eo2_add(SIMPLE_CLASS, NULL, simple_a_set(7)); + obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7)); fail_if(!obj); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 7); eo_unref(obj); - obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor(), simple_a_set(7)); + obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7)); fail_if(!obj); pd = eo_data_scope_get(obj, SIMPLE_CLASS); fail_if(pd->a != 7); @@ -771,21 +771,21 @@ START_TEST(eo_pointers_indirection) eo_init(); static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Simple", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_NOOPS(), + EO_CLASS_DESCRIPTION_NOOPS(), NULL, 0, NULL, NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); fail_if(!klass); /* Check simple id validity */ - Eo *obj = eo2_add(klass, NULL); + Eo *obj = eo_add(klass, NULL); fail_if(!obj); fail_if(!eo_isa(obj, klass)); obj = (Eo *)((char *)(obj) + 1); @@ -796,10 +796,10 @@ START_TEST(eo_pointers_indirection) fail_if(eo_isa(obj, klass)); /* Check id invalidity after deletion */ - Eo *obj1 = eo2_add(klass, NULL); + Eo *obj1 = eo_add(klass, NULL); fail_if(!obj1); eo_unref(obj1); - Eo *obj2 = eo2_add(klass, NULL); + Eo *obj2 = eo_add(klass, NULL); fail_if(!obj2); fail_if(!eo_isa(obj2, klass)); fail_if(eo_isa(obj1, klass)); @@ -812,7 +812,7 @@ START_TEST(eo_pointers_indirection) /* Creation of the objects */ for ( obj_id = 0; obj_id < NB_OBJS; obj_id++) { - objs[obj_id] = eo2_add(klass, NULL); + objs[obj_id] = eo_add(klass, NULL); if(!objs[obj_id]) fail_if(!objs[obj_id]); if(!eo_isa(objs[obj_id], klass)) @@ -828,7 +828,7 @@ START_TEST(eo_pointers_indirection) /* Creation of the deleted objects */ for ( obj_id = 0; obj_id < NB_OBJS; obj_id+=2000) { - objs[obj_id] = eo2_add(klass, NULL); + objs[obj_id] = eo_add(klass, NULL); if(!objs[obj_id]) fail_if(!objs[obj_id]); if(!eo_isa(objs[obj_id], klass)) @@ -860,6 +860,6 @@ void eo_test_general(TCase *tc) tcase_add_test(tc, eo_generic_data); tcase_add_test(tc, eo_magic_checks); tcase_add_test(tc, eo_multiple_do); - tcase_add_test(tc, eo2_add_do_and_custom); + tcase_add_test(tc, eo_add_do_and_custom); tcase_add_test(tc, eo_pointers_indirection); } diff --git a/src/tests/eo/suite/eo_test_threaded_calls.c b/src/tests/eo/suite/eo_test_threaded_calls.c index a954463e46..951b6551b4 100644 --- a/src/tests/eo/suite/eo_test_threaded_calls.c +++ b/src/tests/eo/suite/eo_test_threaded_calls.c @@ -18,9 +18,9 @@ typedef struct #define THREAD_TEST_CLASS thread_test_class_get() const Eo_Class *thread_test_class_get(void); -EO2_FUNC_BODY(thread_test_v_get, int, 0); -EO2_VOID_FUNC_BODY(thread_test_try_swap_stack); -EO2_VOID_FUNC_BODYV(thread_test_constructor, EO2_FUNC_CALL(v), int v); +EO_FUNC_BODY(thread_test_v_get, int, 0); +EO_VOID_FUNC_BODY(thread_test_try_swap_stack); +EO_VOID_FUNC_BODYV(thread_test_constructor, EO_FUNC_CALL(v), int v); static int _v_get(Eo *obj EINA_UNUSED, void *class_data) @@ -53,30 +53,30 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, int v) { Thread_Test_Public_Data *pd = class_data; - eo2_do_super(obj, THREAD_TEST_CLASS, eo2_constructor()); + eo_do_super(obj, THREAD_TEST_CLASS, eo_constructor()); pd->v = v; } -static Eo2_Op_Description op_descs[] = { - EO2_OP_FUNC(thread_test_constructor, _constructor, "Constructor."), - EO2_OP_FUNC(thread_test_v_get, _v_get, "Get property v."), - EO2_OP_FUNC(thread_test_try_swap_stack, _try_swap_stack, "Swap call stack frames if it is not thread safe."), - EO2_OP_SENTINEL +static Eo_Op_Description op_descs[] = { + EO_OP_FUNC(thread_test_constructor, _constructor, "Constructor."), + EO_OP_FUNC(thread_test_v_get, _v_get, "Get property v."), + EO_OP_FUNC(thread_test_try_swap_stack, _try_swap_stack, "Swap call stack frames if it is not thread safe."), + EO_OP_SENTINEL }; static const Eo_Class_Description class_desc = { - EO2_VERSION, + EO_VERSION, "Thread Test", EO_CLASS_TYPE_REGULAR, - EO2_CLASS_DESCRIPTION_OPS(op_descs), + EO_CLASS_DESCRIPTION_OPS(op_descs), NULL, sizeof(Thread_Test_Public_Data), NULL, NULL }; -EO_DEFINE_CLASS(thread_test_class_get, &class_desc, EO2_BASE_CLASS, NULL) +EO_DEFINE_CLASS(thread_test_class_get, &class_desc, EO_BASE_CLASS, NULL) static void * _thread_job(void *data, Eina_Thread t EINA_UNUSED) @@ -87,9 +87,9 @@ _thread_job(void *data, Eina_Thread t EINA_UNUSED) if (v == 1) eina_spinlock_take(&locks[0]); - obj = eo2_add_custom(THREAD_TEST_CLASS, NULL, thread_test_constructor(v)); + obj = eo_add_custom(THREAD_TEST_CLASS, NULL, thread_test_constructor(v)); - eo2_do(obj, thread_test_try_swap_stack(), v = thread_test_v_get()); + eo_do(obj, thread_test_try_swap_stack(), v = thread_test_v_get()); eina_spinlock_release(&locks[1]); diff --git a/src/tests/eo/suite/eo_test_value.c b/src/tests/eo/suite/eo_test_value.c index 5715457657..afdec776ce 100644 --- a/src/tests/eo/suite/eo_test_value.c +++ b/src/tests/eo/suite/eo_test_value.c @@ -16,10 +16,10 @@ START_TEST(eo_value) Eina_Value val2, eo_val; void *tmpp = NULL; Eo_Dbg_Info *eo_dbg_info; - Eo *obj = eo2_add(SIMPLE_CLASS, NULL); + Eo *obj = eo_add(SIMPLE_CLASS, NULL); eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "Root"); - eo2_do(obj, eo2_dbg_info_get(eo_dbg_info)); + eo_do(obj, eo_dbg_info_get(eo_dbg_info)); fail_if(!eo_dbg_info); ck_assert_str_eq(eo_dbg_info->name, "Root"); str = eina_value_to_string(&eo_dbg_info->value); From 35525a53e0c47ecd68e573fa0878ff249498e2ef Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 11:16:09 +0100 Subject: [PATCH 157/169] Adjust eo_do calls to work with the eo2 api. --- src/lib/ecore/ecore_timer.c | 2 +- src/lib/edje/edje_edit.c | 2 +- src/lib/edje/edje_program.c | 4 +-- src/lib/edje/edje_smart.c | 6 ++--- src/lib/evas/canvas/evas_callbacks.c | 4 +-- src/lib/evas/canvas/evas_data.c | 4 +-- src/lib/evas/canvas/evas_events.c | 7 +++--- src/lib/evas/canvas/evas_object_box.c | 26 +++++++++---------- src/lib/evas/canvas/evas_object_image.c | 14 +++++------ src/lib/evas/canvas/evas_object_line.c | 4 +-- src/lib/evas/canvas/evas_object_main.c | 28 ++++++++++----------- src/lib/evas/canvas/evas_object_polygon.c | 4 +-- src/lib/evas/canvas/evas_object_rectangle.c | 4 +-- src/lib/evas/canvas/evas_object_smart.c | 6 ++--- src/lib/evas/canvas/evas_object_text.c | 8 +++--- src/lib/evas/canvas/evas_object_textblock.c | 16 ++++++------ src/lib/evas/canvas/evas_object_textgrid.c | 6 ++--- src/lib/evas/canvas/evas_out.c | 8 +++--- src/lib/evas/canvas/evas_render.c | 2 +- src/lib/evas/canvas/evas_render2.c | 2 +- src/lib/evas/filters/evas_filter.c | 2 +- 21 files changed, 80 insertions(+), 79 deletions(-) diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c index cbd87eae1a..2de040edd0 100644 --- a/src/lib/ecore/ecore_timer.c +++ b/src/lib/ecore/ecore_timer.c @@ -431,7 +431,7 @@ ecore_timer_freeze_get(Ecore_Timer *timer) { int r = 0; - eo_do(timer, eo_event_freeze_get(&r)); + eo_do(timer, r = eo_event_freeze_get()); return !!r; } diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index db301f1078..6120ff0adb 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -193,7 +193,7 @@ _edje_edit_edje_file_set(Eo *obj, Edje_Edit *eed, const char *file, const char * * groups). */ Eina_Bool int_ret = EINA_FALSE; - eo_do_super(obj, MY_CLASS, edje_obj_file_set(file, group, &int_ret)); + eo_do_super(obj, MY_CLASS, int_ret = edje_obj_file_set(file, group)); if (!int_ret) return ret; diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c index 1a2126c5ad..46bb3fdfe0 100644 --- a/src/lib/edje/edje_program.c +++ b/src/lib/edje/edje_program.c @@ -78,7 +78,7 @@ edje_object_signal_callback_del(Evas_Object *obj, const char *emission, const ch { if (!obj) return NULL; void *ret = NULL; - eo_do(obj, edje_obj_signal_callback_del(emission, source, (Edje_Signal_Cb)func, NULL, &ret)); + eo_do(obj, ret = edje_obj_signal_callback_del(emission, source, (Edje_Signal_Cb)func, NULL)); return ret; } @@ -107,7 +107,7 @@ edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, con { if (!obj) return NULL; void *ret = NULL; - eo_do(obj, edje_obj_signal_callback_del(emission, source, func, data, &ret)); + eo_do(obj, ret = edje_obj_signal_callback_del(emission, source, func, data)); return ret; } diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c index 536356edb7..a4de77fc0c 100644 --- a/src/lib/edje/edje_smart.c +++ b/src/lib/edje/edje_smart.c @@ -52,8 +52,8 @@ _edje_eo_base_dbg_info_get(Eo *eo_obj, Edje *_pd EINA_UNUSED, Eo_Dbg_Info *root) EO_DBG_INFO_APPEND(group, "File", EINA_VALUE_TYPE_STRING, file); EO_DBG_INFO_APPEND(group, "Group", EINA_VALUE_TYPE_STRING, edje_group); - Edje_Load_Error error; - eo_do(eo_obj, edje_obj_load_error_get(&error)); + Edje_Load_Error error = EDJE_LOAD_ERROR_NONE; + eo_do(eo_obj, error = edje_obj_load_error_get()); if (error != EDJE_LOAD_ERROR_NONE) { EO_DBG_INFO_APPEND(group, "Error", EINA_VALUE_TYPE_STRING, @@ -363,4 +363,4 @@ _edje_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const char *g return ret; } -#include "edje.eo.c" \ No newline at end of file +#include "edje.eo.c" diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c index 654c5d033a..5aa362f3a1 100644 --- a/src/lib/evas/canvas/evas_callbacks.c +++ b/src/lib/evas/canvas/evas_callbacks.c @@ -238,7 +238,7 @@ evas_event_callback_cleanup(Evas *eo_e) void evas_event_callback_call(Evas *eo_e, Evas_Callback_Type type, void *event_info) { - eo_do(eo_e, eo_event_callback_call(_legacy_evas_callback_table[type], event_info, NULL)); + eo_do(eo_e, eo_event_callback_call(_legacy_evas_callback_table[type], event_info)); } void @@ -299,7 +299,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data break; } - eo_do(eo_obj, eo_event_callback_call(_legacy_evas_callback_table[type], event_info, NULL)); + eo_do(eo_obj, eo_event_callback_call(_legacy_evas_callback_table[type], event_info)); if (type == EVAS_CALLBACK_MOUSE_DOWN) { diff --git a/src/lib/evas/canvas/evas_data.c b/src/lib/evas/canvas/evas_data.c index 01355b3ce1..14a384886a 100644 --- a/src/lib/evas/canvas/evas_data.c +++ b/src/lib/evas/canvas/evas_data.c @@ -18,7 +18,7 @@ evas_object_data_get(const Evas_Object *obj, const char *key) return NULL; MAGIC_CHECK_END(); void *data = NULL; - eo_do((Evas_Object *)obj, eo_base_data_get(key, &data)); + eo_do((Evas_Object *)obj, data = eo_base_data_get(key)); return data; } @@ -29,6 +29,6 @@ evas_object_data_del(Evas_Object *obj, const char *key) return NULL; MAGIC_CHECK_END(); void *data = NULL; - eo_do(obj, eo_base_data_get(key, &data), eo_base_data_del(key)); + eo_do(obj, data = eo_base_data_get(key), eo_base_data_del(key)); return data; } diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c index 3308da2bc1..d53451b94e 100644 --- a/src/lib/evas/canvas/evas_events.c +++ b/src/lib/evas/canvas/evas_events.c @@ -958,8 +958,9 @@ _canvas_event_thaw(Eo *eo_e, void *_pd, va_list *list EINA_UNUSED) { int fcount = -1; eo_do_super(eo_e, EVAS_CLASS, - eo_event_thaw(), - eo_event_freeze_get(&fcount)); + eo_event_thaw()); + eo_do_super(eo_e, EVAS_CLASS, + fcount = eo_event_freeze_get()); if (0 == fcount) { Evas_Public_Data *e = _pd; @@ -988,7 +989,7 @@ evas_event_freeze_get(const Evas *eo_e) return 0; MAGIC_CHECK_END(); int ret = 0; - eo_do((Eo *)eo_e, eo_event_freeze_get(&ret)); + eo_do((Eo *)eo_e, ret = eo_event_freeze_get()); return ret; } diff --git a/src/lib/evas/canvas/evas_object_box.c b/src/lib/evas/canvas/evas_object_box.c index 761c736296..903578f232 100644 --- a/src/lib/evas/canvas/evas_object_box.c +++ b/src/lib/evas/canvas/evas_object_box.c @@ -131,7 +131,7 @@ _on_child_del(void *data, Eo *o, const Eo_Event_Description *desc EINA_UNUSED, v Evas_Object *box = data; Evas_Object *ret = NULL; - eo_do(box, evas_obj_box_internal_remove(o, &ret)); + eo_do(box, ret = evas_obj_box_internal_remove(o)); if (!ret) ERR("child removal failed"); evas_object_smart_changed(box); @@ -163,7 +163,7 @@ _evas_object_box_option_new(Evas_Object *o, Evas_Object_Box_Data *priv EINA_UNUS { Evas_Object_Box_Option *opt = NULL; - eo_do(o, evas_obj_box_internal_option_new(child, &opt)); + eo_do(o, opt = evas_obj_box_internal_option_new(child)); if (!opt) { ERR("option_new failed"); @@ -464,7 +464,7 @@ _evas_box_eo_base_constructor(Eo *obj, Evas_Object_Box_Data *class_data EINA_UNU { eo_do_super(obj, MY_CLASS, eo_constructor()); eo_do(obj, - evas_obj_smart_callbacks_descriptions_set(_signals, NULL), + evas_obj_smart_callbacks_descriptions_set(_signals), evas_obj_type_set(MY_CLASS_NAME_LEGACY)); } @@ -1686,7 +1686,7 @@ _evas_box_append(Eo *o, Evas_Object_Box_Data *priv, Evas_Object *child) if (!child) return NULL; - eo_do(o, evas_obj_box_internal_append(child, &opt)); + eo_do(o, opt = evas_obj_box_internal_append(child)); if (opt) { @@ -1705,7 +1705,7 @@ _evas_box_prepend(Eo *o, Evas_Object_Box_Data *priv, Evas_Object *child) if (!child) return NULL; - eo_do(o, evas_obj_box_internal_prepend(child, &opt)); + eo_do(o, opt = evas_obj_box_internal_prepend(child)); if (opt) { @@ -1723,7 +1723,7 @@ _evas_box_insert_before(Eo *o, Evas_Object_Box_Data *priv, Evas_Object *child, c if (!child) return NULL; - eo_do(o, evas_obj_box_internal_insert_before(child, reference, &opt)); + eo_do(o, opt = evas_obj_box_internal_insert_before(child, reference)); if (opt) { @@ -1742,7 +1742,7 @@ _evas_box_insert_after(Eo *o, Evas_Object_Box_Data *priv, Evas_Object *child, co if (!child) return NULL; - eo_do(o, evas_obj_box_internal_insert_after(child, reference, &opt)); + eo_do(o, opt = evas_obj_box_internal_insert_after(child, reference)); if (opt) { @@ -1761,7 +1761,7 @@ _evas_box_insert_at(Eo *o, Evas_Object_Box_Data *priv, Evas_Object *child, unsig if (!child) return NULL; - eo_do(o, evas_obj_box_internal_insert_at(child, pos, &opt)); + eo_do(o, opt = evas_obj_box_internal_insert_at(child, pos)); if (opt) { @@ -1778,7 +1778,7 @@ _evas_box_remove(Eo *o, Evas_Object_Box_Data *_pd EINA_UNUSED, Evas_Object *chil { Evas_Object *obj = NULL; - eo_do(o, evas_obj_box_internal_remove(child, &obj)); + eo_do(o, obj = evas_obj_box_internal_remove(child)); if (obj) { @@ -1796,7 +1796,7 @@ _evas_box_remove_at(Eo *o, Evas_Object_Box_Data *_pd EINA_UNUSED, unsigned int p { Evas_Object *obj = NULL; - eo_do(o, evas_obj_box_internal_remove_at(pos, &obj)); + eo_do(o, obj = evas_obj_box_internal_remove_at(pos)); if (obj) { @@ -1819,7 +1819,7 @@ _evas_box_remove_all(Eo *o, Evas_Object_Box_Data *priv, Eina_Bool clear) Evas_Object_Box_Option *opt = priv->children->data; Evas_Object *obj = NULL; - eo_do(o, evas_obj_box_internal_remove(opt->obj, &obj)); + eo_do(o, obj = evas_obj_box_internal_remove(opt->obj)); if (obj) { _evas_object_box_child_callbacks_unregister(obj, o); @@ -1921,7 +1921,7 @@ EAPI Eina_Bool evas_object_box_option_property_vset(Evas_Object *o, Evas_Object_Box_Option *opt, int property, va_list args) { Eina_Bool ret = EINA_FALSE; - eo_do(o, evas_obj_box_option_property_vset(opt, property, (va_list *) &args, &ret)); + eo_do(o, ret = evas_obj_box_option_property_vset(opt, property, (va_list *) &args)); return ret; } @@ -1948,7 +1948,7 @@ EAPI Eina_Bool evas_object_box_option_property_vget(const Evas_Object *o, Evas_Object_Box_Option *opt, int property, va_list args) { Eina_Bool ret = EINA_FALSE; - eo_do((Eo *)o, evas_obj_box_option_property_vget(opt, property, (va_list *) &args, &ret)); + eo_do((Eo *)o, ret = evas_obj_box_option_property_vget(opt, property, (va_list *) &args)); return ret; } diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index 287ad1a199..146265021e 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -324,12 +324,12 @@ _evas_image_eo_base_constructor(Eo *eo_obj, Evas_Image_Data *o) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); Evas *eo_e; - Eo *parent; + Eo *parent = NULL; Evas_Colorspace cspace; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); eo_e = evas_object_evas_get(parent); evas_object_image_init(eo_obj); @@ -650,7 +650,7 @@ EAPI Eina_Bool evas_object_image_source_unset(Evas_Object *eo_obj) { Eina_Bool result = EINA_FALSE; - eo_do(eo_obj, evas_obj_image_source_set(NULL, &result)); + eo_do(eo_obj, result = evas_obj_image_source_set(NULL)); return result; } @@ -719,8 +719,8 @@ _evas_image_eo_base_dbg_info_get(Eo *eo_obj, Evas_Image_Data *o, Eo_Dbg_Info *ro if (evas_object_image_load_error_get(eo_obj) != EVAS_LOAD_ERROR_NONE) { - Evas_Load_Error error; - eo_do(eo_obj, evas_obj_image_load_error_get(&error)); + Evas_Load_Error error = EVAS_LOAD_ERROR_GENERIC; + eo_do(eo_obj, error = evas_obj_image_load_error_get()); EO_DBG_INFO_APPEND(group, "Load Error", EINA_VALUE_TYPE_STRING, evas_load_error_str(error)); } @@ -2357,8 +2357,8 @@ _proxy_subrender(Evas *eo_e, Evas_Object *eo_source, Evas_Object *eo_proxy, Evas ctx = e->engine.func->context_new(e->engine.data.output); - Eina_Bool source_clip; - eo_do(eo_proxy, evas_obj_image_source_clip_get(&source_clip)); + Eina_Bool source_clip = EINA_FALSE; + eo_do(eo_proxy, source_clip = evas_obj_image_source_clip_get()); Evas_Proxy_Render_Data proxy_render_data = { .eo_proxy = eo_proxy, diff --git a/src/lib/evas/canvas/evas_object_line.c b/src/lib/evas/canvas/evas_object_line.c index 9157314728..5968d8a001 100644 --- a/src/lib/evas/canvas/evas_object_line.c +++ b/src/lib/evas/canvas/evas_object_line.c @@ -221,13 +221,13 @@ _evas_line_eo_base_constructor(Eo *eo_obj, Evas_Line_Data *class_data EINA_UNUSE { Evas_Object_Protected_Data *obj; Evas_Line_Data *o; - Eo *parent; + Eo *parent = NULL; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); evas_object_line_init(eo_obj); - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); o = class_data; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 18ab16c253..61b54bb600 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1418,7 +1418,7 @@ evas_object_evas_get(const Evas_Object *eo_obj) return NULL; MAGIC_CHECK_END(); Evas *eo_evas = NULL; - eo_do((Eo *)eo_obj, evas_common_evas_get(&eo_evas)); + eo_do((Eo *)eo_obj, eo_evas = evas_common_evas_get()); return eo_evas; } @@ -1448,24 +1448,24 @@ _evas_object_eo_base_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EI Eina_Bool clipees_has; eo_do(eo_obj, - evas_obj_visibility_get(&visible), - evas_obj_layer_get(&layer), - evas_obj_name_get(&name), + visible = evas_obj_visibility_get(), + layer = evas_obj_layer_get(), + name = evas_obj_name_get(), evas_obj_position_get(&x, &y), evas_obj_size_get(&w, &h), - evas_obj_scale_get(&scale), + scale = evas_obj_scale_get(), evas_obj_size_hint_min_get(&minw, &minh), evas_obj_size_hint_max_get(&maxw, &maxh), evas_obj_size_hint_request_get(&requestw, &requesth), evas_obj_size_hint_align_get(&dblx, &dbly), evas_obj_size_hint_weight_get(&dblw, &dblh), evas_obj_color_get(&r, &g, &b, &a), - evas_obj_focus_get(&focus), - evas_obj_pointer_mode_get(&m), - evas_obj_pass_events_get(&pass_event), - evas_obj_repeat_events_get(&repeat_event), - evas_obj_propagate_events_get(&propagate_event), - evas_obj_clipees_has(&clipees_has)); + focus = evas_obj_focus_get(), + m = evas_obj_pointer_mode_get(), + pass_event = evas_obj_pass_events_get(), + repeat_event = evas_obj_repeat_events_get(), + propagate_event = evas_obj_propagate_events_get(), + clipees_has = evas_obj_clipees_has()); EO_DBG_INFO_APPEND(group, "Visibility", EINA_VALUE_TYPE_CHAR, visible); @@ -1540,7 +1540,7 @@ _evas_object_eo_base_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EI EO_DBG_INFO_APPEND(group, "Has clipees", EINA_VALUE_TYPE_CHAR, clipees_has); Evas_Object *clipper = NULL; - eo_do(eo_obj, evas_obj_clip_get(&clipper)); + eo_do(eo_obj, clipper = evas_obj_clip_get()); EO_DBG_INFO_APPEND(group, "Clipper", EINA_VALUE_TYPE_UINT64, (uintptr_t) clipper); const Evas_Map *map = evas_object_map_get(eo_obj); @@ -1616,8 +1616,8 @@ evas_object_top_at_pointer_get(const Evas *eo_e) Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CLASS); Evas_Object *ret = NULL; if (!e) return NULL; - eo_do((Eo *)eo_e, evas_canvas_object_top_at_xy_get(e->pointer.x, e->pointer.y, EINA_TRUE, - EINA_TRUE, &ret)); + eo_do((Eo *)eo_e, ret = evas_canvas_object_top_at_xy_get(e->pointer.x, e->pointer.y, EINA_TRUE, + EINA_TRUE)); return ret; } diff --git a/src/lib/evas/canvas/evas_object_polygon.c b/src/lib/evas/canvas/evas_object_polygon.c index 2c6d0bdc8b..d38c9c8825 100644 --- a/src/lib/evas/canvas/evas_object_polygon.c +++ b/src/lib/evas/canvas/evas_object_polygon.c @@ -108,13 +108,13 @@ EOLIAN static void _evas_polygon_eo_base_constructor(Eo *eo_obj, Evas_Polygon_Data *class_data EINA_UNUSED) { Evas_Object_Protected_Data *obj; - Eo *parent; + Eo *parent = NULL; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); evas_object_polygon_init(eo_obj); - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); } diff --git a/src/lib/evas/canvas/evas_object_rectangle.c b/src/lib/evas/canvas/evas_object_rectangle.c index 8714fc35f0..dd84f45c74 100644 --- a/src/lib/evas/canvas/evas_object_rectangle.c +++ b/src/lib/evas/canvas/evas_object_rectangle.c @@ -95,14 +95,14 @@ evas_object_rectangle_add(Evas *e) EOLIAN static void _evas_rectangle_eo_base_constructor(Eo *eo_obj, Evas_Rectangle_Data *class_data EINA_UNUSED) { - Eo *parent; + Eo *parent = NULL; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); evas_object_rectangle_init(eo_obj); - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); } diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c index 2a2aeb2869..d6c3ba2571 100644 --- a/src/lib/evas/canvas/evas_object_smart.c +++ b/src/lib/evas/canvas/evas_object_smart.c @@ -547,7 +547,7 @@ _evas_smart_eo_base_constructor(Eo *eo_obj, Evas_Smart_Data *class_data EINA_UNU { Evas_Object_Protected_Data *obj; Evas_Smart_Data *smart; - Eo *parent; + Eo *parent = NULL; smart = class_data; smart->object = eo_obj; @@ -556,7 +556,7 @@ _evas_smart_eo_base_constructor(Eo *eo_obj, Evas_Smart_Data *class_data EINA_UNU evas_object_smart_init(eo_obj); obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); eo_do(eo_obj, evas_obj_type_set(MY_CLASS_NAME_LEGACY), @@ -797,7 +797,7 @@ evas_object_smart_callback_call(Evas_Object *eo_obj, const char *event, void *ev if (!event) return; const _Evas_Event_Description *event_desc = eina_hash_find(signals_hash_table, event); if (event_desc) - eo_do(eo_obj, eo_event_callback_call(event_desc->eo_desc, event_info, NULL)); + eo_do(eo_obj, eo_event_callback_call(event_desc->eo_desc, event_info)); } EOLIAN static Eina_Bool diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 1e56bfa073..2e77b1644a 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -383,9 +383,9 @@ _evas_text_eo_base_constructor(Eo *eo_obj, Evas_Text_Data *class_data EINA_UNUSE eo_do_super(eo_obj, MY_CLASS, eo_constructor()); evas_object_text_init(eo_obj); Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); - Eo *parent; + Eo *parent = NULL; - eo_do(eo_obj, eo_parent_get(&parent)); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); } @@ -961,10 +961,10 @@ _evas_text_eo_base_dbg_info_get(Eo *eo_obj, Evas_Text_Data *o EINA_UNUSED, Eo_Db EO_DBG_INFO_APPEND(group, "Font", EINA_VALUE_TYPE_STRING, text); EO_DBG_INFO_APPEND(group, "Text size", EINA_VALUE_TYPE_INT, size); - eo_do(eo_obj, evas_obj_text_font_source_get(&text)); + eo_do(eo_obj, text = evas_obj_text_font_source_get()); EO_DBG_INFO_APPEND(group, "Font source", EINA_VALUE_TYPE_STRING, text); - eo_do(eo_obj, evas_obj_text_text_get(&text)); + eo_do(eo_obj, text = evas_obj_text_text_get()); EO_DBG_INFO_APPEND(group, "Text", EINA_VALUE_TYPE_STRING, text); } diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 785d687a92..060c91c27e 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -5499,7 +5499,7 @@ _evas_textblock_eo_base_constructor(Eo *eo_obj, Evas_Textblock_Data *class_data { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); Evas_Textblock_Data *o; - Eo *eo_parent; + Eo *eo_parent = NULL; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); @@ -5513,7 +5513,7 @@ _evas_textblock_eo_base_constructor(Eo *eo_obj, Evas_Textblock_Data *class_data _format_command_init(); evas_object_textblock_init(eo_obj); - eo_do(eo_obj, eo_parent_get(&eo_parent)); + eo_do(eo_obj, eo_parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(eo_parent)); } @@ -6889,7 +6889,7 @@ EAPI const Evas_Object_Textblock_Node_Format * evas_textblock_node_format_first_get(const Evas_Object *eo_obj) { const Evas_Object_Textblock_Node_Format *format = NULL; - eo_do((Eo *)eo_obj, evas_obj_textblock_node_format_first_get(&format)); + eo_do((Eo *)eo_obj, format = evas_obj_textblock_node_format_first_get()); return format; } @@ -6903,7 +6903,7 @@ EAPI const Evas_Object_Textblock_Node_Format * evas_textblock_node_format_last_get(const Evas_Object *eo_obj) { const Evas_Object_Textblock_Node_Format *format = NULL; - eo_do((Eo *)eo_obj, evas_obj_textblock_node_format_last_get(&format)); + eo_do((Eo *)eo_obj, format = evas_obj_textblock_node_format_last_get()); return format; } @@ -10506,13 +10506,13 @@ _evas_textblock_eo_base_dbg_info_get(Eo *eo_obj, Evas_Textblock_Data *o EINA_UNU Eo_Dbg_Info *node; const char *style; - const char *text; + const char *text = NULL; char shorttext[48]; - const Evas_Textblock_Style *ts; + const Evas_Textblock_Style *ts = NULL; - eo_do(eo_obj, evas_obj_textblock_style_get(&ts)); + eo_do(eo_obj, ts = evas_obj_textblock_style_get()); style = evas_textblock_style_get(ts); - eo_do(eo_obj, evas_obj_textblock_text_markup_get(&text)); + eo_do(eo_obj, text = evas_obj_textblock_text_markup_get()); strncpy(shorttext, text, 38); if (shorttext[37]) strcpy(shorttext + 37, "\xe2\x80\xa6"); /* HORIZONTAL ELLIPSIS */ diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c index 6870b60d6c..6af6a89a80 100644 --- a/src/lib/evas/canvas/evas_object_textgrid.c +++ b/src/lib/evas/canvas/evas_object_textgrid.c @@ -1065,14 +1065,14 @@ evas_object_textgrid_add(Evas *e) EOLIAN static void _evas_textgrid_eo_base_constructor(Eo *eo_obj, Evas_Textgrid_Data *class_data EINA_UNUSED) { - Eo *eo_parent; + Eo *eo_parent = NULL; eo_do_super(eo_obj, MY_CLASS, eo_constructor()); Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); evas_object_textgrid_init(eo_obj); - eo_do(eo_obj, eo_parent_get(&eo_parent)); + eo_do(eo_obj, eo_parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(eo_parent)); } @@ -1497,7 +1497,7 @@ _evas_textgrid_eo_base_dbg_info_get(Eo *eo_obj, Evas_Textgrid_Data *o EINA_UNUSE EO_DBG_INFO_APPEND(group, "Font", EINA_VALUE_TYPE_STRING, text); EO_DBG_INFO_APPEND(group, "Text size", EINA_VALUE_TYPE_INT, size); - eo_do(eo_obj, evas_obj_textgrid_font_source_get(&text)); + eo_do(eo_obj, text = evas_obj_textgrid_font_source_get()); EO_DBG_INFO_APPEND(group, "Font source", EINA_VALUE_TYPE_STRING, text); { diff --git a/src/lib/evas/canvas/evas_out.c b/src/lib/evas/canvas/evas_out.c index 314ced98da..a77bed0788 100644 --- a/src/lib/evas/canvas/evas_out.c +++ b/src/lib/evas/canvas/evas_out.c @@ -29,10 +29,10 @@ evas_out_add(Evas *e) EOLIAN static void _evas_out_eo_base_constructor(Eo *eo_obj, Evas_Out_Data *eo_dat) { - Eo *eo_parent; + Eo *eo_parent = NULL; Evas_Public_Data *e; - eo_do(eo_obj, eo_parent_get(&eo_parent)); + eo_do(eo_obj, eo_parent = eo_parent_get()); e = eo_data_scope_get(eo_parent, EVAS_CLASS); eo_do_super(eo_obj, MY_CLASS, eo_constructor()); @@ -54,10 +54,10 @@ evas_output_del(Evas_Out *evo) EOLIAN static void _evas_out_eo_base_destructor(Eo *eo_obj, Evas_Out_Data *eo_dat) { - Eo *eo_parent; + Eo *eo_parent = NULL; Evas_Public_Data *e; - eo_do(eo_obj, eo_parent_get(&eo_parent)); + eo_do(eo_obj, eo_parent = eo_parent_get()); e = eo_data_scope_get(eo_parent, EVAS_CLASS); if (!e) return ; // XXX: need to free output and context one they get allocated one day diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c index f1776ff958..5ffe0f41c1 100644 --- a/src/lib/evas/canvas/evas_render.c +++ b/src/lib/evas/canvas/evas_render.c @@ -1599,7 +1599,7 @@ _cb_always_call(Evas *eo_e, Evas_Callback_Type type, void *event_info) { int freeze_num = 0, i; - eo_do(eo_e, eo_event_freeze_get(&freeze_num)); + eo_do(eo_e, freeze_num = eo_event_freeze_get()); for (i = 0; i < freeze_num; i++) eo_do(eo_e, eo_event_thaw()); evas_event_callback_call(eo_e, type, event_info); for (i = 0; i < freeze_num; i++) eo_do(eo_e, eo_event_freeze()); diff --git a/src/lib/evas/canvas/evas_render2.c b/src/lib/evas/canvas/evas_render2.c index f853473a56..5fe8913849 100644 --- a/src/lib/evas/canvas/evas_render2.c +++ b/src/lib/evas/canvas/evas_render2.c @@ -121,7 +121,7 @@ _evas_render2_always_call(Eo *eo_e, Evas_Callback_Type type, void *event_info) { int freeze_num = 0, i; - eo_do(eo_e, eo_event_freeze_get(&freeze_num)); + eo_do(eo_e, freeze_num = eo_event_freeze_get()); for (i = 0; i < freeze_num; i++) eo_do(eo_e, eo_event_thaw()); evas_event_callback_call(eo_e, type, event_info); for (i = 0; i < freeze_num; i++) eo_do(eo_e, eo_event_freeze()); diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c index dec5149677..e5536da704 100644 --- a/src/lib/evas/filters/evas_filter.c +++ b/src/lib/evas/filters/evas_filter.c @@ -250,7 +250,7 @@ _proxy_subrender(Evas *eo_e, Evas_Object *eo_source, Evas_Object *eo_proxy, ctx = e->engine.func->context_new(e->engine.data.output); if (eo_isa(eo_proxy, EVAS_OBJ_IMAGE_CLASS)) - eo_do(eo_proxy, evas_obj_image_source_clip_get(&source_clip)); + eo_do(eo_proxy, source_clip = evas_obj_image_source_clip_get()); Evas_Proxy_Render_Data proxy_render_data = { .eo_proxy = eo_proxy, From 1866909ba1084d1b2cbcd324c9c8a81ab80405f0 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 11:41:25 +0100 Subject: [PATCH 158/169] Eo: Changed eo_prefix for base class to 'eo'. This is better than eo_base, as it's super common. --- src/lib/eo/eo_base.eo | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo index 376ba38415..d44b9154b4 100644 --- a/src/lib/eo/eo_base.eo +++ b/src/lib/eo/eo_base.eo @@ -1,5 +1,7 @@ abstract Eo_Base () { + eo_prefix: eo; + constructors { constructor { /*@ Call the object's constructor. @@ -75,7 +77,7 @@ Prevents event callbacks from being called for the object. */ /*@ Call the object's destructor. Should not be used with #eo_do. Only use it with #eo_do_super. */ } - data_set { + key_data_set { /*@ Set generic data to object. */ params { @in const char* key; /*@ the key associated with the data */ @@ -83,7 +85,7 @@ Should not be used with #eo_do. Only use it with #eo_do_super. */ @in eo_base_data_free_func free_func; /*@ the func to free data with (NULL means */ } } - data_get { + key_data_get { /*@ Get generic data from object. */ params { @in const char* key; /*@ the key associated with the data */ @@ -102,7 +104,7 @@ Should not be used with #eo_do. Only use it with #eo_do_super. */ /*@ thaw events of object. Lets event callbacks be called for the object. */ } - data_del { + key_data_del { /*@ Del generic data from object. */ params { @in const char* key; /*@ the key associated with the data */ From 374af9b9cad96e499cfd9d3de99b30d2096d8cab Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 11:42:00 +0100 Subject: [PATCH 159/169] Eo: eo_base's data_*->key_data_*. --- src/examples/ecore/ecore_audio_playback.c | 2 +- src/examples/eo/evas/evas_evas_obj.h | 4 +- src/lib/ecore_audio/ecore_audio.eo | 2 +- src/lib/ecore_audio/ecore_audio_in_tone.eo | 6 +-- src/lib/edje/edje_multisense.c | 2 +- src/lib/eo/Eo.h | 22 ++++---- src/lib/eo/eo2_base_class.c | 20 +++---- src/lib/eo/eo_base.eo | 2 +- src/lib/evas/canvas/evas_data.c | 6 +-- src/tests/ecore/ecore_test_ecore_audio.c | 12 ++--- .../composite_objects_comp.c | 2 +- .../composite_objects_main.c | 2 +- src/tests/eo/signals/signals_simple.c | 2 +- src/tests/eo/suite/eo_test_general.c | 52 +++++++++---------- 14 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/examples/ecore/ecore_audio_playback.c b/src/examples/ecore/ecore_audio_playback.c index 6c93fd565a..56bfa070f9 100644 --- a/src/examples/ecore/ecore_audio_playback.c +++ b/src/examples/ecore/ecore_audio_playback.c @@ -266,7 +266,7 @@ main(int argc, const char *argv[]) { if (!strncmp(val, "freq=", 5)) { freq = atoi(&val[5]); - eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); + eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); } else if (!strncmp(val, "duration=", 9)) { eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9]))); } diff --git a/src/examples/eo/evas/evas_evas_obj.h b/src/examples/eo/evas/evas_evas_obj.h index 7aa761c648..cda796023d 100644 --- a/src/examples/eo/evas/evas_evas_obj.h +++ b/src/examples/eo/evas/evas_evas_obj.h @@ -76,7 +76,7 @@ static inline Evas_Object * eo_evas_object_get(const Eo *obj) { void *data; - eo_do((Eo *) obj, eo_base_data_get(EXEVAS_OBJ_STR, &data)); + eo_do((Eo *) obj, eo_key_data_get(EXEVAS_OBJ_STR, &data)); return data; } @@ -84,7 +84,7 @@ eo_evas_object_get(const Eo *obj) static inline void eo_evas_object_set(Eo *obj, Evas_Object *evas_obj) { - eo_do(obj, eo_base_data_set(EXEVAS_OBJ_STR, evas_obj, NULL)); + eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj, NULL)); } #endif diff --git a/src/lib/ecore_audio/ecore_audio.eo b/src/lib/ecore_audio/ecore_audio.eo index b5dcf99b33..ace7e801b6 100644 --- a/src/lib/ecore_audio/ecore_audio.eo +++ b/src/lib/ecore_audio/ecore_audio.eo @@ -110,7 +110,7 @@ class Ecore_Audio (Eo_Base) params { Ecore_Audio_Vio *vio; /*The @ref Ecore_Audio_Vio struct with the function callbacks*/ void *data; /*User data to pass to the VIO functions*/ - eo_base_data_free_func free_func; /*This function takes care to clean up @ref data when he VIO is destroyed. NULL means do nothing.*/ + eo_key_data_free_func free_func; /*This function takes care to clean up @ref data when he VIO is destroyed. NULL means do nothing.*/ } } } diff --git a/src/lib/ecore_audio/ecore_audio_in_tone.eo b/src/lib/ecore_audio/ecore_audio_in_tone.eo index 6b3e489368..d0970519b8 100644 --- a/src/lib/ecore_audio/ecore_audio_in_tone.eo +++ b/src/lib/ecore_audio/ecore_audio_in_tone.eo @@ -3,10 +3,10 @@ class Ecore_Audio_In_Tone (Ecore_Audio_In) eo_prefix: ecore_audio_obj_in_tone; implements { Eo_Base::constructor; - Eo_Base::data_set; - Eo_Base::data_get; + Eo_Base::key_data_set; + Eo_Base::key_data_get; Ecore_Audio_In::length::set; Ecore_Audio_In::seek; Ecore_Audio_In::read_internal; } -} \ No newline at end of file +} diff --git a/src/lib/edje/edje_multisense.c b/src/lib/edje/edje_multisense.c index 07653a15ea..7fc8fc54ed 100644 --- a/src/lib/edje/edje_multisense.c +++ b/src/lib/edje/edje_multisense.c @@ -264,7 +264,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const { in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL); eo_do(in, ecore_audio_obj_name_set("tone")); - eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL)); + eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL)); eo_do(in, ecore_audio_obj_in_length_set(duration)); eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL)); diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 6258960f9f..57dca7e1ce 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -942,10 +942,10 @@ EAPI const Eo_Class *eo_class_class_get(void); EAPI const Eo_Class *eo_base_class_get(void); /** - * @typedef eo_base_data_free_func + * @typedef eo_key_data_free_func * Data free func prototype. */ -typedef void (*eo_base_data_free_func)(void *); +typedef void (*eo_key_data_free_func)(void *); /** * @brief Set generic data to object. @@ -953,20 +953,20 @@ typedef void (*eo_base_data_free_func)(void *); * @param[in] data the data to set. * @param[in] free_func the func to free data with (NULL means "do nothing"). * - * @see #eo_base_data_get - * @see #eo_base_data_del + * @see #eo_key_data_get + * @see #eo_key_data_del */ -EAPI void eo_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func); +EAPI void eo_key_data_set(const char *key, const void *data, eo_key_data_free_func free_func); /** * @brief Get generic data from object. * @param[in] key the key associated with the data * @param[out] data the data for the key * - * @see #eo_base_data_set - * @see #eo_base_data_del + * @see #eo_key_data_set + * @see #eo_key_data_del */ -EAPI void *eo_base_data_get(const char *key); +EAPI void *eo_key_data_get(const char *key); /** * @brief Get dbg information from the object. @@ -978,10 +978,10 @@ EAPI void eo_dbg_info_get(Eo_Dbg_Info *root_node); * @brief Del generic data from object. * @param[in] key the key associated with the data * - * @see #eo_base_data_set - * @see #eo_base_data_get + * @see #eo_key_data_set + * @see #eo_key_data_get */ -EAPI void eo_base_data_del(const char *key); +EAPI void eo_key_data_del(const char *key); /** * @brief Set the parent of an object diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index e41433d538..2ed01fcecd 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -31,7 +31,7 @@ typedef struct EINA_INLIST; Eina_Stringshare *key; void *data; - eo_base_data_free_func free_func; + eo_key_data_free_func free_func; } Eo_Generic_Data_Node; static void @@ -60,7 +60,7 @@ _eo_generic_data_del_all(Private_Data *pd) static void _data_set(Eo *obj, void *class_data, - const char *key, const void *data, eo_base_data_free_func free_func) + const char *key, const void *data, eo_key_data_free_func free_func) { Private_Data *pd = class_data; @@ -68,7 +68,7 @@ _data_set(Eo *obj, void *class_data, if (!key) return; - eo_do(obj, eo_base_data_del(key); ); + eo_do(obj, eo_key_data_del(key); ); node = malloc(sizeof(Eo_Generic_Data_Node)); if (!node) return; @@ -78,8 +78,8 @@ _data_set(Eo *obj, void *class_data, pd->generic_data = eina_inlist_prepend(pd->generic_data, EINA_INLIST_GET(node)); } -EAPI EO_VOID_FUNC_BODYV(eo_base_data_set, EO_FUNC_CALL(key, data, free_func), - const char *key, const void *data, eo_base_data_free_func free_func); +EAPI EO_VOID_FUNC_BODYV(eo_key_data_set, EO_FUNC_CALL(key, data, free_func), + const char *key, const void *data, eo_key_data_free_func free_func); static void * _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) @@ -102,7 +102,7 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key) return NULL; } -EAPI EO_FUNC_BODYV(eo_base_data_get, void*, NULL, EO_FUNC_CALL(key), const char *key); +EAPI EO_FUNC_BODYV(eo_key_data_get, void*, NULL, EO_FUNC_CALL(key), const char *key); static void _parent_set(Eo *obj, void *class_data, Eo *parent_id) @@ -289,7 +289,7 @@ _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key) } } } -EAPI EO_VOID_FUNC_BODYV(eo_base_data_del, EO_FUNC_CALL(key), const char *key); +EAPI EO_VOID_FUNC_BODYV(eo_key_data_del, EO_FUNC_CALL(key), const char *key); /* Weak reference. */ @@ -961,9 +961,9 @@ static Eo_Op_Description op_descs [] = { EO_OP_FUNC(eo_parent_set, _parent_set, "Set parent."), EO_OP_FUNC(eo_parent_get, _parent_get, "Get parent."), EO_OP_FUNC(eo_children_iterator_new, _children_iterator_new, "Get Children Iterator."), - EO_OP_FUNC(eo_base_data_set, _data_set, "Set data for key."), - EO_OP_FUNC(eo_base_data_get, _data_get, "Get data for key."), - EO_OP_FUNC(eo_base_data_del, _data_del, "Del key."), + EO_OP_FUNC(eo_key_data_set, _data_set, "Set data for key."), + EO_OP_FUNC(eo_key_data_get, _data_get, "Get data for key."), + EO_OP_FUNC(eo_key_data_del, _data_del, "Del key."), EO_OP_FUNC(eo_wref_add, _wref_add, "Add a weak ref to the object."), EO_OP_FUNC(eo_wref_del, _wref_del, "Delete the weak ref."), EO_OP_FUNC(eo_event_callback_priority_add, _ev_cb_priority_add, "Add an event callback with a priority."), diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo index d44b9154b4..d3980544b2 100644 --- a/src/lib/eo/eo_base.eo +++ b/src/lib/eo/eo_base.eo @@ -82,7 +82,7 @@ Should not be used with #eo_do. Only use it with #eo_do_super. */ params { @in const char* key; /*@ the key associated with the data */ @in const void* data; /*@ the data to set */ - @in eo_base_data_free_func free_func; /*@ the func to free data with (NULL means */ + @in eo_key_data_free_func free_func; /*@ the func to free data with (NULL means */ } } key_data_get { diff --git a/src/lib/evas/canvas/evas_data.c b/src/lib/evas/canvas/evas_data.c index 14a384886a..4686595d36 100644 --- a/src/lib/evas/canvas/evas_data.c +++ b/src/lib/evas/canvas/evas_data.c @@ -8,7 +8,7 @@ evas_object_data_set(Evas_Object *obj, const char *key, const void *data) MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); - eo_do(obj, eo_base_data_set(key, data, NULL)); + eo_do(obj, eo_key_data_set(key, data, NULL)); } EAPI void * @@ -18,7 +18,7 @@ evas_object_data_get(const Evas_Object *obj, const char *key) return NULL; MAGIC_CHECK_END(); void *data = NULL; - eo_do((Evas_Object *)obj, data = eo_base_data_get(key)); + eo_do((Evas_Object *)obj, data = eo_key_data_get(key)); return data; } @@ -29,6 +29,6 @@ evas_object_data_del(Evas_Object *obj, const char *key) return NULL; MAGIC_CHECK_END(); void *data = NULL; - eo_do(obj, data = eo_base_data_get(key), eo_base_data_del(key)); + eo_do(obj, data = eo_key_data_get(key), eo_key_data_del(key)); return data; } diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c index d62838422e..04782ce916 100644 --- a/src/tests/ecore/ecore_test_ecore_audio.c +++ b/src/tests/ecore/ecore_test_ecore_audio.c @@ -116,7 +116,7 @@ START_TEST(ecore_test_ecore_audio_cleanup) in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL); fail_if(!in); - eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); + eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); eo_do(in, ecore_audio_obj_in_length_set(2)); out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); @@ -166,17 +166,17 @@ START_TEST(ecore_test_ecore_audio_obj_tone) eo_do(in, ecore_audio_obj_in_remaining_get(&len)); fail_if(len != 2.5); - eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); + eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); fail_if(freq != 1000); freq = 2000; - eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); + eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); - eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); + eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); fail_if(freq != 2000); - eo_do(in, eo_base_data_set("foo", "bar", NULL)); - eo_do(in, eo_base_data_get("foo", (void **)&tmp)); + eo_do(in, eo_key_data_set("foo", "bar", NULL)); + eo_do(in, eo_key_data_get("foo", (void **)&tmp)); ck_assert_str_eq(tmp, "bar"); eo_do(in, ecore_audio_obj_in_seek(5.0, SEEK_SET, &len)); diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index c711ffe28f..8d4756be5b 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -31,7 +31,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) fail_if(eo_composite_is(obj)); fail_if(!eo_composite_is(simple)); - eo_do(obj, eo_base_data_set("simple-obj", simple, NULL)); + eo_do(obj, eo_key_data_set("simple-obj", simple, NULL)); eo_unref(simple); } diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c index ecf5983cb0..9c3d95c426 100644 --- a/src/tests/eo/composite_objects/composite_objects_main.c +++ b/src/tests/eo/composite_objects/composite_objects_main.c @@ -45,7 +45,7 @@ main(int argc, char *argv[]) /* disable the callback forwarder, and fail if it's still called. */ Eo *simple = NULL; - eo_do(obj, simple = eo_base_data_get("simple-obj")); + eo_do(obj, simple = eo_key_data_get("simple-obj")); eo_ref(simple); eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj)); diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c index 6786aae8fb..f370a2794b 100644 --- a/src/tests/eo/signals/signals_simple.c +++ b/src/tests/eo/signals/signals_simple.c @@ -68,7 +68,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED) eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); - eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL)); + eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0, NULL)); } EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a); diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index a5e9f3340c..2f6d79e4cc 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -519,56 +519,56 @@ START_TEST(eo_generic_data) Eo *obj = eo_add(SIMPLE_CLASS, NULL); void *data = NULL; - eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); - eo_do(obj, data = eo_base_data_get("test1")); + eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL)); + eo_do(obj, data = eo_key_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test1")); - eo_do(obj, data = eo_base_data_get("test1")); + eo_do(obj, eo_key_data_del("test1")); + eo_do(obj, data = eo_key_data_get("test1")); fail_if(data); - eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL)); - eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL)); - eo_do(obj, data = eo_base_data_get("test1")); + eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL)); + eo_do(obj, eo_key_data_set("test2", (void *) 2, NULL)); + eo_do(obj, data = eo_key_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, data = eo_base_data_get("test2")); + eo_do(obj, data = eo_key_data_get("test2")); fail_if(2 != (intptr_t) data); - eo_do(obj, data = eo_base_data_get("test2")); + eo_do(obj, data = eo_key_data_get("test2")); fail_if(2 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test2")); - eo_do(obj, data = eo_base_data_get("test2")); + eo_do(obj, eo_key_data_del("test2")); + eo_do(obj, data = eo_key_data_get("test2")); fail_if(data); - eo_do(obj, data = eo_base_data_get("test1")); + eo_do(obj, data = eo_key_data_get("test1")); fail_if(1 != (intptr_t) data); - eo_do(obj, eo_base_data_del("test1")); - eo_do(obj, data = eo_base_data_get("test1")); + eo_do(obj, eo_key_data_del("test1")); + eo_do(obj, data = eo_key_data_get("test1")); fail_if(data); int a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, data = eo_base_data_get("test3")); + eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func)); + eo_do(obj, data = eo_key_data_get("test3")); fail_if(&a != data); - eo_do(obj, eo_base_data_get("test3")); - eo_do(obj, eo_base_data_del("test3")); + eo_do(obj, eo_key_data_get("test3")); + eo_do(obj, eo_key_data_del("test3")); fail_if(a != 1); a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func)); + eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_key_data_set("test3", NULL, _fake_free_func)); fail_if(a != 1); a = 0; data = (void *) 123; - eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func)); - eo_do(obj, data = eo_base_data_get(NULL)); + eo_do(obj, eo_key_data_set(NULL, &a, _fake_free_func)); + eo_do(obj, data = eo_key_data_get(NULL)); fail_if(data); - eo_do(obj, eo_base_data_del(NULL)); + eo_do(obj, eo_key_data_del(NULL)); a = 0; - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); - eo_do(obj, eo_base_data_set("test3", NULL, NULL)); + eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_key_data_set("test3", NULL, NULL)); fail_if(a != 1); - eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func)); + eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func)); eo_unref(obj); fail_if(a != 2); From 92cc33c46ff04db9a4a3a88e563a66a52f22cbe0 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 12:01:16 +0100 Subject: [PATCH 160/169] Eo: EO_BASE_CLASS->EO_CLASS. --- src/benchmarks/eo/class_simple.c | 2 +- src/examples/eo/evas/evas_evas_obj.c | 2 +- src/examples/eo/isa/eo_isa_simple.c | 2 +- src/examples/eo/simple/simple_simple.c | 2 +- src/lib/ecore_audio/ecore_audio_obj.h | 2 +- src/lib/ecore_audio/ecore_audio_obj_in.c | 2 +- .../ecore_audio/ecore_audio_obj_in_sndfile.c | 2 +- src/lib/ecore_audio/ecore_audio_obj_in_tone.c | 8 ++--- src/lib/ecore_audio/ecore_audio_obj_in_tone.h | 2 +- src/lib/ecore_audio/ecore_audio_obj_out.c | 2 +- .../ecore_audio/ecore_audio_obj_out_pulse.c | 8 ++--- src/lib/ecore_audio/ecore_audio_private.h | 2 +- src/lib/eo/Eo.h | 6 ++-- src/lib/eo/eo2_base_class.c | 8 ++--- src/tests/eo/access/access_simple.c | 2 +- .../composite_objects_comp.c | 2 +- .../composite_objects_simple.c | 2 +- .../eo/constructors/constructors_mixin.c | 2 +- .../eo/constructors/constructors_simple.c | 2 +- .../eo/constructors/constructors_simple2.c | 2 +- .../eo/constructors/constructors_simple3.c | 2 +- .../eo/constructors/constructors_simple5.c | 2 +- .../eo/constructors/constructors_simple6.c | 2 +- .../function_overrides_simple.c | 2 +- src/tests/eo/interface/interface_simple.c | 2 +- src/tests/eo/mixin/mixin_mixin.c | 2 +- src/tests/eo/mixin/mixin_simple.c | 2 +- src/tests/eo/signals/signals_main.c | 30 +++++++++---------- src/tests/eo/signals/signals_simple.c | 2 +- src/tests/eo/suite/eo_test_class_errors.c | 8 ++--- src/tests/eo/suite/eo_test_class_simple.c | 2 +- src/tests/eo/suite/eo_test_general.c | 20 ++++++------- src/tests/eo/suite/eo_test_threaded_calls.c | 2 +- 33 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/benchmarks/eo/class_simple.c b/src/benchmarks/eo/class_simple.c index 2e8dc3f621..05d025ec97 100644 --- a/src/benchmarks/eo/class_simple.c +++ b/src/benchmarks/eo/class_simple.c @@ -46,5 +46,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL) diff --git a/src/examples/eo/evas/evas_evas_obj.c b/src/examples/eo/evas/evas_evas_obj.c index 01f48a544b..768d3d4ea6 100644 --- a/src/examples/eo/evas/evas_evas_obj.c +++ b/src/examples/eo/evas/evas_evas_obj.c @@ -143,4 +143,4 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(evas_object_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(evas_object_class_get, &class_desc, EO_CLASS, NULL) diff --git a/src/examples/eo/isa/eo_isa_simple.c b/src/examples/eo/isa/eo_isa_simple.c index 789c5f4711..67f47fd5f9 100644 --- a/src/examples/eo/isa/eo_isa_simple.c +++ b/src/examples/eo/isa/eo_isa_simple.c @@ -75,4 +75,4 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL); diff --git a/src/examples/eo/simple/simple_simple.c b/src/examples/eo/simple/simple_simple.c index a172bce3fc..42eb1f75b2 100644 --- a/src/examples/eo/simple/simple_simple.c +++ b/src/examples/eo/simple/simple_simple.c @@ -75,4 +75,4 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL); diff --git a/src/lib/ecore_audio/ecore_audio_obj.h b/src/lib/ecore_audio/ecore_audio_obj.h index b473a55f11..153a638292 100644 --- a/src/lib/ecore_audio/ecore_audio_obj.h +++ b/src/lib/ecore_audio/ecore_audio_obj.h @@ -175,7 +175,7 @@ enum Ecore_Audio_Obj_Sub_Ids * @param[in] free_func This function takes care to clean up @ref data when * the VIO is destroyed. NULL means do nothing. */ -#define ecore_audio_obj_vio_set(vio, data, free_func) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VIO_SET), EO_TYPECHECK(Ecore_Audio_Vio *, vio), EO_TYPECHECK(void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func) +#define ecore_audio_obj_vio_set(vio, data, free_func) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VIO_SET), EO_TYPECHECK(Ecore_Audio_Vio *, vio), EO_TYPECHECK(void *, data), EO_TYPECHECK(eo_key_data_free_func, free_func) #endif /** diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.c b/src/lib/ecore_audio/ecore_audio_obj_in.c index f77374f551..db88b03e64 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in.c @@ -149,7 +149,7 @@ static void _free_vio(Ecore_Audio_Object *ea_obj) } EOLIAN static void -_ecore_audio_in_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_Input *obj, Ecore_Audio_Vio *vio, void *data, eo_base_data_free_func free_func) +_ecore_audio_in_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_Input *obj, Ecore_Audio_Vio *vio, void *data, eo_key_data_free_func free_func) { Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c index d18908da79..6860f9dd5a 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c @@ -142,7 +142,7 @@ static void _free_vio(Ecore_Audio_Object *ea_obj) } EOLIAN static void -_ecore_audio_in_sndfile_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_In_Sndfile_Data *obj, Ecore_Audio_Vio *vio, void *data, eo_base_data_free_func free_func) +_ecore_audio_in_sndfile_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_In_Sndfile_Data *obj, Ecore_Audio_Vio *vio, void *data, eo_key_data_free_func free_func) { Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c index 60f634881f..1be57a426b 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c @@ -83,26 +83,26 @@ _ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_D } EOLIAN static void -_ecore_audio_in_tone_eo_base_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_base_data_free_func func) +_ecore_audio_in_tone_eo_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_key_data_free_func func) { if (!key) return; if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { obj->freq = *(int *)val; } else { - eo_do_super(eo_obj, MY_CLASS, eo_base_data_set(key, val, func)); + eo_do_super(eo_obj, MY_CLASS, eo_key_data_set(key, val, func)); } } EOLIAN static void* -_ecore_audio_in_tone_eo_base_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) +_ecore_audio_in_tone_eo_key_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) { if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { return (void *) (intptr_t) obj->freq; } else { void *ret = NULL; - eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, &ret)); + eo_do_super(eo_obj, MY_CLASS, eo_key_data_get(key, &ret)); return ret; } } diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.h b/src/lib/ecore_audio/ecore_audio_obj_in_tone.h index 6bfd505a28..738f49a55a 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.h +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.h @@ -37,7 +37,7 @@ extern "C" /** * @brief The frequency of the tone in Hz * - * Set with @ref eo_base_data_set() + * Set with @ref eo_key_data_set() */ #define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq" diff --git a/src/lib/ecore_audio/ecore_audio_obj_out.c b/src/lib/ecore_audio/ecore_audio_obj_out.c index 40d16004e9..52e379fa3b 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out.c @@ -113,7 +113,7 @@ static void _free_vio(Ecore_Audio_Object *ea_obj) } EOLIAN static void -_ecore_audio_out_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_Output *_pd EINA_UNUSED, Ecore_Audio_Vio *vio, void *data, eo_base_data_free_func free_func) +_ecore_audio_out_ecore_audio_vio_set(Eo *eo_obj, Ecore_Audio_Output *_pd EINA_UNUSED, Ecore_Audio_Vio *vio, void *data, eo_key_data_free_func free_func) { Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c index 8e7fc6d900..4da2d0b77f 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c @@ -60,7 +60,7 @@ _ecore_audio_out_pulse_ecore_audio_volume_set(Eo *eo_obj, Ecore_Audio_Out_Pulse_ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_volume_set(volume)); EINA_LIST_FOREACH(out_obj->inputs, input, in) { - eo_do(in, eo_base_data_get("pulse_data", (void **)&stream)); + eo_do(in, eo_key_data_get("pulse_data", (void **)&stream)); idx = pa_stream_get_index(stream); pa_operation_unref(pa_context_set_sink_input_volume(class_vars.context, idx, &pa_volume, NULL, NULL)); } @@ -95,7 +95,7 @@ static Eina_Bool _update_samplerate_cb(void *data EINA_UNUSED, Eo *eo_obj, const eo_do(eo_obj, ecore_audio_obj_in_samplerate_get(&samplerate)); eo_do(eo_obj, ecore_audio_obj_in_speed_get(&speed)); - eo_do(eo_obj, eo_base_data_get("pulse_data", (void **)&stream)); + eo_do(eo_obj, eo_key_data_get("pulse_data", (void **)&stream)); pa_operation_unref(pa_stream_update_sample_rate(stream, samplerate * speed, NULL, NULL)); @@ -132,7 +132,7 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in) eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, _update_samplerate_cb, eo_obj)); - eo_do(in, eo_base_data_set("pulse_data", stream, NULL)); + eo_do(in, eo_key_data_set("pulse_data", stream, NULL)); pa_stream_set_write_callback(stream, _write_cb, in); @@ -185,7 +185,7 @@ _ecore_audio_out_pulse_ecore_audio_out_input_detach(Eo *eo_obj, Ecore_Audio_Out_ if (!ret2) return EINA_FALSE; - eo_do(in, eo_base_data_get("pulse_data", (void **)&stream)); + eo_do(in, eo_key_data_get("pulse_data", (void **)&stream)); pa_stream_set_write_callback(stream, NULL, NULL); pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL)); diff --git a/src/lib/ecore_audio/ecore_audio_private.h b/src/lib/ecore_audio/ecore_audio_private.h index b997ea8e03..36a06f5f4c 100644 --- a/src/lib/ecore_audio/ecore_audio_private.h +++ b/src/lib/ecore_audio/ecore_audio_private.h @@ -94,7 +94,7 @@ struct _Ecore_Audio_Module struct _Ecore_Audio_Vio_Internal { Ecore_Audio_Vio *vio; void *data; - eo_base_data_free_func free_func; + eo_key_data_free_func free_func; }; typedef struct _Ecore_Audio_Vio_Internal Ecore_Audio_Vio_Internal; diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 57dca7e1ce..6e6979942d 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -931,12 +931,12 @@ EAPI const Eo_Class *eo_class_class_get(void); */ /** - * @def EO_BASE_CLASS + * @def EO_CLASS * The class type for the Eo base class. */ -#define EO_BASE_CLASS eo_base_class_get() +#define EO_CLASS eo_base_class_get() /** - * @brief Use #EO_BASE_CLASS + * @brief Use #EO_CLASS * @internal * */ EAPI const Eo_Class *eo_base_class_get(void); diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index 2ed01fcecd..d11d073c14 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -121,7 +121,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) { Private_Data *old_parent_pd; - old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS); + old_parent_pd = eo_data_scope_get(pd->parent, EO_CLASS); if (old_parent_pd) { old_parent_pd->children = eina_list_remove(old_parent_pd->children, @@ -140,7 +140,7 @@ _parent_set(Eo *obj, void *class_data, Eo *parent_id) if (parent_id) { Private_Data *parent_pd = NULL; - parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS); + parent_pd = eo_data_scope_get(parent_id, EO_CLASS); if (EINA_LIKELY(parent_pd != NULL)) { @@ -909,8 +909,8 @@ EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE; /* EOF event callbacks */ -/* EO_BASE_CLASS stuff */ -#define MY_CLASS EO_BASE_CLASS +/* EO_CLASS stuff */ +#define MY_CLASS EO_CLASS /* FIXME: Set proper type descriptions. */ // FIXME: eo multiple definition diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c index 2eeb8cc570..6bf44ded70 100644 --- a/src/tests/eo/access/access_simple.c +++ b/src/tests/eo/access/access_simple.c @@ -53,5 +53,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL) diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c index 8d4756be5b..d880c9823e 100644 --- a/src/tests/eo/composite_objects/composite_objects_comp.c +++ b/src/tests/eo/composite_objects/composite_objects_comp.c @@ -53,6 +53,6 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS, +EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_CLASS, SIMPLE_CLASS, NULL); diff --git a/src/tests/eo/composite_objects/composite_objects_simple.c b/src/tests/eo/composite_objects/composite_objects_simple.c index c4490da8c0..a1dfd4dbd8 100644 --- a/src/tests/eo/composite_objects/composite_objects_simple.c +++ b/src/tests/eo/composite_objects/composite_objects_simple.c @@ -52,5 +52,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c index 3076802143..ca7343ffe0 100644 --- a/src/tests/eo/constructors/constructors_mixin.c +++ b/src/tests/eo/constructors/constructors_mixin.c @@ -54,5 +54,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c index 3441d44451..fa6b3fd820 100644 --- a/src/tests/eo/constructors/constructors_simple.c +++ b/src/tests/eo/constructors/constructors_simple.c @@ -104,6 +104,6 @@ static const Eo_Class_Description class_desc = { _class_destructor }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, MIXIN_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c index 06c9e1d87a..0318a9ff09 100644 --- a/src/tests/eo/constructors/constructors_simple2.c +++ b/src/tests/eo/constructors/constructors_simple2.c @@ -32,5 +32,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple3.c b/src/tests/eo/constructors/constructors_simple3.c index 79ef940c8c..9c720b51eb 100644 --- a/src/tests/eo/constructors/constructors_simple3.c +++ b/src/tests/eo/constructors/constructors_simple3.c @@ -30,5 +30,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple5.c b/src/tests/eo/constructors/constructors_simple5.c index bbfbafd00e..df51e4ae87 100644 --- a/src/tests/eo/constructors/constructors_simple5.c +++ b/src/tests/eo/constructors/constructors_simple5.c @@ -30,5 +30,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/constructors/constructors_simple6.c b/src/tests/eo/constructors/constructors_simple6.c index 71e29953f4..3f4c70e480 100644 --- a/src/tests/eo/constructors/constructors_simple6.c +++ b/src/tests/eo/constructors/constructors_simple6.c @@ -32,5 +32,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c index ce6590b143..1ba2382948 100644 --- a/src/tests/eo/function_overrides/function_overrides_simple.c +++ b/src/tests/eo/function_overrides/function_overrides_simple.c @@ -75,5 +75,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c index e4bd477357..d35e142d3a 100644 --- a/src/tests/eo/interface/interface_simple.c +++ b/src/tests/eo/interface/interface_simple.c @@ -75,4 +75,4 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE2_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, INTERFACE2_CLASS, NULL); diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c index 073ad3b988..d91a04fe11 100644 --- a/src/tests/eo/mixin/mixin_mixin.c +++ b/src/tests/eo/mixin/mixin_mixin.c @@ -49,5 +49,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, EO_CLASS, NULL) diff --git a/src/tests/eo/mixin/mixin_simple.c b/src/tests/eo/mixin/mixin_simple.c index 5da36be987..0212939580 100644 --- a/src/tests/eo/mixin/mixin_simple.c +++ b/src/tests/eo/mixin/mixin_simple.c @@ -56,6 +56,6 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL); diff --git a/src/tests/eo/signals/signals_main.c b/src/tests/eo/signals/signals_main.c index eb0784febd..4886d35b5f 100644 --- a/src/tests/eo/signals/signals_main.c +++ b/src/tests/eo/signals/signals_main.c @@ -133,15 +133,15 @@ main(int argc, char *argv[]) eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_freeze()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_freeze()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 2); eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); @@ -149,30 +149,30 @@ main(int argc, char *argv[]) eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_thaw()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_thaw()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); eo_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_thaw()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); - eo_do(EO_BASE_CLASS, eo_event_global_freeze()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_freeze()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 1); eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); - eo_do(EO_BASE_CLASS, eo_event_global_thaw()); - eo_do(EO_BASE_CLASS, fcount = eo_event_global_freeze_get()); + eo_do(EO_CLASS, eo_event_global_thaw()); + eo_do(EO_CLASS, fcount = eo_event_global_freeze_get()); fail_if(fcount != 0); diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c index f370a2794b..a928cec854 100644 --- a/src/tests/eo/signals/signals_simple.c +++ b/src/tests/eo/signals/signals_simple.c @@ -96,5 +96,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL); +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL); diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index 36a85151cc..e6fee93cae 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -56,7 +56,7 @@ START_TEST(eo_inherit_errors) klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL); fail_if(!klass_mixin); - klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL); + klass_simple = eo_class_new(&class_desc_simple, EO_CLASS, NULL); fail_if(!klass_simple); TEST_EO_ERROR("eo_class_new", "Non-regular classes ('%s') aren't allowed to inherit from regular classes ('%s')."); @@ -142,14 +142,14 @@ START_TEST(eo_inconsistent_mro) fail_if(!klass_mixin3); TEST_EO_ERROR("_eo_class_mro_init", "Cannot create a consistent method resolution order for class '%s' because of '%s'."); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL); + klass = eo_class_new(&class_desc_simple, EO_CLASS, klass_mixin, klass_mixin2, NULL); fail_if(klass); fail_unless(ctx.did); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL); + klass = eo_class_new(&class_desc_simple, EO_CLASS, klass_mixin2, klass_mixin, NULL); fail_if(!klass); - klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); + klass = eo_class_new(&class_desc_simple, EO_CLASS, klass_mixin2, klass_mixin3, NULL); fail_if(!klass); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c index 5b8c2e06ac..cbefee7d1d 100644 --- a/src/tests/eo/suite/eo_test_class_simple.c +++ b/src/tests/eo/suite/eo_test_class_simple.c @@ -98,5 +98,5 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index 2f6d79e4cc..cf2bd1bb36 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -11,7 +11,7 @@ START_TEST(eo_simple) { eo_init(); - Eo *obj = eo_add(EO_BASE_CLASS, NULL); + Eo *obj = eo_add(EO_CLASS, NULL); fail_if(obj); obj = eo_add(SIMPLE_CLASS, NULL); @@ -135,7 +135,7 @@ START_TEST(eo_data_fetch) NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_CLASS, NULL); fail_if(!klass); Eo *obj = eo_add(klass, NULL); @@ -146,7 +146,7 @@ START_TEST(eo_data_fetch) eo_unref(obj); class_desc.data_size = 0; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_CLASS, NULL); fail_if(!klass); obj = eo_add(klass, NULL); @@ -211,7 +211,7 @@ START_TEST(eo_isa_tests) NULL }; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL); + klass = eo_class_new(&class_desc, EO_CLASS, iface, mixin, NULL); fail_if(!klass); } @@ -221,7 +221,7 @@ START_TEST(eo_isa_tests) fail_if(!eo_isa(obj, iface)); fail_if(!eo_isa(obj, mixin)); fail_if(!eo_isa(obj, klass)); - fail_if(!eo_isa(obj, EO_BASE_CLASS)); + fail_if(!eo_isa(obj, EO_CLASS)); eo_unref(obj); obj = eo_add(SIMPLE_CLASS, NULL); @@ -230,7 +230,7 @@ START_TEST(eo_isa_tests) fail_if(eo_isa(obj, iface)); fail_if(eo_isa(obj, mixin)); fail_if(!eo_isa(obj, SIMPLE_CLASS)); - fail_if(!eo_isa(obj, EO_BASE_CLASS)); + fail_if(!eo_isa(obj, EO_CLASS)); eo_unref(obj); eo_shutdown(); @@ -300,7 +300,7 @@ START_TEST(eo_man_free) NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_CLASS, NULL); fail_if(!klass); cur_klass = klass; @@ -314,7 +314,7 @@ START_TEST(eo_man_free) eo_unref(obj); _man_should_des = EINA_FALSE; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_CLASS, NULL); cur_klass = klass; fail_if(!klass); @@ -333,7 +333,7 @@ START_TEST(eo_man_free) fail_if(!eo_manual_free(obj)); _man_should_con = EINA_FALSE; - klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + klass = eo_class_new(&class_desc, EO_CLASS, NULL); cur_klass = klass; fail_if(!klass); @@ -781,7 +781,7 @@ START_TEST(eo_pointers_indirection) NULL }; - const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL); + const Eo_Class *klass = eo_class_new(&class_desc, EO_CLASS, NULL); fail_if(!klass); /* Check simple id validity */ diff --git a/src/tests/eo/suite/eo_test_threaded_calls.c b/src/tests/eo/suite/eo_test_threaded_calls.c index 951b6551b4..ee7b70f526 100644 --- a/src/tests/eo/suite/eo_test_threaded_calls.c +++ b/src/tests/eo/suite/eo_test_threaded_calls.c @@ -76,7 +76,7 @@ static const Eo_Class_Description class_desc = { NULL }; -EO_DEFINE_CLASS(thread_test_class_get, &class_desc, EO_BASE_CLASS, NULL) +EO_DEFINE_CLASS(thread_test_class_get, &class_desc, EO_CLASS, NULL) static void * _thread_job(void *data, Eina_Thread t EINA_UNUSED) From d36ca8f949489ff19e6e9987646ff262e4773d36 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 13:16:04 +0100 Subject: [PATCH 161/169] Eo: Reintroduce the events now that eo1 is gone. --- src/lib/eo/eo2_base_class.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo2_base_class.c index d11d073c14..b1bd8b2673 100644 --- a/src/lib/eo/eo2_base_class.c +++ b/src/lib/eo/eo2_base_class.c @@ -912,14 +912,12 @@ EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE; /* EO_CLASS stuff */ #define MY_CLASS EO_CLASS -/* FIXME: Set proper type descriptions. */ -// FIXME: eo multiple definition -/* EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = */ -/* EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); */ -/* EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = */ -/* EO_EVENT_DESCRIPTION("callback,del", "A callback was deleted."); */ -/* EAPI const Eo_Event_Description _EO_EV_DEL = */ -/* EO_HOT_EVENT_DESCRIPTION("del", "Obj is being deleted."); */ +EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD = + EO_EVENT_DESCRIPTION("callback,add", "A callback was added."); +EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL = + EO_EVENT_DESCRIPTION("callback,del", "A callback was deleted."); +EAPI const Eo_Event_Description _EO_EV_DEL = + EO_HOT_EVENT_DESCRIPTION("del", "Obj is being deleted."); static void _constructor(Eo *obj, void *class_data EINA_UNUSED) From 96fe5bd941c5100f6435c77e2cfec18866c4bdb2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 14:21:57 +0100 Subject: [PATCH 162/169] More adjustments for eo2 calls. --- src/lib/ecore_audio/ecore_audio_obj_in.c | 20 +++---- src/lib/ecore_audio/ecore_audio_obj_in_tone.c | 6 +-- src/lib/ecore_audio/ecore_audio_obj_out.c | 8 +-- .../ecore_audio/ecore_audio_obj_out_pulse.c | 52 +++++++++---------- .../ecore_audio/ecore_audio_obj_out_sndfile.c | 16 +++--- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.c b/src/lib/ecore_audio/ecore_audio_obj_in.c index db88b03e64..970e2adba3 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in.c @@ -27,7 +27,7 @@ _ecore_audio_in_speed_set(Eo *eo_obj EINA_UNUSED, Ecore_Audio_Input *obj, double obj->speed = speed; - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, NULL)); } EOLIAN static double @@ -41,7 +41,7 @@ _ecore_audio_in_samplerate_set(Eo *eo_obj EINA_UNUSED, Ecore_Audio_Input *obj, i { obj->samplerate = samplerate; - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, NULL)); } EOLIAN static int @@ -88,8 +88,8 @@ _ecore_audio_in_remaining_get(Eo *eo_obj, Ecore_Audio_Input *obj) { if (!obj->seekable) return -1; else { - double ret; - eo_do(eo_obj, ecore_audio_obj_in_seek(0, SEEK_CUR, &ret)); + double ret = 0.0; + eo_do(eo_obj, ret = ecore_audio_obj_in_seek(0, SEEK_CUR)); return obj->length - ret; } } @@ -104,14 +104,14 @@ _ecore_audio_in_read(Eo *eo_obj, Ecore_Audio_Input *obj, void *buf, size_t len) memset(buf, 0, len); len_read = len; } else { - eo_do(eo_obj, ecore_audio_obj_in_read_internal(buf, len, &len_read)); + eo_do(eo_obj, len_read = ecore_audio_obj_in_read_internal(buf, len)); if (len_read == 0) { if (!obj->looped || !obj->seekable) { - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_STOPPED, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_STOPPED, NULL)); } else { - eo_do(eo_obj, ecore_audio_obj_in_seek(0, SEEK_SET, NULL)); - eo_do(eo_obj, ecore_audio_obj_in_read_internal(buf, len, &len_read)); - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_LOOPED, NULL, NULL)); + eo_do(eo_obj, ecore_audio_obj_in_seek(0, SEEK_SET)); + eo_do(eo_obj, len_read = ecore_audio_obj_in_read_internal(buf, len)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_IN_EVENT_IN_LOOPED, NULL)); } } @@ -182,7 +182,7 @@ EOLIAN static void _ecore_audio_in_eo_base_destructor(Eo *eo_obj, Ecore_Audio_Input *obj) { if(obj->output) - eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj, NULL)); + eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj)); eo_do_super(eo_obj, MY_CLASS, eo_destructor()); } diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c index 1be57a426b..749772f401 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c @@ -83,7 +83,7 @@ _ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_D } EOLIAN static void -_ecore_audio_in_tone_eo_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_key_data_free_func func) +_ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_key_data_free_func func) { if (!key) return; @@ -96,13 +96,13 @@ _ecore_audio_in_tone_eo_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, } EOLIAN static void* -_ecore_audio_in_tone_eo_key_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) +_ecore_audio_in_tone_eo_base_key_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) { if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { return (void *) (intptr_t) obj->freq; } else { void *ret = NULL; - eo_do_super(eo_obj, MY_CLASS, eo_key_data_get(key, &ret)); + eo_do_super(eo_obj, MY_CLASS, ret = eo_key_data_get(key)); return ret; } } diff --git a/src/lib/ecore_audio/ecore_audio_obj_out.c b/src/lib/ecore_audio/ecore_audio_obj_out.c index 52e379fa3b..495e05c701 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out.c @@ -25,7 +25,7 @@ static Eina_Bool _write_cb(void *data) Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); - ssize_t written, bread; + ssize_t written, bread = 0; float buf[1024]; if (!ea_obj->vio || !ea_obj->vio->vio->write) @@ -34,7 +34,7 @@ static Eina_Bool _write_cb(void *data) /* FIXME: Multiple inputs */ in = eina_list_data_get(out_obj->inputs); - eo_do(in, ecore_audio_obj_in_read(buf, 4*1024, &bread)); + eo_do(in, bread = ecore_audio_obj_in_read(buf, 4*1024)); if (bread == 0) { ea_obj->paused = EINA_TRUE; @@ -61,7 +61,7 @@ _ecore_audio_out_input_attach(Eo *eo_obj, Ecore_Audio_Output *obj, Eo *input) if (in->output == eo_obj) return EINA_FALSE; - if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input, NULL)); + if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input)); in->output = eo_obj; /* TODO: Send event */ @@ -144,7 +144,7 @@ _ecore_audio_out_eo_base_destructor(Eo *eo_obj, Ecore_Audio_Output *obj) Eo *in; EINA_LIST_FOREACH_SAFE(obj->inputs, cur, tmp, in) { - eo_do(eo_obj, ecore_audio_obj_out_input_detach(in, NULL)); + eo_do(eo_obj, ecore_audio_obj_out_input_detach(in)); } eo_do_super(eo_obj, MY_CLASS, eo_destructor()); diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c index 4da2d0b77f..d958d2153b 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c @@ -46,7 +46,7 @@ EOLIAN static void _ecore_audio_out_pulse_ecore_audio_volume_set(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED, double volume) { Eo *in; - pa_stream *stream; + pa_stream *stream = NULL; Eina_List *input; uint32_t idx; pa_cvolume pa_volume; @@ -60,7 +60,7 @@ _ecore_audio_out_pulse_ecore_audio_volume_set(Eo *eo_obj, Ecore_Audio_Out_Pulse_ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_volume_set(volume)); EINA_LIST_FOREACH(out_obj->inputs, input, in) { - eo_do(in, eo_key_data_get("pulse_data", (void **)&stream)); + eo_do(in, stream = eo_key_data_get("pulse_data")); idx = pa_stream_get_index(stream); pa_operation_unref(pa_context_set_sink_input_volume(class_vars.context, idx, &pa_volume, NULL, NULL)); } @@ -72,12 +72,12 @@ static void _write_cb(pa_stream *stream, size_t len, void *data) Eo *in = data; void *buf; - ssize_t bread; + ssize_t bread = 0; size_t wlen = len; pa_stream_begin_write(stream, &buf, &wlen); - eo_do(in, ecore_audio_obj_in_read(buf, wlen, &bread)); + eo_do(in, bread = ecore_audio_obj_in_read(buf, wlen)); pa_stream_write(stream, buf, bread, NULL, 0, PA_SEEK_RELATIVE); if (bread < (int)len) @@ -88,14 +88,14 @@ static void _write_cb(pa_stream *stream, size_t len, void *data) static Eina_Bool _update_samplerate_cb(void *data EINA_UNUSED, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { - pa_stream *stream; - int samplerate; - double speed; + pa_stream *stream = NULL; + int samplerate = 0; + double speed = 0; - eo_do(eo_obj, ecore_audio_obj_in_samplerate_get(&samplerate)); - eo_do(eo_obj, ecore_audio_obj_in_speed_get(&speed)); + eo_do(eo_obj, samplerate = ecore_audio_obj_in_samplerate_get()); + eo_do(eo_obj, speed = ecore_audio_obj_in_speed_get()); - eo_do(eo_obj, eo_key_data_get("pulse_data", (void **)&stream)); + eo_do(eo_obj, stream = eo_key_data_get("pulse_data")); pa_operation_unref(pa_stream_update_sample_rate(stream, samplerate * speed, NULL, NULL)); @@ -104,29 +104,29 @@ static Eina_Bool _update_samplerate_cb(void *data EINA_UNUSED, Eo *eo_obj, const static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in) { - const char *name; + const char *name = NULL; pa_sample_spec ss; - double speed; + double speed = 0; pa_stream *stream; - Eina_Bool ret; + Eina_Bool ret = EINA_FALSE; Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); - eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret)); + eo_do_super(eo_obj, MY_CLASS, ret = ecore_audio_obj_out_input_attach(in)); if (!ret) return EINA_FALSE; ss.format = PA_SAMPLE_FLOAT32LE; - eo_do(in, ecore_audio_obj_in_samplerate_get((int *)&ss.rate)); - eo_do(in, ecore_audio_obj_in_speed_get(&speed)); - eo_do(in, ecore_audio_obj_in_channels_get((int *)&ss.channels)); - eo_do(in, ecore_audio_obj_name_get(&name)); + eo_do(in, ss.rate = ecore_audio_obj_in_samplerate_get()); + eo_do(in, speed = ecore_audio_obj_in_speed_get()); + eo_do(in, ss.channels = ecore_audio_obj_in_channels_get()); + eo_do(in, name = ecore_audio_obj_name_get()); ss.rate = ss.rate * speed; stream = pa_stream_new(class_vars.context, name, &ss, NULL); if (!stream) { ERR("Could not create stream"); - eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL)); + eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in)); return EINA_FALSE; } @@ -178,14 +178,14 @@ static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EIN EOLIAN static Eina_Bool _ecore_audio_out_pulse_ecore_audio_out_input_detach(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED, Eo *in) { - pa_stream *stream; - Eina_Bool ret2; + pa_stream *stream = NULL; + Eina_Bool ret2 = EINA_FALSE; - eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, &ret2)); + eo_do_super(eo_obj, MY_CLASS, ret2 = ecore_audio_obj_out_input_detach(in)); if (!ret2) return EINA_FALSE; - eo_do(in, eo_key_data_get("pulse_data", (void **)&stream)); + eo_do(in, stream = eo_key_data_get("pulse_data")); pa_stream_set_write_callback(stream, NULL, NULL); pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL)); @@ -210,12 +210,12 @@ static void _state_cb(pa_context *context, void *data EINA_UNUSED) if (state == PA_CONTEXT_READY) { DBG("PA context ready."); EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_READY, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_READY, NULL)); } } else if ((state == PA_CONTEXT_FAILED) || (state == PA_CONTEXT_TERMINATED)) { DBG("PA context fail."); EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL)); } } else { DBG("Connection state %i", state); @@ -241,7 +241,7 @@ static void _state_job(void *data EINA_UNUSED) } // the callback here can delete things in the list.. EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { - eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL, NULL)); + eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL)); } // now unref everything safely EINA_LIST_FOREACH_SAFE(class_vars.outputs, out, tmp, eo_obj) { diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c index d1ca3b5263..5e0e02f061 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c @@ -37,13 +37,13 @@ static Eina_Bool _write_cb(void *data) Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); - ssize_t written, bread; + ssize_t written, bread = 0; float buf[1024]; /* TODO: Support mixing of multiple inputs */ in = eina_list_data_get(out_obj->inputs); - eo_do(in, ecore_audio_obj_in_read(buf, 4*1024, &bread)); + eo_do(in, bread = ecore_audio_obj_in_read(buf, 4*1024)); if (bread == 0) { sf_write_sync(obj->handle); @@ -64,21 +64,21 @@ _ecore_audio_out_sndfile_ecore_audio_out_input_attach(Eo *eo_obj, Ecore_Audio_Ou { Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); - Eina_Bool ret2; + Eina_Bool ret2 = EINA_FALSE; - eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret2)); + eo_do_super(eo_obj, MY_CLASS, ret2 = ecore_audio_obj_out_input_attach(in)); if (!ret2) return EINA_FALSE; - eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate)); - eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels)); + eo_do(in, obj->sfinfo.samplerate = ecore_audio_obj_in_samplerate_get()); + eo_do(in, obj->sfinfo.channels = ecore_audio_obj_in_channels_get()); obj->handle = sf_open(ea_obj->source, SFM_WRITE, &obj->sfinfo); if (!obj->handle) { eina_stringshare_del(ea_obj->source); ea_obj->source = NULL; - eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL)); + eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in)); return EINA_FALSE; } @@ -165,7 +165,7 @@ _ecore_audio_out_sndfile_eo_base_constructor(Eo *eo_obj, Ecore_Audio_Out_Sndfile eo_do_super(eo_obj, MY_CLASS, eo_constructor()); - eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG, NULL)); + eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG)); // FIXME: Use writer from output out_obj->need_writer = EINA_FALSE; From 3a0d62ffcfad75600a1226afbd703ffdd80c8ca7 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 15:30:13 +0100 Subject: [PATCH 163/169] Ecore audio tests: Updated to Eo2. --- src/tests/ecore/ecore_test_ecore_audio.c | 190 +++++++++++------------ src/tests/eo/suite/eo_test_general.c | 3 +- 2 files changed, 96 insertions(+), 97 deletions(-) diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c index 04782ce916..e4ce60a3dd 100644 --- a/src/tests/ecore/ecore_test_ecore_audio.c +++ b/src/tests/ecore/ecore_test_ecore_audio.c @@ -45,14 +45,14 @@ static Eina_Bool _looped_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Desc static Eina_Bool _seek_vol(void *data) { - double len; + double len = 0; Eo *in = data; - Eo *out; + Eo *out = NULL; - eo_do(in, ecore_audio_obj_in_output_get(&out)); + eo_do(in, out = ecore_audio_obj_in_output_get()); eo_do(out, ecore_audio_obj_volume_set(0.4)); - eo_do(in, ecore_audio_obj_in_seek(-0.3, SEEK_END, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(-0.3, SEEK_END)); fail_if(len < 0); return EINA_FALSE; @@ -61,14 +61,14 @@ _seek_vol(void *data) START_TEST(ecore_test_ecore_audio_obj_pulse) { Eo *in, *out; - Eina_Bool ret; + Eina_Bool ret = EINA_FALSE; Eina_Bool pulse_context_failed = EINA_FALSE; in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL); fail_if(!in); eo_do(in, ecore_audio_obj_name_set("modem.wav")); - eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/modem.wav", &ret)); + eo_do(in, ret = ecore_audio_obj_source_set(TESTS_SRC_DIR"/modem.wav")); fail_if(!ret); out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL); @@ -79,7 +79,7 @@ START_TEST(ecore_test_ecore_audio_obj_pulse) eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _finished_cb, NULL)); eo_do(out, eo_event_callback_add(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, _failed_cb, &pulse_context_failed)); - eo_do(out, ecore_audio_obj_out_input_attach(in, &ret)); + eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); fail_if(!ret); ecore_main_loop_begin(); @@ -112,7 +112,7 @@ START_TEST(ecore_test_ecore_audio_cleanup) { Eo *in, *out; int freq = 1000; - Eina_Bool ret; + Eina_Bool ret = EINA_FALSE; in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL); fail_if(!in); @@ -121,12 +121,12 @@ START_TEST(ecore_test_ecore_audio_cleanup) out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); fail_if(!out); - eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG, &ret)); + eo_do(out, ret = ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG)); fail_if(!ret); - eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.ogg", &ret)); + eo_do(out, ret = ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.ogg")); fail_if(!ret); - eo_do(out, ecore_audio_obj_out_input_attach(in, &ret)); + eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); fail_if(!ret); ecore_idler_add(_idle_del, in); @@ -150,69 +150,69 @@ START_TEST(ecore_test_ecore_audio_obj_tone) eo_do(in, ecore_audio_obj_name_set("tone")); - eo_do(in, ecore_audio_obj_in_channels_get(&channel)); + eo_do(in, channel = ecore_audio_obj_in_channels_get()); fail_if(channel != 1); - eo_do(in, ecore_audio_obj_in_samplerate_get(&rate)); + eo_do(in, rate = ecore_audio_obj_in_samplerate_get()); fail_if(rate != 44100); - eo_do(in, ecore_audio_obj_in_length_get(&len)); + eo_do(in, len = ecore_audio_obj_in_length_get()); fail_if(len != 1); eo_do(in, ecore_audio_obj_in_length_set(2.5)); - eo_do(in, ecore_audio_obj_in_length_get(&len)); + eo_do(in, len = ecore_audio_obj_in_length_get()); fail_if(len != 2.5); eo_do(in, ecore_audio_obj_in_looped_set(EINA_TRUE)); - eo_do(in, ecore_audio_obj_in_remaining_get(&len)); + eo_do(in, len = ecore_audio_obj_in_remaining_get()); fail_if(len != 2.5); - eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); + eo_do(in, freq = (intptr_t) eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ)); fail_if(freq != 1000); freq = 2000; eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); - eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); + eo_do(in, freq = (intptr_t) eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ)); fail_if(freq != 2000); eo_do(in, eo_key_data_set("foo", "bar", NULL)); - eo_do(in, eo_key_data_get("foo", (void **)&tmp)); + eo_do(in, tmp = eo_key_data_get("foo")); ck_assert_str_eq(tmp, "bar"); - eo_do(in, ecore_audio_obj_in_seek(5.0, SEEK_SET, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(5.0, SEEK_SET)); fail_if(len != -1); - eo_do(in, ecore_audio_obj_in_seek(1.0, 42, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(1.0, 42)); fail_if(len != -1); - eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_SET, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(1.0, SEEK_SET)); fail_if(len != 1.0); - eo_do(in, ecore_audio_obj_in_remaining_get(&len)); + eo_do(in, len = ecore_audio_obj_in_remaining_get()); fail_if(len != 1.5); - eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_CUR, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(1.0, SEEK_CUR)); fail_if(len != 2.0); - eo_do(in, ecore_audio_obj_in_remaining_get(&len)); + eo_do(in, len = ecore_audio_obj_in_remaining_get()); fail_if(len != 0.5); - eo_do(in, ecore_audio_obj_in_seek(-1.0, SEEK_END, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(-1.0, SEEK_END)); fail_if(len != 1.5); - eo_do(in, ecore_audio_obj_in_remaining_get(&len)); + eo_do(in, len = ecore_audio_obj_in_remaining_get()); fail_if(len != 1.0); out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); fail_if(!out); eo_do(out, ecore_audio_obj_name_set("tmp.wav")); - eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV, &ret)); + eo_do(out, ret = ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV)); fail_if(!ret); - eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav", &ret)); + eo_do(out, ret = ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav")); fail_if(!ret); - eo_do(out, ecore_audio_obj_out_input_attach(in, &ret)); + eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); fail_if(!ret); eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_LOOPED, _looped_cb, NULL)); @@ -240,70 +240,70 @@ START_TEST(ecore_test_ecore_audio_obj_sndfile) in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL); fail_if(!in); - eo_do(in, ecore_audio_obj_format_get(&fmt)); + eo_do(in, fmt = ecore_audio_obj_format_get()); fail_if(fmt != ECORE_AUDIO_FORMAT_AUTO); - eo_do(in, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_FLAC, &ret)); + eo_do(in, ret = ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_FLAC)); fail_if(!ret); - eo_do(in, ecore_audio_obj_format_get(&fmt)); + eo_do(in, fmt = ecore_audio_obj_format_get()); fail_if(fmt != ECORE_AUDIO_FORMAT_FLAC); - eo_do(in, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_AUTO, &ret)); + eo_do(in, ret = ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_AUTO)); fail_if(!ret); eo_do(in, ecore_audio_obj_name_set("sms.ogg")); - eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg", &ret)); + eo_do(in, ret = ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg")); fail_if(!ret); - eo_do(in, ecore_audio_obj_source_get(&src)); + eo_do(in, src = ecore_audio_obj_source_get()); ck_assert_str_eq(src, TESTS_SRC_DIR"/sms.ogg"); - eo_do(in, ecore_audio_obj_format_get(&fmt)); + eo_do(in, fmt = ecore_audio_obj_format_get()); fail_if(fmt != ECORE_AUDIO_FORMAT_OGG); - eo_do(in, ecore_audio_obj_in_channels_get(&channel)); + eo_do(in, channel = ecore_audio_obj_in_channels_get()); fail_if(channel != 2); - eo_do(in, ecore_audio_obj_in_samplerate_get(&rate)); + eo_do(in, rate = ecore_audio_obj_in_samplerate_get()); fail_if(rate != 44100); - eo_do(in, ecore_audio_obj_in_length_get(&len)); + eo_do(in, len = ecore_audio_obj_in_length_get()); fail_if(len == 0); - eo_do(in, ecore_audio_obj_in_remaining_get(&rem)); + eo_do(in, rem = ecore_audio_obj_in_remaining_get()); fail_if(len != rem); - eo_do(in, ecore_audio_obj_format_get(&fmt)); + eo_do(in, fmt = ecore_audio_obj_format_get()); fail_if(fmt != ECORE_AUDIO_FORMAT_OGG); - eo_do(in, ecore_audio_obj_in_seek(0.5, SEEK_SET, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(0.5, SEEK_SET)); fail_if(len != 0.5); - eo_do(in, ecore_audio_obj_in_seek(0.5, SEEK_CUR, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(0.5, SEEK_CUR)); fail_if(len != 1.0); - eo_do(in, ecore_audio_obj_in_seek(-1.0, SEEK_END, &len)); + eo_do(in, len = ecore_audio_obj_in_seek(-1.0, SEEK_END)); fail_if(fabs(rem - 1 - len) > 0.1); out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); fail_if(!out); eo_do(out, ecore_audio_obj_name_set("tmp.wav")); - eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV, &ret)); + eo_do(out, ret = ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV)); fail_if(!ret); - eo_do(out, ecore_audio_obj_format_get(&fmt)); + eo_do(out, fmt = ecore_audio_obj_format_get()); fail_if(fmt != ECORE_AUDIO_FORMAT_WAV); // eo_do(out, ecore_audio_obj_source_set("/tmp/file/does/not/exist/hopefully.wav", &ret)); // fail_if(ret); - eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav", &ret)); + eo_do(out, ret = ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav")); fail_if(!ret); - eo_do(out, ecore_audio_obj_source_get(&src)); + eo_do(out, src = ecore_audio_obj_source_get()); ck_assert_str_eq(src, TESTS_BUILD_DIR"/tmp.wav"); - eo_do(out, ecore_audio_obj_out_input_attach(in, &ret)); + eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); fail_if(!ret); eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _finished_cb, NULL)); @@ -332,47 +332,47 @@ START_TEST(ecore_test_ecore_audio_obj_in_out) fail_if(!in2); fail_if(!out); - fail_if(!eo_do(in, ecore_audio_obj_in_output_get(&out2))); + eo_do(in, out2 = ecore_audio_obj_in_output_get()); fail_if(out2); - fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3))); + eo_do(out, in3 = ecore_audio_obj_out_inputs_get()); fail_if(eina_list_count(in3) != 0); - fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, &attached))); + eo_do(out, attached = ecore_audio_obj_out_input_attach(in)); fail_if(!attached); - fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, &attached))); + eo_do(out, attached = ecore_audio_obj_out_input_attach(in)); fail_if(attached); - fail_if(!eo_do(in, ecore_audio_obj_in_output_get(&out2))); + eo_do(in, out2 = ecore_audio_obj_in_output_get()); fail_if(out2 != out); - fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3))); + eo_do(out, in3 = ecore_audio_obj_out_inputs_get()); fail_if(eina_list_count(in3) != 1); fail_if(eina_list_data_get(in3) != in); - fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in2, &attached))); + eo_do(out, attached = ecore_audio_obj_out_input_attach(in2)); fail_if(!attached); - fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3))); + eo_do(out, in3 = ecore_audio_obj_out_inputs_get()); fail_if(eina_list_count(in3) != 2); fail_if(eina_list_data_get(in3) != in); eo_del(in2); - fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3))); + eo_do(out, in3 = ecore_audio_obj_out_inputs_get()); fail_if(eina_list_count(in3) != 1); fail_if(eina_list_data_get(in3) != in); eo_del(out); - fail_if(!eo_do(in, ecore_audio_obj_in_output_get(&out2))); + eo_do(in, out2 = ecore_audio_obj_in_output_get()); fail_if(out2); @@ -431,7 +431,7 @@ START_TEST(ecore_test_ecore_audio_obj_vio) eo_do(in, ecore_audio_obj_vio_set(&in_vio, NULL, NULL)); eo_do(out, ecore_audio_obj_vio_set(&out_vio, NULL, NULL)); - eo_do(out, ecore_audio_obj_out_input_attach(in, NULL)); + eo_do(out, ecore_audio_obj_out_input_attach(in)); ecore_main_loop_begin(); @@ -464,73 +464,73 @@ START_TEST(ecore_test_ecore_audio_obj_in) fail_if(!in); - fail_if(!eo_do(in, ecore_audio_obj_vio_set(&vio, &freed, _myfree))); + eo_do(in, ecore_audio_obj_vio_set(&vio, &freed, _myfree)); fail_if(freed); - fail_if(!eo_do(in, ecore_audio_obj_vio_set(NULL, NULL, NULL))); + eo_do(in, ecore_audio_obj_vio_set(NULL, NULL, NULL)); fail_if(!freed); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); + eo_do(in, speed = ecore_audio_obj_in_speed_get()); fail_if(speed != 1.0); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(2.5))); + eo_do(in, ecore_audio_obj_in_speed_set(2.5)); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); + eo_do(in, speed = ecore_audio_obj_in_speed_get()); fail_if(speed != 2.5); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(0))); + eo_do(in, ecore_audio_obj_in_speed_set(0)); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); + eo_do(in, speed = ecore_audio_obj_in_speed_get()); fail_if(speed != 0.2); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(10))); + eo_do(in, ecore_audio_obj_in_speed_set(10)); - fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); + eo_do(in, speed = ecore_audio_obj_in_speed_get()); fail_if(speed != 5.0); - fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_get(&samplerate))); + eo_do(in, samplerate = ecore_audio_obj_in_samplerate_get()); fail_if(samplerate != 0); - fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_set(1234))); + eo_do(in, ecore_audio_obj_in_samplerate_set(1234)); - fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_get(&samplerate))); + eo_do(in, samplerate = ecore_audio_obj_in_samplerate_get()); fail_if(samplerate != 1234); - fail_if(!eo_do(in, ecore_audio_obj_in_channels_get(&channels))); + eo_do(in, channels = ecore_audio_obj_in_channels_get()); fail_if(channels != 0); - fail_if(!eo_do(in, ecore_audio_obj_in_channels_set(2))); + eo_do(in, ecore_audio_obj_in_channels_set(2)); - fail_if(!eo_do(in, ecore_audio_obj_in_channels_get(&channels))); + eo_do(in, channels = ecore_audio_obj_in_channels_get()); fail_if(channels != 2); - fail_if(!eo_do(in, ecore_audio_obj_in_looped_get(&looped))); + eo_do(in, looped = ecore_audio_obj_in_looped_get()); fail_if(looped); - fail_if(!eo_do(in, ecore_audio_obj_in_looped_set(EINA_TRUE))); + eo_do(in, ecore_audio_obj_in_looped_set(EINA_TRUE)); - fail_if(!eo_do(in, ecore_audio_obj_in_looped_get(&looped))); + eo_do(in, looped = ecore_audio_obj_in_looped_get()); fail_if(!looped); - fail_if(!eo_do(in, ecore_audio_obj_in_length_get(&length))); + eo_do(in, length = ecore_audio_obj_in_length_get()); fail_if(length != 0); - fail_if(eo_do(in, ecore_audio_obj_in_length_set(10.0))); + eo_do(in, ecore_audio_obj_in_length_set(10.0)); - fail_if(!eo_do(in, ecore_audio_obj_in_remaining_get(&length))); + eo_do(in, length = ecore_audio_obj_in_remaining_get()); fail_if(length != -1); memset(buf, 0xaa, 10); - fail_if(!eo_do(in, ecore_audio_obj_in_read(buf, 10, &read))); + eo_do(in, read = ecore_audio_obj_in_read(buf, 10)); fail_if(read != 0); for (i=0; i<10; i++) { fail_if(buf[i] != 0xaa); } - fail_if(!eo_do(in, ecore_audio_obj_paused_set(EINA_TRUE))); + eo_do(in, ecore_audio_obj_paused_set(EINA_TRUE)); - fail_if(!eo_do(in, ecore_audio_obj_in_read(buf, 10, &read))); + eo_do(in, read = ecore_audio_obj_in_read(buf, 10)); fail_if(read != 10); for (i=0; i<10; i++) { @@ -560,29 +560,29 @@ START_TEST(ecore_test_ecore_audio_obj) fail_if(!obj); - fail_if(!eo_do(obj, ecore_audio_obj_name_get(&name))); + eo_do(obj, name = ecore_audio_obj_name_get()); fail_if(name); - fail_if(!eo_do(obj, ecore_audio_obj_name_set("In1"))); - fail_if(!eo_do(obj, ecore_audio_obj_name_get(&name))); + eo_do(obj, ecore_audio_obj_name_set("In1")); + eo_do(obj, name = ecore_audio_obj_name_get()); ck_assert_str_eq(name, "In1"); - fail_if(!eo_do(obj, ecore_audio_obj_name_get(NULL))); + eo_do(obj, ecore_audio_obj_name_get()); - fail_if(!eo_do(obj, ecore_audio_obj_paused_get(&paused))); + eo_do(obj, paused = ecore_audio_obj_paused_get()); fail_if(paused); - fail_if(!eo_do(obj, ecore_audio_obj_paused_set(EINA_TRUE))); - fail_if(!eo_do(obj, ecore_audio_obj_paused_get(&paused))); + eo_do(obj, ecore_audio_obj_paused_set(EINA_TRUE)); + eo_do(obj, paused = ecore_audio_obj_paused_get()); fail_if(!paused); - fail_if(!eo_do(obj, ecore_audio_obj_volume_get(&volume))); + eo_do(obj, volume = ecore_audio_obj_volume_get()); fail_if(volume != 1.0); - fail_if(!eo_do(obj, ecore_audio_obj_volume_set(0.5))); - fail_if(!eo_do(obj, ecore_audio_obj_volume_get(&volume))); + eo_do(obj, ecore_audio_obj_volume_set(0.5)); + eo_do(obj, volume = ecore_audio_obj_volume_get()); fail_if(volume != 0.5); eo_del(obj); diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index cf2bd1bb36..6547218a53 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -614,7 +614,6 @@ START_TEST(eo_magic_checks) fail_if(eo_class_name_get((Eo_Class*) buf)); fail_if(eo_class_get(obj) != SIMPLE_CLASS); fail_if(eo_class_get(SIMPLE_CLASS) != EO_CLASS_CLASS); - eo_class_funcs_set((Eo_Class *) buf, NULL); eo_do((Eo_Class *) buf,(void) NULL); eo_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i)); eo_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); @@ -659,7 +658,7 @@ START_TEST(eo_magic_checks) obj2 = NULL; eo_do(obj, eo_parent_set((Eo *) buf)); - eo_do(obj, eo_parent_get(&obj2)); + eo_do(obj, obj2 = eo_parent_get()); fail_if(obj2 && (obj2 == (Eo *) buf)); eo_unref(obj); From 8c025ee4d948c391b88211f5250f907212a68947 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 2 Apr 2014 15:34:40 +0100 Subject: [PATCH 164/169] Eo: Renamed eo files from eo2* to eo*. --- src/Makefile_Eo.am | 4 ++-- src/lib/eo/{eo2_base_class.c => eo_base_class.c} | 0 src/lib/eo/{eo2_class_class.c => eo_class_class.c} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/lib/eo/{eo2_base_class.c => eo_base_class.c} (100%) rename src/lib/eo/{eo2_class_class.c => eo_class_class.c} (100%) diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index c34b54b58c..7c2b093b38 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -10,8 +10,8 @@ lib_eo_libeo_la_SOURCES = \ lib/eo/eo.c \ lib/eo/eo_ptr_indirection.c \ lib/eo/eo_ptr_indirection.h \ -lib/eo/eo2_base_class.c \ -lib/eo/eo2_class_class.c \ +lib/eo/eo_base_class.c \ +lib/eo/eo_class_class.c \ lib/eo/eo_private.h lib_eo_libeo_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EO_CFLAGS@ diff --git a/src/lib/eo/eo2_base_class.c b/src/lib/eo/eo_base_class.c similarity index 100% rename from src/lib/eo/eo2_base_class.c rename to src/lib/eo/eo_base_class.c diff --git a/src/lib/eo/eo2_class_class.c b/src/lib/eo/eo_class_class.c similarity index 100% rename from src/lib/eo/eo2_class_class.c rename to src/lib/eo/eo_class_class.c From 1fbcb6ef9806dea4d392d9fd3b9ea90f6aa3dd0e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 3 Apr 2014 10:27:43 +0100 Subject: [PATCH 165/169] Eo: Removed redundant code. --- src/lib/eo/eo_private.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index dd486b4fa0..8648d023b8 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -210,7 +210,6 @@ _eo_condtor_reset(_Eo_Object *obj) static inline void _eo_del_internal(const char *file, int line, _Eo_Object *obj) { - Eina_Bool do_err; /* We need that for the event callbacks that may ref/unref. */ obj->refcount++; @@ -220,15 +219,8 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj) _eo_condtor_reset(obj); - do_err = EINA_FALSE; eo_do(_eo_id_get(obj), eo_destructor();); - if (EINA_UNLIKELY(do_err)) - { - ERR("in %s:%d: Object of class '%s' - One of the object destructors have failed.", - file, line, klass->desc->name); - } - if (!obj->condtor_done) { ERR("in %s:%d: Object of class '%s' - Not all of the object destructors have been executed.", From a77f0902564b4ef51bead693f2adc2c4cd866fe4 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 3 Apr 2014 17:54:30 +0100 Subject: [PATCH 166/169] Eo2: Make internal function static + improved debug output. --- src/lib/eo/eo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 70e88efa02..8a4c68cb2b 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -666,7 +666,7 @@ eo_api_funcs_cmp(const void *p1, const void *p2) else return 0; } -EAPI Eina_Bool +static Eina_Bool _eo_class_funcs_set(_Eo_Class *klass) { int op_id; @@ -711,8 +711,8 @@ _eo_class_funcs_set(_Eo_Class *klass) if (api_desc == NULL) { - ERR("Class '%s': Can't find api func description in class hierarchy (%p->%p).", - klass->desc->name, op_desc->api_func, op_desc->func); + ERR("Class '%s': Can't find api func description in class hierarchy (%p->%p) (%s).", + klass->desc->name, op_desc->api_func, op_desc->func, op_desc->doc); return EINA_FALSE; } From ca6e6c93f53e7f63a04a7f3f2fde7a2693f777ba Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 10 Apr 2014 03:11:29 +0100 Subject: [PATCH 167/169] Eo2: Adjust test suite to recent changes. --- src/tests/eo/suite/eo_test_class_errors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c index e6fee93cae..cd9ddf5b55 100644 --- a/src/tests/eo/suite/eo_test_class_errors.c +++ b/src/tests/eo/suite/eo_test_class_errors.c @@ -264,7 +264,7 @@ START_TEST(eo_wrong_override) NULL }; - TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': Can't find api func description in class hierarchy (%p->%p)."); + TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': Can't find api func description in class hierarchy (%p->%p) (%s)."); klass = eo_class_new(&class_desc, NULL, NULL); fail_if(klass); fail_unless(ctx.did); From 1a48d11fb99e4e278ffec59bb73afe86763dc3bc Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sat, 5 Apr 2014 03:22:28 +0300 Subject: [PATCH 168/169] Eolian: Fix generation of Eo APIs. When return is forced to void, even if the function contains only one parameter, the return type will be void. --- src/bin/eolian/eo1_generator.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c index 669125b1cf..ce4ffd6f37 100644 --- a/src/bin/eolian/eo1_generator.c +++ b/src/bin/eolian/eo1_generator.c @@ -167,7 +167,6 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function char *fsuffix = ""; rettype = eolian_function_return_type_get(func, ftype); - if (rettype && !strcmp(rettype, "void")) rettype = NULL; if (ftype == EOLIAN_PROP_GET) { fsuffix = "_get"; @@ -468,7 +467,6 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun Eina_Strbuf *full_params = eina_strbuf_new(); /* variables types + names */ rettype = eolian_function_return_type_get(funcid, ftype); - if (rettype && !strcmp(rettype, "void")) rettype = NULL; retname = "ret"; if (ftype == EOLIAN_PROP_GET) { From 1a895149e76b1e48233575b17451e2ce77690fba Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Thu, 10 Apr 2014 11:42:54 +0300 Subject: [PATCH 169/169] Eo: fix warning on printf --- src/lib/eo/eo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8a4c68cb2b..d207f206c0 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -347,7 +347,7 @@ _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow) else next_sz = sz >> 1; - DBG("resize from %lu to %lu", sz, next_sz); + DBG("resize from %lu to %lu", (long unsigned int)sz, (long unsigned int)next_sz); stack->frames = realloc(stack->frames, next_sz * sizeof(Eo_Stack_Frame)); if(!stack->frames) {