summaryrefslogtreecommitdiff
path: root/src/bin/eolian
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-08-07 15:49:03 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-08-07 16:06:22 +0300
commit99888ceaec4641113eeb5be9678a27dc6202b66b (patch)
tree54c2ca8dfb3abe26e465ce2efff2b36a713c4554 /src/bin/eolian
parentba7ea64d9749edfa3080597e51db0cda31e830fe (diff)
Eolian/Generator: fix generation of class functions.
The generation for legacy was missing. The patch removes too the EINA_UNUSED flag for static functions data.
Diffstat (limited to 'src/bin/eolian')
-rw-r--r--src/bin/eolian/eo_generator.c2
-rw-r--r--src/bin/eolian/legacy_generator.c46
2 files changed, 35 insertions, 13 deletions
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index 65690d192d..2d5f7deb73 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -494,8 +494,6 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
494 if (need_implementation) 494 if (need_implementation)
495 { 495 {
496 Eina_Bool is_cf = eolian_function_is_class(funcid); 496 Eina_Bool is_cf = eolian_function_is_class(funcid);
497 if (is_cf)
498 eina_strbuf_append(full_params, " EINA_UNUSED");
499 eina_strbuf_replace_all(fbody, "@#full_params", eina_strbuf_string_get(full_params)); 497 eina_strbuf_replace_all(fbody, "@#full_params", eina_strbuf_string_get(full_params));
500 const char *data_type = eolian_class_data_type_get(class); 498 const char *data_type = eolian_class_data_type_get(class);
501 if (is_cf || (data_type && !strcmp(data_type, "null"))) 499 if (is_cf || (data_type && !strcmp(data_type, "null")))
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index db4f64e20e..52303a525a 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -16,7 +16,7 @@ tmpl_eapi_funcdef[] = "\n\
16 *\n\ 16 *\n\
17@#list_desc_param\ 17@#list_desc_param\
18 */\n\ 18 */\n\
19EAPI @#type_return%s(@#is_constEo *obj@#params)@#flags;\n\ 19EAPI @#type_return%s(@#params)@#flags;\n\
20"; 20";
21 21
22/*@#CLASS_CHECK(obj) @#check_ret;\n\*/ 22/*@#CLASS_CHECK(obj) @#check_ret;\n\*/
@@ -24,18 +24,18 @@ static const char
24tmpl_eapi_body[] ="\ 24tmpl_eapi_body[] ="\
25\n\ 25\n\
26EAPI @#ret_type\n\ 26EAPI @#ret_type\n\
27@#eapi_func(@#is_constEo *obj@#full_params)\n\ 27@#eapi_func(@#full_params)\n\
28{\n\ 28{\n\
29 return eo_do((Eo *) obj, @#eo_func(@#eo_params));\n\ 29 return eo_do(@#eo_obj, @#eo_func(@#eo_params));\n\
30}\n\ 30}\n\
31"; 31";
32static const char 32static const char
33tmpl_eapi_body_void[] ="\ 33tmpl_eapi_body_void[] ="\
34\n\ 34\n\
35EAPI void\n\ 35EAPI void\n\
36@#eapi_func(@#is_constEo *obj@#full_params)\n\ 36@#eapi_func(@#full_params)\n\
37{\n\ 37{\n\
38 eo_do((Eo *) obj, @#eo_func(@#eo_params));\n\ 38 eo_do(@#eo_obj, @#eo_func(@#eo_params));\n\
39}\n\ 39}\n\
40"; 40";
41 41
@@ -85,6 +85,12 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
85 if (func_env.legacy_func[0] == '\0') goto end; 85 if (func_env.legacy_func[0] == '\0') goto end;
86 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func); 86 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func);
87 87
88 if (!eolian_function_is_class(funcid))
89 {
90 if (ftype == EOLIAN_PROP_GET || eolian_function_object_is_const(funcid))
91 eina_strbuf_append(fparam, "const ");
92 eina_strbuf_append(fparam, "Eo *obj");
93 }
88 sprintf (tmpstr, "comment%s", suffix); 94 sprintf (tmpstr, "comment%s", suffix);
89 const char *desc = eolian_function_description_get(funcid, tmpstr); 95 const char *desc = eolian_function_description_get(funcid, tmpstr);
90 Eina_Strbuf *linedesc = eina_strbuf_new(); 96 Eina_Strbuf *linedesc = eina_strbuf_new();
@@ -113,7 +119,8 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
113 eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, &pdesc); 119 eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, &pdesc);
114 ptype = eolian_type_c_type_get(ptypet); 120 ptype = eolian_type_c_type_get(ptypet);
115 leg_param_idx++; 121 leg_param_idx++;
116 eina_strbuf_append_printf(fparam, ", %s%s %s", 122 if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
123 eina_strbuf_append_printf(fparam, "%s%s %s",
117 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const":"", 124 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const":"",
118 ptype, pname); 125 ptype, pname);
119 eina_stringshare_del(ptype); 126 eina_stringshare_del(ptype);
@@ -148,7 +155,8 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
148 if (ftype == EOLIAN_PROP_GET) pdir = EOLIAN_OUT_PARAM; 155 if (ftype == EOLIAN_PROP_GET) pdir = EOLIAN_OUT_PARAM;
149 if (ftype == EOLIAN_PROP_SET) pdir = EOLIAN_IN_PARAM; 156 if (ftype == EOLIAN_PROP_SET) pdir = EOLIAN_IN_PARAM;
150 leg_param_idx++; 157 leg_param_idx++;
151 eina_strbuf_append_printf(fparam, ", %s%s%s%s%s", 158 if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
159 eina_strbuf_append_printf(fparam, "%s%s%s%s%s",
152 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"", 160 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"",
153 ptype, had_star?"":" ", add_star?"*":"", pname); 161 ptype, had_star?"":" ", add_star?"*":"", pname);
154 eina_stringshare_del(ptype); 162 eina_stringshare_del(ptype);
@@ -167,6 +175,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
167 } 175 }
168 eina_iterator_free(itr); 176 eina_iterator_free(itr);
169 } 177 }
178 if (!eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, "void");
170 if (flags) eina_strbuf_append_printf(flags, ")"); 179 if (flags) eina_strbuf_append_printf(flags, ")");
171 180
172 if (rettypet) rettype = eolian_type_c_type_get(rettypet); 181 if (rettypet) rettype = eolian_type_c_type_get(rettypet);
@@ -179,7 +188,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
179 rettype ? rettype : "void", 188 rettype ? rettype : "void",
180 rettype && strchr(rettype, '*')?"":" "); 189 rettype && strchr(rettype, '*')?"":" ");
181 eina_strbuf_replace_all(fbody, "@#type_return", eina_strbuf_string_get(fparam)); 190 eina_strbuf_replace_all(fbody, "@#type_return", eina_strbuf_string_get(fparam));
182 eina_strbuf_replace_all(fbody, "@#is_const", (ftype == EOLIAN_PROP_GET || eolian_function_object_is_const(funcid)) ? "const " : "");
183 if (eolian_function_return_is_warn_unused(funcid, ftype)) 191 if (eolian_function_return_is_warn_unused(funcid, ftype))
184 { 192 {
185 Eina_Bool no_nonull = !flags; 193 Eina_Bool no_nonull = !flags;
@@ -251,6 +259,20 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
251 else 259 else
252 eina_strbuf_append(fbody, tmpl_eapi_body_void); 260 eina_strbuf_append(fbody, tmpl_eapi_body_void);
253 261
262 if (!eolian_function_is_class(funcid))
263 {
264 if (ftype == EOLIAN_PROP_GET || eolian_function_object_is_const(funcid))
265 eina_strbuf_append(fparam, "const ");
266 eina_strbuf_append(fparam, "Eo *obj");
267 eina_strbuf_replace_all(fbody, "@#eo_obj", "(Eo *)obj");
268 }
269 else
270 {
271 Eina_Strbuf *class_buf = eina_strbuf_new();
272 _template_fill(class_buf, "@#CLASS_@#CLASSTYPE", class, NULL, NULL, EINA_TRUE);
273 eina_strbuf_replace_all(fbody, "@#eo_obj", eina_strbuf_string_get(class_buf));
274 eina_strbuf_free(class_buf);
275 }
254 eina_strbuf_replace_all(fbody, "@#eapi_func", func_env.legacy_func); 276 eina_strbuf_replace_all(fbody, "@#eapi_func", func_env.legacy_func);
255 eina_strbuf_replace_all(fbody, "@#eo_func", func_env.lower_eo_func); 277 eina_strbuf_replace_all(fbody, "@#eo_func", func_env.lower_eo_func);
256 278
@@ -264,7 +286,8 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
264 const char *ptype; 286 const char *ptype;
265 eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, NULL); 287 eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, NULL);
266 ptype = eolian_type_c_type_get(ptypet); 288 ptype = eolian_type_c_type_get(ptypet);
267 eina_strbuf_append_printf(fparam, ", %s%s %s", 289 if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
290 eina_strbuf_append_printf(fparam, "%s%s %s",
268 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"", 291 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"",
269 ptype, pname); 292 ptype, pname);
270 eina_stringshare_del(ptype); 293 eina_stringshare_del(ptype);
@@ -285,7 +308,8 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
285 ptype = eolian_type_c_type_get(ptypet); 308 ptype = eolian_type_c_type_get(ptypet);
286 Eina_Bool had_star = !!strchr(ptype, '*'); 309 Eina_Bool had_star = !!strchr(ptype, '*');
287 if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM); 310 if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
288 eina_strbuf_append_printf(fparam, ", %s%s%s%s%s", 311 if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
312 eina_strbuf_append_printf(fparam, "%s%s%s%s%s",
289 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"", 313 eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET)?"const ":"",
290 ptype, had_star?"":" ", add_star?"*":"", pname); 314 ptype, had_star?"":" ", add_star?"*":"", pname);
291 eina_stringshare_del(ptype); 315 eina_stringshare_del(ptype);
@@ -294,6 +318,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
294 } 318 }
295 eina_iterator_free(itr); 319 eina_iterator_free(itr);
296 } 320 }
321 if (!eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, "void");
297 322
298 if (rettype && (!ret_is_void)) 323 if (rettype && (!ret_is_void))
299 { 324 {
@@ -323,7 +348,6 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
323 eina_strbuf_replace_all(fbody, "@#eo_params", eina_strbuf_string_get(eoparam)); 348 eina_strbuf_replace_all(fbody, "@#eo_params", eina_strbuf_string_get(eoparam));
324 349
325 eina_strbuf_replace_all(fbody, "@#ret_val", (rettype && !ret_is_void) ? retname : ""); 350 eina_strbuf_replace_all(fbody, "@#ret_val", (rettype && !ret_is_void) ? retname : "");
326 eina_strbuf_replace_all(fbody, "@#is_const", (ftype == EOLIAN_PROP_GET || eolian_function_object_is_const(funcid)) ? "const " : "");
327 351
328 eina_strbuf_append(buf, eina_strbuf_string_get(fbody)); 352 eina_strbuf_append(buf, eina_strbuf_string_get(fbody));
329 353