jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=eb65cac12d55ae5fe843c7cd055e08882929aca3

commit eb65cac12d55ae5fe843c7cd055e08882929aca3
Author: Daniel Zaoui <[email protected]>
Date:   Thu Mar 27 09:17:05 2014 +0200

    Eolian/Generator: enable forcing return type as void.
    
    For get properties, if only one parameter is given, the generator sets this 
one as return type.
    
    There are cases where this parameter must stay a parameter (legacy API).
    
    For example, elm_thumb_compress_get must be like:
    void elm_thumb_compress_get(const Eo *obj, int *compress).
    Eolian was generating the function as:
    int elm_thumb_compress_get(const Eo *obj);
    
    By setting "return void;" in the .eo file, you force the function to
    return void.
---
 src/bin/eolian/legacy_generator.c | 12 +++++++-----
 src/lib/eolian/eolian_database.c  |  4 +---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/bin/eolian/legacy_generator.c 
b/src/bin/eolian/legacy_generator.c
index 00464ed..99ed371 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -40,9 +40,10 @@ _eapi_decl_func_generate(const char *classname, 
Eolian_Function funcid, Eolian_F
    const char *func_lpref = NULL;
    Eina_Bool var_as_ret = EINA_FALSE;
    Eina_Bool add_star = EINA_FALSE;
+   Eina_Bool ret_is_void = EINA_FALSE;
 
    rettype = eolian_function_return_type_get(funcid, ftype);
-   if (rettype && !strcmp(rettype, "void")) rettype = NULL;
+   if (rettype && !strcmp(rettype, "void")) ret_is_void = EINA_TRUE;
    if (ftype == GET)
      {
         suffix = "_get";
@@ -158,7 +159,7 @@ _eapi_decl_func_generate(const char *classname, 
Eolian_Function funcid, Eolian_F
      }
    if (flags) eina_strbuf_append_printf(flags, ")");
 
-   if (rettype && strcmp(rettype, "void"))
+   if (rettype && !ret_is_void)
      {
         const char *pdesc = eolian_function_return_comment_get(funcid, ftype);
         eina_strbuf_append_printf(descparam, " * @param[out] ret %s\n", 
pdesc?pdesc:"No description supplied.");
@@ -201,13 +202,14 @@ _eapi_func_generate(const char *classname, 
Eolian_Function funcid, Eolian_Functi
    const char *retname = NULL;
    Eina_Bool ret_const = EINA_FALSE;
    Eina_Bool add_star = EINA_FALSE;
+   Eina_Bool ret_is_void = EINA_FALSE;
 
    Eina_Strbuf *fbody = eina_strbuf_new();
    Eina_Strbuf *fparam = eina_strbuf_new();
    Eina_Strbuf *eoparam = eina_strbuf_new();
 
    rettype = eolian_function_return_type_get(funcid, ftype);
-   if (rettype && !strcmp(rettype, "void")) rettype = NULL;
+   if (rettype && !strcmp(rettype, "void")) ret_is_void = EINA_TRUE;
    retname = "ret";
    if (ftype == GET)
      {
@@ -293,7 +295,7 @@ _eapi_func_generate(const char *classname, Eolian_Function 
funcid, Eolian_Functi
 
    char tmp_ret_str[0xFF];
    sprintf (tmp_ret_str, "%s%s", ret_const?"const ":"", 
rettype?rettype:"void");
-   if (rettype && strcmp(rettype, "void"))
+   if (rettype && !ret_is_void)
      {
         if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
         Eina_Bool had_star = !!strchr(rettype, '*');
@@ -309,7 +311,7 @@ _eapi_func_generate(const char *classname, Eolian_Function 
funcid, Eolian_Functi
    eina_strbuf_replace_all(fbody, "@#eo_params", 
eina_strbuf_string_get(eoparam));
    eina_strbuf_replace_all(fbody, "@#ret_type", tmp_ret_str);
    eina_strbuf_replace_all(fbody, "@#ret_init_val", tmpstr);
-   eina_strbuf_replace_all(fbody, "@#ret_val", (rettype) ? retname : "");
+   eina_strbuf_replace_all(fbody, "@#ret_val", (rettype && !ret_is_void) ? 
retname : "");
    eina_strbuf_replace_all(fbody, "@#is_const", (ftype == GET || 
eolian_function_object_is_const(funcid)) ? "const " : "");
 
    eina_strbuf_append(buf, eina_strbuf_string_get(fbody));
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 90a073f..c24533d 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -861,9 +861,7 @@ eolian_function_return_type_get(Eolian_Function foo_id, 
Eolian_Function_Type fty
       case UNRESOLVED: case METHOD_FUNC: key = EOLIAN_METHOD_RETURN_TYPE; 
break;
       default: return NULL;
      }
-   const char *ret = eolian_function_data_get(foo_id, key);
-   if (!ret) ret = "void";
-   return ret;
+   return eolian_function_data_get(foo_id, key);
 }
 
 void database_function_return_dflt_val_set(Eolian_Function foo_id, 
Eolian_Function_Type ftype, const char *ret_dflt_value)

-- 


Reply via email to