summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-02-29 09:12:35 +0000
committerTom Hacohen <tom@stosb.com>2016-02-29 11:33:24 +0000
commit56ea371dfb064c28906c7d8344b0c0e03c1d3d4d (patch)
tree8752b68e7813915f2671c82c516acf3638cc6c32
parent409f45478be1143d843f5f9efe8bacb537677ed3 (diff)
downloadefl-56ea371dfb064c28906c7d8344b0c0e03c1d3d4d.tar.gz
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
-rw-r--r--src/lib/eo/Eo.h4
-rw-r--r--src/lib/eo/eo_base.eo7
-rw-r--r--src/lib/eo/eo_base_class.c13
3 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 4580722d7d..cfabd74c9a 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -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
diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo
index 7695208174..29a1531bc9 100644
--- a/src/lib/eo/eo_base.eo
+++ b/src/lib/eo/eo_base.eo
@@ -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;
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 64c6df343f..948a0b0d41 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -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;