From 13b30abe56becfdd38a4cd613ae13c4eaeeac72e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Nov 2013 10:25:38 +0000 Subject: [PATCH] eo2: cleaned up the function overrides test. --- .../function_overrides_inherit2.c | 45 ++++++++++----------- .../function_overrides_inherit2.h | 7 +--- .../function_overrides/function_overrides_main.c | 47 ++++++++++------------ .../function_overrides/function_overrides_simple.c | 31 +++++++------- .../function_overrides/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 e092031..f228528 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); + + eo2_do_super(klass, MY_CLASS, called = simple_class_print2()); + fail_if(!called); - class_print2_called = EINA_FALSE; - eo2_do_super(klass, MY_CLASS, simple_class_print2()); - fail_if(!class_print2_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 c891bd9..48be203 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 1caf902..11f4c8f 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 0819544..3de5938 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 29ab651..e473968 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 -- 2.7.4