summaryrefslogtreecommitdiff
path: root/legacy/eobj
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-08-23 10:47:11 +0000
committerTom Hacohen <tom@stosb.com>2012-08-23 10:47:11 +0000
commit41c490609c098a3ceb4efeb6b0b7dd8142eb0bea (patch)
tree3338e04dddcc702f9b62905e9560c8cd28e636d6 /legacy/eobj
parentb6c18924638d8c79902a76ecceb2ddc737451b3e (diff)
Eo: Added a non-default constructor test.
SVN revision: 75616
Diffstat (limited to 'legacy/eobj')
-rw-r--r--legacy/eobj/src/tests/constructors/main.c10
-rw-r--r--legacy/eobj/src/tests/constructors/simple.c17
-rw-r--r--legacy/eobj/src/tests/constructors/simple.h2
3 files changed, 29 insertions, 0 deletions
diff --git a/legacy/eobj/src/tests/constructors/main.c b/legacy/eobj/src/tests/constructors/main.c
index 9bcf095d1e..04d888803f 100644
--- a/legacy/eobj/src/tests/constructors/main.c
+++ b/legacy/eobj/src/tests/constructors/main.c
@@ -59,6 +59,16 @@ main(int argc, char *argv[])
59 obj = eo_add(SIMPLE7_CLASS, NULL); 59 obj = eo_add(SIMPLE7_CLASS, NULL);
60 fail_if(obj); 60 fail_if(obj);
61 61
62 my_init_count = 0;
63 obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7));
64 fail_if(!obj);
65
66 fail_if(my_init_count != 2);
67 eo_do(obj, simple_a_get(&a));
68 fail_if(a != 7);
69
70 eo_unref(obj);
71
62 eo_shutdown(); 72 eo_shutdown();
63 return ret; 73 return ret;
64} 74}
diff --git a/legacy/eobj/src/tests/constructors/simple.c b/legacy/eobj/src/tests/constructors/simple.c
index 856b2b4898..5712534907 100644
--- a/legacy/eobj/src/tests/constructors/simple.c
+++ b/legacy/eobj/src/tests/constructors/simple.c
@@ -42,6 +42,21 @@ _GET_SET_FUNC(b)
42extern int my_init_count; 42extern int my_init_count;
43 43
44static void 44static void
45_simple_constructor(Eo *obj, void *class_data, va_list *list)
46{
47 Private_Data *pd = class_data;
48 int a;
49 a = va_arg(*list, int);
50
51 eo_do_super(obj, eo_constructor());
52
53 pd->a = a;
54 printf("%s %d\n", __func__, pd->a);
55
56 my_init_count++;
57}
58
59static void
45_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) 60_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
46{ 61{
47 eo_do_super(obj, eo_constructor()); 62 eo_do_super(obj, eo_constructor());
@@ -63,6 +78,7 @@ _class_constructor(Eo_Class *klass)
63 const Eo_Op_Func_Description func_desc[] = { 78 const Eo_Op_Func_Description func_desc[] = {
64 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), 79 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
65 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), 80 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
81 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), _simple_constructor),
66 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), 82 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
67 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), 83 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
68 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set), 84 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
@@ -82,6 +98,7 @@ _class_destructor(Eo_Class *klass EINA_UNUSED)
82} 98}
83 99
84static const Eo_Op_Description op_desc[] = { 100static const Eo_Op_Description op_desc[] = {
101 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_CONSTRUCTOR, "Construct and set A."),
85 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), 102 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
86 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), 103 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
87 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"), 104 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
diff --git a/legacy/eobj/src/tests/constructors/simple.h b/legacy/eobj/src/tests/constructors/simple.h
index 773b7374c4..ac3e287bbd 100644
--- a/legacy/eobj/src/tests/constructors/simple.h
+++ b/legacy/eobj/src/tests/constructors/simple.h
@@ -6,6 +6,7 @@
6extern EAPI Eo_Op SIMPLE_BASE_ID; 6extern EAPI Eo_Op SIMPLE_BASE_ID;
7 7
8enum { 8enum {
9 SIMPLE_SUB_ID_CONSTRUCTOR,
9 SIMPLE_SUB_ID_A_SET, 10 SIMPLE_SUB_ID_A_SET,
10 SIMPLE_SUB_ID_A_GET, 11 SIMPLE_SUB_ID_A_GET,
11 SIMPLE_SUB_ID_B_SET, 12 SIMPLE_SUB_ID_B_SET,
@@ -15,6 +16,7 @@ enum {
15 16
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) 17#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17 18
19#define simple_constructor(a) SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(int, a)
18#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) 20#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
19#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) 21#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
20#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b) 22#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)