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 "";
+}
\ No newline at end of file
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
switch (dir)
{
case EOLIAN_IN_PARAM:
+ case EOLIAN_REF_PARAM:
eina_strbuf_append(buf, " * @param[in] ");
curl += sizeof(" * @param[in] ") - 1;
break;
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);
}
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;
if (ftype == EOLIAN_PROP_GET)
{
suffix = "_get";
- add_star = EINA_TRUE;
if (!rettypet)
{
itr = eolian_property_values_get(funcid, ftype);
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)
{
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)
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)
{
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);
}
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;
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);
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))
{
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);
retname = "ret";
if (ftype == EOLIAN_PROP_GET)
{
- add_star = EINA_TRUE;
if (!rettypet)
{
itr = eolian_property_values_get(funcid, ftype);
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);
}
{
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);
{
EOLIAN_IN_PARAM = 0,
EOLIAN_OUT_PARAM,
- EOLIAN_INOUT_PARAM
+ EOLIAN_INOUT_PARAM,
+ EOLIAN_REF_PARAM
} Eolian_Parameter_Dir;
typedef enum
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);
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
}
})
M.parameter_dir = {
IN = 0,
OUT = 1,
- INOUT = 2
+ INOUT = 2,
+ REF = 3
}
ffi.metatype("Eolian_Function_Parameter", {
{
EOLIAN_IN_PARAM = 0,
EOLIAN_OUT_PARAM,
- EOLIAN_INOUT_PARAM
+ EOLIAN_INOUT_PARAM,
+ EOLIAN_REF_PARAM
} Eolian_Parameter_Dir;
typedef enum
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.
*
* @param[in] tp the type declaration.
}
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
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, '*');
}
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] != '*')
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, "}");
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);
}
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)
{
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;
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), \
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");
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);
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);
Eolian_Object base;
Eolian_Type *type;
Eolian_Documentation *doc;
+ Eina_Bool is_ref: 1;
};
struct _Eolian_Enum_Type_Field
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 */
@in a: int; [[a]]
@inout b: char;
@out c: double (1337.6);
+ @ref d: int;
}
return: char * (null); [[comment for method return]]
}
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);
*
* @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);
*
* @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
struct Named {
- field: int;
+ @ref field: int;
something: string;
}
typedef struct _Named
{
- int field;
+ int *field;
const char *something;
} Named;
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);
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);