forked from enlightenment/efl
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)
This commit is contained in:
parent
bb8af681f9
commit
a78f779486
|
@ -106,7 +106,7 @@ tmpl_eo_funcdef[] = "\n\
|
|||
";
|
||||
|
||||
static const char
|
||||
tmpl_eo_pardesc[] =" * @param[%s] %s\n";
|
||||
tmpl_eo_pardesc[] =" * @param[%s] %s %s\n";
|
||||
|
||||
static const char
|
||||
tmpl_eobind_body[] ="\
|
||||
|
@ -148,7 +148,7 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
|
|||
_template_fill(str_func, tmpl_eo_funcdef, classname, funcname, EINA_TRUE);
|
||||
|
||||
Eina_Strbuf *linedesc = eina_strbuf_new();
|
||||
eina_strbuf_append(linedesc, funcdesc ? funcdesc : "");
|
||||
eina_strbuf_append(linedesc, funcdesc ? funcdesc : "No description supplied.");
|
||||
if (eina_strbuf_length_get(linedesc))
|
||||
{
|
||||
eina_strbuf_replace_all(linedesc, "\n", "\n * ");
|
||||
|
@ -167,21 +167,14 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
|
|||
Eina_Strbuf *str_pardesc = eina_strbuf_new();
|
||||
Eina_Strbuf *str_typecheck = eina_strbuf_new();
|
||||
|
||||
const char* rettype = eolian_function_return_type_get(func, ftype);
|
||||
if (rettype && strcmp(rettype, "void"))
|
||||
{
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "out", "ret");
|
||||
eina_strbuf_append(str_par, "ret");
|
||||
eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s*, ret)", rettype);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(eolian_property_keys_list_get(func), l, data)
|
||||
{
|
||||
const char *pname;
|
||||
const char *ptype;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, NULL);
|
||||
const char *pdesc = NULL;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, &pdesc);
|
||||
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "in", pname);
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "in", pname, pdesc?pdesc:"No description supplied.");
|
||||
|
||||
if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", ");
|
||||
eina_strbuf_append(str_par, pname);
|
||||
|
@ -193,20 +186,35 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
|
|||
{
|
||||
const char *pname;
|
||||
const char *ptype;
|
||||
const char *pdesc;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eolian_Parameter_Dir pdir;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL);
|
||||
if (ftype == GET) pdir = EOLIAN_OUT_PARAM;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc);
|
||||
if (ftype == GET) {
|
||||
add_star = EINA_TRUE;
|
||||
pdir = EOLIAN_OUT_PARAM;
|
||||
}
|
||||
if (ftype == SET) pdir = EOLIAN_IN_PARAM;
|
||||
char *umpr = (pdir == EOLIAN_IN_PARAM) ? "" : "*";
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
|
||||
const char *dir_str = str_dir[(int)pdir];
|
||||
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, dir_str, pname);
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, dir_str, pname, pdesc?pdesc:"No description supplied.");
|
||||
|
||||
if (eina_strbuf_length_get(str_par)) eina_strbuf_append(str_par, ", ");
|
||||
eina_strbuf_append(str_par, pname);
|
||||
|
||||
eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s, %s)", ptype, umpr, pname);
|
||||
eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s%s, %s)", ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
}
|
||||
|
||||
const char* rettype = eolian_function_return_type_get(func, ftype);
|
||||
if (rettype && strcmp(rettype, "void"))
|
||||
{
|
||||
const char *ret_desc = eolian_function_return_comment_get(func, ftype);
|
||||
eina_strbuf_append_printf(str_pardesc, tmpl_eo_pardesc, "out", "ret", ret_desc);
|
||||
eina_strbuf_append(str_par, ", ret");
|
||||
Eina_Bool had_star = !!strchr(rettype, '*');
|
||||
eina_strbuf_append_printf(str_typecheck, ", EO_TYPECHECK(%s%s*, ret)", rettype, had_star?"":" ");
|
||||
}
|
||||
|
||||
eina_strbuf_replace_all(str_func, "@#list_param", eina_strbuf_string_get(str_par));
|
||||
|
@ -319,11 +327,11 @@ Eina_Bool
|
|||
eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, const char *impl_name)
|
||||
{
|
||||
const char *suffix = "";
|
||||
const char *umpr = NULL;
|
||||
Eina_Bool var_as_ret = EINA_FALSE;
|
||||
const char *rettype = NULL;
|
||||
const char *retname = NULL;
|
||||
Eina_Bool ret_const = EINA_FALSE;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
|
||||
if (eolian_function_is_virtual_pure(funcid)) return EINA_TRUE;
|
||||
Eina_Strbuf *fbody = eina_strbuf_new();
|
||||
|
@ -337,7 +345,7 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
|
|||
if (ftype == GET)
|
||||
{
|
||||
suffix = "_get";
|
||||
umpr = "*";
|
||||
add_star = EINA_TRUE;
|
||||
if (!rettype)
|
||||
{
|
||||
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
|
|||
if (ftype == SET)
|
||||
{
|
||||
suffix = "_set";
|
||||
umpr = "";
|
||||
}
|
||||
|
||||
char tmpstr[0xFF];
|
||||
|
@ -387,25 +394,26 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
|
|||
const char *ptype;
|
||||
Eolian_Parameter_Dir pdir;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL);
|
||||
const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : " *" );
|
||||
Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data);
|
||||
eina_strbuf_append_printf(va_args, " %s%s %s%s = va_arg(*list, %s%s%s);\n",
|
||||
ftype == GET && is_const?"const ":"", ptype, ptrstr, pname,
|
||||
ftype == GET && is_const?"const ":"", (*ptrstr) ? ptype : _varg_upgr(ptype), ptrstr);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
eina_strbuf_append_printf(va_args, " %s%s%s%s%s = va_arg(*list, %s%s%s%s);\n",
|
||||
ftype == GET && is_const?"const ":"", ptype, had_star?"":" ", add_star?"*":"", pname,
|
||||
ftype == GET && is_const?"const ":"", add_star ? ptype : _varg_upgr(ptype), !had_star && add_star?" ":"", add_star?"*":"");
|
||||
eina_strbuf_append_printf(params, ", %s", pname);
|
||||
eina_strbuf_append_printf(full_params, ", %s%s%s %s",
|
||||
eina_strbuf_append_printf(full_params, ", %s%s%s%s%s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
ptype, ptrstr, pname);
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
}
|
||||
}
|
||||
|
||||
if (rettype && strcmp(rettype, "void"))
|
||||
{
|
||||
eina_strbuf_append_printf(va_args, " %s%s *%s = va_arg(*list, %s%s *);\n",
|
||||
Eina_Bool had_star = !!strchr(rettype, '*');
|
||||
eina_strbuf_append_printf(va_args, " %s%s%s*%s = va_arg(*list, %s%s%s*);\n",
|
||||
ret_const?"const ":"",
|
||||
rettype, retname,
|
||||
rettype, had_star?"":" ", retname,
|
||||
ret_const?"const ":"",
|
||||
rettype);
|
||||
rettype, had_star?"":" ");
|
||||
Eina_Strbuf *ret_param = eina_strbuf_new();
|
||||
eina_strbuf_append_printf(ret_param, "*%s = ", retname);
|
||||
eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param));
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
static const char
|
||||
tmpl_eapi_funcdef[] = "\n\
|
||||
/**\n\
|
||||
* @def @#class_@#func\n\
|
||||
*\n\
|
||||
@#desc\n\
|
||||
*\n\
|
||||
@#list_desc_param\
|
||||
*/\n\
|
||||
EAPI @#type_return @#class_@#func(@#is_constEvas_Object *obj@#params);@#flags\n\
|
||||
EAPI @#type_return@#class_@#func(@#is_constEvas_Object *obj@#params);@#flags\n\
|
||||
";
|
||||
|
||||
/*@#CLASS_CHECK(obj) @#check_ret;\n\*/
|
||||
|
@ -36,17 +37,17 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
{
|
||||
//TODO return value
|
||||
const char *suffix = "";
|
||||
const char *umpr = NULL;
|
||||
const char *rettype = NULL;
|
||||
const char *func_lpref = NULL;
|
||||
Eina_Bool var_as_ret = EINA_FALSE;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
|
||||
rettype = eolian_function_return_type_get(funcid, ftype);
|
||||
if (rettype && !strcmp(rettype, "void")) rettype = NULL;
|
||||
if (ftype == GET)
|
||||
{
|
||||
suffix = "_get";
|
||||
umpr = "*";
|
||||
add_star = EINA_TRUE;
|
||||
func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET);
|
||||
if (!rettype)
|
||||
{
|
||||
|
@ -63,7 +64,6 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
if (ftype == SET)
|
||||
{
|
||||
suffix = "_set";
|
||||
umpr = "";
|
||||
func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
|
||||
const char *desc = eolian_function_description_get(funcid, tmpstr);
|
||||
Eina_Strbuf *linedesc = eina_strbuf_new();
|
||||
eina_strbuf_append(linedesc, desc ? desc : "");
|
||||
eina_strbuf_append(linedesc, desc ? desc : "No description supplied.");
|
||||
if (eina_strbuf_length_get(linedesc))
|
||||
{
|
||||
eina_strbuf_replace_all(linedesc, "\n", "\n * ");
|
||||
|
@ -113,7 +113,7 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
eina_strbuf_append_printf(fparam, ", %s%s %s",
|
||||
eolian_parameter_get_const_attribute_get(data)?"const":"",
|
||||
ptype, pname);
|
||||
eina_strbuf_append_printf(descparam, " * @param %s\n", pname);
|
||||
eina_strbuf_append_printf(descparam, " * @param[in] %s %s\n", pname, pdesc?pdesc:"No description supplied.");
|
||||
if (eolian_parameter_is_nonull((Eolian_Function_Parameter)data))
|
||||
{
|
||||
if (!flags)
|
||||
|
@ -133,13 +133,17 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
const char *pdesc;
|
||||
const char *ptype;
|
||||
Eolian_Parameter_Dir pdir;
|
||||
const char *str_dir[] = {"in", "out", "inout"};
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == GET) pdir = EOLIAN_OUT_PARAM;
|
||||
if (ftype == SET) pdir = EOLIAN_IN_PARAM;
|
||||
leg_param_idx++;
|
||||
const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : "*" );
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s %s",
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s%s%s",
|
||||
eolian_parameter_get_const_attribute_get(data)?"const":"",
|
||||
ptype, ptrstr, pname);
|
||||
eina_strbuf_append_printf(descparam, " * @param %s\n", pname);
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
const char *dir_str = str_dir[(int)pdir];
|
||||
eina_strbuf_append_printf(descparam, " * @param[%s] %s %s\n", dir_str, pname, pdesc?pdesc:"No description supplied.");
|
||||
if (eolian_parameter_is_nonull((Eolian_Function_Parameter)data))
|
||||
{
|
||||
if (!flags)
|
||||
|
@ -154,9 +158,19 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
}
|
||||
if (flags) eina_strbuf_append_printf(flags, ")");
|
||||
|
||||
if (rettype && strcmp(rettype, "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.");
|
||||
}
|
||||
|
||||
eina_strbuf_replace_all(fbody, "@#params", eina_strbuf_string_get(fparam));
|
||||
eina_strbuf_replace_all(fbody, "@#list_desc_param", eina_strbuf_string_get(descparam));
|
||||
eina_strbuf_replace_all(fbody, "@#type_return", (rettype) ? rettype : "void");
|
||||
eina_strbuf_reset(fparam);
|
||||
eina_strbuf_append_printf(fparam, "%s%s",
|
||||
rettype ? rettype : "void",
|
||||
rettype && strchr(rettype, '*')?"":" ");
|
||||
eina_strbuf_replace_all(fbody, "@#type_return", eina_strbuf_string_get(fparam));
|
||||
eina_strbuf_replace_all(fbody, "@#is_const", (ftype == GET || eolian_function_object_is_const(funcid)) ? "const " : "");
|
||||
if (eolian_function_return_is_warn_unused(funcid, ftype))
|
||||
{
|
||||
|
@ -180,12 +194,12 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
{
|
||||
//TODO return value
|
||||
const char *suffix = "";
|
||||
const char *umpr = NULL;
|
||||
const char *func_lpref = NULL;
|
||||
Eina_Bool var_as_ret = EINA_FALSE;
|
||||
const char *rettype = NULL;
|
||||
const char *retname = NULL;
|
||||
Eina_Bool ret_const = EINA_FALSE;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
|
||||
rettype = eolian_function_return_type_get(funcid, ftype);
|
||||
if (rettype && !strcmp(rettype, "void")) rettype = NULL;
|
||||
|
@ -193,7 +207,7 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
if (ftype == GET)
|
||||
{
|
||||
suffix = "_get";
|
||||
umpr = "*";
|
||||
add_star = EINA_TRUE;
|
||||
func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET);
|
||||
if (!rettype)
|
||||
{
|
||||
|
@ -210,7 +224,6 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
if (ftype == SET)
|
||||
{
|
||||
suffix = "_set";
|
||||
umpr = "";
|
||||
func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET);
|
||||
}
|
||||
|
||||
|
@ -258,10 +271,10 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
const char *ptype;
|
||||
Eolian_Parameter_Dir pdir;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, NULL);
|
||||
const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : "*" );
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s %s",
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s%s%s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
ptype, ptrstr, pname);
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
|
||||
eina_strbuf_append_printf(eoparam, "%s", pname);
|
||||
}
|
||||
|
@ -272,7 +285,8 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
if (rettype && strcmp(rettype, "void"))
|
||||
{
|
||||
if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
|
||||
sprintf (tmpstr, " %s%s %s;\n", ret_const?"const ":"", rettype, retname);
|
||||
Eina_Bool had_star = !!strchr(rettype, '*');
|
||||
sprintf (tmpstr, " %s%s%s%s;\n", ret_const?"const ":"", rettype, had_star?"":" ", retname);
|
||||
eina_strbuf_append_printf(eoparam, "&%s", retname);
|
||||
}
|
||||
|
||||
|
|
|
@ -433,6 +433,21 @@ EAPI Eina_Bool eolian_parameter_is_nonull(Eolian_Function_Parameter param_desc);
|
|||
*/
|
||||
EAPI const char *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Get the return comment of a function.
|
||||
*
|
||||
* @param[in] function_id id of the function
|
||||
* @param[in] ftype type of the function
|
||||
* @return the return comment of the function
|
||||
*
|
||||
* The type of the function is needed because a given function can represent a
|
||||
* property, that can be set and get functions.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const char *
|
||||
eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Indicates if a function return is warn-unused.
|
||||
*
|
||||
|
|
|
@ -796,6 +796,20 @@ eolian_function_return_type_get(Eolian_Function foo_id, Eolian_Function_Type fty
|
|||
return ret;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||
{
|
||||
const char *key = NULL;
|
||||
switch (ftype)
|
||||
{
|
||||
case SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break;
|
||||
case GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break;
|
||||
case UNRESOLVED: case METHOD_FUNC: key = EOLIAN_RETURN_COMMENT; break;
|
||||
default: return NULL;
|
||||
}
|
||||
return eolian_function_data_get(foo_id, key);
|
||||
}
|
||||
|
||||
void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,
|
||||
Eolian_Function_Type ftype, Eina_Bool warn_unused)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue