summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-11-07 17:00:09 +0000
committerTom Hacohen <tom@stosb.com>2013-11-07 17:56:53 +0000
commit2d9a084286da002e88020af3ef0842035f0bd1fa (patch)
treed7dfe15cd08ba78fab8d94c85a161fd518b370ef
parent7927cdabfc1e155246e242603707f0f9b29def7f (diff)
downloadefl-2d9a084286da002e88020af3ef0842035f0bd1fa.tar.gz
Eo2: Migrated function_overrides test to eo2.
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit.c2
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit2.c71
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit2.h17
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit3.c22
-rw-r--r--src/tests/eo/function_overrides/function_overrides_main.c50
-rw-r--r--src/tests/eo/function_overrides/function_overrides_simple.c70
-rw-r--r--src/tests/eo/function_overrides/function_overrides_simple.h24
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()));
-}
-
-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
- };
+ class_print_called = EINA_FALSE;
+ eo2_do_super(klass, MY_CLASS, simple_class_print());
+ fail_if(!class_print_called);
- eo_class_funcs_set(klass, func_desc);
+ class_print2_called = EINA_FALSE;
+ eo2_do_super(klass, MY_CLASS, simple_class_print2());
+ fail_if(!class_print2_called);
}
-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
+EAPI EO2_VOID_FUNC_BODY(inherit2_print);
+EAPI EO2_VOID_FUNC_BODY(inherit2_print2);
+
+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