summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-09-25 14:58:53 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-09-25 14:58:53 +0100
commita1552fe6a9f8fc07929a68dafc0413c5338bcd61 (patch)
treedc99ea5d04e06acb11a8f869e37b0826ab57fbf4
parent88843b73776b8351c5c92606f56027595422b9ef (diff)
eolian: new API: eolian_event_c_name_get
-rw-r--r--src/bin/eolian/eo_generator.c17
-rw-r--r--src/lib/eolian/Eolian.h12
-rw-r--r--src/lib/eolian/database_event_api.c12
-rw-r--r--src/lib/eolian/eo_parser.c1
-rw-r--r--src/lib/eolian/eolian_database.h1
5 files changed, 36 insertions, 7 deletions
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index 84ae94ff20..e1a7bfe1a7 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -265,7 +265,7 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
265 itr = eolian_class_events_get(class); 265 itr = eolian_class_events_get(class);
266 EINA_ITERATOR_FOREACH(itr, event) 266 EINA_ITERATOR_FOREACH(itr, event)
267 { 267 {
268 const char *evname = eolian_event_name_get(event); 268 const char *evname = eolian_event_c_name_get(event);
269 const char *evdesc = eolian_event_description_get(event); 269 const char *evdesc = eolian_event_description_get(event);
270 Eolian_Object_Scope scope = eolian_event_scope_get(event); 270 Eolian_Object_Scope scope = eolian_event_scope_get(event);
271 271
@@ -288,7 +288,8 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
288 eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf)); 288 eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf));
289 289
290 eina_strbuf_reset(tmpbuf); 290 eina_strbuf_reset(tmpbuf);
291 eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname); 291 eina_strbuf_append(tmpbuf, evname);
292 eina_stringshare_del(evname);
292 eina_strbuf_replace_all(tmpbuf, ",", "_"); 293 eina_strbuf_replace_all(tmpbuf, ",", "_");
293 char* s = (char *)eina_strbuf_string_get(tmpbuf); 294 char* s = (char *)eina_strbuf_string_get(tmpbuf);
294 eina_str_toupper(&s); 295 eina_str_toupper(&s);
@@ -667,21 +668,22 @@ eo_source_beginning_generate(const Eolian_Class *class, Eina_Strbuf *buf)
667 itr = eolian_class_events_get(class); 668 itr = eolian_class_events_get(class);
668 EINA_ITERATOR_FOREACH(itr, event) 669 EINA_ITERATOR_FOREACH(itr, event)
669 { 670 {
670 const char *evname = eolian_event_name_get(event); 671 const char *evname = eolian_event_c_name_get(event);
671 const char *evdesc = eolian_event_description_get(event); 672 const char *evdesc = eolian_event_description_get(event);
672 char *evdesc_line1; 673 char *evdesc_line1;
673 char *p; 674 char *p;
674 675
675 eina_strbuf_reset(str_ev); 676 eina_strbuf_reset(str_ev);
676 evdesc_line1 = _source_desc_get(evdesc); 677 evdesc_line1 = _source_desc_get(evdesc);
677 eina_strbuf_append_printf(str_ev, "%s_EVENT_%s", class_env.upper_classname, evname); 678 eina_strbuf_append(str_ev, evname);
679 eina_stringshare_del(evname);
678 p = (char *)eina_strbuf_string_get(str_ev); 680 p = (char *)eina_strbuf_string_get(str_ev);
679 eina_str_toupper(&p); 681 eina_str_toupper(&p);
680 eina_strbuf_replace_all(str_ev, ",", "_"); 682 eina_strbuf_replace_all(str_ev, ",", "_");
681 683
682 eina_strbuf_append_printf(tmpbuf, 684 eina_strbuf_append_printf(tmpbuf,
683 "EOAPI const Eo_Event_Description _%s =\n EO_EVENT_DESCRIPTION(\"%s\", \"%s\");\n", 685 "EOAPI const Eo_Event_Description _%s =\n EO_EVENT_DESCRIPTION(\"%s\", \"%s\");\n",
684 eina_strbuf_string_get(str_ev), evname, evdesc_line1); 686 eina_strbuf_string_get(str_ev), eolian_event_name_get(event), evdesc_line1);
685 free(evdesc_line1); 687 free(evdesc_line1);
686 } 688 }
687 eina_iterator_free(itr); 689 eina_iterator_free(itr);
@@ -878,11 +880,12 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
878 itr = eolian_class_events_get(class); 880 itr = eolian_class_events_get(class);
879 EINA_ITERATOR_FOREACH(itr, event) 881 EINA_ITERATOR_FOREACH(itr, event)
880 { 882 {
881 const char *evname = eolian_event_name_get(event); 883 const char *evname = eolian_event_c_name_get(event);
882 char *p; 884 char *p;
883 885
884 eina_strbuf_reset(tmpbuf); 886 eina_strbuf_reset(tmpbuf);
885 eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname); 887 eina_strbuf_append(tmpbuf, evname);
888 eina_stringshare_del(evname);
886 p = (char *)eina_strbuf_string_get(tmpbuf); 889 p = (char *)eina_strbuf_string_get(tmpbuf);
887 eina_str_toupper(&p); 890 eina_str_toupper(&p);
888 eina_strbuf_replace_all(tmpbuf, ",", "_"); 891 eina_strbuf_replace_all(tmpbuf, ",", "_");
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index b9ce307c82..33310710b0 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1211,6 +1211,18 @@ EAPI Eina_Stringshare *eolian_event_description_get(const Eolian_Event *event);
1211EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event); 1211EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
1212 1212
1213/* 1213/*
1214 * @brief Returns the C name of an event
1215 *
1216 * @param[in] event the event handle
1217 * @return the event C name
1218 *
1219 * You're responsible for deleting the stringshare.
1220 *
1221 * @ingroup Eolian
1222 */
1223EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event);
1224
1225/*
1214 * @brief Indicates if the class constructor has to invoke 1226 * @brief Indicates if the class constructor has to invoke
1215 * a non-generated class constructor function. 1227 * a non-generated class constructor function.
1216 * 1228 *
diff --git a/src/lib/eolian/database_event_api.c b/src/lib/eolian/database_event_api.c
index 71a44ff5e4..9aa597ac36 100644
--- a/src/lib/eolian/database_event_api.c
+++ b/src/lib/eolian/database_event_api.c
@@ -32,3 +32,15 @@ eolian_event_scope_get(const Eolian_Event *event)
32 EINA_SAFETY_ON_NULL_RETURN_VAL(event, EOLIAN_SCOPE_PUBLIC); 32 EINA_SAFETY_ON_NULL_RETURN_VAL(event, EOLIAN_SCOPE_PUBLIC);
33 return event->scope; 33 return event->scope;
34} 34}
35
36EAPI Eina_Stringshare *
37eolian_event_c_name_get(const Eolian_Event *event)
38{
39 char buf[512];
40 char *tmp = buf;
41 snprintf(buf, sizeof(buf), "%s_EVENT_%s", event->klass->full_name,
42 event->name);
43 eina_str_toupper(&tmp);
44 while ((tmp = strchr(tmp, '.'))) *tmp = '_';
45 return eina_stringshare_add(buf);
46}
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 0fc9457ed5..70f7dc1a4c 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1699,6 +1699,7 @@ parse_event(Eo_Lexer *ls)
1699 ev->comment = eina_stringshare_ref(ls->t.value.s); 1699 ev->comment = eina_stringshare_ref(ls->t.value.s);
1700 eo_lexer_get(ls); 1700 eo_lexer_get(ls);
1701 } 1701 }
1702 ev->klass = ls->tmp.kls;
1702} 1703}
1703 1704
1704static void 1705static void
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index c9433b8207..393fee61d2 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -188,6 +188,7 @@ struct _Eolian_Event
188 Eina_Stringshare *name; 188 Eina_Stringshare *name;
189 Eina_Stringshare *comment; 189 Eina_Stringshare *comment;
190 Eolian_Type *type; 190 Eolian_Type *type;
191 Eolian_Class *klass;
191 int scope; 192 int scope;
192}; 193};
193 194