forked from enlightenment/efl
eolian: add a new references system to help replace pointers
It's now possible to mark struct fields and function params as "references", which causes them to become pointers in C (in bindings, they become whatever is necessary). They're not a part of the type and are much more restricted than pointers, allowing bindings to be easier. This system will be gradually utilized and expanded as required. @feature
This commit is contained in:
parent
614d1fad6e
commit
9752c44a48
|
@ -129,3 +129,27 @@ _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class *class, c
|
|||
eina_strbuf_replace_all(buf, "@#CLASS", tmp_env.upper_classname);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
|
||||
{
|
||||
switch (ftype)
|
||||
{
|
||||
case EOLIAN_PROP_GET:
|
||||
if (pdir == EOLIAN_REF_PARAM)
|
||||
return "**";
|
||||
else
|
||||
return "*";
|
||||
case EOLIAN_PROP_SET:
|
||||
if (pdir == EOLIAN_REF_PARAM)
|
||||
return "*";
|
||||
else
|
||||
return "";
|
||||
default:
|
||||
if (pdir != EOLIAN_IN_PARAM)
|
||||
return "*";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
|
@ -63,4 +63,6 @@ void _class_env_create(const Eolian_Class *class, const char *over_classname, _e
|
|||
|
||||
void _class_func_env_create(const Eolian_Class *class, const char *funcname, Eolian_Function_Type ftype EINA_UNUSED, _eolian_class_func_vars *env);
|
||||
|
||||
const char *_get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -517,6 +517,7 @@ docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
|||
switch (dir)
|
||||
{
|
||||
case EOLIAN_IN_PARAM:
|
||||
case EOLIAN_REF_PARAM:
|
||||
eina_strbuf_append(buf, " * @param[in] ");
|
||||
curl += sizeof(" * @param[in] ") - 1;
|
||||
break;
|
||||
|
|
|
@ -132,19 +132,11 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
|
|||
const Eolian_Type *ptypet = eolian_parameter_type_get(param);
|
||||
const char *pname = eolian_parameter_name_get(param);
|
||||
const char *ptype = eolian_type_c_type_get(ptypet);
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eolian_Parameter_Dir pdir = eolian_parameter_direction_get(param);
|
||||
|
||||
if (ftype == EOLIAN_PROP_GET) {
|
||||
add_star = EINA_TRUE;
|
||||
pdir = EOLIAN_OUT_PARAM;
|
||||
}
|
||||
if (ftype == EOLIAN_PROP_SET) pdir = EOLIAN_IN_PARAM;
|
||||
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
|
||||
eina_strbuf_append_printf(str_par, ", %s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
ptype, had_star?"":" ", _get_add_star(ftype, pdir), pname);
|
||||
|
||||
eina_stringshare_del(ptype);
|
||||
}
|
||||
|
@ -302,7 +294,6 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
Eina_Bool var_as_ret = EINA_FALSE;
|
||||
const Eolian_Type *rettypet = NULL;
|
||||
const char *rettype = NULL;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eina_Iterator *itr;
|
||||
void *data, *data2;
|
||||
const Eolian_Expression *default_ret_val = NULL;
|
||||
|
@ -334,7 +325,6 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
if (ftype == EOLIAN_PROP_GET)
|
||||
{
|
||||
suffix = "_get";
|
||||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
|
@ -382,10 +372,11 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
const char *ptype = eolian_type_c_type_get(ptypet);
|
||||
Eolian_Parameter_Dir pdir = eolian_parameter_direction_get(param);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
const char *add_star = _get_add_star(ftype, pdir);
|
||||
|
||||
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
|
||||
if (eina_strbuf_length_get(params)) eina_strbuf_append(params, ", ");
|
||||
|
||||
/* FIXME: this looks really bad and should not be here */
|
||||
if(!has_promise && !strcmp(ptype, "Eina_Promise *") &&
|
||||
(ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) && pdir == EOLIAN_INOUT_PARAM)
|
||||
{
|
||||
|
@ -408,12 +399,12 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
|
|||
else
|
||||
{
|
||||
eina_strbuf_append_printf(impl_full_params, ", %s%s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname, is_empty && !dflt_value ?" EINA_UNUSED":"");
|
||||
ptype, had_star?"":" ", add_star, pname, is_empty && !dflt_value ?" EINA_UNUSED":"");
|
||||
eina_strbuf_append_printf(params, "%s", pname);
|
||||
}
|
||||
|
||||
eina_strbuf_append_printf(full_params, ", %s%s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname, is_empty && !dflt_value ?" EINA_UNUSED":"");
|
||||
ptype, had_star?"":" ", add_star, pname, is_empty && !dflt_value ?" EINA_UNUSED":"");
|
||||
if (is_auto)
|
||||
{
|
||||
if (ftype == EOLIAN_PROP_SET)
|
||||
|
|
|
@ -39,7 +39,6 @@ _params_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina_Bo
|
|||
eina_iterator_free(itr);
|
||||
if (!var_as_ret)
|
||||
{
|
||||
Eina_Bool add_star = (ftype == EOLIAN_PROP_GET);
|
||||
itr = is_prop ? eolian_property_values_get(foo, ftype) : eolian_function_parameters_get(foo);
|
||||
EINA_ITERATOR_FOREACH(itr, param)
|
||||
{
|
||||
|
@ -47,15 +46,15 @@ _params_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina_Bo
|
|||
const char *pname = eolian_parameter_name_get(param);
|
||||
const char *ptype = eolian_type_c_type_get(ptypet);
|
||||
Eolian_Parameter_Dir pdir = eolian_parameter_direction_get(param);
|
||||
const char *add_star = _get_add_star(ftype, pdir);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
|
||||
if (eina_strbuf_length_get(params))
|
||||
{
|
||||
eina_strbuf_append(params, ", ");
|
||||
eina_strbuf_append(short_params, ", ");
|
||||
}
|
||||
eina_strbuf_append_printf(params, "%s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
ptype, had_star?"":" ", add_star, pname);
|
||||
eina_strbuf_append_printf(short_params, "%s", pname);
|
||||
eina_stringshare_del(ptype);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
const Eolian_Type *rettypet = NULL;
|
||||
const char *rettype = NULL;
|
||||
Eina_Bool var_as_ret = EINA_FALSE;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
|
||||
Eina_Iterator *itr;
|
||||
void *data, *data2;
|
||||
|
@ -58,7 +57,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
rettypet = eolian_function_return_type_get(funcid, ftype);
|
||||
if (ftype == EOLIAN_PROP_GET)
|
||||
{
|
||||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
|
@ -129,14 +127,11 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
|
|||
const char *ptype = eolian_type_c_type_get(ptypet);
|
||||
Eolian_Parameter_Dir pdir = eolian_parameter_direction_get(param);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
|
||||
else if (ftype == EOLIAN_PROP_GET) pdir = EOLIAN_OUT_PARAM;
|
||||
else if (ftype == EOLIAN_PROP_SET) pdir = EOLIAN_IN_PARAM;
|
||||
|
||||
leg_param_idx++;
|
||||
if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
|
||||
eina_strbuf_append_printf(fparam, "%s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
ptype, had_star?"":" ", _get_add_star(ftype, pdir), pname);
|
||||
eina_stringshare_del(ptype);
|
||||
if (eolian_parameter_is_nonull((Eolian_Function_Parameter*)data))
|
||||
{
|
||||
|
@ -190,7 +185,6 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
const Eolian_Type *rettypet = NULL;
|
||||
const char *rettype = NULL;
|
||||
const char *retname = NULL;
|
||||
Eina_Bool add_star = EINA_FALSE;
|
||||
Eina_Bool ret_is_void = EINA_FALSE;
|
||||
Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
|
||||
|
||||
|
@ -208,7 +202,6 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
retname = "ret";
|
||||
if (ftype == EOLIAN_PROP_GET)
|
||||
{
|
||||
add_star = EINA_TRUE;
|
||||
if (!rettypet)
|
||||
{
|
||||
itr = eolian_property_values_get(funcid, ftype);
|
||||
|
@ -278,10 +271,9 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
|
|||
const char *ptype = eolian_type_c_type_get(ptypet);
|
||||
Eolian_Parameter_Dir pdir = eolian_parameter_direction_get(param);
|
||||
Eina_Bool had_star = !!strchr(ptype, '*');
|
||||
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
|
||||
if (eina_strbuf_length_get(fparam)) eina_strbuf_append(fparam, ", ");
|
||||
eina_strbuf_append_printf(fparam, "%s%s%s%s",
|
||||
ptype, had_star?"":" ", add_star?"*":"", pname);
|
||||
ptype, had_star?"":" ", _get_add_star(ftype, pdir), pname);
|
||||
eina_stringshare_del(ptype);
|
||||
eina_strbuf_append_printf(eoparam, ", %s", pname);
|
||||
}
|
||||
|
|
|
@ -71,8 +71,9 @@ _type_generate(const Eolian_Typedecl *tp, Eina_Bool full, Eina_Bool use_legacy)
|
|||
{
|
||||
const Eolian_Type *type = eolian_typedecl_struct_field_type_get(member);
|
||||
Eina_Stringshare *c_type = eolian_type_c_type_get(type);
|
||||
eina_strbuf_append_printf(buf, " %s%s%s;",
|
||||
c_type, strchr(c_type, '*')?"":" ",
|
||||
Eina_Bool is_ref = eolian_typedecl_struct_field_is_ref(member);
|
||||
eina_strbuf_append_printf(buf, " %s%s%s%s;",
|
||||
c_type, is_ref ? (strchr(c_type, '*') ? "*" : " *") : "", (is_ref || strchr(c_type, '*'))?"":" ",
|
||||
eolian_typedecl_struct_field_name_get(member));
|
||||
const Eolian_Documentation *fdoc
|
||||
= eolian_typedecl_struct_field_documentation_get(member);
|
||||
|
|
|
@ -41,7 +41,8 @@ ffi.cdef [[
|
|||
{
|
||||
EOLIAN_IN_PARAM = 0,
|
||||
EOLIAN_OUT_PARAM,
|
||||
EOLIAN_INOUT_PARAM
|
||||
EOLIAN_INOUT_PARAM,
|
||||
EOLIAN_REF_PARAM
|
||||
} Eolian_Parameter_Dir;
|
||||
|
||||
typedef enum
|
||||
|
@ -280,6 +281,7 @@ ffi.cdef [[
|
|||
const char *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
|
||||
const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
|
||||
const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
||||
Eina_Bool eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl);
|
||||
Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
|
||||
const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
|
||||
const char *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
|
||||
|
@ -485,6 +487,10 @@ ffi.metatype("Eolian_Struct_Type_Field", {
|
|||
local v = eolian.eolian_typedecl_struct_field_type_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
is_ref = function(self)
|
||||
return eolian.eolian_typedecl_struct_field_is_ref(self) ~= 0
|
||||
end
|
||||
}
|
||||
})
|
||||
|
@ -815,7 +821,8 @@ M.Function = ffi.metatype("Eolian_Function", {
|
|||
M.parameter_dir = {
|
||||
IN = 0,
|
||||
OUT = 1,
|
||||
INOUT = 2
|
||||
INOUT = 2,
|
||||
REF = 3
|
||||
}
|
||||
|
||||
ffi.metatype("Eolian_Function_Parameter", {
|
||||
|
|
|
@ -184,7 +184,8 @@ typedef enum
|
|||
{
|
||||
EOLIAN_IN_PARAM = 0,
|
||||
EOLIAN_OUT_PARAM,
|
||||
EOLIAN_INOUT_PARAM
|
||||
EOLIAN_INOUT_PARAM,
|
||||
EOLIAN_REF_PARAM
|
||||
} Eolian_Parameter_Dir;
|
||||
|
||||
typedef enum
|
||||
|
@ -1448,6 +1449,16 @@ EAPI const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(
|
|||
*/
|
||||
EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
|
||||
|
||||
/*
|
||||
* @brief Check if a struct field is a reference.
|
||||
*
|
||||
* @param[in] fl the field.
|
||||
* @return EINA_TRUE if it is, EINA_FALSE otherwise.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl);
|
||||
|
||||
/*
|
||||
* @brief Get an iterator to all fields of an enum type.
|
||||
*
|
||||
|
|
|
@ -70,7 +70,7 @@ database_enum_add(Eolian_Typedecl *tp)
|
|||
}
|
||||
|
||||
void
|
||||
database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
|
||||
database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eina_Bool is_ref)
|
||||
{
|
||||
if ((tp->type == EOLIAN_TYPE_REGULAR
|
||||
|| tp->type == EOLIAN_TYPE_COMPLEX
|
||||
|
@ -104,7 +104,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
|
|||
else
|
||||
{
|
||||
Eolian_Type *btp = tp->base_type;
|
||||
database_type_to_str(tp->base_type, buf, NULL);
|
||||
database_type_to_str(tp->base_type, buf, NULL, EINA_FALSE);
|
||||
if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const)
|
||||
eina_strbuf_append_char(buf, ' ');
|
||||
eina_strbuf_append_char(buf, '*');
|
||||
|
@ -112,6 +112,12 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
|
|||
}
|
||||
if (tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_CLASS)
|
||||
eina_strbuf_append(buf, " *");
|
||||
if (is_ref)
|
||||
{
|
||||
if (eina_strbuf_string_get(buf)[eina_strbuf_length_get(buf) - 1] != '*')
|
||||
eina_strbuf_append_char(buf, ' ');
|
||||
eina_strbuf_append_char(buf, '*');
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
if (eina_strbuf_string_get(buf)[eina_strbuf_length_get(buf) - 1] != '*')
|
||||
|
@ -143,7 +149,7 @@ _stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name)
|
|||
eina_strbuf_append(buf, "{ ");
|
||||
EINA_LIST_FOREACH(tp->field_list, l, sf)
|
||||
{
|
||||
database_type_to_str(sf->type, buf, sf->name);
|
||||
database_type_to_str(sf->type, buf, sf->name, sf->is_ref);
|
||||
eina_strbuf_append(buf, "; ");
|
||||
}
|
||||
eina_strbuf_append(buf, "}");
|
||||
|
@ -228,7 +234,7 @@ _atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
|
|||
|
||||
Eina_Strbuf *fulln = eina_strbuf_new();
|
||||
_append_name(tp, fulln);
|
||||
database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln));
|
||||
database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln), EINA_FALSE);
|
||||
eina_strbuf_free(fulln);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,13 @@ eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl)
|
|||
return fl->type;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_typedecl_struct_field_is_ref(const Eolian_Struct_Type_Field *fl)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, EINA_FALSE);
|
||||
return fl->is_ref;
|
||||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
|
||||
{
|
||||
|
@ -345,7 +352,7 @@ eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name)
|
|||
Eina_Strbuf *buf;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
buf = eina_strbuf_new();
|
||||
database_type_to_str(tp, buf, name);
|
||||
database_type_to_str(tp, buf, name, EINA_FALSE);
|
||||
ret = eina_stringshare_add(eina_strbuf_string_get(buf));
|
||||
eina_strbuf_free(buf);
|
||||
return ret;
|
||||
|
|
|
@ -32,7 +32,7 @@ enum Tokens
|
|||
KWAT(c_only), KWAT(class), KWAT(const), KWAT(empty), KWAT(extern), \
|
||||
KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(nullable), \
|
||||
KWAT(optional), KWAT(out), KWAT(private), KWAT(property), \
|
||||
KWAT(protected), KWAT(restart), KWAT(virtual_pure), KWAT(warn_unused), \
|
||||
KWAT(protected), KWAT(ref), KWAT(restart), KWAT(virtual_pure), KWAT(warn_unused), \
|
||||
\
|
||||
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
|
||||
KW(long), KW(ulong), KW(llong), KW(ullong), \
|
||||
|
|
|
@ -502,9 +502,15 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
|||
while (ls->t.token != '}')
|
||||
{
|
||||
const char *fname;
|
||||
Eina_Bool is_ref = EINA_FALSE;
|
||||
Eolian_Struct_Type_Field *fdef;
|
||||
Eolian_Type *tp;
|
||||
int fline = ls->line_number, fcol = ls->column;
|
||||
if (ls->t.kw == KW_at_ref)
|
||||
{
|
||||
is_ref = EINA_TRUE;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
check(ls, TOK_VALUE);
|
||||
if (eina_hash_find(def->fields, ls->t.value.s))
|
||||
eo_lexer_syntax_error(ls, "double field definition");
|
||||
|
@ -518,6 +524,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
|||
FILL_BASE(fdef->base, ls, fline, fcol);
|
||||
fdef->type = tp;
|
||||
fdef->name = eina_stringshare_ref(fname);
|
||||
fdef->is_ref = is_ref;
|
||||
pop_type(ls);
|
||||
check_next(ls, ';');
|
||||
FILL_DOC(ls, fdef, doc);
|
||||
|
@ -1007,26 +1014,27 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
|
|||
Eolian_Function_Parameter *par = calloc(1, sizeof(Eolian_Function_Parameter));
|
||||
FILL_BASE(par->base, ls, ls->line_number, ls->column);
|
||||
*params = eina_list_append(*params, par);
|
||||
if (allow_inout)
|
||||
if (allow_inout && ls->t.kw == KW_at_in)
|
||||
{
|
||||
if (ls->t.kw == KW_at_in)
|
||||
{
|
||||
par->param_dir = EOLIAN_IN_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else if (ls->t.kw == KW_at_out)
|
||||
{
|
||||
par->param_dir = EOLIAN_OUT_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else if (ls->t.kw == KW_at_inout)
|
||||
{
|
||||
par->param_dir = EOLIAN_INOUT_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else
|
||||
par->param_dir = EOLIAN_IN_PARAM;
|
||||
par->param_dir = EOLIAN_IN_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else if (allow_inout && ls->t.kw == KW_at_out)
|
||||
{
|
||||
par->param_dir = EOLIAN_OUT_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else if (allow_inout && ls->t.kw == KW_at_inout)
|
||||
{
|
||||
par->param_dir = EOLIAN_INOUT_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else if (ls->t.kw == KW_at_ref)
|
||||
{
|
||||
par->param_dir = EOLIAN_REF_PARAM;
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
else par->param_dir = EOLIAN_IN_PARAM;
|
||||
check(ls, TOK_VALUE);
|
||||
par->name = eina_stringshare_ref(ls->t.value.s);
|
||||
eo_lexer_get(ls);
|
||||
|
|
|
@ -232,6 +232,7 @@ struct _Eolian_Struct_Type_Field
|
|||
Eolian_Object base;
|
||||
Eolian_Type *type;
|
||||
Eolian_Documentation *doc;
|
||||
Eina_Bool is_ref: 1;
|
||||
};
|
||||
|
||||
struct _Eolian_Enum_Type_Field
|
||||
|
@ -300,7 +301,7 @@ void database_enum_add(Eolian_Typedecl *tp);
|
|||
void database_type_del(Eolian_Type *tp);
|
||||
void database_typedecl_del(Eolian_Typedecl *tp);
|
||||
|
||||
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name);
|
||||
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eina_Bool is_ref);
|
||||
void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name);
|
||||
|
||||
/* expressions */
|
||||
|
|
|
@ -27,6 +27,7 @@ class Class_Simple {
|
|||
@in a: int; [[a]]
|
||||
@inout b: char;
|
||||
@out c: double (1337.6);
|
||||
@ref d: int;
|
||||
}
|
||||
return: char * (null); [[comment for method return]]
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ void _class_simple_b_set(Eo *obj, Evas_Simple_Data *pd);
|
|||
|
||||
EOAPI EO_VOID_FUNC_BODY(evas_obj_simple_b_set);
|
||||
|
||||
char * _class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c);
|
||||
char * _class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d);
|
||||
|
||||
static char * __eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c)
|
||||
static char * __eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d)
|
||||
{
|
||||
if (c) *c = 1337.600000;
|
||||
return _class_simple_foo(obj, pd, a, b, c);
|
||||
return _class_simple_foo(obj, pd, a, b, c, d);
|
||||
}
|
||||
|
||||
EOAPI EO_FUNC_BODYV(evas_obj_simple_foo, char *, NULL, EO_FUNC_CALL(a, b, c), int a, char *b, double *c);
|
||||
EOAPI EO_FUNC_BODYV(evas_obj_simple_foo, char *, NULL, EO_FUNC_CALL(a, b, c, d), int a, char *b, double *c, int *d);
|
||||
|
||||
int _class_simple_bar(Eo *obj, Evas_Simple_Data *pd, int x);
|
||||
|
||||
|
|
|
@ -55,12 +55,13 @@ EOAPI void evas_obj_simple_b_set(Eo *obj);
|
|||
*
|
||||
* @param[in,out] b
|
||||
* @param[out] c
|
||||
* @param[in] d
|
||||
*
|
||||
* @return comment for method return
|
||||
*
|
||||
* @ingroup Class_Simple
|
||||
*/
|
||||
EOAPI char *evas_obj_simple_foo(Eo *obj, int a, char *b, double *c);
|
||||
EOAPI char *evas_obj_simple_foo(Eo *obj, int a, char *b, double *c, int *d);
|
||||
#endif
|
||||
|
||||
EOAPI int evas_obj_simple_bar(Eo *obj, int x);
|
||||
|
|
|
@ -46,12 +46,13 @@ EAPI void evas_object_simple_b_set(Class_Simple *obj);
|
|||
*
|
||||
* @param[in,out] b
|
||||
* @param[out] c
|
||||
* @param[in] d
|
||||
*
|
||||
* @return comment for method return
|
||||
*
|
||||
* @ingroup Class_Simple
|
||||
*/
|
||||
EAPI char *evas_object_simple_foo(Class_Simple *obj, int a, char *b, double *c);
|
||||
EAPI char *evas_object_simple_foo(Class_Simple *obj, int a, char *b, double *c, int *d);
|
||||
EAPI int evas_object_simple_bar(Class_Simple *obj, int x);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct Named {
|
||||
field: int;
|
||||
@ref field: int;
|
||||
something: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef Eo Struct;
|
|||
|
||||
typedef struct _Named
|
||||
{
|
||||
int field;
|
||||
int *field;
|
||||
const char *something;
|
||||
} Named;
|
||||
|
||||
|
|
|
@ -639,6 +639,10 @@ START_TEST(eolian_simple_parsing)
|
|||
v = eolian_expression_eval(expr, EOLIAN_MASK_FLOAT);
|
||||
fail_if(v.type != EOLIAN_EXPR_DOUBLE);
|
||||
fail_if(v.value.d != 1337.6);
|
||||
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
||||
fail_if(eolian_parameter_direction_get(param) != EOLIAN_REF_PARAM);
|
||||
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
|
||||
fail_if(strcmp(eolian_parameter_name_get(param), "d"));
|
||||
fail_if(eina_iterator_next(iter, &dummy));
|
||||
eina_iterator_free(iter);
|
||||
|
||||
|
@ -680,10 +684,12 @@ START_TEST(eolian_struct)
|
|||
fail_if(strcmp(file, "struct.eo"));
|
||||
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
|
||||
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
||||
fail_if(!eolian_typedecl_struct_field_is_ref(field));
|
||||
fail_if(!(type_name = eolian_type_name_get(ftype)));
|
||||
fail_if(strcmp(type_name, "int"));
|
||||
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
|
||||
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
||||
fail_if(eolian_typedecl_struct_field_is_ref(field));
|
||||
fail_if(!(type_name = eolian_type_c_type_get(ftype)));
|
||||
fail_if(strcmp(type_name, "const char *"));
|
||||
eina_stringshare_del(type_name);
|
||||
|
|
Loading…
Reference in New Issue