summaryrefslogtreecommitdiff
path: root/src/lib/eo
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-04-20 18:24:38 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-04-20 18:24:38 +0200
commitb780cf2af299ce17be260486bb7ab64badddbaec (patch)
tree8f612033b3936259cc4e620b0b54ceb1c447963d /src/lib/eo
parentda982535f603688021fdef6caf4681e523791261 (diff)
eo: move unbindable event APIs to C
In a few classes, this requires some manual expansion. This should not break anything but it's also fairly ugly; a better solution would be appreciated, for now we do this. Similar changes will be done to a few other Efl.Object APIs as well at later point.
Diffstat (limited to 'src/lib/eo')
-rw-r--r--src/lib/eo/Eo.h86
-rw-r--r--src/lib/eo/efl_object.eo78
-rw-r--r--src/lib/eo/eo_base_class.c37
3 files changed, 123 insertions, 78 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 178308a8e1..fe67aa0938 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -234,6 +234,92 @@ struct _Efl_Event {
234}; 234};
235 235
236/** 236/**
237 * @brief Add a callback for an event with a specific priority.
238 *
239 * callbacks of the same priority are called in reverse order of creation.
240 *
241 * A callback is only executed on events emitted after this call finished.
242 *
243 * @param[in] desc The description of the event to listen to
244 * @param[in] priority The priority of the callback
245 * @param[in] cb the callback to call
246 * @param[in] data additional data to pass to the callback
247 *
248 * @return Return @c true when the callback has been successfully added.
249 */
250EOAPI Eina_Bool efl_event_callback_priority_add(Eo *obj, const Efl_Event_Description *desc, Efl_Callback_Priority priority, Efl_Event_Cb cb, const void *data);
251
252/**
253 * @brief Delete a callback with a specific data associated to it for an event.
254 *
255 * The callback will never be emitted again after this call, even if a event
256 * emission is going on.
257 *
258 * @param[in] desc The description of the event to listen to
259 * @param[in] func The callback to delete
260 * @param[in] user_data The data to compare
261 *
262 * @return Return @c true when the callback has been successfully removed.
263 */
264EOAPI Eina_Bool efl_event_callback_del(Eo *obj, const Efl_Event_Description *desc, Efl_Event_Cb func, const void *user_data);
265
266/**
267 * @brief Add an array of callbacks created by @ref EFL_CALLBACKS_ARRAY_DEFINE
268 * for an event with a specific priority. The array need to be sorted with @ref
269 * efl_callbacks_cmp if you are not using the @ref EFL_CALLBACKS_ARRAY_DEFINE
270 * macro.
271 *
272 * callbacks of the same priority are called in reverse order of creation.
273 *
274 * A callback from the array is only executed on events emitted after this
275 * call finished.
276 *
277 * @param[in] array An #Efl_Callback_Array_Item of events to listen to
278 * @param[in] priority The priority of the callback
279 * @param[in] data Additional data to pass to the callback
280 *
281 * @return Return @c true when the callback has been successfully added.
282 */
283EOAPI Eina_Bool efl_event_callback_array_priority_add(Eo *obj, const Efl_Callback_Array_Item *array, Efl_Callback_Priority priority, const void *data);
284
285/**
286 * @brief Del a callback array with a specific data associated to it for an
287 * event. The callbacks from the array will never be emitted again after this
288 * call, even if a event emission is going on.
289 *
290 * @param[in] array An #Efl_Callback_Array_Item of events to listen to
291 * @param[in] user_data The data to compare
292 *
293 * @return Return @c true when the callback has been successfully removed.
294 */
295EOAPI Eina_Bool efl_event_callback_array_del(Eo *obj, const Efl_Callback_Array_Item *array, const void *user_data);
296
297/**
298 * @brief Call the callbacks for an event of an object.
299 *
300 * @param[in] desc The description of the event to call
301 * @param[in] event_info Extra event info to pass to the callbacks
302 *
303 * @return @c false if one of the callbacks aborted the call, @c true otherwise
304 */
305EOAPI Eina_Bool efl_event_callback_call(Eo *obj, const Efl_Event_Description *desc, void *event_info);
306
307/**
308 * @brief Call the callbacks for an event of an object.
309 *
310 * Like @ref efl_event_callback_call, but also call legacy smart callbacks that
311 * have the same name of the given event.
312 *
313 * @param[in] desc The description of the event to call
314 * @param[in] event_info Extra event info to pass to the callbacks
315 *
316 * @return @c false if one of the callbacks aborted the call, @c true otherwise
317 *
318 * @since 1.19
319 */
320EOAPI Eina_Bool efl_event_callback_legacy_call(Eo *obj, const Efl_Event_Description *desc, void *event_info);
321
322/**
237 * @addtogroup Eo_Debug_Information Eo's Debug information helper. 323 * @addtogroup Eo_Debug_Information Eo's Debug information helper.
238 * @{ 324 * @{
239 */ 325 */
diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo
index 1d47ebab05..c55ed76e2c 100644
--- a/src/lib/eo/efl_object.eo
+++ b/src/lib/eo/efl_object.eo
@@ -309,84 +309,6 @@ abstract Efl.Object ()
309 Prevents event callbacks from being called for the object. 309 Prevents event callbacks from being called for the object.
310 ]] 310 ]]
311 } 311 }
312 event_callback_priority_add {
313 [[Add a callback for an event with a specific priority.
314
315 callbacks of the same priority are called in reverse order of
316 creation.
317
318 A callback is only executed on events emitted after this call finished.
319 ]]
320 return: bool; [[Return $true when the callback has been successfully added.]]
321 params {
322 @in desc: ptr(const(Efl.Event.Description)); [[The description of the event to listen to]]
323 @in priority: Efl.Callback_Priority; [[The priority of the callback]]
324 @in cb: Efl.Event_Cb; [[the callback to call]]
325 @in data: const(void_ptr); [[additional data to pass to the callback]]
326 }
327 }
328 event_callback_del {
329 [[Delete a callback with a specific data associated to it for an event.
330
331 The callback will never be emitted again after this call, even if a event emission is going on.
332 ]]
333 return: bool; [[Return $true when the callback has been successfully removed.]]
334 params {
335 @in desc: ptr(const(Efl.Event.Description)); [[The description of the event to listen to]]
336 @in func: Efl.Event_Cb; [[The callback to delete]]
337 @in user_data: const(void_ptr); [[The data to compare]]
338 }
339 }
340 event_callback_array_priority_add {
341 [[Add an array of callbacks created by \@ref EFL_CALLBACKS_ARRAY_DEFINE for an event
342 with a specific priority. The array need to be sorted with \@ref efl_callbacks_cmp
343 if you are not using the \@ref EFL_CALLBACKS_ARRAY_DEFINE macro.
344
345 callbacks of the same priority are called in reverse order of
346 creation.
347
348 A callback from the array is only executed on events emitted after this call finished.
349 ]]
350 return: bool; [[Return $true when the callback has been successfully added.]]
351 params {
352 @in array: ptr(const(Efl.Callback_Array_Item)); [[An #Efl_Callback_Array_Item of events to listen to]]
353 @in priority: Efl.Callback_Priority; [[The priority of the callback]]
354 @in data: const(void_ptr); [[Additional data to pass to the callback]]
355 }
356 }
357 event_callback_array_del {
358 [[Del a callback array with a specific data associated to it for an
359 event.
360 The callbacks from the array will never be emitted again after this call, even if a event emission is going on.
361 ]]
362 return: bool; [[Return $true when the callback has been successfully removed.]]
363 params {
364 @in array: ptr(const(Efl.Callback_Array_Item)); [[An #Efl_Callback_Array_Item of events to listen to]]
365 @in user_data: const(void_ptr); [[The data to compare]]
366 }
367 }
368 event_callback_call {
369 [[Call the callbacks for an event of an object.]]
370 params {
371 @in desc: ptr(const(Efl.Event.Description)); [[The description of the event to call]]
372 @in event_info: void_ptr; [[Extra event info to pass to the callbacks]]
373 }
374 return: bool; [[$false if one of the callbacks aborted the call, $true otherwise]]
375 }
376 event_callback_legacy_call {
377 [[Call the callbacks for an event of an object.
378
379 Like @.event_callback_call, but also call legacy smart callbacks
380 that have the same name of the given event.
381
382 @since 1.19
383 ]]
384 params {
385 @in desc: ptr(const(Efl.Event.Description)); [[The description of the event to call]]
386 @in event_info: void_ptr; [[Extra event info to pass to the callbacks]]
387 }
388 return: bool; [[$false if one of the callbacks aborted the call, $true otherwise]]
389 }
390 event_callback_stop { 312 event_callback_stop {
391 [[Stop the current callback call. 313 [[Stop the current callback call.
392 314
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index f8a12c9505..fe3dc289a3 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -1219,6 +1219,12 @@ err:
1219 return EINA_FALSE; 1219 return EINA_FALSE;
1220} 1220}
1221 1221
1222EOAPI EFL_FUNC_BODYV(efl_event_callback_priority_add,
1223 Eina_Bool, 0, EFL_FUNC_CALL(desc, priority, cb, data),
1224 const Efl_Event_Description *desc,
1225 Efl_Callback_Priority priority,
1226 Efl_Event_Cb cb, const void *data);
1227
1222static void 1228static void
1223_efl_object_event_callback_clean(Eo *obj, Efl_Object_Data *pd, 1229_efl_object_event_callback_clean(Eo *obj, Efl_Object_Data *pd,
1224 const Efl_Callback_Array_Item *array, 1230 const Efl_Callback_Array_Item *array,
@@ -1262,6 +1268,11 @@ _efl_object_event_callback_del(Eo *obj, Efl_Object_Data *pd,
1262 return EINA_FALSE; 1268 return EINA_FALSE;
1263} 1269}
1264 1270
1271EOAPI EFL_FUNC_BODYV(efl_event_callback_del,
1272 Eina_Bool, 0, EFL_FUNC_CALL(desc, func, user_data),
1273 const Efl_Event_Description *desc,
1274 Efl_Event_Cb func, const void *user_data);
1275
1265EOLIAN static Eina_Bool 1276EOLIAN static Eina_Bool
1266_efl_object_event_callback_array_priority_add(Eo *obj, Efl_Object_Data *pd, 1277_efl_object_event_callback_array_priority_add(Eo *obj, Efl_Object_Data *pd,
1267 const Efl_Callback_Array_Item *array, 1278 const Efl_Callback_Array_Item *array,
@@ -1314,6 +1325,11 @@ err:
1314 return EINA_FALSE; 1325 return EINA_FALSE;
1315} 1326}
1316 1327
1328EOAPI EFL_FUNC_BODYV(efl_event_callback_array_priority_add,
1329 Eina_Bool, 0, EFL_FUNC_CALL(array, priority, data),
1330 const Efl_Callback_Array_Item *array,
1331 Efl_Callback_Priority priority, const void *data);
1332
1317EOLIAN static Eina_Bool 1333EOLIAN static Eina_Bool
1318_efl_object_event_callback_array_del(Eo *obj, Efl_Object_Data *pd, 1334_efl_object_event_callback_array_del(Eo *obj, Efl_Object_Data *pd,
1319 const Efl_Callback_Array_Item *array, 1335 const Efl_Callback_Array_Item *array,
@@ -1339,6 +1355,11 @@ _efl_object_event_callback_array_del(Eo *obj, Efl_Object_Data *pd,
1339 return EINA_FALSE; 1355 return EINA_FALSE;
1340} 1356}
1341 1357
1358EOAPI EFL_FUNC_BODYV(efl_event_callback_array_del,
1359 Eina_Bool, 0, EFL_FUNC_CALL(array, user_data),
1360 const Efl_Callback_Array_Item *array,
1361 const void *user_data);
1362
1342static Eina_Bool 1363static Eina_Bool
1343_cb_desc_match(const Efl_Event_Description *a, const Efl_Event_Description *b, Eina_Bool legacy_compare) 1364_cb_desc_match(const Efl_Event_Description *a, const Efl_Event_Description *b, Eina_Bool legacy_compare)
1344{ 1365{
@@ -1506,6 +1527,10 @@ _efl_object_event_callback_call(Eo *obj_id, Efl_Object_Data *pd,
1506 return _event_callback_call(obj_id, pd, desc, event_info, EINA_FALSE); 1527 return _event_callback_call(obj_id, pd, desc, event_info, EINA_FALSE);
1507} 1528}
1508 1529
1530EOAPI EFL_FUNC_BODYV(efl_event_callback_call,
1531 Eina_Bool, 0, EFL_FUNC_CALL(desc, event_info),
1532 const Efl_Event_Description *desc, void *event_info);
1533
1509EOLIAN static Eina_Bool 1534EOLIAN static Eina_Bool
1510_efl_object_event_callback_legacy_call(Eo *obj_id, Efl_Object_Data *pd, 1535_efl_object_event_callback_legacy_call(Eo *obj_id, Efl_Object_Data *pd,
1511 const Efl_Event_Description *desc, 1536 const Efl_Event_Description *desc,
@@ -1514,6 +1539,10 @@ _efl_object_event_callback_legacy_call(Eo *obj_id, Efl_Object_Data *pd,
1514 return _event_callback_call(obj_id, pd, desc, event_info, EINA_TRUE); 1539 return _event_callback_call(obj_id, pd, desc, event_info, EINA_TRUE);
1515} 1540}
1516 1541
1542EOAPI EFL_FUNC_BODYV(efl_event_callback_legacy_call,
1543 Eina_Bool, 0, EFL_FUNC_CALL(desc, event_info),
1544 const Efl_Event_Description *desc, void *event_info);
1545
1517EOLIAN static void 1546EOLIAN static void
1518_efl_object_event_callback_stop(Eo *obj EINA_UNUSED, Efl_Object_Data *pd) 1547_efl_object_event_callback_stop(Eo *obj EINA_UNUSED, Efl_Object_Data *pd)
1519{ 1548{
@@ -1933,4 +1962,12 @@ _efl_object_future_link(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, Efl_Future *li
1933 return !!efl_future_then(link, _efl_object_future_link_tracking_end, _efl_object_future_link_tracking_end, NULL, obj); 1962 return !!efl_future_then(link, _efl_object_future_link_tracking_end, _efl_object_future_link_tracking_end, NULL, obj);
1934} 1963}
1935 1964
1965#define EFL_OBJECT_EXTRA_OPS \
1966 EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, _efl_object_event_callback_priority_add), \
1967 EFL_OBJECT_OP_FUNC(efl_event_callback_del, _efl_object_event_callback_del), \
1968 EFL_OBJECT_OP_FUNC(efl_event_callback_array_priority_add, _efl_object_event_callback_array_priority_add), \
1969 EFL_OBJECT_OP_FUNC(efl_event_callback_array_del, _efl_object_event_callback_array_del), \
1970 EFL_OBJECT_OP_FUNC(efl_event_callback_call, _efl_object_event_callback_call), \
1971 EFL_OBJECT_OP_FUNC(efl_event_callback_legacy_call, _efl_object_event_callback_legacy_call)
1972
1936#include "efl_object.eo.c" 1973#include "efl_object.eo.c"