summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2015-04-28 14:27:01 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-05-07 09:57:15 +0300
commit2c5ec0b132222131306514d578b6f604c00b61b1 (patch)
tree668628039bfc294e38544c9840431990a079b264
parent7c2d0453757fd6fc712f5dcef70f33daa2871fb3 (diff)
Eolian: Add API to retrieve an event of a class by its name
@feature
-rw-r--r--src/lib/eolian/Eolian.h11
-rw-r--r--src/lib/eolian/database_event_api.c20
-rw-r--r--src/tests/eolian/eolian_parsing.c3
3 files changed, 34 insertions, 0 deletions
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
@@ -1329,6 +1329,17 @@ EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
1329EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event); 1329EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event);
1330 1330
1331/* 1331/*
1332 * @brief Get an event in a class by its name
1333 *
1334 * @param[in] klass the class
1335 * @param[in] event_name name of the event
1336 * @return the Eolian_Event if found, NULL otherwise.
1337 *
1338 * @ingroup Eolian
1339 */
1340EAPI const Eolian_Event *eolian_class_event_get_by_name(const Eolian_Class *klass, const char *event_name);
1341
1342/*
1332 * @brief Indicates if the class constructor has to invoke 1343 * @brief Indicates if the class constructor has to invoke
1333 * a non-generated class constructor function. 1344 * a non-generated class constructor function.
1334 * 1345 *
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)
44 while ((tmp = strpbrk(tmp, ".,"))) *tmp = '_'; 44 while ((tmp = strpbrk(tmp, ".,"))) *tmp = '_';
45 return eina_stringshare_add(buf); 45 return eina_stringshare_add(buf);
46} 46}
47
48EAPI const Eolian_Event *
49eolian_class_event_get_by_name(const Eolian_Class *klass, const char *event_name)
50{
51 Eina_List *itr;
52 Eolian_Event *event = NULL;
53 if (!klass) return NULL;
54 Eina_Stringshare *shr_ev = eina_stringshare_add(event_name);
55
56 EINA_LIST_FOREACH(klass->events, itr, event)
57 {
58 if (event->name == shr_ev)
59 goto end;
60 }
61
62 event = NULL;
63end:
64 eina_stringshare_del(shr_ev);
65 return event;
66}
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)
129 fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info")); 129 fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
130 fail_if(eina_iterator_next(iter, &dummy)); 130 fail_if(eina_iterator_next(iter, &dummy));
131 eina_iterator_free(iter); 131 eina_iterator_free(iter);
132 /* Check eolian_class_event_get_by_name */
133 fail_if(!eolian_class_event_get_by_name(class, "clicked,double"));
134 fail_if(eolian_class_event_get_by_name(class, "clicked,triple"));
132 135
133 eolian_shutdown(); 136 eolian_shutdown();
134} 137}