summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-23 16:20:37 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-24 08:14:31 +0200
commit753a4b310687cef6ccb386b468aeabf9098f5087 (patch)
treeb856575a5d96ea9fd3b31ab8300dfdb54634c179 /src
parentf9a54462c0a21f12b37edac679b066a1b2e274d2 (diff)
Eolian: Integration of Ecore Idler
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Ecore.am12
-rw-r--r--src/lib/ecore/Ecore_Eo.h3
-rw-r--r--src/lib/ecore/ecore_idler.c84
-rw-r--r--src/lib/ecore/ecore_idler.eo17
4 files changed, 50 insertions, 66 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index c28161f..60e425a 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -7,13 +7,16 @@ BUILT_SOURCES += \
7 lib/ecore/ecore_poll.eo.c \ 7 lib/ecore/ecore_poll.eo.c \
8 lib/ecore/ecore_poll.eo.h \ 8 lib/ecore/ecore_poll.eo.h \
9 lib/ecore/ecore_job.eo.c \ 9 lib/ecore/ecore_job.eo.c \
10 lib/ecore/ecore_job.eo.h 10 lib/ecore/ecore_job.eo.h \
11 11 lib/ecore/ecore_idler.eo.c \
12 lib/ecore/ecore_idler.eo.h
13
12ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ 14ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
13ecoreeolianfiles_DATA = \ 15ecoreeolianfiles_DATA = \
14 lib/ecore/ecore_timer.eo \ 16 lib/ecore/ecore_timer.eo \
15 lib/ecore/ecore_poll.eo \ 17 lib/ecore/ecore_poll.eo \
16 lib/ecore/ecore_job.eo 18 lib/ecore/ecore_job.eo \
19 lib/ecore/ecore_idler.eo
17 20
18EXTRA_DIST += \ 21EXTRA_DIST += \
19 ${ecoreeolianfiles_DATA} 22 ${ecoreeolianfiles_DATA}
@@ -31,7 +34,8 @@ lib/ecore/Ecore_Getopt.h
31nodist_installed_ecoremainheaders_DATA = \ 34nodist_installed_ecoremainheaders_DATA = \
32 lib/ecore/ecore_timer.eo.h \ 35 lib/ecore/ecore_timer.eo.h \
33 lib/ecore/ecore_poll.eo.h \ 36 lib/ecore/ecore_poll.eo.h \
34 lib/ecore/ecore_job.eo.h 37 lib/ecore/ecore_job.eo.h \
38 lib/ecore/ecore_idler.eo.h
35 39
36lib_ecore_libecore_la_SOURCES = \ 40lib_ecore_libecore_la_SOURCES = \
37lib/ecore/ecore.c \ 41lib/ecore/ecore.c \
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 739deb9..a175ca7 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -238,6 +238,8 @@ enum
238 * 238 *
239 * @{ 239 * @{
240 */ 240 */
241#include "ecore_idler.eo.h"
242#if 0
241 243
242#define ECORE_IDLER_CLASS ecore_idler_class_get() 244#define ECORE_IDLER_CLASS ecore_idler_class_get()
243const Eo_Class *ecore_idler_class_get(void) EINA_CONST; 245const Eo_Class *ecore_idler_class_get(void) EINA_CONST;
@@ -264,6 +266,7 @@ enum
264 */ 266 */
265#define ecore_idler_constructor(func, data) ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data) 267#define ecore_idler_constructor(func, data) ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
266 268
269#endif
267/** 270/**
268 * 271 *
269 */ 272 */
diff --git a/src/lib/ecore/ecore_idler.c b/src/lib/ecore/ecore_idler.c
index 3ac38ee..7650af5 100644
--- a/src/lib/ecore/ecore_idler.c
+++ b/src/lib/ecore/ecore_idler.c
@@ -13,9 +13,7 @@
13 13
14#define MY_CLASS_NAME "Ecore_Idler" 14#define MY_CLASS_NAME "Ecore_Idler"
15 15
16EAPI Eo_Op ECORE_IDLER_BASE_ID = EO_NOOP; 16struct _Ecore_Idler_Data
17
18struct _Ecore_Idler_Private_Data
19{ 17{
20 EINA_INLIST; 18 EINA_INLIST;
21 Ecore_Idler *obj; 19 Ecore_Idler *obj;
@@ -25,9 +23,9 @@ struct _Ecore_Idler_Private_Data
25 Eina_Bool delete_me : 1; 23 Eina_Bool delete_me : 1;
26}; 24};
27 25
28typedef struct _Ecore_Idler_Private_Data Ecore_Idler_Private_Data; 26typedef struct _Ecore_Idler_Data Ecore_Idler_Data;
29static Ecore_Idler_Private_Data *idlers = NULL; 27static Ecore_Idler_Data *idlers = NULL;
30static Ecore_Idler_Private_Data *idler_current = NULL; 28static Ecore_Idler_Data *idler_current = NULL;
31static int idlers_delete_me = 0; 29static int idlers_delete_me = 0;
32 30
33static void * 31static void *
@@ -48,20 +46,15 @@ ecore_idler_add(Ecore_Task_Cb func,
48 return ie; 46 return ie;
49} 47}
50 48
51static void 49EOLIAN static void
52_idler_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 50_ecore_idler_constructor(Eo *obj, Ecore_Idler_Data *ie, Ecore_Task_Cb func, const void *data)
53{ 51{
54 Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
55 const void *data = va_arg(*list, const void *);
56
57 if (EINA_UNLIKELY(!eina_main_loop_is())) 52 if (EINA_UNLIKELY(!eina_main_loop_is()))
58 { 53 {
59 eo_error_set(obj); 54 eo_error_set(obj);
60 EINA_MAIN_LOOP_CHECK_RETURN; 55 EINA_MAIN_LOOP_CHECK_RETURN;
61 } 56 }
62 57
63 Ecore_Idler_Private_Data *ie = _pd;
64
65 ie->obj = obj; 58 ie->obj = obj;
66 eo_do_super(obj, MY_CLASS, eo_constructor()); 59 eo_do_super(obj, MY_CLASS, eo_constructor());
67 eo_manual_free_set(obj, EINA_TRUE); 60 eo_manual_free_set(obj, EINA_TRUE);
@@ -75,12 +68,11 @@ _idler_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
75 68
76 ie->func = func; 69 ie->func = func;
77 ie->data = (void *)data; 70 ie->data = (void *)data;
78 idlers = (Ecore_Idler_Private_Data *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); 71 idlers = (Ecore_Idler_Data *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
79} 72}
80 73
81 74EOLIAN static void
82static void 75_ecore_idler_eo_base_constructor(Eo *obj, Ecore_Idler_Data *_pd EINA_UNUSED)
83_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
84{ 76{
85 eo_error_set(obj); 77 eo_error_set(obj);
86 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); 78 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
@@ -111,18 +103,16 @@ ecore_idler_del(Ecore_Idler *idler)
111static void * 103static void *
112_ecore_idler_del(Ecore_Idler *obj) 104_ecore_idler_del(Ecore_Idler *obj)
113{ 105{
114 Ecore_Idler_Private_Data *idler = eo_data_scope_get(obj, MY_CLASS); 106 Ecore_Idler_Data *idler = eo_data_scope_get(obj, MY_CLASS);
115 EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL); 107 EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
116 idler->delete_me = 1; 108 idler->delete_me = 1;
117 idlers_delete_me = 1; 109 idlers_delete_me = 1;
118 return idler->data; 110 return idler->data;
119} 111}
120 112
121static void 113EOLIAN static void
122_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 114_ecore_idler_eo_base_destructor(Eo *obj, Ecore_Idler_Data *idler)
123{ 115{
124 Ecore_Idler_Private_Data *idler = _pd;
125
126 idler->delete_me = 1; 116 idler->delete_me = 1;
127 idlers_delete_me = 1; 117 idlers_delete_me = 1;
128 118
@@ -132,10 +122,10 @@ _destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
132void 122void
133_ecore_idler_shutdown(void) 123_ecore_idler_shutdown(void)
134{ 124{
135 Ecore_Idler_Private_Data *ie; 125 Ecore_Idler_Data *ie;
136 while ((ie = idlers)) 126 while ((ie = idlers))
137 { 127 {
138 idlers = (Ecore_Idler_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); 128 idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
139 129
140 eo_do(ie->obj, eo_parent_set(NULL)); 130 eo_do(ie->obj, eo_parent_set(NULL));
141 if (eo_destructed_is(ie->obj)) 131 if (eo_destructed_is(ie->obj))
@@ -158,12 +148,12 @@ _ecore_idler_all_call(void)
158 else 148 else
159 { 149 {
160 /* recursive main loop, continue from where we were */ 150 /* recursive main loop, continue from where we were */
161 idler_current = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(idler_current)->next; 151 idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next;
162 } 152 }
163 153
164 while (idler_current) 154 while (idler_current)
165 { 155 {
166 Ecore_Idler_Private_Data *ie = (Ecore_Idler_Private_Data *)idler_current; 156 Ecore_Idler_Data *ie = (Ecore_Idler_Data *)idler_current;
167 if (!ie->delete_me) 157 if (!ie->delete_me)
168 { 158 {
169 ie->references++; 159 ie->references++;
@@ -174,16 +164,16 @@ _ecore_idler_all_call(void)
174 ie->references--; 164 ie->references--;
175 } 165 }
176 if (idler_current) /* may have changed in recursive main loops */ 166 if (idler_current) /* may have changed in recursive main loops */
177 idler_current = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(idler_current)->next; 167 idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next;
178 } 168 }
179 if (idlers_delete_me) 169 if (idlers_delete_me)
180 { 170 {
181 Ecore_Idler_Private_Data *l; 171 Ecore_Idler_Data *l;
182 int deleted_idlers_in_use = 0; 172 int deleted_idlers_in_use = 0;
183 for (l = idlers; l; ) 173 for (l = idlers; l; )
184 { 174 {
185 Ecore_Idler_Private_Data *ie = l; 175 Ecore_Idler_Data *ie = l;
186 l = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(l)->next; 176 l = (Ecore_Idler_Data *)EINA_INLIST_GET(l)->next;
187 if (ie->delete_me) 177 if (ie->delete_me)
188 { 178 {
189 if (ie->references) 179 if (ie->references)
@@ -192,7 +182,7 @@ _ecore_idler_all_call(void)
192 continue; 182 continue;
193 } 183 }
194 184
195 idlers = (Ecore_Idler_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); 185 idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
196 186
197 eo_do(ie->obj, eo_parent_set(NULL)); 187 eo_do(ie->obj, eo_parent_set(NULL));
198 if (eo_destructed_is(ie->obj)) 188 if (eo_destructed_is(ie->obj))
@@ -215,34 +205,4 @@ _ecore_idler_exist(void)
215 return 0; 205 return 0;
216} 206}
217 207
218static void 208#include "ecore_idler.eo.c" \ No newline at end of file
219_class_constructor(Eo_Class *klass)
220{
221 const Eo_Op_Func_Description func_desc[] = {
222 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
223 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
224
225 EO_OP_FUNC(ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), _idler_constructor),
226 EO_OP_FUNC_SENTINEL
227 };
228
229 eo_class_funcs_set(klass, func_desc);
230}
231
232static const Eo_Op_Description op_desc[] = {
233 EO_OP_DESCRIPTION(ECORE_IDLER_SUB_ID_CONSTRUCTOR, "Add an idler handler."),
234 EO_OP_DESCRIPTION_SENTINEL
235};
236
237static const Eo_Class_Description class_desc = {
238 EO_VERSION,
239 MY_CLASS_NAME,
240 EO_CLASS_TYPE_REGULAR,
241 EO_CLASS_DESCRIPTION_OPS(&ECORE_IDLER_BASE_ID, op_desc, ECORE_IDLER_SUB_ID_LAST),
242 NULL,
243 sizeof(Ecore_Idler_Private_Data),
244 _class_constructor,
245 NULL
246};
247
248EO_DEFINE_CLASS(ecore_idler_class_get, &class_desc, EO_BASE_CLASS, NULL)
diff --git a/src/lib/ecore/ecore_idler.eo b/src/lib/ecore/ecore_idler.eo
new file mode 100644
index 0000000..567ed7a
--- /dev/null
+++ b/src/lib/ecore/ecore_idler.eo
@@ -0,0 +1,17 @@
1class Ecore_Idler (Eo_Base)
2{
3 eo_prefix: ecore_idler;
4 constructors {
5 constructor {
6 /*@ Contructor. */
7 params {
8 @in Ecore_Task_Cb func;
9 @in const void *data;
10 }
11 }
12 }
13 implements {
14 Eo_Base::constructor;
15 Eo_Base::destructor;
16 }
17} \ No newline at end of file