summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite/eo_test_class_simple.c
blob: 56620c68a27bdef23c847391391100af70c513b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "eo_test_class_simple.h"

#define MY_CLASS SIMPLE_CLASS

EAPI const Efl_Event_Description _EV_A_CHANGED =
        EFL_EVENT_DESCRIPTION("a,changed");

EAPI const Efl_Event_Description _EV_A_CHANGED2 =
        EFL_EVENT_DESCRIPTION("a,changed");

static void
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
{
   Simple_Public_Data *pd = class_data;
   printf("%s %d\n", efl_class_name_get(MY_CLASS), a);
   pd->a = a;

   efl_event_callback_legacy_call(obj, EV_A_CHANGED, &pd->a);
}

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;
   printf("Print %s %d\n", efl_class_name_get(MY_CLASS), pd->a);

   return EINA_TRUE;
}

static Eina_Bool
_class_hi_print(Efl_Class *klass, void *data EINA_UNUSED)
{
   printf("Hi Print %s\n", efl_class_name_get(klass));

   return EINA_TRUE;
}

EFL_FUNC_BODYV(simple_part_get, Eo *, NULL, EFL_FUNC_CALL(name), const char *name);

static Eo *
_part_get(Eo *obj, void *class_data EINA_UNUSED, const char *name EINA_UNUSED)
{
   /* A normal part get will do something saner, we just create objects. */
   return efl_add(SIMPLE_CLASS, obj);
}

EFL_VOID_FUNC_BODYV(simple_recursive, EFL_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++;
        simple_recursive(obj, n);
     }
   else
     count = 0;
}

static void
_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Efl_Dbg_Info *root)
{
   efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
   Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Test list");
   EFL_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
}

EFL_VOID_FUNC_BODYV(simple_a_set, EFL_FUNC_CALL(a), int a);
EFL_FUNC_BODY(simple_a_get, int, 0);
EFL_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE);
EFL_FUNC_BODY_CONST(simple_class_hi_print, Eina_Bool, EINA_FALSE);
EFL_VOID_FUNC_BODY(simple_pure_virtual);
EFL_VOID_FUNC_BODY(simple_no_implementation);

static Eina_Bool
_class_initializer(Efl_Class *klass)
{
   EFL_OPS_DEFINE(ops,
         EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
         EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
         EFL_OBJECT_OP_FUNC(simple_a_print, _a_print),
         EFL_OBJECT_OP_FUNC(simple_recursive, _recursive),
         EFL_OBJECT_OP_FUNC(simple_part_get, _part_get),
         EFL_OBJECT_OP_FUNC(simple_pure_virtual, NULL),
         EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _dbg_info_get),
   );
   EFL_OPS_DEFINE(cops,
         EFL_OBJECT_OP_FUNC(simple_class_hi_print, _class_hi_print),
   );

   return efl_class_functions_set(klass, &ops, &cops);
}

static const Efl_Class_Description class_desc = {
     EO_VERSION,
     "Simple",
     EFL_CLASS_TYPE_REGULAR,
     sizeof(Simple_Public_Data),
     _class_initializer,
     NULL,
     NULL
};

EFL_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL)


static int
_beef_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED)
{
   return 0xBEEF;
}

EFL_FUNC_BODY_CONST(simple2_class_beef_get, int, 0);

static Eina_Bool
_class_initializer2(Efl_Class *klass)
{
   EFL_OPS_DEFINE(cops,
         EFL_OBJECT_OP_FUNC(simple2_class_beef_get, _beef_get),
   );

   return efl_class_functions_set(klass, NULL, &cops);
}

static const Efl_Class_Description class_desc2 = {
     EO_VERSION,
     "Simple2",
     EFL_CLASS_TYPE_REGULAR,
     0,
     _class_initializer2,
     NULL,
     NULL
};

EFL_DEFINE_CLASS(simple2_class_get, &class_desc2, EO_CLASS, NULL)

static Efl_Object*
_interface_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Efl_Object *klass)
{
   if (klass == SEARCHABLE_CLASS) return obj;

   return efl_provider_find(efl_super(obj, SEARCHABLE_CLASS), klass);
}

static Eina_Bool
_searchable_class_initializer(Efl_Class *klass)
{
   EFL_OPS_DEFINE(ops,
         EFL_OBJECT_OP_FUNC(efl_provider_find, _interface_get)
   );

   return efl_class_functions_set(klass, &ops, NULL);
}

static const Efl_Class_Description class_desc_searchable = {
     EO_VERSION,
     "Searchable",
     EFL_CLASS_TYPE_REGULAR,
     0,
     _searchable_class_initializer,
     NULL,
     NULL
};

EFL_DEFINE_CLASS(searchable_class_get, &class_desc_searchable, EO_CLASS, NULL)