forked from enlightenment/efl
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.
This commit is contained in:
parent
067753eb2e
commit
7786b96359
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)));
|
||||
|
|
Loading…
Reference in New Issue