efl_loop: remove message_handler_get
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 21 Feb 2019 17:56:00 +0000 (18:56 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:35 +0000 (20:49 +0900)
it appears that this could be emulated with other functions. Plus the
function had the limitation, that no constructors could be used.

ref T7597

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7985

src/lib/ecore/ecore_event_message_handler.c
src/lib/ecore/ecore_events.c
src/lib/ecore/ecore_private.h
src/lib/ecore/efl_loop.c
src/lib/ecore/efl_loop.eo

index 0e9e17e..1513a14 100644 (file)
@@ -86,10 +86,12 @@ _ecore_event_filters_call(Eo *obj, Efl_Loop_Data *pd)
 {
    Filter *f;
    Ecore_Event_Message_Handler_Data *eemhd;
-   Eo *ecore_event_handler = efl_loop_message_handler_get
-     (obj, ECORE_EVENT_MESSAGE_HANDLER_CLASS);
-
+   Eo *ecore_event_handler = efl_provider_find(obj, ECORE_EVENT_MESSAGE_HANDLER_CLASS);
+   /* If this is not != NULL, then _ecore_event_init was not called yet, which means,
+      there cannot be any registered events yet
+    */
    if (!ecore_event_handler) return;
+
    eemhd = efl_data_scope_get(ecore_event_handler, MY_CLASS);
    if (!eemhd) return;
    if (!eemhd->filters) return;
index c85b69d..6d368a0 100644 (file)
@@ -247,9 +247,9 @@ _ecore_event_init(void)
    const char *choice = getenv("EINA_MEMPOOL");
    if ((!choice) || (!choice[0])) choice = "chained_mempool";
 
-   _event_msg_handler =
-     efl_loop_message_handler_get(_mainloop_singleton,
-                                  ECORE_EVENT_MESSAGE_HANDLER_CLASS);
+   _event_msg_handler = efl_add(ECORE_EVENT_MESSAGE_HANDLER_CLASS, _mainloop_singleton);
+   efl_loop_register(_mainloop_singleton, ECORE_EVENT_MESSAGE_HANDLER_CLASS, _event_msg_handler);
+
    if (!_event_msg_handler)
      {
         ERR("Cannot create legacy ecore event message handler");
index 808721e..7783613 100644 (file)
@@ -94,15 +94,8 @@ typedef struct _Efl_Loop_Data Efl_Loop_Data;
 typedef struct _Efl_Task_Data Efl_Task_Data;
 typedef struct _Efl_Appthread_Data Efl_Appthread_Data;
 
-typedef struct _Message_Handler Message_Handler;
 typedef struct _Message Message;
 
-struct _Message_Handler
-{
-   Eo       *handler;
-   const Eo *klass;
-};
-
 struct _Message
 {
    EINA_INLIST;
@@ -149,7 +142,6 @@ struct _Efl_Loop_Data
    Eina_List           *win32_handlers_to_delete;
 # endif
 
-   Eina_Inarray        *message_handlers;
    Eina_Inlist         *message_queue;
    unsigned int         message_walking;
 
index d49d01a..9b36b5b 100644 (file)
@@ -30,24 +30,6 @@ struct _Efl_Loop_Promise_Simple_Data
 };
 GENERIC_ALLOC_SIZE_DECLARE(Efl_Loop_Promise_Simple_Data);
 
-EOLIAN static Efl_Loop_Message_Handler *
-_efl_loop_message_handler_get(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, const Efl_Class *klass)
-{
-   Message_Handler mh = { 0 }, *mh2;
-   unsigned int i, n;
-
-   n = eina_inarray_count(pd->message_handlers);
-   for (i = 0; i < n; i++)
-     {
-        mh2 = eina_inarray_nth(pd->message_handlers, i);
-        if (mh2->klass == klass) return mh2->handler;
-     }
-   mh.klass = klass;
-   mh.handler = efl_add(klass, obj);
-   eina_inarray_push(pd->message_handlers, &mh);
-   return mh.handler;
-}
-
 Eo            *_mainloop_singleton = NULL;
 Efl_Loop_Data *_mainloop_singleton_data = NULL;
 
@@ -305,11 +287,11 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
 
    pd->loop_time = ecore_time_get();
    pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
-   pd->message_handlers = eina_inarray_new(sizeof(Message_Handler), 32);
    pd->epoll_fd = -1;
    pd->timer_fd = -1;
-   pd->future_message_handler = efl_loop_message_handler_get
-     (obj, EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS);
+   pd->future_message_handler = efl_add(EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, obj);
+   efl_loop_register(obj, EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, pd->future_message_handler);
+
    return obj;
 }
 
@@ -328,12 +310,6 @@ _efl_loop_efl_object_invalidate(Eo *obj, Efl_Loop_Data *pd)
    pd->poll_medium = NULL;
    pd->poll_high = NULL;
 
-   if (pd->message_handlers)
-     {
-        eina_inarray_free(pd->message_handlers);
-        pd->message_handlers = NULL;
-     }
-
    // After invalidate, it won't be possible to parent to the singleton anymore
    if (obj == _mainloop_singleton)
      {
index 4d08a6a..e8cadb5 100644 (file)
@@ -113,16 +113,6 @@ abstract @beta Efl.Loop extends Efl.Task
          }
          return: bool; [[$true if successfully unregistered, $false otherwise.]]
       }
-      message_handler_get {
-         [[Get a message handler object that is created by and owned by
-           the Efl.Loop object, so you can listen to this message type by
-           listening to message events on the handler as well as send
-           objects as events.]]
-         params {
-            @in klass: const(Efl.Class); [[The class of the message object.]]
-         }
-         return: Efl.Loop_Message_Handler; [[The message handler to use.]]
-      }
    }
    events {
       idle,enter @restart: void; [[Event occurs once the main loop enters the idle state.]]