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.
This commit is contained in:
Daniel Zaoui 2014-03-27 09:17:05 +02:00
parent b1dc908681
commit eb65cac12d
2 changed files with 8 additions and 8 deletions

View File

@ -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));

View File

@ -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)