summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-23 16:02:19 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-24 08:14:31 +0200
commitf9a54462c0a21f12b37edac679b066a1b2e274d2 (patch)
tree7033880d49ae1035ba6e86e7b318d0d7f8c4e82e /src
parent5584564531b1d492199db42bfea96ae07178f79d (diff)
Eolian: Integration of Ecore Job
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_job.c57
-rw-r--r--src/lib/ecore/ecore_job.eo17
4 files changed, 39 insertions, 50 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index 41099e4..c28161f 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -5,12 +5,15 @@ BUILT_SOURCES += \
5 lib/ecore/ecore_timer.eo.c \ 5 lib/ecore/ecore_timer.eo.c \
6 lib/ecore/ecore_timer.eo.h \ 6 lib/ecore/ecore_timer.eo.h \
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 9 lib/ecore/ecore_job.eo.c \
10 lib/ecore/ecore_job.eo.h
11
10ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ 12ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
11ecoreeolianfiles_DATA = \ 13ecoreeolianfiles_DATA = \
12 lib/ecore/ecore_timer.eo \ 14 lib/ecore/ecore_timer.eo \
13 lib/ecore/ecore_poll.eo 15 lib/ecore/ecore_poll.eo \
16 lib/ecore/ecore_job.eo
14 17
15EXTRA_DIST += \ 18EXTRA_DIST += \
16 ${ecoreeolianfiles_DATA} 19 ${ecoreeolianfiles_DATA}
@@ -27,7 +30,8 @@ lib/ecore/Ecore_Getopt.h
27 30
28nodist_installed_ecoremainheaders_DATA = \ 31nodist_installed_ecoremainheaders_DATA = \
29 lib/ecore/ecore_timer.eo.h \ 32 lib/ecore/ecore_timer.eo.h \
30 lib/ecore/ecore_poll.eo.h 33 lib/ecore/ecore_poll.eo.h \
34 lib/ecore/ecore_job.eo.h
31 35
32lib_ecore_libecore_la_SOURCES = \ 36lib_ecore_libecore_la_SOURCES = \
33lib/ecore/ecore.c \ 37lib/ecore/ecore.c \
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index a1bc073..739deb9 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -344,6 +344,8 @@ enum
344 * 344 *
345 * @{ 345 * @{
346 */ 346 */
347#include "ecore_job.eo.h"
348#if 0
347 349
348#define ECORE_JOB_CLASS ecore_job_class_get() 350#define ECORE_JOB_CLASS ecore_job_class_get()
349const Eo_Class *ecore_job_class_get(void) EINA_CONST; 351const Eo_Class *ecore_job_class_get(void) EINA_CONST;
@@ -370,6 +372,7 @@ enum
370 */ 372 */
371#define ecore_job_constructor(func, data) ECORE_JOB_ID(ECORE_JOB_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Cb, func), EO_TYPECHECK(const void *, data) 373#define ecore_job_constructor(func, data) ECORE_JOB_ID(ECORE_JOB_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Cb, func), EO_TYPECHECK(const void *, data)
372 374
375#endif
373/** 376/**
374 * @} 377 * @}
375 */ 378 */
diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c
index ce86bbd..dfa0072 100644
--- a/src/lib/ecore/ecore_job.c
+++ b/src/lib/ecore/ecore_job.c
@@ -13,8 +13,6 @@
13 13
14#define MY_CLASS_NAME "Ecore_Job" 14#define MY_CLASS_NAME "Ecore_Job"
15 15
16EAPI Eo_Op ECORE_JOB_BASE_ID = EO_NOOP;
17
18static Eina_Bool _ecore_job_event_handler(void *data, 16static Eina_Bool _ecore_job_event_handler(void *data,
19 int type, 17 int type,
20 void *ev); 18 void *ev);
@@ -24,9 +22,9 @@ static void _ecore_job_event_free(void *data,
24static int ecore_event_job_type = 0; 22static int ecore_event_job_type = 0;
25static Ecore_Event_Handler *_ecore_job_handler = NULL; 23static Ecore_Event_Handler *_ecore_job_handler = NULL;
26 24
27typedef struct _Ecore_Job_Private_Data Ecore_Job_Private_Data; 25typedef struct _Ecore_Job_Data Ecore_Job_Data;
28 26
29struct _Ecore_Job_Private_Data 27struct _Ecore_Job_Data
30{ 28{
31 Ecore_Event *event; 29 Ecore_Event *event;
32 Ecore_Cb func; 30 Ecore_Cb func;
@@ -71,12 +69,9 @@ ecore_job_add(Ecore_Cb func,
71 return job; 69 return job;
72} 70}
73 71
74static void 72EOLIAN static void
75_job_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 73_ecore_job_constructor(Eo *obj, Ecore_Job_Data *job, Ecore_Cb func, const void *data)
76{ 74{
77 Ecore_Cb func = va_arg(*list, Ecore_Cb);
78 const void *data = va_arg(*list, const void *);
79
80 if (EINA_UNLIKELY(!eina_main_loop_is())) 75 if (EINA_UNLIKELY(!eina_main_loop_is()))
81 { 76 {
82 eo_error_set(obj); 77 eo_error_set(obj);
@@ -92,8 +87,6 @@ _job_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
92 return; 87 return;
93 } 88 }
94 89
95 Ecore_Job_Private_Data *job = _pd;
96
97 job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, obj); 90 job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, obj);
98 if (!job->event) 91 if (!job->event)
99 { 92 {
@@ -105,8 +98,8 @@ _job_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
105 job->data = (void *)data; 98 job->data = (void *)data;
106} 99}
107 100
108static void 101EOLIAN static void
109_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 102_ecore_job_eo_base_constructor(Eo *obj, Ecore_Job_Data *_pd EINA_UNUSED)
110{ 103{
111 eo_error_set(obj); 104 eo_error_set(obj);
112 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); 105 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
@@ -124,15 +117,15 @@ ecore_job_del(Ecore_Job *obj)
124 117
125 if (!obj) return NULL; 118 if (!obj) return NULL;
126 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 119 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
127 Ecore_Job_Private_Data *job = eo_data_scope_get(obj, MY_CLASS); 120 Ecore_Job_Data *job = eo_data_scope_get(obj, MY_CLASS);
128 data = job->data; 121 data = job->data;
129 ecore_event_del(job->event); 122 ecore_event_del(job->event);
130 eo_do(obj, eo_parent_set(NULL)); 123 eo_do(obj, eo_parent_set(NULL));
131 return data; 124 return data;
132} 125}
133 126
134static void 127EOLIAN static void
135_destructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 128_ecore_job_eo_base_destructor(Eo *obj, Ecore_Job_Data *_pd EINA_UNUSED)
136{ 129{
137 /*FIXME: check if ecore_event_del should be called from here*/ 130 /*FIXME: check if ecore_event_del should be called from here*/
138 eo_do_super(obj, MY_CLASS, eo_destructor()); 131 eo_do_super(obj, MY_CLASS, eo_destructor());
@@ -147,7 +140,7 @@ _ecore_job_event_handler(void *data EINA_UNUSED,
147 int type EINA_UNUSED, 140 int type EINA_UNUSED,
148 void *ev) 141 void *ev)
149{ 142{
150 Ecore_Job_Private_Data *job; 143 Ecore_Job_Data *job;
151 144
152 job = ev; 145 job = ev;
153 job->func(job->data); 146 job->func(job->data);
@@ -168,32 +161,4 @@ _ecore_job_event_free(void *data,
168 eo_manual_free_set(obj, EINA_FALSE); 161 eo_manual_free_set(obj, EINA_FALSE);
169} 162}
170 163
171static void 164#include "ecore_job.eo.c"
172_class_constructor(Eo_Class *klass)
173{
174 const Eo_Op_Func_Description func_desc[] = {
175 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
176 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
177 EO_OP_FUNC(ECORE_JOB_ID(ECORE_JOB_SUB_ID_CONSTRUCTOR), _job_constructor),
178 EO_OP_FUNC_SENTINEL
179 };
180
181 eo_class_funcs_set(klass, func_desc);
182}
183
184static const Eo_Op_Description op_desc[] = {
185 EO_OP_DESCRIPTION(ECORE_JOB_SUB_ID_CONSTRUCTOR, "Add a job to the event queue."),
186 EO_OP_DESCRIPTION_SENTINEL
187};
188static const Eo_Class_Description class_desc = {
189 EO_VERSION,
190 MY_CLASS_NAME,
191 EO_CLASS_TYPE_REGULAR,
192 EO_CLASS_DESCRIPTION_OPS(&ECORE_JOB_BASE_ID, op_desc, ECORE_JOB_SUB_ID_LAST),
193 NULL,
194 sizeof(Ecore_Job_Private_Data),
195 _class_constructor,
196 NULL
197};
198
199EO_DEFINE_CLASS(ecore_job_class_get, &class_desc, EO_BASE_CLASS, NULL);
diff --git a/src/lib/ecore/ecore_job.eo b/src/lib/ecore/ecore_job.eo
new file mode 100644
index 0000000..381ae10
--- /dev/null
+++ b/src/lib/ecore/ecore_job.eo
@@ -0,0 +1,17 @@
1class Ecore_Job (Eo_Base)
2{
3 eo_prefix: ecore_job;
4 constructors {
5 constructor {
6 /*@ Contructor. */
7 params {
8 @in Ecore_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