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)
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
Diffstat (limited to '')
-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
153typedef enum _Eo_Op_Type Eo_Op_Type; 153typedef enum _Eo_Op_Type Eo_Op_Type;
154 154
155/** XXX: Hack until fixed in Eolian */ 155/** XXX: Hack until fixed in Eolian */
156typedef struct _Eo_Event_Description Eo_Event_Description2; 156typedef struct _Eo_Event Eo_Event2;
157/** 157/**
158 * @typedef Eo_Event_Cb 158 * @typedef Eo_Event_Cb
159 * 159 *
@@ -165,7 +165,7 @@ typedef struct _Eo_Event_Description Eo_Event_Description2;
165 * @param event_info additional data passed with the event. 165 * @param event_info additional data passed with the event.
166 * @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue. 166 * @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue.
167 */ 167 */
168typedef Eina_Bool (*Eo_Event_Cb)(void *data, Eo *obj, const Eo_Event_Description2 *desc, void *event_info); 168typedef Eina_Bool (*Eo_Event_Cb)(void *data, const Eo_Event2 *event);
169 169
170#include "eo_base.eo.h" 170#include "eo_base.eo.h"
171#define EO_CLASS EO_BASE_CLASS 171#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
34 \@ref EO_CALLBACK_PRIORITY_DEFAULT 34 \@ref EO_CALLBACK_PRIORITY_DEFAULT
35 ]] 35 ]]
36 36
37struct Eo.Event {
38 [[Parameter passed in event callbacks holding extra event parameters]]
39 obj: Eo.Base *; [[The object the event was called on.]]
40 desc: const(Eo.Event_Description) *; [[The event description.]]
41 event_info: void *; [[Extra event information passed by the event caller.]]
42}
43
37abstract Eo.Base () 44abstract Eo.Base ()
38{ 45{
39 eo_prefix: eo; 46 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,
676{ 676{
677 Eina_Bool ret = EINA_TRUE; 677 Eina_Bool ret = EINA_TRUE;
678 Eo_Callback_Description *cb; 678 Eo_Callback_Description *cb;
679 Eo_Event ev;
680 ev.obj = obj_id;
681 ev.desc = desc;
682 ev.event_info = event_info;
679 683
680 pd->walking_list++; 684 pd->walking_list++;
681 685
@@ -696,8 +700,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
696 continue; 700 continue;
697 701
698 /* Abort callback calling if the func says so. */ 702 /* Abort callback calling if the func says so. */
699 if (!it->func((void *) cb->func_data, obj_id, desc, 703 if (!it->func((void *) cb->func_data, &ev))
700 (void *) event_info))
701 { 704 {
702 ret = EINA_FALSE; 705 ret = EINA_FALSE;
703 goto end; 706 goto end;
@@ -713,8 +716,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
713 continue; 716 continue;
714 717
715 /* Abort callback calling if the func says so. */ 718 /* Abort callback calling if the func says so. */
716 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, 719 if (!cb->items.item.func((void *) cb->func_data, &ev))
717 (void *) event_info))
718 { 720 {
719 ret = EINA_FALSE; 721 ret = EINA_FALSE;
720 goto end; 722 goto end;
@@ -731,9 +733,8 @@ end:
731} 733}
732 734
733static Eina_Bool 735static Eina_Bool
734_eo_event_forwarder_callback(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) 736_eo_event_forwarder_callback(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc, void *event_info)
735{ 737{
736 (void) obj;
737 Eo *new_obj = (Eo *) data; 738 Eo *new_obj = (Eo *) data;
738 Eina_Bool ret = EINA_FALSE; 739 Eina_Bool ret = EINA_FALSE;
739 740