aboutsummaryrefslogtreecommitdiffstats
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
parentefreet: TODO++ (diff)
downloadefl-a1552fe6a9f8fc07929a68dafc0413c5338bcd61.tar.gz
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)
itr = eolian_class_events_get(class);
EINA_ITERATOR_FOREACH(itr, event)
{
- const char *evname = eolian_event_name_get(event);
+ const char *evname = eolian_event_c_name_get(event);
const char *evdesc = eolian_event_description_get(event);
Eolian_Object_Scope scope = eolian_event_scope_get(event);
@@ -288,7 +288,8 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf));
eina_strbuf_reset(tmpbuf);
- eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname);
+ eina_strbuf_append(tmpbuf, evname);
+ eina_stringshare_del(evname);
eina_strbuf_replace_all(tmpbuf, ",", "_");
char* s = (char *)eina_strbuf_string_get(tmpbuf);
eina_str_toupper(&s);
@@ -667,21 +668,22 @@ eo_source_beginning_generate(const Eolian_Class *class, Eina_Strbuf *buf)
itr = eolian_class_events_get(class);
EINA_ITERATOR_FOREACH(itr, event)
{
- const char *evname = eolian_event_name_get(event);
+ const char *evname = eolian_event_c_name_get(event);
const char *evdesc = eolian_event_description_get(event);
char *evdesc_line1;
char *p;
eina_strbuf_reset(str_ev);
evdesc_line1 = _source_desc_get(evdesc);
- eina_strbuf_append_printf(str_ev, "%s_EVENT_%s", class_env.upper_classname, evname);
+ eina_strbuf_append(str_ev, evname);
+ eina_stringshare_del(evname);
p = (char *)eina_strbuf_string_get(str_ev);
eina_str_toupper(&p);
eina_strbuf_replace_all(str_ev, ",", "_");
eina_strbuf_append_printf(tmpbuf,
"EOAPI const Eo_Event_Description _%s =\n EO_EVENT_DESCRIPTION(\"%s\", \"%s\");\n",
- eina_strbuf_string_get(str_ev), evname, evdesc_line1);
+ eina_strbuf_string_get(str_ev), eolian_event_name_get(event), evdesc_line1);
free(evdesc_line1);
}
eina_iterator_free(itr);
@@ -878,11 +880,12 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
itr = eolian_class_events_get(class);
EINA_ITERATOR_FOREACH(itr, event)
{
- const char *evname = eolian_event_name_get(event);
+ const char *evname = eolian_event_c_name_get(event);
char *p;
eina_strbuf_reset(tmpbuf);
- eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname);
+ eina_strbuf_append(tmpbuf, evname);
+ eina_stringshare_del(evname);
p = (char *)eina_strbuf_string_get(tmpbuf);
eina_str_toupper(&p);
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);
EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
/*
+ * @brief Returns the C name of an event
+ *
+ * @param[in] event the event handle
+ * @return the event C name
+ *
+ * You're responsible for deleting the stringshare.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event);
+
+/*
* @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 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)
EINA_SAFETY_ON_NULL_RETURN_VAL(event, EOLIAN_SCOPE_PUBLIC);
return event->scope;
}
+
+EAPI Eina_Stringshare *
+eolian_event_c_name_get(const Eolian_Event *event)
+{
+ char buf[512];
+ char *tmp = buf;
+ snprintf(buf, sizeof(buf), "%s_EVENT_%s", event->klass->full_name,
+ event->name);
+ eina_str_toupper(&tmp);
+ while ((tmp = strchr(tmp, '.'))) *tmp = '_';
+ return eina_stringshare_add(buf);
+}
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)
ev->comment = eina_stringshare_ref(ls->t.value.s);
eo_lexer_get(ls);
}
+ ev->klass = ls->tmp.kls;
}
static 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
Eina_Stringshare *name;
Eina_Stringshare *comment;
Eolian_Type *type;
+ Eolian_Class *klass;
int scope;
};