eo: enable priority with event forwarder.
authorCedric BAIL <cedric@osg.samsung.com>
Wed, 12 Dec 2018 22:07:52 +0000 (14:07 -0800)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 3 Jan 2019 09:00:27 +0000 (18:00 +0900)
Note: Their isn't any ability to do something like a static array of
events at the moment. It might lead to large memory being used when it
wouldn't be necessary. If that was the case, we could fix it, but it
would require a lot of dynamic hash operation I think.

Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7482

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

index ca133df..eac6bfe 100644 (file)
@@ -2063,6 +2063,19 @@ EAPI int efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const Efl_Callback_
    efl_event_callback_array_priority_add(obj, array, \
          EFL_CALLBACK_PRIORITY_DEFAULT, data)
 
+
+/**
+ * @def efl_event_callback_forwarder_add(obj, desc, new_obj)
+ * @brief Add an event callback forwarder for an event and an object.
+ *
+ * @param[in] obj The object.
+ * @param[in] desc The description of the event to listen to
+ * @param[in] new_obj The object to emit events from
+ *
+ * @ingroup Efl_Object
+ */
+#define efl_event_callback_forwarder_add(obj, desc, new_obj) efl_event_callback_forwarder_priority_add(obj, desc, EFL_CALLBACK_PRIORITY_DEFAULT, new_obj)
+
 /**
  * @def Replace the previous Eo pointer with new content.
  *
index 7507e01..4bc643d 100644 (file)
@@ -229,18 +229,19 @@ abstract Efl.Object
            under certain conditions to block a certain event.
          ]]
       }
-      event_callback_forwarder_add {
+      event_callback_forwarder_priority_add {
          [[Add an event callback forwarder for an event and an object.]]
          params {
             @cref desc: Efl.Event_Description; [[The description of the event to listen to]]
-            @in new_obj: Efl.Object; [[The object to emit events from]]
+            @in priority: short; [[The priority at which to insert the callback handler.]]
+            @in new_obj: Efl.Object @nonull; [[The object to emit events from]]
          }
       }
       event_callback_forwarder_del {
          [[Remove an event callback forwarder for an event and an object.]]
          params {
             @cref desc: Efl.Event_Description; [[The description of the event to listen to]]
-            @in new_obj: Efl.Object; [[The object to emit events from]]
+            @in new_obj: Efl.Object @nonull; [[The object to emit events from]]
          }
       }
       children_iterator_new {
index 7f57332..ef3a1ba 100644 (file)
@@ -1806,25 +1806,25 @@ _efl_event_forwarder_callback(void *data, const Efl_Event *event)
      }
 }
 
-/* FIXME: Change default priority? Maybe call later? */
 EOLIAN static void
-_efl_object_event_callback_forwarder_add(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
-                     const Efl_Event_Description *desc,
-                     Eo *new_obj)
+_efl_object_event_callback_forwarder_priority_add(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
+                                                  const Efl_Event_Description *desc,
+                                                  short priority,
+                                                  Eo *new_obj)
 {
+   EO_OBJ_POINTER_RETURN(new_obj, new_data);
+   EO_OBJ_DONE(new_obj);
 
-   /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
-
-   efl_event_callback_add(obj, desc, _efl_event_forwarder_callback, new_obj);
+   efl_event_callback_priority_add(obj, desc, priority, _efl_event_forwarder_callback, new_obj);
 }
 
 EOLIAN static void
 _efl_object_event_callback_forwarder_del(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
-                     const Efl_Event_Description *desc,
-                     Eo *new_obj)
+                                         const Efl_Event_Description *desc,
+                                         Eo *new_obj)
 {
-
-   /* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
+   EO_OBJ_POINTER_RETURN(new_obj, new_data);
+   EO_OBJ_DONE(new_obj);
 
    efl_event_callback_del(obj, desc, _efl_event_forwarder_callback, new_obj);
 }