eolian: remove support for function types

These won't be needed because of Eo callbacks. They're also difficult
to handle in bindings, so this will relieve bindings of some effort.
This commit is contained in:
Daniel Kolesa 2014-11-27 17:20:21 +00:00
parent b598aefa67
commit 5b9ece9c85
7 changed files with 11 additions and 160 deletions

View File

@ -195,7 +195,6 @@ typedef enum
EOLIAN_TYPE_REGULAR_ENUM,
EOLIAN_TYPE_COMPLEX,
EOLIAN_TYPE_POINTER,
EOLIAN_TYPE_FUNCTION,
EOLIAN_TYPE_STRUCT,
EOLIAN_TYPE_STRUCT_OPAQUE,
EOLIAN_TYPE_ENUM,
@ -1342,16 +1341,6 @@ EAPI Eina_Iterator *eolian_type_enums_get_by_file(const char *fname);
*/
EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
/*
* @brief Get an iterator to all arguments of a function type.
*
* @param[in] tp the type.
* @return the iterator when @c tp is an EOLIAN_TYPE_FUNCTION, NULL otherwise.
*
* @ingroup Eolian
*/
EAPI Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp);
/*
* @brief Get an iterator to all subtypes of a type.
*
@ -1501,16 +1490,6 @@ EAPI Eina_Stringshare *eolian_type_description_get(const Eolian_Type *tp);
*/
EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
/*
* @brief Get the return type of a function type.
*
* @param[in] tp the type.
* @return the return type when @c tp is an EOLIAN_TYPE_FUNCTION, NULL otherwise.
*
* @ingroup Eolian
*/
EAPI const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp);
/*
* @brief Get the base type of a pointer or alias type.
*

View File

@ -69,28 +69,6 @@ database_enum_add(Eolian_Type *tp)
((Eina_List*)eina_hash_find(_enumsf, tp->base.file), tp));
}
static void
_ftype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
{
Eina_List *l;
Eolian_Type *stp;
Eina_Bool first = EINA_TRUE;
if (tp->ret_type)
database_type_to_str(tp->ret_type, buf, NULL);
else
eina_strbuf_append(buf, "void");
eina_strbuf_append(buf, " (*");
if (name) eina_strbuf_append(buf, name);
eina_strbuf_append(buf, ")(");
EINA_LIST_FOREACH(tp->arguments, l, stp)
{
if (!first) eina_strbuf_append(buf, ", ");
first = EINA_FALSE;
database_type_to_str(stp, buf, NULL);
}
eina_strbuf_append(buf, ")");
}
static void
_stype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
{
@ -197,11 +175,6 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
_atype_to_str(tp, buf);
return;
}
else if (tp->type == EOLIAN_TYPE_FUNCTION)
{
_ftype_to_str(tp, buf, name);
return;
}
else if (tp->type == EOLIAN_TYPE_STRUCT
|| tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
{
@ -286,8 +259,6 @@ database_expr_print(Eolian_Expression *exp)
void
database_type_print(Eolian_Type *tp)
{
Eina_List *l;
Eolian_Type *stp;
if (tp->type == EOLIAN_TYPE_ALIAS)
{
_typedef_print(tp);
@ -312,26 +283,6 @@ database_type_print(Eolian_Type *tp)
database_type_print(tp->base_type);
putchar('*');
}
else if (tp->type == EOLIAN_TYPE_FUNCTION)
{
Eina_Bool first = EINA_TRUE;
printf("func");
if (tp->ret_type)
{
putchar(' ');
database_type_print(tp->ret_type);
}
else
printf(" void");
printf(" (");
EINA_LIST_FOREACH(tp->arguments, l, stp)
{
if (!first) printf(", ");
first = EINA_FALSE;
database_type_print(stp);
}
putchar(')');
}
else if (tp->type == EOLIAN_TYPE_STRUCT)
{
Eolian_Struct_Type_Field *sf;

View File

@ -75,15 +75,6 @@ eolian_type_type_get(const Eolian_Type *tp)
return tp->type;
}
EAPI Eina_Iterator *
eolian_type_arguments_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL);
if (!tp->arguments) return NULL;
return eina_list_iterator_new(tp->arguments);
}
EAPI Eina_Iterator *
eolian_type_subtypes_get(const Eolian_Type *tp)
{
@ -192,7 +183,6 @@ eolian_type_description_get(const Eolian_Type *tp)
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
tpp = eolian_type_type_get(tp);
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
&& tpp != EOLIAN_TYPE_FUNCTION
&& tpp != EOLIAN_TYPE_VOID, NULL);
return tp->comment;
}
@ -204,19 +194,10 @@ eolian_type_file_get(const Eolian_Type *tp)
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
tpp = eolian_type_type_get(tp);
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
&& tpp != EOLIAN_TYPE_FUNCTION
&& tpp != EOLIAN_TYPE_VOID, NULL);
return tp->base.file;
}
EAPI const Eolian_Type *
eolian_type_return_type_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL);
return tp->ret_type;
}
EAPI const Eolian_Type *
eolian_type_base_type_get(const Eolian_Type *tp)
{
@ -282,7 +263,6 @@ eolian_type_name_get(const Eolian_Type *tp)
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
tpp = eolian_type_type_get(tp);
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
&& tpp != EOLIAN_TYPE_FUNCTION
&& tpp != EOLIAN_TYPE_VOID, NULL);
return tp->name;
}
@ -294,7 +274,6 @@ eolian_type_full_name_get(const Eolian_Type *tp)
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
tpp = eolian_type_type_get(tp);
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
&& tpp != EOLIAN_TYPE_FUNCTION
&& tpp != EOLIAN_TYPE_VOID, NULL);
return tp->full_name;
}
@ -306,7 +285,6 @@ eolian_type_namespaces_get(const Eolian_Type *tp)
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
tpp = eolian_type_type_get(tp);
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
&& tpp != EOLIAN_TYPE_FUNCTION
&& tpp != EOLIAN_TYPE_VOID, NULL);
if (!tp->namespaces) return NULL;
return eina_list_iterator_new(tp->namespaces);

View File

@ -91,17 +91,6 @@ _validate_type(const Eolian_Type *tp)
case EOLIAN_TYPE_POINTER:
case EOLIAN_TYPE_ALIAS:
return _validate_type(tp->base_type);
case EOLIAN_TYPE_FUNCTION:
{
Eina_List *l;
Eolian_Type *tpp;
if (tp->ret_type && !_validate_type(tp->ret_type))
return EINA_FALSE;
EINA_LIST_FOREACH(tp->arguments, l, tpp)
if (!_validate_type(tpp))
return EINA_FALSE;
return EINA_TRUE;
}
case EOLIAN_TYPE_STRUCT:
{
Eina_Bool succ = EINA_TRUE;

View File

@ -25,7 +25,7 @@ enum Tokens
#define KEYWORDS KW(class), KW(const), KW(enum), KW(return), KW(struct), \
\
KW(abstract), KW(constructor), KW(constructors), KW(data), \
KW(destructor), KW(eo), KW(eo_prefix), KW(events), KW(free), KW(func), \
KW(destructor), KW(eo), KW(eo_prefix), KW(events), KW(free), \
KW(get), KW(implements), KW(interface), KW(keys), KW(legacy), \
KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \
KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \

View File

@ -495,40 +495,6 @@ parse_type_named(Eo_Lexer *ls, Eina_Bool allow_named)
return ret;
}
static Eolian_Type *
parse_function_type(Eo_Lexer *ls)
{
int line, col;
Eolian_Type *def = push_type(ls);
def->type = EOLIAN_TYPE_FUNCTION;
def->base.file = eina_stringshare_ref(ls->filename);
def->base.line = ls->line_number;
def->base.column = ls->column;
eo_lexer_get(ls);
if (ls->t.kw == KW_void)
eo_lexer_get(ls);
else
{
def->ret_type = parse_type_void(ls);
pop_type(ls);
}
line = ls->line_number;
col = ls->column;
check_next(ls, '(');
if (ls->t.token != ')')
{
def->arguments = eina_list_append(def->arguments, parse_type(ls));
pop_type(ls);
while (test_next(ls, ','))
{
def->arguments = eina_list_append(def->arguments, parse_type(ls));
pop_type(ls);
}
}
check_match(ls, ')', '(', line, col);
return def;
}
static void
_struct_field_free(Eolian_Struct_Type_Field *def)
{
@ -875,8 +841,6 @@ parse_type_named_void(Eo_Lexer *ls, Eina_Bool allow_named)
_fill_name(sname, &def->full_name, &def->name, &def->namespaces);
goto parse_ptr;
}
case KW_func:
return parse_function_type(ls);
default:
break;
}

View File

@ -139,26 +139,16 @@ struct _Eolian_Type
{
Eolian_Object base;
Eolian_Type_Type type;
union {
/* functions */
struct {
Eina_List *arguments;
Eolian_Type *ret_type;
};
/* everything else */
struct {
Eina_List *subtypes;
Eolian_Type *base_type;
Eina_Stringshare *name;
Eina_Stringshare *full_name;
Eina_List *namespaces;
Eina_Hash *fields;
Eina_List *field_list;
Eina_Stringshare *comment;
Eina_Stringshare *legacy;
Eina_Stringshare *freefunc;
};
};
Eina_List *subtypes;
Eolian_Type *base_type;
Eina_Stringshare *name;
Eina_Stringshare *full_name;
Eina_List *namespaces;
Eina_Hash *fields;
Eina_List *field_list;
Eina_Stringshare *comment;
Eina_Stringshare *legacy;
Eina_Stringshare *freefunc;
Eina_Bool is_const :1;
Eina_Bool is_own :1;
Eina_Bool is_extern :1;