forked from enlightenment/efl
Eolian: extend const attributes for parameters to 'set' properties.
When const is used for parameters into 'set' properties, the generator doesn't prepend 'const'. This fixes this bad behavior.
This commit is contained in:
parent
23b0d4f14d
commit
fd25b44cab
|
@ -196,7 +196,7 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
|
|||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eolian_Parameter_Dir pdir;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc);
|
||||
Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data);
|
||||
Eina_Bool is_const = eolian_parameter_const_attribute_get(data, ftype == GET);
|
||||
if (ftype == GET) {
|
||||
add_star = EINA_TRUE;
|
||||
pdir = EOLIAN_OUT_PARAM;
|
||||
|
@ -390,7 +390,7 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
|
|||
void* data = eina_list_data_get(l);
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &rettype, &retname, NULL);
|
||||
var_as_ret = EINA_TRUE;
|
||||
ret_const = eolian_parameter_get_const_attribute_get(data);
|
||||
ret_const = eolian_parameter_const_attribute_get(data, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,13 +413,13 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
|
|||
const char *pname;
|
||||
const char *ptype;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, NULL);
|
||||
Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data);
|
||||
Eina_Bool is_const = eolian_parameter_const_attribute_get(data, ftype == GET);
|
||||
eina_strbuf_append_printf(va_args, " %s%s %s = va_arg(*list, %s%s);\n",
|
||||
ftype == GET && is_const?"const ":"", ptype, pname,
|
||||
ftype == GET && is_const?"const ":"", _varg_upgr(ptype));
|
||||
eina_strbuf_append_printf(params, ", %s", pname);
|
||||
eina_strbuf_append_printf(full_params, ", %s%s %s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
ftype == GET && eolian_parameter_const_attribute_get(data, ftype == GET)?"const ":"",
|
||||
ptype, pname);
|
||||
}
|
||||
if (!var_as_ret)
|
||||
|
@ -430,15 +430,15 @@ 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);
|
||||
Eina_Bool is_const = eolian_parameter_get_const_attribute_get(data);
|
||||
Eina_Bool is_const = eolian_parameter_const_attribute_get(data, ftype == GET);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == UNRESOLVED || ftype == METHOD_FUNC) add_star = (pdir == EOLIAN_OUT_PARAM);
|
||||
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?"*":"");
|
||||
is_const?"const ":"", ptype, had_star?"":" ", add_star?"*":"", pname,
|
||||
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%s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
is_const?"const ":"",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, &pdesc);
|
||||
leg_param_idx++;
|
||||
eina_strbuf_append_printf(fparam, ", %s%s %s",
|
||||
eolian_parameter_get_const_attribute_get(data)?"const":"",
|
||||
eolian_parameter_const_attribute_get(data, ftype == GET)?"const":"",
|
||||
ptype, 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))
|
||||
|
@ -141,7 +141,7 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
if (ftype == SET) pdir = EOLIAN_IN_PARAM;
|
||||
leg_param_idx++;
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s%s%s",
|
||||
eolian_parameter_get_const_attribute_get(data)?"const":"",
|
||||
eolian_parameter_const_attribute_get(data, ftype == GET)?"const":"",
|
||||
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.");
|
||||
|
@ -224,7 +224,7 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
void* data = eina_list_data_get(l);
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &rettype, &retname, NULL);
|
||||
var_as_ret = EINA_TRUE;
|
||||
ret_const = eolian_parameter_get_const_attribute_get(data);
|
||||
ret_const = eolian_parameter_const_attribute_get(data, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
const char *ptype;
|
||||
eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, NULL);
|
||||
eina_strbuf_append_printf(fparam, ", %s%s %s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
eolian_parameter_const_attribute_get(data, ftype == GET)?"const ":"",
|
||||
ptype, pname);
|
||||
if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
|
||||
eina_strbuf_append_printf(eoparam, "%s", pname);
|
||||
|
@ -286,7 +286,7 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
|
|||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == UNRESOLVED || ftype == METHOD_FUNC) add_star = (pdir == EOLIAN_OUT_PARAM);
|
||||
eina_strbuf_append_printf(fparam, ", %s%s%s%s%s",
|
||||
ftype == GET && eolian_parameter_get_const_attribute_get(data)?"const ":"",
|
||||
eolian_parameter_const_attribute_get(data, ftype == GET)?"const ":"",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
if (eina_strbuf_length_get(eoparam)) eina_strbuf_append(eoparam, ", ");
|
||||
eina_strbuf_append_printf(eoparam, "%s", pname);
|
||||
|
|
|
@ -423,11 +423,12 @@ EAPI Eina_Stringshare *eolian_parameter_name_get(const Eolian_Function_Parameter
|
|||
* parameter in the get operation.
|
||||
*
|
||||
* @param[in] param_desc parameter handle
|
||||
* @param[in] is_get indicates if the information needed is for get or set.
|
||||
* @return EINA_TRUE if const in get, EINA_FALSE otherwise
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_parameter_get_const_attribute_get(Eolian_Function_Parameter param_desc);
|
||||
EAPI Eina_Bool eolian_parameter_const_attribute_get(Eolian_Function_Parameter param_desc, Eina_Bool is_get);
|
||||
|
||||
/*
|
||||
* @brief Indicates if a parameter cannot be NULL.
|
||||
|
|
|
@ -4434,22 +4434,18 @@ eo_tokenizer_database_fill(const char *filename)
|
|||
accessor->comment);
|
||||
Eo_Accessor_Param *acc_param;
|
||||
Eina_List *m2;
|
||||
/* Only in get access, we check const attribute */
|
||||
if (accessor->type == GETTER)
|
||||
EINA_LIST_FOREACH(accessor->params, m2, acc_param)
|
||||
{
|
||||
EINA_LIST_FOREACH(accessor->params, m2, acc_param)
|
||||
Eolian_Function_Parameter desc = eolian_function_parameter_get(foo_id, acc_param->name);
|
||||
if (!desc)
|
||||
{
|
||||
Eolian_Function_Parameter desc = eolian_function_parameter_get(foo_id, acc_param->name);
|
||||
if (!desc)
|
||||
{
|
||||
printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name);
|
||||
}
|
||||
else
|
||||
if (strstr(acc_param->attrs, "const"))
|
||||
{
|
||||
database_parameter_get_const_attribute_set(desc, EINA_TRUE);
|
||||
}
|
||||
printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name);
|
||||
}
|
||||
else
|
||||
if (strstr(acc_param->attrs, "const"))
|
||||
{
|
||||
database_parameter_const_attribute_set(desc, accessor->type == GETTER, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
database_class_function_add(kls->name, foo_id);
|
||||
|
|
|
@ -1408,22 +1408,18 @@ eo_tokenizer_database_fill(const char *filename)
|
|||
accessor->comment);
|
||||
Eo_Accessor_Param *acc_param;
|
||||
Eina_List *m2;
|
||||
/* Only in get access, we check const attribute */
|
||||
if (accessor->type == GETTER)
|
||||
EINA_LIST_FOREACH(accessor->params, m2, acc_param)
|
||||
{
|
||||
EINA_LIST_FOREACH(accessor->params, m2, acc_param)
|
||||
Eolian_Function_Parameter desc = eolian_function_parameter_get(foo_id, acc_param->name);
|
||||
if (!desc)
|
||||
{
|
||||
Eolian_Function_Parameter desc = eolian_function_parameter_get(foo_id, acc_param->name);
|
||||
if (!desc)
|
||||
{
|
||||
printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name);
|
||||
}
|
||||
else
|
||||
if (strstr(acc_param->attrs, "const"))
|
||||
{
|
||||
database_parameter_get_const_attribute_set(desc, EINA_TRUE);
|
||||
}
|
||||
printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name);
|
||||
}
|
||||
else
|
||||
if (strstr(acc_param->attrs, "const"))
|
||||
{
|
||||
database_parameter_const_attribute_set(desc, accessor->type == GETTER, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
database_class_function_add(kls->name, foo_id);
|
||||
|
|
|
@ -52,7 +52,8 @@ typedef struct
|
|||
Eina_Stringshare *type;
|
||||
Eina_Stringshare *description;
|
||||
Eolian_Parameter_Dir param_dir;
|
||||
Eina_Bool is_const :1; /* True if const in this function (e.g get) but not const in the opposite one (e.g set) */
|
||||
Eina_Bool is_const_on_get :1; /* True if const in this the get property */
|
||||
Eina_Bool is_const_on_set :1; /* True if const in this the set property */
|
||||
Eina_Bool nonull :1; /* True if this argument cannot be NULL */
|
||||
Eina_Bool own :1; /* True if the ownership of this argument passes to the caller/callee */
|
||||
} _Parameter_Desc;
|
||||
|
@ -790,19 +791,25 @@ eolian_parameter_information_get(Eolian_Function_Parameter param_desc, Eolian_Pa
|
|||
}
|
||||
|
||||
void
|
||||
database_parameter_get_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_const)
|
||||
database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_get, Eina_Bool is_const)
|
||||
{
|
||||
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
||||
EINA_SAFETY_ON_NULL_RETURN(param);
|
||||
param->is_const = is_const;
|
||||
if (is_get)
|
||||
param->is_const_on_get = is_const;
|
||||
else
|
||||
param->is_const_on_set = is_const;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_parameter_get_const_attribute_get(Eolian_Function_Parameter param_desc)
|
||||
eolian_parameter_const_attribute_get(Eolian_Function_Parameter param_desc, Eina_Bool is_get)
|
||||
{
|
||||
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
|
||||
return param->is_const;
|
||||
if (is_get)
|
||||
return param->is_const_on_get;
|
||||
else
|
||||
return param->is_const_on_set;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -86,7 +86,7 @@ Eolian_Function_Parameter database_property_value_add(Eolian_Function foo_id, co
|
|||
/* Add a parameter to a method */
|
||||
Eolian_Function_Parameter database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, const char *type, const char *name, const char *description);
|
||||
|
||||
void database_parameter_get_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_const);
|
||||
void database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_get, Eina_Bool is_const);
|
||||
|
||||
void database_parameter_nonull_set(Eolian_Function_Parameter, Eina_Bool nonull);
|
||||
|
||||
|
|
Loading…
Reference in New Issue