Eolian: Add API to retrieve an event of a class by its name
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Tue, 28 Apr 2015 11:27:01 +0000 (14:27 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Thu, 7 May 2015 06:57:15 +0000 (09:57 +0300)
@feature

src/lib/eolian/Eolian.h
src/lib/eolian/database_event_api.c
src/tests/eolian/eolian_parsing.c

index d231782c8125c021aa41294625cfdeb49ab23929..d8c5e90965ca1a4a741b2cf9e737295a08e17017 100644 (file)
@@ -1328,6 +1328,17 @@ EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
  */
 EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event);
 
+/*
+ * @brief Get an event in a class by its name
+ *
+ * @param[in] klass the class
+ * @param[in] event_name name of the event
+ * @return the Eolian_Event if found, NULL otherwise.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Event *eolian_class_event_get_by_name(const Eolian_Class *klass, const char *event_name);
+
 /*
  * @brief Indicates if the class constructor has to invoke
  * a non-generated class constructor function.
index f2c98a713325b7b508558f10dea2a14c5a92b8b2..0a6b22dcff03a3d50de8da099f2202c7be5db643 100644 (file)
@@ -44,3 +44,23 @@ eolian_event_c_name_get(const Eolian_Event *event)
     while ((tmp = strpbrk(tmp, ".,"))) *tmp = '_';
     return eina_stringshare_add(buf);
 }
+
+EAPI const Eolian_Event *
+eolian_class_event_get_by_name(const Eolian_Class *klass, const char *event_name)
+{
+   Eina_List *itr;
+   Eolian_Event *event = NULL;
+   if (!klass) return NULL;
+   Eina_Stringshare *shr_ev = eina_stringshare_add(event_name);
+
+   EINA_LIST_FOREACH(klass->events, itr, event)
+        {
+           if (event->name == shr_ev)
+              goto end;
+        }
+
+   event = NULL;
+end:
+   eina_stringshare_del(shr_ev);
+   return event;
+}
index f61434635c15163a867a28b02131feeac79e368b..8269c2c68e4b85d3c19dafa378233297c0ce7b6d 100644 (file)
@@ -129,6 +129,9 @@ START_TEST(eolian_events)
    fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
    fail_if(eina_iterator_next(iter, &dummy));
    eina_iterator_free(iter);
+   /* Check eolian_class_event_get_by_name */
+   fail_if(!eolian_class_event_get_by_name(class, "clicked,double"));
+   fail_if(eolian_class_event_get_by_name(class, "clicked,triple"));
 
    eolian_shutdown();
 }