summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-30 13:59:22 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit1fa36d558f03e002b7e9d5b26dd16d18b7689f26 (patch)
tree5cc8ad15b29be20650c1248e471c77dfc9ef7d7e
parentf660f371a2cae925f89df330457d1912a31519f4 (diff)
eolian gen2: sanitize data type properly
-rw-r--r--src/bin/eolian2/sources.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index aa0a596d98..bc6c3bc936 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -34,6 +34,20 @@ _get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
34 return ""; 34 return "";
35} 35}
36 36
37static char *
38_get_data_type(const Eolian_Class *cl)
39{
40 const char *dt = eolian_class_data_type_get(cl);
41 if (!dt)
42 return NULL;
43 char *dtr = strdup(dt);
44 if (!dtr)
45 abort();
46 for (char *p = strchr(dtr, '.'); p; p = strchr(p, '.'))
47 *p = '_';
48 return dtr;
49}
50
37static void 51static void
38_gen_func(const Eolian_Class *cl, const Eolian_Function *fid, 52_gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
39 Eolian_Function_Type ftype, Eina_Strbuf *buf, 53 Eolian_Function_Type ftype, Eina_Strbuf *buf,
@@ -223,14 +237,15 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
223 { 237 {
224 /* figure out the data type */ 238 /* figure out the data type */
225 Eina_Bool is_cf = eolian_function_is_class(fid); 239 Eina_Bool is_cf = eolian_function_is_class(fid);
226 const char *dt = eolian_class_data_type_get(cl); 240 char *dt = _get_data_type(cl);
227 char adt[128]; 241 char adt[128];
228 if (is_cf || (dt && !strcmp(dt, "null"))) 242 if (is_cf || (dt && !strcmp(dt, "null")))
229 snprintf(adt, sizeof(adt), "void"); 243 snprintf(adt, sizeof(adt), "void");
230 else if (dt) 244 else if (dt)
231 snprintf(adt, sizeof(adt), "%s", dt); 245 snprintf(adt, sizeof(adt), "%s", dt);
232 else 246 else
233 snprintf(adt, sizeof(adt), "%s_Data", eolian_class_full_name_get(cl)); 247 snprintf(adt, sizeof(adt), "%s_Data", cname);
248 free(dt);
234 249
235 eina_strbuf_append_char(buf, '\n'); 250 eina_strbuf_append_char(buf, '\n');
236 /* no need for prototype with empty/auto impl */ 251 /* no need for prototype with empty/auto impl */
@@ -654,7 +669,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
654 " EO_VERSION,\n"); 669 " EO_VERSION,\n");
655 eina_strbuf_append_printf(buf, " \"%s\",\n", cname); 670 eina_strbuf_append_printf(buf, " \"%s\",\n", cname);
656 671
657 const char *dt = eolian_class_data_type_get(cl); 672 char *dt = _get_data_type(cl);
658 if (dt && !strcmp(dt, "null")) 673 if (dt && !strcmp(dt, "null"))
659 eina_strbuf_append(buf, " 0,\n"); 674 eina_strbuf_append(buf, " 0,\n");
660 else 675 else
@@ -666,6 +681,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
666 eina_strbuf_append_printf(buf, "%s_Data", cname); 681 eina_strbuf_append_printf(buf, "%s_Data", cname);
667 eina_strbuf_append(buf, "),\n"); 682 eina_strbuf_append(buf, "),\n");
668 } 683 }
684 free(dt);
669 685
670 if (has_init) 686 if (has_init)
671 eina_strbuf_append_printf(buf, " _%s_class_initializer,\n", cnamel); 687 eina_strbuf_append_printf(buf, " _%s_class_initializer,\n", cnamel);