From: Daniel Zaoui Date: Tue, 28 Apr 2015 11:27:01 +0000 (+0300) Subject: Eolian: Add API to retrieve an event of a class by its name X-Git-Tag: v1.15.0-alpha1~740 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c5ec0b132222131306514d578b6f604c00b61b1;p=platform%2Fupstream%2Fefl.git Eolian: Add API to retrieve an event of a class by its name @feature --- diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index d231782c81..d8c5e90965 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -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. diff --git a/src/lib/eolian/database_event_api.c b/src/lib/eolian/database_event_api.c index f2c98a7133..0a6b22dcff 100644 --- a/src/lib/eolian/database_event_api.c +++ b/src/lib/eolian/database_event_api.c @@ -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; +} diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index f61434635c..8269c2c68e 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -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(); }