eolian: distinguish between get/set for property keys/values retrieval
This commit is contained in:
parent
c02bab4149
commit
5c199857c9
|
@ -95,7 +95,7 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
|||
rettypet = eolian_function_return_type_get(func, ftype);
|
||||
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(func);
|
||||
itr = eolian_property_values_get(func, ftype);
|
||||
/* We want to check if there is only one parameter */
|
||||
if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
|||
Eina_Strbuf *str_retdesc = eina_strbuf_new();
|
||||
Eina_Strbuf *str_typecheck = eina_strbuf_new();
|
||||
|
||||
itr = eolian_property_keys_get(func);
|
||||
itr = eolian_property_keys_get(func, ftype);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -165,7 +165,7 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
|||
|
||||
if (!var_as_ret)
|
||||
{
|
||||
itr = is_prop ? eolian_property_values_get(func) : eolian_function_parameters_get(func);
|
||||
itr = is_prop ? eolian_property_values_get(func, ftype) : eolian_function_parameters_get(func);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -390,7 +390,7 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid);
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
/* We want to check if there is only one parameter */
|
||||
if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
|
||||
{
|
||||
|
@ -408,7 +408,7 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
suffix = "_set";
|
||||
}
|
||||
|
||||
itr = eolian_property_keys_get(funcid);
|
||||
itr = eolian_property_keys_get(funcid, ftype);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -426,7 +426,7 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
eina_iterator_free(itr);
|
||||
if (!var_as_ret)
|
||||
{
|
||||
itr = is_prop ? eolian_property_values_get(funcid) : eolian_function_parameters_get(funcid);
|
||||
itr = is_prop ? eolian_property_values_get(funcid, ftype) : eolian_function_parameters_get(funcid);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -559,13 +559,13 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
Eina_Strbuf *eo_func_decl = eina_strbuf_new();
|
||||
Eina_Bool has_params = EINA_FALSE;
|
||||
|
||||
itr = eolian_property_keys_get(funcid);
|
||||
itr = eolian_property_keys_get(funcid, ftype);
|
||||
has_params |= (eina_iterator_next(itr, &data));
|
||||
eina_iterator_free(itr);
|
||||
|
||||
if (!has_params && !var_as_ret)
|
||||
{
|
||||
itr = is_prop ? eolian_property_values_get(funcid) : eolian_function_parameters_get(funcid);
|
||||
itr = is_prop ? eolian_property_values_get(funcid, ftype) : eolian_function_parameters_get(funcid);
|
||||
has_params |= (eina_iterator_next(itr, &data));
|
||||
eina_iterator_free(itr);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ _params_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina_Bo
|
|||
Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
|
||||
eina_strbuf_reset(params);
|
||||
eina_strbuf_reset(short_params);
|
||||
itr = eolian_property_keys_get(foo);
|
||||
itr = eolian_property_keys_get(foo, ftype);
|
||||
EINA_ITERATOR_FOREACH(itr, param)
|
||||
{
|
||||
const Eolian_Type *ptypet = eolian_parameter_type_get(param);
|
||||
|
@ -43,7 +43,7 @@ _params_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina_Bo
|
|||
if (!var_as_ret)
|
||||
{
|
||||
Eina_Bool add_star = (ftype == EOLIAN_PROP_GET);
|
||||
itr = is_prop ? eolian_property_values_get(foo) : eolian_function_parameters_get(foo);
|
||||
itr = is_prop ? eolian_property_values_get(foo, ftype) : eolian_function_parameters_get(foo);
|
||||
EINA_ITERATOR_FOREACH(itr, param)
|
||||
{
|
||||
const Eolian_Type *ptypet = eolian_parameter_type_get(param);
|
||||
|
@ -148,7 +148,7 @@ _prototype_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina
|
|||
const Eolian_Type *rettypet = eolian_function_return_type_get(foo, ftype);
|
||||
if (ftype == EOLIAN_PROP_GET && !rettypet)
|
||||
{
|
||||
Eina_Iterator *itr = eolian_property_values_get(foo);
|
||||
Eina_Iterator *itr = eolian_property_values_get(foo, ftype);
|
||||
void *data, *data2;
|
||||
/* We want to check if there is only one parameter */
|
||||
if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
|
||||
|
|
|
@ -72,7 +72,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid);
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
/* We want to check if there is only one parameter */
|
||||
if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
eina_strbuf_replace_all(fbody, "@#desc", eina_strbuf_string_get(linedesc));
|
||||
eina_strbuf_free(linedesc);
|
||||
|
||||
itr = eolian_property_keys_get(funcid);
|
||||
itr = eolian_property_keys_get(funcid, ftype);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -143,7 +143,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
eina_iterator_free(itr);
|
||||
if (!var_as_ret)
|
||||
{
|
||||
itr = is_prop ? eolian_property_values_get(funcid) : eolian_function_parameters_get(funcid);
|
||||
itr = is_prop ? eolian_property_values_get(funcid, ftype) : eolian_function_parameters_get(funcid);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -242,7 +242,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid);
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
/* We want to check if there is only one parameter */
|
||||
if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
|
||||
tmpstr[0] = '\0';
|
||||
|
||||
itr = eolian_property_keys_get(funcid);
|
||||
itr = eolian_property_keys_get(funcid, ftype);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
@ -304,7 +304,7 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
eina_iterator_free(itr);
|
||||
if (!var_as_ret)
|
||||
{
|
||||
itr = is_prop ? eolian_property_values_get(funcid) : eolian_function_parameters_get(funcid);
|
||||
itr = is_prop ? eolian_property_values_get(funcid, ftype) : eolian_function_parameters_get(funcid);
|
||||
EINA_ITERATOR_FOREACH(itr, data)
|
||||
{
|
||||
Eolian_Function_Parameter *param = data;
|
||||
|
|
|
@ -214,8 +214,8 @@ ffi.cdef [[
|
|||
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
|
||||
Eina_Bool eolian_function_is_c_only(const Eolian_Function *function_id);
|
||||
const Eolian_Function_Parameter *eolian_function_parameter_get_by_name(const Eolian_Function *function_id, const char *param_name);
|
||||
Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id);
|
||||
Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id);
|
||||
Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id);
|
||||
Eolian_Parameter_Dir eolian_parameter_direction_get(const Eolian_Function_Parameter *param);
|
||||
const Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Parameter *param);
|
||||
|
@ -677,14 +677,14 @@ M.Function = ffi.metatype("Eolian_Function", {
|
|||
return v
|
||||
end,
|
||||
|
||||
property_keys_get = function(self)
|
||||
property_keys_get = function(self, ftype)
|
||||
return Ptr_Iterator("const Eolian_Function_Parameter*",
|
||||
eolian.eolian_property_keys_get(self))
|
||||
eolian.eolian_property_keys_get(self, ftype))
|
||||
end,
|
||||
|
||||
property_values_get = function(self)
|
||||
property_values_get = function(self, ftype)
|
||||
return Ptr_Iterator("const Eolian_Function_Parameter*",
|
||||
eolian.eolian_property_values_get(self))
|
||||
eolian.eolian_property_values_get(self, ftype))
|
||||
end,
|
||||
|
||||
parameters_get = function(self)
|
||||
|
|
|
@ -926,21 +926,23 @@ EAPI Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *functi
|
|||
* @brief Returns an iterator to the keys params of a given function.
|
||||
*
|
||||
* @param[in] function_id Id of the function
|
||||
* @param[in] ftype The function type, for property get/set distinction.
|
||||
* @return the iterator
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id);
|
||||
EAPI Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Returns an iterator to the values params of a given function.
|
||||
*
|
||||
* @param[in] function_id Id of the function
|
||||
* @param[in] ftype The function type, for property get/set distinction.
|
||||
* @return the iterator
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id);
|
||||
EAPI Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Get direction of a parameter
|
||||
|
|
|
@ -178,22 +178,29 @@ eolian_function_parameter_get_by_name(const Eolian_Function *fid, const char *pa
|
|||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
eolian_property_keys_get(const Eolian_Function *fid)
|
||||
eolian_property_keys_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||
if (ftype != EOLIAN_PROP_GET && ftype != EOLIAN_PROP_SET)
|
||||
return NULL;
|
||||
return (fid->keys ? eina_list_iterator_new(fid->keys) : NULL);
|
||||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
eolian_property_values_get(const Eolian_Function *fid)
|
||||
eolian_property_values_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
|
||||
{
|
||||
return eolian_function_parameters_get(fid);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||
if (ftype != EOLIAN_PROP_GET && ftype != EOLIAN_PROP_SET)
|
||||
return NULL;
|
||||
return (fid->params ? eina_list_iterator_new(fid->params) : NULL);
|
||||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
eolian_function_parameters_get(const Eolian_Function *fid)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||
if (fid->type != EOLIAN_METHOD)
|
||||
return NULL;
|
||||
return (fid->params ? eina_list_iterator_new(fid->params) : NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -260,8 +260,8 @@ local Property = Method:clone {
|
|||
if self.cached_proto then return self.cached_proto end
|
||||
|
||||
local prop = self.property
|
||||
local keys = prop:property_keys_get():to_array()
|
||||
local vals = prop:property_values_get():to_array()
|
||||
local keys = prop:property_keys_get(self.ftype):to_array()
|
||||
local vals = prop:property_values_get(self.ftype):to_array()
|
||||
local rett = prop:return_type_get(self.ftype)
|
||||
|
||||
local proto = {
|
||||
|
@ -486,11 +486,14 @@ end
|
|||
or tp == func_type.METHOD then
|
||||
cfuncs[#cfuncs + 1] = cfunc
|
||||
if tp ~= func_type.METHOD then
|
||||
for par in cfunc:property_keys_get() do
|
||||
for par in cfunc:property_keys_get(func_type.PROP_SET) do
|
||||
parnames[#parnames + 1] = build_pn(cn, par:name_get())
|
||||
end
|
||||
end
|
||||
for par in cfunc:parameters_get() do
|
||||
local iter = (tp ~= func_type.METHOD)
|
||||
and cfunc:property_values_get(func_type.PROP_SET)
|
||||
or cfunc:parameters_get()
|
||||
for par in iter do
|
||||
if par:direction_get() ~= param_dir.OUT then
|
||||
parnames[#parnames + 1] = build_pn(cn, par:name_get())
|
||||
end
|
||||
|
@ -507,19 +510,23 @@ end
|
|||
-- write ctor body
|
||||
local j = 1
|
||||
for i, cfunc in ipairs(cfuncs) do
|
||||
local tp = cfunc:type_get()
|
||||
s:write(" self:", cfunc:name_get())
|
||||
if cfunc:type_get() ~= func_type.METHOD then
|
||||
s:write("_set")
|
||||
end
|
||||
s:write("(")
|
||||
local fpars = {}
|
||||
if cfunc:type_get() ~= func_type.METHOD then
|
||||
for par in cfunc:property_keys_get() do
|
||||
if tp ~= func_type.METHOD then
|
||||
for par in cfunc:property_keys_get(func_type.PROP_SET) do
|
||||
fpars[#fpars + 1] = parnames[j]
|
||||
j = j + 1
|
||||
end
|
||||
end
|
||||
for par in cfunc:parameters_get() do
|
||||
local iter = (tp ~= func_type.METHOD)
|
||||
and cfunc:property_values_get(func_type.PROP_SET)
|
||||
or cfunc:parameters_get()
|
||||
for par in iter do
|
||||
if par:direction_get() ~= param_dir.OUT then
|
||||
fpars[#fpars + 1] = parnames[j]
|
||||
j = j + 1
|
||||
|
|
|
@ -450,7 +450,7 @@ START_TEST(eolian_complex_type)
|
|||
eina_stringshare_del(type_name);
|
||||
eina_iterator_free(iter);
|
||||
/* Properties parameter type */
|
||||
fail_if(!(iter = eolian_function_parameters_get(fid)));
|
||||
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
||||
fail_if(eina_iterator_next(iter, &dummy));
|
||||
eina_iterator_free(iter);
|
||||
|
@ -595,8 +595,8 @@ START_TEST(eolian_simple_parsing)
|
|||
fail_if(string);
|
||||
|
||||
/* Function parameters */
|
||||
fail_if(eolian_property_keys_get(fid) != NULL);
|
||||
fail_if(!(iter = eolian_property_values_get(fid)));
|
||||
fail_if(eolian_property_keys_get(fid, EOLIAN_PROP_GET) != NULL);
|
||||
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
||||
fail_if(eina_iterator_next(iter, &dummy));
|
||||
eina_iterator_free(iter);
|
||||
|
@ -639,7 +639,7 @@ START_TEST(eolian_simple_parsing)
|
|||
fail_if(eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
|
||||
|
||||
/* Function parameters */
|
||||
fail_if(!(iter = eolian_property_values_get(fid)));
|
||||
fail_if(!(iter = eolian_function_parameters_get(fid)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
||||
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
||||
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
|
||||
|
|
Loading…
Reference in New Issue