eolian: correctness fixes in tests and eo files

This commit is contained in:
Daniel Kolesa 2017-09-15 17:48:28 +02:00
parent c559380f7f
commit 1afd3c215f
22 changed files with 50 additions and 44 deletions

View File

@ -43,5 +43,5 @@ struct Efl.Observable.Tuple
{ {
[[This type describes an observable touple]] [[This type describes an observable touple]]
key: string; [[Touple key]] key: string; [[Touple key]]
data: free(own(iterator<Efl.Observer>), eina_iterator_free); [[Touple data]] data: iterator<Efl.Observer> @owned; [[Touple data]]
} }

View File

@ -66,7 +66,7 @@ class Efl.Config.Global (Efl.Object, Efl.Config)
is_user: bool; [[$true to lookup for a user profile or $false for is_user: bool; [[$true to lookup for a user profile or $false for
a system one.]] a system one.]]
} }
return: string @owned; [[Directory of the profile, free after use.]] return: stringshare @owned; [[Directory of the profile, free after use.]]
} }
profile_derived_add @protected { profile_derived_add @protected {
[[Add a new profile of the given name to be derived from the current [[Add a new profile of the given name to be derived from the current

View File

@ -339,7 +339,8 @@ class Elm.Web (Elm.Widget)
The string returned must be freed by the user when it's done The string returned must be freed by the user when it's done
with it. with it.
]] ]]
return: string @owned @warn_unused; [[A newly allocated string, or /* FIXME: const doesn't belong here */
return: const(string) @owned @warn_unused; [[A newly allocated string, or
$null if nothing is selected $null if nothing is selected
or an error occurred.]] or an error occurred.]]
} }

View File

@ -146,7 +146,12 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
} }
int kw = eo_lexer_keyword_str_to_id(tp->name); int kw = eo_lexer_keyword_str_to_id(tp->name);
if (kw && eo_lexer_is_type_keyword(kw)) if (kw && eo_lexer_is_type_keyword(kw))
eina_strbuf_append(buf, eo_lexer_get_c_type(kw)); {
/* FIXME: deal with aliased strings? */
if ((kw == KW_string) && !tp->owned)
eina_strbuf_append(buf, "const ");
eina_strbuf_append(buf, eo_lexer_get_c_type(kw));
}
else else
eina_strbuf_append(buf, tp->name); eina_strbuf_append(buf, tp->name);
} }

View File

@ -75,7 +75,7 @@ static const char * const ctypes[] =
"Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List", "Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List",
"Efl_Future", "Efl_Future",
"Eina_Value", "const char *", "Eina_Stringshare *", "Eina_Value", "char *", "Eina_Stringshare *",
"void *", "void *",

View File

@ -2,19 +2,19 @@ class Complex_Type {
methods { methods {
@property a { @property a {
set { set {
return: own(list<array<own(ptr(Eo))> >); return: list<array<ptr(Eo) @owned> > @owned;
} }
get { get {
} }
values { values {
value: own(list<int>); value: list<int> @owned;
} }
} }
foo { foo {
params { params {
buf: own(ptr(char)); buf: string @owned;
} }
return: own(list<stringshare>); [[comment for method return]] return: list<stringshare> @owned; [[comment for method return]]
} }
} }
} }

View File

@ -16,7 +16,7 @@ class Decl {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -39,7 +39,7 @@ class Enum {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -22,7 +22,7 @@ class Extern {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -24,7 +24,7 @@ class Free_Func {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -19,7 +19,7 @@ class Function_As_Argument {
a: int; a: int;
b: double; b: double;
} }
return: own(string); return: string @owned;
} }
} }
} }

View File

@ -19,7 +19,7 @@ _function_as_argument_set_nonull_cb(Eo *obj, Function_As_Argument_Data *pd, void
} }
EOLIAN static const char * EOLIAN static char *
_function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b) _function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b)
{ {

View File

@ -7,9 +7,9 @@ void _function_as_argument_set_nonull_cb(Eo *obj, Function_As_Argument_Data *pd,
EOAPI EFL_VOID_FUNC_BODYV(function_as_argument_set_nonull_cb, EFL_FUNC_CALL(cb_data, cb, cb_free_cb), void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb); EOAPI EFL_VOID_FUNC_BODYV(function_as_argument_set_nonull_cb, EFL_FUNC_CALL(cb_data, cb, cb_free_cb), void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb);
const char *_function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b); char *_function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b);
EOAPI EFL_FUNC_BODYV(function_as_argument_call_cb, const char *, NULL, EFL_FUNC_CALL(a, b), int a, double b); EOAPI EFL_FUNC_BODYV(function_as_argument_call_cb, char *, NULL, EFL_FUNC_CALL(a, b), int a, double b);
static Eina_Bool static Eina_Bool
_function_as_argument_class_initializer(Efl_Class *klass) _function_as_argument_class_initializer(Efl_Class *klass)

View File

@ -21,6 +21,6 @@ EOAPI void function_as_argument_set_cb(Eo *obj, void *cb_data, SimpleFunc cb, Ei
EOAPI void function_as_argument_set_nonull_cb(Eo *obj, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb) EINA_ARG_NONNULL(3); EOAPI void function_as_argument_set_nonull_cb(Eo *obj, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb) EINA_ARG_NONNULL(3);
EOAPI const char *function_as_argument_call_cb(Eo *obj, int a, double b); EOAPI char *function_as_argument_call_cb(Eo *obj, int a, double b);
#endif #endif

View File

@ -16,7 +16,7 @@ function SimpleFunc {
function ComplexFunc { function ComplexFunc {
params { params {
@in c: string; @in c: string;
@out d: own(string); @out d: string @owned;
} }
return: double; return: double;
}; };

View File

@ -8,7 +8,7 @@ typedef void (*VoidFunc)(void *data);
typedef const char * (*SimpleFunc)(void *data, int a, double b); typedef const char * (*SimpleFunc)(void *data, int a, double b);
typedef double (*ComplexFunc)(void *data, const char *c, const char **d); typedef double (*ComplexFunc)(void *data, const char *c, char **d);
typedef void (*FuncAsArgFunc)(void *data, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb, void *another_cb_data, SimpleFunc another_cb, Eina_Free_Cb another_cb_free_cb); typedef void (*FuncAsArgFunc)(void *data, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb, void *another_cb_data, SimpleFunc another_cb, Eina_Free_Cb another_cb_free_cb);

View File

@ -13,7 +13,7 @@ class Object_Impl (Base) {
part: string; part: string;
} }
values { values {
value: own(list<int>); value: list<int> @owned;
} }
} }
@property b { @property b {
@ -23,7 +23,7 @@ class Object_Impl (Base) {
/* set as virtual pure - no implementation expected */ /* set as virtual pure - no implementation expected */
} }
values { values {
value: own(list<int>); value: list<int> @owned;
} }
} }
constructor_1 { constructor_1 {

View File

@ -9,7 +9,7 @@ class Object_Impl_Add (Base) {
/* set as virtual pure - no implementation expected */ /* set as virtual pure - no implementation expected */
} }
values { values {
value: own(list<int>); value: list<int> @owned;
} }
} }
} }

View File

@ -23,7 +23,7 @@ class Struct {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
bar { bar {
return: ptr(Named); return: ptr(Named);

View File

@ -1,5 +1,5 @@
type Evas.Coord: int; /* Simple type definition */ type Evas.Coord: int; /* Simple type definition */
type List_Objects: own(list<ptr(Eo)>); /* A little more complex */ type List_Objects: list<ptr(Eo)>; /* A little more complex */
type Evas.Coord2: Evas.Coord; type Evas.Coord2: Evas.Coord;
type Evas.Coord3: Evas.Coord2; type Evas.Coord3: Evas.Coord2;
@ -33,7 +33,7 @@ class Typedef {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -16,7 +16,7 @@ class Var {
params { params {
idx: int; idx: int;
} }
return: own(ptr(char)); return: string @owned;
} }
} }
} }

View File

@ -338,7 +338,7 @@ START_TEST(eolian_typedef)
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_typedecl_base_type_get(tdl))); fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_is_const(type)); fail_if(eolian_type_is_const(type));
fail_if(eolian_type_base_type_get(type)); fail_if(eolian_type_base_type_get(type));
fail_if(strcmp(type_name, "int")); fail_if(strcmp(type_name, "int"));
@ -358,14 +358,14 @@ START_TEST(eolian_typedef)
fail_if(strcmp(type_name, "List_Objects")); fail_if(strcmp(type_name, "List_Objects"));
fail_if(!(type = eolian_typedecl_base_type_get(tdl))); fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(!eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *")); fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type)); fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(strcmp(type_name, "Eo *")); fail_if(strcmp(type_name, "Eo *"));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
/* List */ /* List */
@ -411,19 +411,19 @@ START_TEST(eolian_complex_type)
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY))); fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_PROP_SET))); fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_PROP_SET)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *")); fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type)); fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_Array *")); fail_if(strcmp(type_name, "Eina_Array *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type)); fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eo *")); fail_if(strcmp(type_name, "Eo *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
/* Properties parameter type */ /* Properties parameter type */
@ -434,13 +434,13 @@ START_TEST(eolian_complex_type)
fail_if(strcmp(eolian_parameter_name_get(param), "value")); fail_if(strcmp(eolian_parameter_name_get(param), "value"));
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *")); fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type)); fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "int")); fail_if(strcmp(type_name, "int"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
@ -448,13 +448,13 @@ START_TEST(eolian_complex_type)
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD))); fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_METHOD))); fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_METHOD)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *")); fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type)); fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_Stringshare *")); fail_if(strcmp(type_name, "Eina_Stringshare *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
/* Methods parameter type */ /* Methods parameter type */
@ -465,7 +465,7 @@ START_TEST(eolian_complex_type)
fail_if(strcmp(eolian_parameter_name_get(param), "buf")); fail_if(strcmp(eolian_parameter_name_get(param), "buf"));
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "char *")); fail_if(strcmp(type_name, "char *"));
eina_stringshare_del(type_name); eina_stringshare_del(type_name);
@ -1458,7 +1458,7 @@ START_TEST(eolian_function_types)
fail_if(strcmp(eolian_parameter_name_get(param), "c")); fail_if(strcmp(eolian_parameter_name_get(param), "c"));
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "const char *")); fail_if(strcmp(type_name, "const char *"));
@ -1467,9 +1467,9 @@ START_TEST(eolian_function_types)
fail_if(strcmp(eolian_parameter_name_get(param), "d")); fail_if(strcmp(eolian_parameter_name_get(param), "d"));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(!eolian_type_is_own(type)); fail_if(!eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM))); fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "const char *")); fail_if(strcmp(type_name, "char *"));
fail_if(eina_iterator_next(iter, &dummy)); fail_if(eina_iterator_next(iter, &dummy));
@ -1488,7 +1488,7 @@ START_TEST(eolian_function_types)
fail_if(strcmp(eolian_parameter_name_get(param), "cb")); fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "VoidFunc")); fail_if(strcmp(type_name, "VoidFunc"));
fail_if(!(arg_decl = eolian_type_typedecl_get(type))); fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
@ -1498,7 +1498,7 @@ START_TEST(eolian_function_types)
fail_if(strcmp(eolian_parameter_name_get(param), "another_cb")); fail_if(strcmp(eolian_parameter_name_get(param), "another_cb"));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR); fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc")); fail_if(strcmp(type_name, "SimpleFunc"));
@ -1539,7 +1539,7 @@ START_TEST(eolian_function_as_arguments)
fail_if(strcmp(eolian_parameter_name_get(param), "cb")); fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
fail_if(!(type = eolian_parameter_type_get(param))); fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type))); fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc")); fail_if(strcmp(type_name, "SimpleFunc"));
fail_if(!(arg_decl = eolian_type_typedecl_get(type))); fail_if(!(arg_decl = eolian_type_typedecl_get(type)));