summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-02-06 13:48:43 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-06 13:48:43 -0500
commitf484ca0951e4875f926ebbd9f779d38a13659577 (patch)
treee67dfc2db88b882e6e904d4ac6219c9549472cb7 /src/lib/edje
parent917e0aa0feb9a79721953ea632723d26a251a850 (diff)
edje: migrate Eo API to use Eo callback instead of opaque type.
Summary: Depends on D7869 Reviewers: zmike, q66, segfaultxavi, bu5hm4n Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T7671 Differential Revision: https://phab.enlightenment.org/D7870
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_legacy.c8
-rw-r--r--src/lib/edje/edje_match.c5
-rw-r--r--src/lib/edje/edje_private.h21
-rw-r--r--src/lib/edje/edje_program.c27
-rw-r--r--src/lib/edje/edje_signal.c109
-rw-r--r--src/lib/edje/efl_layout_signal.eo15
6 files changed, 125 insertions, 60 deletions
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index e96e470724..fead8b04be 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -81,7 +81,7 @@ edje_object_signal_callback_add(Evas_Object *obj, const char *emission, const ch
81 81
82 ed = _edje_fetch(obj); 82 ed = _edje_fetch(obj);
83 if (!ed || ed->delete_me) return; 83 if (!ed || ed->delete_me) return;
84 _edje_object_signal_callback_add(ed, emission, source, func, data); 84 _edje_object_signal_callback_add(ed, emission, source, func, NULL, NULL, data);
85} 85}
86 86
87EAPI void * 87EAPI void *
@@ -99,7 +99,8 @@ edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, con
99 emission = eina_stringshare_add(emission); 99 emission = eina_stringshare_add(emission);
100 source = eina_stringshare_add(source); 100 source = eina_stringshare_add(source);
101 101
102 ok = _edje_signal_callback_disable(gp, emission, source, func, data); 102 // We can cast here as the function won't be used and is just going to be used for comparison
103 ok = _edje_signal_callback_disable(gp, emission, source, func, NULL, NULL, data);
103 104
104 // Legacy only 105 // Legacy only
105 if (!ok && !data) 106 if (!ok && !data)
@@ -108,7 +109,8 @@ edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, con
108 { 109 {
109 if (emission == gp->matches->matches[i].signal && 110 if (emission == gp->matches->matches[i].signal &&
110 source == gp->matches->matches[i].source && 111 source == gp->matches->matches[i].source &&
111 func == gp->matches->matches[i].func && 112 func == gp->matches->matches[i].legacy &&
113 gp->flags[i].legacy &&
112 !gp->flags[i].delete_me) 114 !gp->flags[i].delete_me)
113 { 115 {
114 gp->flags[i].delete_me = EINA_TRUE; 116 gp->flags[i].delete_me = EINA_TRUE;
diff --git a/src/lib/edje/edje_match.c b/src/lib/edje/edje_match.c
index 57e319bdb9..7f4065ae96 100644
--- a/src/lib/edje/edje_match.c
+++ b/src/lib/edje/edje_match.c
@@ -553,7 +553,10 @@ edje_match_callback_exec_check_finals(const Edje_Signals_Sources_Patterns *ssp,
553 553
554 if (ed->callbacks->flags[idx].delete_me) continue; 554 if (ed->callbacks->flags[idx].delete_me) continue;
555 555
556 cb->func((void *)ed->callbacks->custom_data[idx], ed->obj, sig, source); 556 if (ed->callbacks->flags[idx].legacy)
557 cb->legacy((void *)ed->callbacks->custom_data[idx], ed->obj, sig, source);
558 else
559 cb->eo((void *)ed->callbacks->custom_data[idx], ed->obj, sig, source);
557 if (_edje_block_break(ed)) 560 if (_edje_block_break(ed))
558 { 561 {
559 r = 0; 562 r = 0;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index a8349ae372..6b7cf50ffc 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1048,12 +1048,16 @@ struct _Edje_Signal_Callback_Match
1048{ 1048{
1049 const char *signal; 1049 const char *signal;
1050 const char *source; 1050 const char *source;
1051 Edje_Signal_Cb func; 1051 union {
1052 Edje_Signal_Cb legacy;
1053 EflLayoutSignalCb eo;
1054 };
1052}; 1055};
1053 1056
1054struct _Edje_Signal_Callback_Matches 1057struct _Edje_Signal_Callback_Matches
1055{ 1058{
1056 Edje_Signal_Callback_Match *matches; 1059 Edje_Signal_Callback_Match *matches;
1060 Eina_Free_Cb *free_cb;
1057 1061
1058 Edje_Signals_Sources_Patterns *patterns; 1062 Edje_Signals_Sources_Patterns *patterns;
1059 1063
@@ -1065,6 +1069,7 @@ struct _Edje_Signal_Callback_Matches
1065 1069
1066struct _Edje_Signal_Callback_Flags 1070struct _Edje_Signal_Callback_Flags
1067{ 1071{
1072 Eina_Bool legacy:1;
1068 Eina_Bool delete_me:1; 1073 Eina_Bool delete_me:1;
1069 Eina_Bool just_added:1; 1074 Eina_Bool just_added:1;
1070 Eina_Bool propagate:1; 1075 Eina_Bool propagate:1;
@@ -2424,8 +2429,9 @@ const Eina_Inarray *edje_match_signal_source_hash_get(const char *signal,
2424 const char *source, 2429 const char *source,
2425 const Eina_Rbtree *tree); 2430 const Eina_Rbtree *tree);
2426void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data); 2431void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data);
2427void _edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m); 2432Eina_Bool _edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source,
2428Eina_Bool _edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data); 2433 Edje_Signal_Cb func_legacy,
2434 Efl_Signal_Cb func_eo, Eina_Free_Cb func_free_cb, void *data);
2429 2435
2430// FIXME remove below 3 eapi decls when edje_convert goes 2436// FIXME remove below 3 eapi decls when edje_convert goes
2431EAPI void _edje_edd_init(void); 2437EAPI void _edje_edd_init(void);
@@ -2548,14 +2554,19 @@ void _edje_callbacks_del(Evas_Object *obj, Edje *ed);
2548void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed); 2554void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed);
2549 2555
2550const Edje_Signal_Callback_Group *_edje_signal_callback_alloc(void); 2556const Edje_Signal_Callback_Group *_edje_signal_callback_alloc(void);
2557void _edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m, Edje_Signal_Callback_Flags *flags, void **custom_data);
2551void _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp); 2558void _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp);
2552Eina_Bool _edje_signal_callback_push(Edje_Signal_Callback_Group *cgp, 2559Eina_Bool _edje_signal_callback_push(Edje_Signal_Callback_Group *cgp,
2553 const char *signal, const char *source, 2560 const char *signal, const char *source,
2554 Edje_Signal_Cb func, void *data, 2561 Edje_Signal_Cb func_legacy,
2562 Efl_Signal_Cb func_eo,
2563 Eina_Free_Cb func_free_cb,
2564 void *data,
2555 Eina_Bool propagate); 2565 Eina_Bool propagate);
2556Eina_Bool _edje_signal_callback_disable(Edje_Signal_Callback_Group *cgp, 2566Eina_Bool _edje_signal_callback_disable(Edje_Signal_Callback_Group *cgp,
2557 const char *signal, const char *source, 2567 const char *signal, const char *source,
2558 Edje_Signal_Cb func, void *data); 2568 Edje_Signal_Cb func_legacy,
2569 EflLayoutSignalCb func, Eina_Free_Cb func_free_cb, void *data);
2559 2570
2560EAPI void _edje_edd_init(void); 2571EAPI void _edje_edd_init(void);
2561EAPI void _edje_edd_shutdown(void); 2572EAPI void _edje_edd_shutdown(void);
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index e6a1373adf..9d8f90f6c5 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -237,7 +237,9 @@ edje_transition_duration_factor_set(double scale)
237} 237}
238 238
239Eina_Bool 239Eina_Bool
240_edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data) 240_edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source,
241 Edje_Signal_Cb func_legacy,
242 Efl_Signal_Cb func_eo, Eina_Free_Cb func_free_cb, void *data)
241{ 243{
242 Edje_Signal_Callback_Group *gp; 244 Edje_Signal_Callback_Group *gp;
243 const char *sig; 245 const char *sig;
@@ -252,7 +254,7 @@ _edje_object_signal_callback_add(Edje *ed, const char *emission, const char *sou
252 src = eina_stringshare_add(source); 254 src = eina_stringshare_add(source);
253 255
254 gp = (Edje_Signal_Callback_Group *) ed->callbacks; 256 gp = (Edje_Signal_Callback_Group *) ed->callbacks;
255 ok = _edje_signal_callback_push(gp, sig, src, func, data, EINA_TRUE); 257 ok = _edje_signal_callback_push(gp, sig, src, func_legacy, func_eo, func_free_cb, data, EINA_TRUE);
256 258
257 eina_stringshare_del(sig); 259 eina_stringshare_del(sig);
258 eina_stringshare_del(src); 260 eina_stringshare_del(src);
@@ -267,17 +269,17 @@ edje_object_propagate_callback_add(Evas_Object *obj, Efl_Signal_Cb func, void *d
267 269
268 ed = _edje_fetch(obj); 270 ed = _edje_fetch(obj);
269 if (!ed || ed->delete_me) return; 271 if (!ed || ed->delete_me) return;
270 _edje_object_signal_callback_add(ed, "*", "*", func, data); 272 _edje_object_signal_callback_add(ed, "*", "*", func, NULL, NULL, data);
271} 273}
272 274
273EOLIAN Eina_Bool 275Eina_Bool
274_efl_canvas_layout_efl_layout_signal_signal_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data) 276_efl_canvas_layout_efl_layout_signal_signal_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
275{ 277{
276 return _edje_object_signal_callback_add(ed, emission, source, func, data); 278 return _edje_object_signal_callback_add(ed, emission, source, NULL, func, func_free_cb, func_data);
277} 279}
278 280
279EOLIAN Eina_Bool 281Eina_Bool
280_efl_canvas_layout_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data) 282_efl_canvas_layout_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
281{ 283{
282 Edje_Signal_Callback_Group *gp; 284 Edje_Signal_Callback_Group *gp;
283 Eina_Bool ok; 285 Eina_Bool ok;
@@ -291,7 +293,7 @@ _efl_canvas_layout_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Ed
291 emission = eina_stringshare_add(emission); 293 emission = eina_stringshare_add(emission);
292 source = eina_stringshare_add(source); 294 source = eina_stringshare_add(source);
293 295
294 ok = _edje_signal_callback_disable(gp, emission, source, func, data); 296 ok = _edje_signal_callback_disable(gp, emission, source, NULL, func, func_free_cb, func_data);
295 297
296 eina_stringshare_del(emission); 298 eina_stringshare_del(emission);
297 eina_stringshare_del(source); 299 eina_stringshare_del(source);
@@ -1669,13 +1671,16 @@ _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Da
1669 1671
1670 cb = &m->matches[*i]; 1672 cb = &m->matches[*i];
1671 1673
1672 cb->func((void *)ed->callbacks->custom_data[*i], ed->obj, sig, src); 1674 if (ed->callbacks->flags[*i].legacy)
1675 cb->legacy((void *)ed->callbacks->custom_data[*i], ed->obj, sig, src);
1676 else
1677 cb->eo((void *)ed->callbacks->custom_data[*i], ed->obj, sig, src);
1673 if (_edje_block_break(ed)) break; 1678 if (_edje_block_break(ed)) break;
1674 } 1679 }
1675 } 1680 }
1676 1681
1677break_prog: 1682break_prog:
1678 _edje_signal_callback_matches_unref(m); 1683 _edje_signal_callback_matches_unref(m, ed->callbacks->flags, ed->callbacks->custom_data);
1679 1684
1680 _edje_signal_callback_patterns_unref(ssp); 1685 _edje_signal_callback_patterns_unref(ssp);
1681 } 1686 }
diff --git a/src/lib/edje/edje_signal.c b/src/lib/edje/edje_signal.c
index 2f4bab3bd6..e13ec1bcb2 100644
--- a/src/lib/edje/edje_signal.c
+++ b/src/lib/edje/edje_signal.c
@@ -22,7 +22,13 @@ _edje_signal_match_key_cmp(const void *key1, int key1_length EINA_UNUSED, const
22 { 22 {
23 if (a->matches[i].signal != b->matches[i].signal) return a->matches[i].signal - b->matches[i].signal; 23 if (a->matches[i].signal != b->matches[i].signal) return a->matches[i].signal - b->matches[i].signal;
24 if (a->matches[i].source != b->matches[i].source) return a->matches[i].source - b->matches[i].source; 24 if (a->matches[i].source != b->matches[i].source) return a->matches[i].source - b->matches[i].source;
25 if (a->matches[i].func != b->matches[i].func) return (unsigned char *)a->matches[i].func - (unsigned char *)b->matches[i].func; 25 // Callback be it legacy or eo, have the same pointer size and so can be just compared like that
26 if (a->matches[i].legacy != b->matches[i].legacy) return (unsigned char *)a->matches[i].legacy - (unsigned char *)b->matches[i].legacy;
27 if (a->free_cb && b->free_cb &&
28 a->free_cb[i] != b->free_cb[i]) return (unsigned char *)a->free_cb[i] - (unsigned char *)b->free_cb[i];
29 if ((!a->free_cb && b->free_cb) ||
30 (a->free_cb && !b->free_cb))
31 return a->free_cb - b->free_cb;
26 } 32 }
27 return 0; 33 return 0;
28} 34}
@@ -39,11 +45,16 @@ _edje_signal_match_key_hash(const void *key, int key_length EINA_UNUSED)
39#ifdef EFL64 45#ifdef EFL64
40 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].signal, sizeof (char *)); 46 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].signal, sizeof (char *));
41 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].source, sizeof (char *)); 47 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].source, sizeof (char *));
42 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].func, sizeof (Edje_Signal_Cb)); 48 hash ^= eina_hash_int64((const unsigned long long int *)&a->matches[i].legacy, sizeof (Edje_Signal_Cb));
49 if (a->free_cb)
50 hash ^= eina_hash_int64((const unsigned long long int *)&a->free_cb[i], sizeof (Eina_Free_Cb));
43#else 51#else
44 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].signal, sizeof (char *)); 52 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].signal, sizeof (char *));
45 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].source, sizeof (char *)); 53 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].source, sizeof (char *));
46 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].func, sizeof (Edje_Signal_Cb)); 54 // Callback be it legacy or eo, have the same pointer size and so using legacy for hash is enough
55 hash ^= eina_hash_int32((const unsigned int *)&a->matches[i].legacy, sizeof (Edje_Signal_Cb));
56 if (a->free_cb)
57 hash ^= eina_hash_int32((const unsigned int *)&a->free_cb[i], sizeof (Eina_Free_Cb));
47#endif 58#endif
48 } 59 }
49 return hash; 60 return hash;
@@ -64,11 +75,17 @@ _edje_signal_callback_matches_dup(const Edje_Signal_Callback_Matches *src)
64 result->patterns = NULL; 75 result->patterns = NULL;
65 EINA_REFCOUNT_REF(result); 76 EINA_REFCOUNT_REF(result);
66 77
78 if (src->free_cb)
79 {
80 result->free_cb = malloc(sizeof (Eina_Free_Cb) * src->matches_count);
81 if (result->free_cb) memcpy(result->free_cb, src->free_cb, sizeof (Eina_Free_Cb) * src->matches_count);
82 }
83
67 for (i = 0; i < src->matches_count; i++) 84 for (i = 0; i < src->matches_count; i++)
68 { 85 {
69 result->matches[i].signal = eina_stringshare_ref(src->matches[i].signal); 86 result->matches[i].signal = eina_stringshare_ref(src->matches[i].signal);
70 result->matches[i].source = eina_stringshare_ref(src->matches[i].source); 87 result->matches[i].source = eina_stringshare_ref(src->matches[i].source);
71 result->matches[i].func = src->matches[i].func; 88 result->matches[i].legacy = src->matches[i].legacy;
72 } 89 }
73 90
74 return result; 91 return result;
@@ -141,14 +158,23 @@ _edje_signal_callback_unset(Edje_Signal_Callback_Group *gp, int idx)
141static void 158static void
142_edje_signal_callback_set(Edje_Signal_Callback_Group *gp, int idx, 159_edje_signal_callback_set(Edje_Signal_Callback_Group *gp, int idx,
143 const char *sig, const char *src, 160 const char *sig, const char *src,
144 Edje_Signal_Cb func, void *data, Edje_Signal_Callback_Flags flags) 161 Edje_Signal_Cb func_legacy,
162 Efl_Signal_Cb func_eo, Eina_Free_Cb func_free_cb,
163 void *data, Edje_Signal_Callback_Flags flags)
145{ 164{
146 Edje_Signal_Callback_Match *m; 165 Edje_Signal_Callback_Match *m;
147 166
148 m = gp->matches->matches + idx; 167 m = gp->matches->matches + idx;
149 m->signal = eina_stringshare_ref(sig); 168 m->signal = eina_stringshare_ref(sig);
150 m->source = eina_stringshare_ref(src); 169 m->source = eina_stringshare_ref(src);
151 m->func = func; 170 if (func_legacy) m->legacy = func_legacy;
171 else m->eo = func_eo;
172 if (func_free_cb)
173 {
174 if (!gp->matches->free_cb)
175 ((Edje_Signal_Callback_Matches *) gp->matches)->free_cb = calloc(sizeof (Eina_Free_Cb), gp->matches->matches_count);
176 gp->matches->free_cb[idx] = func_free_cb;
177 }
152 178
153 gp->custom_data[idx] = data; 179 gp->custom_data[idx] = data;
154 180
@@ -163,6 +189,11 @@ _edje_signal_callback_grow(Edje_Signal_Callback_Group *gp)
163 tmp = (Edje_Signal_Callback_Matches *)gp->matches; 189 tmp = (Edje_Signal_Callback_Matches *)gp->matches;
164 tmp->matches_count++; 190 tmp->matches_count++;
165 tmp->matches = realloc(tmp->matches, sizeof (Edje_Signal_Callback_Match) * tmp->matches_count); 191 tmp->matches = realloc(tmp->matches, sizeof (Edje_Signal_Callback_Match) * tmp->matches_count);
192 if (tmp->free_cb)
193 {
194 tmp->free_cb = realloc(tmp->free_cb, sizeof (Eina_Free_Cb) * tmp->matches_count);
195 tmp->free_cb[tmp->matches_count - 1] = NULL;
196 }
166 gp->custom_data = realloc(gp->custom_data, sizeof (void *) * tmp->matches_count); 197 gp->custom_data = realloc(gp->custom_data, sizeof (void *) * tmp->matches_count);
167 gp->flags = realloc(gp->flags, sizeof (Edje_Signal_Callback_Flags) * tmp->matches_count); 198 gp->flags = realloc(gp->flags, sizeof (Edje_Signal_Callback_Flags) * tmp->matches_count);
168 199
@@ -172,7 +203,9 @@ _edje_signal_callback_grow(Edje_Signal_Callback_Group *gp)
172Eina_Bool 203Eina_Bool
173_edje_signal_callback_push(Edje_Signal_Callback_Group *gp, 204_edje_signal_callback_push(Edje_Signal_Callback_Group *gp,
174 const char *sig, const char *src, 205 const char *sig, const char *src,
175 Edje_Signal_Cb func, void *data, Eina_Bool propagate) 206 Edje_Signal_Cb func_legacy,
207 Efl_Signal_Cb func_eo, Eina_Free_Cb func_free_cb,
208 void *data, Eina_Bool propagate)
176{ 209{
177 unsigned int i; 210 unsigned int i;
178 Edje_Signal_Callback_Flags flags; 211 Edje_Signal_Callback_Flags flags;
@@ -181,23 +214,11 @@ _edje_signal_callback_push(Edje_Signal_Callback_Group *gp,
181 flags.delete_me = EINA_FALSE; 214 flags.delete_me = EINA_FALSE;
182 flags.just_added = EINA_TRUE; 215 flags.just_added = EINA_TRUE;
183 flags.propagate = !!propagate; 216 flags.propagate = !!propagate;
217 flags.legacy = !!func_legacy;
184 218
219 // FIXME: properly handle legacy and non legacy case, including free function
185 tmp = (Edje_Signal_Callback_Matches *)gp->matches; 220 tmp = (Edje_Signal_Callback_Matches *)gp->matches;
186 221
187 // let's first try to see if we do find an empty matching stop
188 for (i = 0; i < tmp->matches_count; i++)
189 {
190 if ((sig == tmp->matches[i].signal) &&
191 (src == tmp->matches[i].source) &&
192 (func == tmp->matches[i].func) &&
193 (gp->flags[i].delete_me))
194 {
195 _edje_signal_callback_unset(gp, i);
196 _edje_signal_callback_set(gp, i, sig, src, func, data, flags);
197 return EINA_TRUE;
198 }
199 }
200
201 if (tmp->hashed) 222 if (tmp->hashed)
202 { 223 {
203 if (EINA_REFCOUNT_GET(tmp) == 1) 224 if (EINA_REFCOUNT_GET(tmp) == 1)
@@ -224,7 +245,7 @@ _edje_signal_callback_push(Edje_Signal_Callback_Group *gp,
224 if (gp->flags[i].delete_me) 245 if (gp->flags[i].delete_me)
225 { 246 {
226 _edje_signal_callback_unset(gp, i); 247 _edje_signal_callback_unset(gp, i);
227 _edje_signal_callback_set(gp, i, sig, src, func, data, flags); 248 _edje_signal_callback_set(gp, i, sig, src, func_legacy, func_eo, func_free_cb, data, flags);
228 return EINA_TRUE; 249 return EINA_TRUE;
229 } 250 }
230 } 251 }
@@ -232,7 +253,7 @@ _edje_signal_callback_push(Edje_Signal_Callback_Group *gp,
232 _edje_signal_callback_grow(gp); 253 _edje_signal_callback_grow(gp);
233 // Set propagate and just_added flags 254 // Set propagate and just_added flags
234 _edje_signal_callback_set(gp, tmp->matches_count - 1, 255 _edje_signal_callback_set(gp, tmp->matches_count - 1,
235 sig, src, func, data, flags); 256 sig, src, func_legacy, func_eo, func_free_cb, data, flags);
236 257
237 return EINA_TRUE; 258 return EINA_TRUE;
238} 259}
@@ -260,12 +281,24 @@ _edje_signal_callback_alloc(void)
260} 281}
261 282
262void 283void
263_edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m) 284_edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m, Edje_Signal_Callback_Flags *flags, void **custom_data)
264{ 285{
286 unsigned int i;
287
288 if (m->free_cb)
289 {
290 for (i = 0; i < m->matches_count; ++i)
291 {
292 if (!flags[i].delete_me &&
293 m->free_cb[i])
294 {
295 m->free_cb[i](custom_data[i]);
296 }
297 }
298 }
299
265 EINA_REFCOUNT_UNREF(m) 300 EINA_REFCOUNT_UNREF(m)
266 { 301 {
267 unsigned int i;
268
269 _edje_signal_callback_patterns_unref(m->patterns); 302 _edje_signal_callback_patterns_unref(m->patterns);
270 303
271 if (m->hashed) 304 if (m->hashed)
@@ -292,7 +325,7 @@ _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp)
292 325
293 if (!gp) return; 326 if (!gp) return;
294 327
295 _edje_signal_callback_matches_unref((Edje_Signal_Callback_Matches *)gp->matches); 328 _edje_signal_callback_matches_unref((Edje_Signal_Callback_Matches *)gp->matches, gp->flags, gp->custom_data);
296 gp->matches = NULL; 329 gp->matches = NULL;
297 free(gp->flags); 330 free(gp->flags);
298 gp->flags = NULL; 331 gp->flags = NULL;
@@ -304,7 +337,8 @@ _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp)
304Eina_Bool 337Eina_Bool
305_edje_signal_callback_disable(Edje_Signal_Callback_Group *gp, 338_edje_signal_callback_disable(Edje_Signal_Callback_Group *gp,
306 const char *sig, const char *src, 339 const char *sig, const char *src,
307 Edje_Signal_Cb func, void *data) 340 Edje_Signal_Cb func_legacy,
341 EflLayoutSignalCb func, Eina_Free_Cb func_free_cb, void *data)
308{ 342{
309 unsigned int i; 343 unsigned int i;
310 344
@@ -314,10 +348,17 @@ _edje_signal_callback_disable(Edje_Signal_Callback_Group *gp,
314 { 348 {
315 if (sig == gp->matches->matches[i].signal && 349 if (sig == gp->matches->matches[i].signal &&
316 src == gp->matches->matches[i].source && 350 src == gp->matches->matches[i].source &&
317 func == gp->matches->matches[i].func && 351 !gp->flags[i].delete_me &&
318 gp->custom_data[i] == data && 352 ((func == gp->matches->matches[i].eo &&
319 !gp->flags[i].delete_me) 353 (!gp->matches->free_cb || func_free_cb == gp->matches->free_cb[i]) &&
354 gp->custom_data[i] == data &&
355 !gp->flags[i].legacy) ||
356 (func_legacy == gp->matches->matches[i].legacy &&
357 gp->custom_data[i] == data &&
358 gp->flags[i].legacy))
359 )
320 { 360 {
361 if (func && func_free_cb) func_free_cb(data);
321 gp->flags[i].delete_me = EINA_TRUE; 362 gp->flags[i].delete_me = EINA_TRUE;
322 //return gp->custom_data[i]; 363 //return gp->custom_data[i];
323 return EINA_TRUE; 364 return EINA_TRUE;
@@ -341,9 +382,7 @@ _edje_signal_callback_move_last(Edje_Signal_Callback_Group *gp,
341 if (!gp->flags[j].delete_me) 382 if (!gp->flags[j].delete_me)
342 { 383 {
343 _edje_signal_callback_unset(gp, i); 384 _edje_signal_callback_unset(gp, i);
344 m->matches[i].signal = m->matches[j].signal; 385 memcpy(&m->matches[i], &m->matches[j], sizeof (Edje_Signal_Callback_Match));
345 m->matches[i].source = m->matches[j].source;
346 m->matches[i].func = m->matches[j].func;
347 gp->flags[i] = gp->flags[j]; 386 gp->flags[i] = gp->flags[j];
348 gp->custom_data[i] = gp->custom_data[j]; 387 gp->custom_data[i] = gp->custom_data[j];
349 return; 388 return;
@@ -394,7 +433,7 @@ _edje_signal_callback_patterns_ref(const Edje_Signal_Callback_Group *gp)
394 } 433 }
395 else 434 else
396 { 435 {
397 _edje_signal_callback_matches_unref((Edje_Signal_Callback_Matches *)gp->matches); 436 _edje_signal_callback_matches_unref((Edje_Signal_Callback_Matches *)gp->matches, gp->flags, gp->custom_data);
398 ((Edje_Signal_Callback_Group *)gp)->matches = m; 437 ((Edje_Signal_Callback_Group *)gp)->matches = m;
399 tmp = (Edje_Signal_Callback_Matches *)gp->matches; 438 tmp = (Edje_Signal_Callback_Matches *)gp->matches;
400 EINA_REFCOUNT_REF(tmp); 439 EINA_REFCOUNT_REF(tmp);
diff --git a/src/lib/edje/efl_layout_signal.eo b/src/lib/edje/efl_layout_signal.eo
index 708dc3279a..3b4562e596 100644
--- a/src/lib/edje/efl_layout_signal.eo
+++ b/src/lib/edje/efl_layout_signal.eo
@@ -8,7 +8,14 @@
8 match that. 8 match that.
9*/ 9*/
10 10
11type Efl.Signal_Cb: __undefined_type; [[Signal callback.]] 11function EflLayoutSignalCb {
12 [[EflLayoutSignalCb function that is called when a specifc pair of signal/emision is triggered]]
13 params {
14 @in object: Efl.Layout.Signal; [[The object the callback is being triggered from.]]
15 @in emission: string; [[The name component of the signal.]]
16 @in source: string; [[The source of a signal used as context.]]
17 }
18};
12 19
13interface Efl.Layout.Signal 20interface Efl.Layout.Signal
14{ 21{
@@ -83,9 +90,8 @@ interface Efl.Layout.Signal
83 params { 90 params {
84 @in emission: string; [[The signal's "emission" string]] 91 @in emission: string; [[The signal's "emission" string]]
85 @in source: string; [[The signal's "source" string]] 92 @in source: string; [[The signal's "source" string]]
86 @in func: Efl.Signal_Cb; 93 @in func: EflLayoutSignalCb;
87 [[The callback function to be executed when the signal is emitted.]] 94 [[The callback function to be executed when the signal is emitted.]]
88 @in data: void_ptr; [[A pointer to data to pass to $func.]]
89 } 95 }
90 return: bool; [[$true in case of success, $false in case of error.]] 96 return: bool; [[$true in case of success, $false in case of error.]]
91 } 97 }
@@ -102,9 +108,8 @@ interface Efl.Layout.Signal
102 params { 108 params {
103 @in emission: string; [[The signal's "emission" string]] 109 @in emission: string; [[The signal's "emission" string]]
104 @in source: string; [[The signal's "source" string]] 110 @in source: string; [[The signal's "source" string]]
105 @in func: Efl.Signal_Cb; 111 @in func: EflLayoutSignalCb;
106 [[The callback function to be executed when the signal is emitted.]] 112 [[The callback function to be executed when the signal is emitted.]]
107 @in data: void_ptr; [[A pointer to data to pass to $func.]]
108 } 113 }
109 return: bool; [[$true in case of success, $false in case of error.]] 114 return: bool; [[$true in case of success, $false in case of error.]]
110 } 115 }