Eo events: Change event callback signature.
authorTom Hacohen <tom@stosb.com>
Mon, 29 Feb 2016 09:12:35 +0000 (09:12 +0000)
committerTom Hacohen <tom@stosb.com>
Mon, 29 Feb 2016 11:33:24 +0000 (11:33 +0000)
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

src/lib/eo/Eo.h
src/lib/eo/eo_base.eo
src/lib/eo/eo_base_class.c

index 4580722..cfabd74 100644 (file)
@@ -153,7 +153,7 @@ enum _Eo_Op_Type
 typedef enum _Eo_Op_Type Eo_Op_Type;
 
 /** XXX: Hack until fixed in Eolian */
-typedef struct _Eo_Event_Description Eo_Event_Description2;
+typedef struct _Eo_Event Eo_Event2;
 /**
  * @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.
  * @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"
 #define EO_CLASS EO_BASE_CLASS
index 7695208..29a1531 100644 (file)
@@ -34,6 +34,13 @@ type Eo.Callback_Priority: short; [[Callback priority value. Range is -32k - 32k
                                     \@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 ()
 {
    eo_prefix: eo;
index 64c6df3..948a0b0 100644 (file)
@@ -676,6 +676,10 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
 {
    Eina_Bool ret = EINA_TRUE;
    Eo_Callback_Description *cb;
+   Eo_Event ev;
+   ev.obj = obj_id;
+   ev.desc = desc;
+   ev.event_info = event_info;
 
    pd->walking_list++;
 
@@ -696,8 +700,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
                           continue;
 
                        /* Abort callback calling if the func says so. */
-                       if (!it->func((void *) cb->func_data, obj_id, desc,
-                                (void *) event_info))
+                       if (!it->func((void *) cb->func_data, &ev))
                          {
                             ret = EINA_FALSE;
                             goto end;
@@ -713,8 +716,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
                     continue;
 
                   /* Abort callback calling if the func says so. */
-                  if (!cb->items.item.func((void *) cb->func_data, obj_id, desc,
-                                           (void *) event_info))
+                  if (!cb->items.item.func((void *) cb->func_data, &ev))
                     {
                        ret = EINA_FALSE;
                        goto end;
@@ -731,9 +733,8 @@ end:
 }
 
 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;
    Eina_Bool ret = EINA_FALSE;