Eolian/Generator: fix generation for return values.
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Tue, 11 Mar 2014 13:17:12 +0000 (15:17 +0200)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Tue, 11 Mar 2014 13:43:46 +0000 (15:43 +0200)
- 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.

src/bin/eolian/eo1_generator.c
src/bin/eolian/legacy_generator.c

index 0b02d5b..7ca7628 100644 (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);
index f7b2363..301886e 100644 (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);
      }