summaryrefslogtreecommitdiff
path: root/src/bin/eolian/eo1_generator.c
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-07 17:37:05 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-07 17:42:41 +0200
commita78f7794868a2961397a27779fd025f3e7430069 (patch)
tree095348ac62c1ba065be1a21a4933f23a9bcd132a /src/bin/eolian/eo1_generator.c
parentbb8af681f96f13c4e12b9f1762dfaacc5cc4b01c (diff)
Eolian: Fixes into generated files.
- Added Doxygen description to parameters and return - Added default description for parameters - Return type needs to be after all the other parameters - Better handling of stars for pointers: try to figure if a space is needed between the type and the variable (e.g int *a / int a)
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/eo1_generator.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index 8ce195c2e4..af1e4ecb27 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -106,7 +106,7 @@ tmpl_eo_funcdef[] = "\n\
106"; 106";
107 107
108static const char 108static const char
109tmpl_eo_pardesc[] =" * @param[%s] %s\n"; 109tmpl_eo_pardesc[] =" * @param[%s] %s %s\n";
110 110
111static const char 111static const char
112tmpl_eobind_body[] ="\ 112tmpl_eobind_body[] ="\
@@ -148,7 +148,7 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
148 _template_fill(str_func, tmpl_eo_funcdef, classname, funcname, EINA_TRUE); 148 _template_fill(str_func, tmpl_eo_funcdef, classname, funcname, EINA_TRUE);
149 149
150 Eina_Strbuf *linedesc = eina_strbuf_new(); 150 Eina_Strbuf *linedesc = eina_strbuf_new();
151 eina_strbuf_append(linedesc, funcdesc ? funcdesc : ""); 151 eina_strbuf_append(linedesc, funcdesc ? funcdesc : "No description supplied.");
152 if (eina_strbuf_length_get(linedesc)) 152 if (eina_strbuf_length_get(linedesc))
153 { 153 {
154 eina_strbuf_replace_all(linedesc, "\n", "\n * "); 154 eina_strbuf_replace_all(linedesc, "\n", "\n * ");
@@ -167,21 +167,14 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
167 Eina_Strbuf *str_pardesc = eina_strbuf_new(); 167 Eina_Strbuf *str_pardesc = eina_strbuf_new();
168 Eina_Strbuf *str_typecheck = eina_strbuf_new(); 168 Eina_Strbuf *str_typecheck = eina_strbuf_new();
169 169
170 const char* rettype = eolian_function_return_type_get(func, ftype);
171 if (rettype && strcmp(rettype, "void"))
172 {
173 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "out", "ret");
174 eina_strbuf_append(str_par, "ret");
175 eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s*, ret)", rettype);
176 }
177
178 EINA_LIST_FOREACH(eolian_property_keys_list_get(func), l, data) 170 EINA_LIST_FOREACH(eolian_property_keys_list_get(func), l, data)
179 { 171 {
180 const char *pname; 172 const char *pname;
181 const char *ptype; 173 const char *ptype;
182 eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, NULL); 174 const char *pdesc = NULL;
175 eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, &pdesc);
183 176
184 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "in", pname); 177 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "in", pname, pdesc?pdesc:"No description supplied.");
185 178
186 if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", "); 179 if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", ");
187 eina_strbuf_append(str_par, pname); 180 eina_strbuf_append(str_par, pname);
@@ -193,20 +186,35 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
193 { 186 {
194 const char *pname; 187 const char *pname;
195 const char *ptype; 188 const char *ptype;
189 const char *pdesc;
190 Eina_Bool add_star = EINA_FALSE;
196 Eolian_Parameter_Dir pdir; 191 Eolian_Parameter_Dir pdir;
197 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL); 192 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc);
198 if (ftype == GET) pdir = EOLIAN_OUT_PARAM; 193 if (ftype == GET) {
194 add_star = EINA_TRUE;
195 pdir = EOLIAN_OUT_PARAM;
196 }
199 if (ftype == SET) pdir = EOLIAN_IN_PARAM; 197 if (ftype == SET) pdir = EOLIAN_IN_PARAM;
200 char *umpr = (pdir == EOLIAN_IN_PARAM) ? "" : "*"; 198 Eina_Bool had_star = !!strchr(ptype, '*');
201 199
202 const char *dir_str = str_dir[(int)pdir]; 200 const char *dir_str = str_dir[(int)pdir];
203 201
204 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, dir_str, pname); 202 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, dir_str, pname, pdesc?pdesc:"No description supplied.");
205 203
206 if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", "); 204 if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", ");
207 eina_strbuf_append(str_par, pname); 205 eina_strbuf_append(str_par, pname);
208 206
209 eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s, %s)", ptype, umpr, pname); 207 eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s%s, %s)", ptype, had_star?"":" ", add_star?"*":"", pname);
208 }
209
210 const char* rettype = eolian_function_return_type_get(func, ftype);
211 if (rettype && strcmp(rettype, "void"))
212 {
213 const char *ret_desc = eolian_function_return_comment_get(func, ftype);
214 eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "out", "ret", ret_desc);
215 eina_strbuf_append(str_par, ", ret");
216 Eina_Bool had_star = !!strchr(rettype, '*');
217 eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s*, ret)", rettype, had_star?"":" ");
210 } 218 }
211 219
212 eina_strbuf_replace_all(str_func, "@#list_param", eina_strbuf_string_get(str_par)); 220 eina_strbuf_replace_all(str_func, "@#list_param", eina_strbuf_string_get(str_par));
@@ -319,11 +327,11 @@ Eina_Bool
319eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, const char *impl_name) 327eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, const char *impl_name)
320{ 328{
321 const char *suffix = ""; 329 const char *suffix = "";
322 const char *umpr = NULL;
323 Eina_Bool var_as_ret = EINA_FALSE; 330 Eina_Bool var_as_ret = EINA_FALSE;
324 const char *rettype = NULL; 331 const char *rettype = NULL;
325 const char *retname = NULL; 332 const char *retname = NULL;
326 Eina_Bool ret_const = EINA_FALSE; 333 Eina_Bool ret_const = EINA_FALSE;
334 Eina_Bool add_star = EINA_FALSE;
327 335
328 if (eolian_function_is_virtual_pure(funcid)) return EINA_TRUE; 336 if (eolian_function_is_virtual_pure(funcid)) return EINA_TRUE;
329 Eina_Strbuf *fbody = eina_strbuf_new(); 337 Eina_Strbuf *fbody = eina_strbuf_new();
@@ -337,7 +345,7 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
337 if (ftype == GET) 345 if (ftype == GET)
338 { 346 {
339 suffix = "_get"; 347 suffix = "_get";
340 umpr = "*"; 348 add_star = EINA_TRUE;
341 if (!rettype) 349 if (!rettype)
342 { 350 {
343 const Eina_List *l = eolian_parameters_list_get(funcid); 351 const Eina_List *l = eolian_parameters_list_get(funcid);
@@ -353,7 +361,6 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
353 if (ftype == SET) 361 if (ftype == SET)
354 { 362 {
355 suffix = "_set"; 363 suffix = "_set";
356 umpr = "";
357 } 364 }
358 365
359 char tmpstr[0xFF]; 366 char tmpstr[0xFF];
@@ -387,25 +394,26 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
387 const char *ptype; 394 const char *ptype;
388 Eolian_Parameter_Dir pdir; 395 Eolian_Parameter_Dir pdir;
389 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL); 396 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL);
390 const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : " *" );
391 Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data); 397 Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data);
392 eina_strbuf_append_printf(va_args, " %s%s %s%s = va_arg(*list, %s%s%s);\n", 398 Eina_Bool had_star = !!strchr(ptype, '*');
393 ftype == GET && is_const?"const ":"", ptype, ptrstr, pname, 399 eina_strbuf_append_printf(va_args, " %s%s%s%s%s = va_arg(*list, %s%s%s%s);\n",
394 ftype == GET && is_const?"const ":"", (*ptrstr) ? ptype : _varg_upgr(ptype), ptrstr); 400 ftype == GET && is_const?"const ":"", ptype, had_star?"":" ", add_star?"*":"", pname,
401 ftype == GET && is_const?"const ":"", add_star ? ptype : _varg_upgr(ptype), !had_star && add_star?" ":"", add_star?"*":"");
395 eina_strbuf_append_printf(params, ", %s", pname); 402 eina_strbuf_append_printf(params, ", %s", pname);
396 eina_strbuf_append_printf(full_params, ", %s%s%s %s", 403 eina_strbuf_append_printf(full_params, ", %s%s%s%s%s",
397 ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"", 404 ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
398 ptype, ptrstr, pname); 405 ptype, had_star?"":" ", add_star?"*":"", pname);
399 } 406 }
400 } 407 }
401 408
402 if (rettype && strcmp(rettype, "void")) 409 if (rettype && strcmp(rettype, "void"))
403 { 410 {
404 eina_strbuf_append_printf(va_args, " %s%s *%s = va_arg(*list, %s%s *);\n", 411 Eina_Bool had_star = !!strchr(rettype, '*');
412 eina_strbuf_append_printf(va_args, " %s%s%s*%s = va_arg(*list, %s%s%s*);\n",
405 ret_const?"const ":"", 413 ret_const?"const ":"",
406 rettype, retname, 414 rettype, had_star?"":" ", retname,
407 ret_const?"const ":"", 415 ret_const?"const ":"",
408 rettype); 416 rettype, had_star?"":" ");
409 Eina_Strbuf *ret_param = eina_strbuf_new(); 417 Eina_Strbuf *ret_param = eina_strbuf_new();
410 eina_strbuf_append_printf(ret_param, "*%s = ", retname); 418 eina_strbuf_append_printf(ret_param, "*%s = ", retname);
411 eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param)); 419 eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param));