Eolian/Generator: fix generation for return values.

- Remove space between type and variable if a star is present.
- Initialize return value to NULL before eo_do. It is needed in case the
eo_do invocation fails (NULL object...).
- Add const to the internal return value if needed.
This commit is contained in:
Daniel Zaoui 2014-03-11 15:17:12 +02:00
parent d3f343bdcc
commit fd67c1692c
2 changed files with 4 additions and 2 deletions

View File

@ -431,7 +431,7 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
ret_const?"const ":"",
rettype, had_star?"":" ");
Eina_Strbuf *ret_param = eina_strbuf_new();
if (rettype) eina_strbuf_append_printf(ret_param, "%s _%s = ", rettype, retname);
if (rettype) eina_strbuf_append_printf(ret_param, "%s%s%s_%s = ", ret_const?"const ":"", rettype, had_star?"":" ", retname);
eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param));
sprintf(tmpstr, "%s%s", ret_const?"const ":"", rettype);
eina_strbuf_replace_all(fbody, "@#ret_type", tmpstr);

View File

@ -298,7 +298,9 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
{
if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
Eina_Bool had_star = !!strchr(rettype, '*');
sprintf (tmpstr, " %s%s%s%s;\n", ret_const?"const ":"", rettype, had_star?"":" ", retname);
sprintf (tmpstr, " %s%s%s%s%s;\n",
ret_const?"const ":"", rettype, had_star?"":" ", retname,
had_star?" = NULL":"");
eina_strbuf_append_printf(eoparam, "&%s", retname);
}