Eo events: Change event callback signature.

Change the Eo event callback signature to what suggested by Marcel
Hollerbach in the ML (Thread: EFL interface change - Animator).

This changes the signature of callbacks from
Eina_Bool cb(void *data, Eo *obj const Eo_Event_Description *desc, void *event_info)
to
Eina_Bool cb(void *data, const Eo_Event *event)

Where Eo_Event is a structure that holds these parameters.

This makes it less annoying to not use parameters (you end up using
EINA_UNUSED less), and allows for future extensions to callback
parameters.

@feature
This commit is contained in:
Tom Hacohen 2016-02-29 09:12:35 +00:00
parent 409f45478b
commit 56ea371dfb
3 changed files with 16 additions and 8 deletions

View File

@ -153,7 +153,7 @@ enum _Eo_Op_Type
typedef enum _Eo_Op_Type Eo_Op_Type; typedef enum _Eo_Op_Type Eo_Op_Type;
/** XXX: Hack until fixed in Eolian */ /** XXX: Hack until fixed in Eolian */
typedef struct _Eo_Event_Description Eo_Event_Description2; typedef struct _Eo_Event Eo_Event2;
/** /**
* @typedef Eo_Event_Cb * @typedef Eo_Event_Cb
* *
@ -165,7 +165,7 @@ typedef struct _Eo_Event_Description Eo_Event_Description2;
* @param event_info additional data passed with the event. * @param event_info additional data passed with the event.
* @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue. * @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue.
*/ */
typedef Eina_Bool (*Eo_Event_Cb)(void *data, Eo *obj, const Eo_Event_Description2 *desc, void *event_info); typedef Eina_Bool (*Eo_Event_Cb)(void *data, const Eo_Event2 *event);
#include "eo_base.eo.h" #include "eo_base.eo.h"
#define EO_CLASS EO_BASE_CLASS #define EO_CLASS EO_BASE_CLASS

View File

@ -34,6 +34,13 @@ type Eo.Callback_Priority: short; [[Callback priority value. Range is -32k - 32k
\@ref EO_CALLBACK_PRIORITY_DEFAULT \@ref EO_CALLBACK_PRIORITY_DEFAULT
]] ]]
struct Eo.Event {
[[Parameter passed in event callbacks holding extra event parameters]]
obj: Eo.Base *; [[The object the event was called on.]]
desc: const(Eo.Event_Description) *; [[The event description.]]
event_info: void *; [[Extra event information passed by the event caller.]]
}
abstract Eo.Base () abstract Eo.Base ()
{ {
eo_prefix: eo; eo_prefix: eo;

View File

@ -676,6 +676,10 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
{ {
Eina_Bool ret = EINA_TRUE; Eina_Bool ret = EINA_TRUE;
Eo_Callback_Description *cb; Eo_Callback_Description *cb;
Eo_Event ev;
ev.obj = obj_id;
ev.desc = desc;
ev.event_info = event_info;
pd->walking_list++; pd->walking_list++;
@ -696,8 +700,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
continue; continue;
/* Abort callback calling if the func says so. */ /* Abort callback calling if the func says so. */
if (!it->func((void *) cb->func_data, obj_id, desc, if (!it->func((void *) cb->func_data, &ev))
(void *) event_info))
{ {
ret = EINA_FALSE; ret = EINA_FALSE;
goto end; goto end;
@ -713,8 +716,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
continue; continue;
/* Abort callback calling if the func says so. */ /* Abort callback calling if the func says so. */
if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, if (!cb->items.item.func((void *) cb->func_data, &ev))
(void *) event_info))
{ {
ret = EINA_FALSE; ret = EINA_FALSE;
goto end; goto end;
@ -731,9 +733,8 @@ end:
} }
static Eina_Bool static Eina_Bool
_eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) _eo_event_forwarder_callback(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc, void *event_info)
{ {
(void) obj;
Eo *new_obj = (Eo *) data; Eo *new_obj = (Eo *) data;
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;