q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7786b963592187509900f246268b746cf18b15fd
commit 7786b963592187509900f246268b746cf18b15fd Author: Daniel Kolesa <d.kol...@samsung.com> Date: Mon Sep 8 14:52:49 2014 +0100 eolian: builtin complex types From now on, there are 5 builtin complex types, particularly accessor, array, iterator, hash and list. All other types are simple - they can't have a complex part. Also, the <> now binds to the type itself, not the pointer. More builtin complex types will be added as needed. --- src/lib/ecore_con/ecore_con_server.eo | 2 +- src/lib/eolian/Eolian.h | 14 ++++++------- src/lib/eolian/database_type.c | 5 ++++- src/lib/eolian/database_type_api.c | 6 +----- src/lib/eolian/database_validate.c | 1 + src/lib/eolian/eo_lexer.c | 6 ++++-- src/lib/eolian/eo_lexer.h | 2 ++ src/lib/eolian/eo_parser.c | 36 +++++++++++++++++++------------- src/tests/eolian/data/complex_type.eo | 6 +++--- src/tests/eolian/data/object_impl.eo | 4 ++-- src/tests/eolian/data/object_impl_add.eo | 2 +- src/tests/eolian/data/typedef.eo | 2 +- src/tests/eolian/eolian_parsing.c | 5 +++++ 13 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/lib/ecore_con/ecore_con_server.eo b/src/lib/ecore_con/ecore_con_server.eo index 83151cc..8f14bb3 100644 --- a/src/lib/ecore_con/ecore_con_server.eo +++ b/src/lib/ecore_con/ecore_con_server.eo @@ -51,7 +51,7 @@ class Ecore.Con.Server (Ecore.Con.Base) { get { } values { - const(Eina_List <const(Ecore.Con.Client) *>) *clients; /*@ The list of clients on this server. */ + const(list<const(Ecore.Con.Client) *>) *clients; /*@ The list of clients on this server. */ } } connection_type { diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index ec1296a..320a2cb 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -143,6 +143,7 @@ typedef enum EOLIAN_TYPE_REGULAR, EOLIAN_TYPE_REGULAR_STRUCT, EOLIAN_TYPE_REGULAR_ENUM, + EOLIAN_TYPE_COMPLEX, EOLIAN_TYPE_POINTER, EOLIAN_TYPE_FUNCTION, EOLIAN_TYPE_STRUCT, @@ -1258,8 +1259,7 @@ EAPI Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp); * @brief Get an iterator to all subtypes of a type. * * @param[in] tp the type. - * @return the iterator when @c tp is a regular/regular struct/class/pointer - * type. + * @return the iterator when @c tp is a complex type. * * @ingroup Eolian */ @@ -1505,11 +1505,11 @@ EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp); /* * @brief Get the name of the given type. You have to manually delete - * the stringshare. For EOLIAN_TYPE_REGULAR and EOLIAN_TYPE_REGULAR_STRUCT, - * this is for example "int". For EOLIAN_TYPE_STRUCT, EOLIAN_TYPE_STRUCT_OPAQUE - * and EOLIAN_TYPE_ALIAS, this is the name of the alias or of the struct. For - * EOLIAN_TYPE_CLASS, this can be "Button". Keep in mind that the name doesn't - * include namespaces for structs and aliases. + * the stringshare. For regular or complex types, this is for example "int". + * For EOLIAN_TYPE_STRUCT, EOLIAN_TYPE_STRUCT_OPAQUE and EOLIAN_TYPE_ALIAS, + * this is the name of the alias or of the struct. For EOLIAN_TYPE_CLASS, this + * can be "Button". Keep in mind that the name doesn't include namespaces for + * structs and aliases. * * @param[in] tp the type. * @return the name. diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index efbd5ad..b74f080 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -216,6 +216,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) return; } if ((tp->type == EOLIAN_TYPE_REGULAR + || tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_REGULAR_STRUCT || tp->type == EOLIAN_TYPE_REGULAR_ENUM || tp->type == EOLIAN_TYPE_VOID @@ -225,6 +226,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) eina_strbuf_append(buf, "const "); } if (tp->type == EOLIAN_TYPE_REGULAR + || tp->type == EOLIAN_TYPE_COMPLEX || tp->type == EOLIAN_TYPE_CLASS || tp->type == EOLIAN_TYPE_REGULAR_STRUCT || tp->type == EOLIAN_TYPE_REGULAR_ENUM) @@ -297,7 +299,8 @@ database_type_print(Eolian_Type *tp) printf("own("); if (tp->is_const) printf("const("); - if (tp->type == EOLIAN_TYPE_REGULAR || tp->type == EOLIAN_TYPE_CLASS) + if (tp->type == EOLIAN_TYPE_REGULAR || tp->type == EOLIAN_TYPE_COMPLEX + || tp->type == EOLIAN_TYPE_CLASS) printf("%s", tp->full_name); else if (tp->type == EOLIAN_TYPE_VOID) printf("void"); diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index e80455d..f874ea8 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -87,11 +87,7 @@ eolian_type_subtypes_get(const Eolian_Type *tp) Eolian_Type_Type tpt; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); tpt = tp->type; - EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_REGULAR - || tpt == EOLIAN_TYPE_POINTER - || tpt == EOLIAN_TYPE_REGULAR_STRUCT - || tpt == EOLIAN_TYPE_REGULAR_ENUM - || tpt == EOLIAN_TYPE_CLASS, NULL); + EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_COMPLEX, NULL); if (!tp->subtypes) return NULL; return eina_list_iterator_new(tp->subtypes); } diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c index 9ed5387..d7b3e5d 100644 --- a/src/lib/eolian/database_validate.c +++ b/src/lib/eolian/database_validate.c @@ -38,6 +38,7 @@ _validate_type(const Eolian_Type *tp) switch (tp->type) { case EOLIAN_TYPE_VOID: + case EOLIAN_TYPE_COMPLEX: return EINA_TRUE; case EOLIAN_TYPE_REGULAR: { diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index cf939d7..932d1a9 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -68,7 +68,9 @@ static const char * const ctypes[] = "Eina_Bool", - "void" + "void", + + "Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List" }; #undef KW @@ -830,7 +832,7 @@ eo_lexer_keyword_str_get(int kw) Eina_Bool eo_lexer_is_type_keyword(int kw) { - return (kw >= KW_byte && kw <= KW_void); + return (kw >= KW_byte && kw <= KW_list); } int diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index 18b215e..4daaf19 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -48,6 +48,8 @@ enum Tokens \ KW(void), \ \ + KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \ + \ KW(true), KW(false), KW(null) /* "regular" keyword and @ prefixed keyword */ diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 8b3e77c..92391cb 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -930,13 +930,34 @@ parse_type_named_void(Eo_Lexer *ls, Eina_Bool allow_named) } else { + int tpid = ls->t.kw; def->type = EOLIAN_TYPE_REGULAR; check(ls, TOK_VALUE); ctype = eo_lexer_get_c_type(ls->t.kw); if (ctype) { - _fill_type_name(def, eina_stringshare_add(ls->t.value.s)); + _fill_type_name(def, eina_stringshare_ref(ls->t.value.s)); eo_lexer_get(ls); + if (tpid >= KW_accessor) + { + def->type = EOLIAN_TYPE_COMPLEX; + if (ls->t.token == '<') + { + int bline = ls->line_number, bcol = ls->column; + eo_lexer_get(ls); + def->subtypes = eina_list_append(def->subtypes, + parse_type(ls)); + pop_type(ls); + if (tpid == KW_hash) + { + check_next(ls, ','); + def->subtypes = eina_list_append(def->subtypes, + parse_type(ls)); + pop_type(ls); + } + check_match(ls, '>', '<', bline, bcol); + } + } } else { @@ -984,19 +1005,6 @@ parse_ptr: def = pdef; eo_lexer_get(ls); } - if (ls->t.token == '<') - { - int bline = ls->line_number, bcol = ls->column; - eo_lexer_get(ls); - def->subtypes = eina_list_append(def->subtypes, parse_type(ls)); - pop_type(ls); - while (test_next(ls, ',')) - { - def->subtypes = eina_list_append(def->subtypes, parse_type(ls)); - pop_type(ls); - } - check_match(ls, '>', '<', bline, bcol); - } return def; } diff --git a/src/tests/eolian/data/complex_type.eo b/src/tests/eolian/data/complex_type.eo index 1a9a670..03f1ee9 100644 --- a/src/tests/eolian/data/complex_type.eo +++ b/src/tests/eolian/data/complex_type.eo @@ -2,12 +2,12 @@ class Complex_Type { properties { a { set { - return: own(Eina.List*)<Eina.Array*<own(Eo**)>>; + return: own(list<array<own(Eo**)>*>*); } get { } values { - own(Eina.List*)<int> value; + own(list<int>*) value; } } } @@ -16,7 +16,7 @@ class Complex_Type { params { own(char*) buf; } - return: own(Eina.List*)<Eina.Stringshare *>; /*@ comment for method return */ + return: own(list<Eina.Stringshare*>*); /*@ comment for method return */ } } } diff --git a/src/tests/eolian/data/object_impl.eo b/src/tests/eolian/data/object_impl.eo index b65efda..6c66c31 100644 --- a/src/tests/eolian/data/object_impl.eo +++ b/src/tests/eolian/data/object_impl.eo @@ -11,7 +11,7 @@ class Object_Impl (Base) { const(char)* part; } values { - own(Eina.List*)<int> value; + own(list<int>*) value; } } b { @@ -21,7 +21,7 @@ class Object_Impl (Base) { /* set as virtual pure - no implementation expected */ } values { - own(Eina.List*)<int> value; + own(list<int>*) value; } } } diff --git a/src/tests/eolian/data/object_impl_add.eo b/src/tests/eolian/data/object_impl_add.eo index 0aafb0a..1851d4a 100644 --- a/src/tests/eolian/data/object_impl_add.eo +++ b/src/tests/eolian/data/object_impl_add.eo @@ -9,7 +9,7 @@ class Object_Impl_Add (Base) { /* set as virtual pure - no implementation expected */ } values { - own(Eina.List*)<int> value; + own(list<int>*) value; } } } diff --git a/src/tests/eolian/data/typedef.eo b/src/tests/eolian/data/typedef.eo index 8139ae0..4044740 100644 --- a/src/tests/eolian/data/typedef.eo +++ b/src/tests/eolian/data/typedef.eo @@ -1,5 +1,5 @@ type Evas.Coord: int; /* Simple type definition */ -type List_Objects: own(Eina.List*)< Eo *>; /* A little more complex */ +type List_Objects: own(list<Eo *>*); /* A little more complex */ class Typedef { methods { diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 201e6fa..09127e0 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -361,6 +361,7 @@ START_TEST(eolian_typedef) fail_if(!eolian_type_is_own(type)); fail_if(strcmp(type_name, "Eina_List *")); eina_stringshare_del(type_name); + fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(iter = eolian_type_subtypes_get(type))); fail_if(!eina_iterator_next(iter, (void**)&type)); fail_if(!(type_name = eolian_type_c_type_get(type))); @@ -405,6 +406,7 @@ START_TEST(eolian_complex_type) fail_if(!eolian_type_is_own(type)); fail_if(strcmp(type_name, "Eina_List *")); eina_stringshare_del(type_name); + fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(iter = eolian_type_subtypes_get(type))); fail_if(!eina_iterator_next(iter, (void**)&type)); fail_if(!(type_name = eolian_type_c_type_get(type))); @@ -412,6 +414,7 @@ START_TEST(eolian_complex_type) fail_if(strcmp(type_name, "Eina_Array *")); eina_stringshare_del(type_name); eina_iterator_free(iter); + fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(iter = eolian_type_subtypes_get(type))); fail_if(!eina_iterator_next(iter, (void**)&type)); fail_if(!(type_name = eolian_type_c_type_get(type))); @@ -430,6 +433,7 @@ START_TEST(eolian_complex_type) fail_if(!eolian_type_is_own(type)); fail_if(strcmp(type_name, "Eina_List *")); eina_stringshare_del(type_name); + fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(iter = eolian_type_subtypes_get(type))); fail_if(!eina_iterator_next(iter, (void**)&type)); fail_if(!(type_name = eolian_type_c_type_get(type))); @@ -445,6 +449,7 @@ START_TEST(eolian_complex_type) fail_if(!eolian_type_is_own(type)); fail_if(strcmp(type_name, "Eina_List *")); eina_stringshare_del(type_name); + fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!(iter = eolian_type_subtypes_get(type))); fail_if(!eina_iterator_next(iter, (void**)&type)); fail_if(!(type_name = eolian_type_c_type_get(type))); --