eolian: allow void and non-ownable types in future

This commit is contained in:
Daniel Kolesa 2018-05-03 17:10:31 +02:00
parent c116695311
commit 3a55fe0bbf
5 changed files with 15 additions and 10 deletions

View File

@ -610,7 +610,7 @@ database_expr_eval_type(const Eolian_Unit *unit, Eolian_Expression *expr,
return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data);
case EOLIAN_TYPE_REGULAR:
{
if (database_type_is_ownable(unit, type))
if (database_type_is_ownable(unit, type, EINA_FALSE))
return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data);
int kw = eo_lexer_keyword_str_to_id(type->base.name);
if (!kw || kw < KW_byte || kw >= KW_void)

View File

@ -61,7 +61,7 @@ database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
}
Eina_Bool
database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp)
database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp, Eina_Bool allow_void)
{
if (tp->is_ptr)
return EINA_TRUE;
@ -77,11 +77,13 @@ database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp)
if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER)
return EINA_TRUE;
if (tpp->type == EOLIAN_TYPEDECL_ALIAS)
return database_type_is_ownable(unit, tpp->base_type);
return database_type_is_ownable(unit, tpp->base_type, allow_void);
return EINA_FALSE;
}
return (ct[strlen(ct) - 1] == '*');
}
if (allow_void && (tp->type == EOLIAN_TYPE_VOID))
return EINA_TRUE;
return (tp->type == EOLIAN_TYPE_CLASS);
}
@ -117,7 +119,7 @@ database_type_to_str(const Eolian_Type *tp,
|| tp->type == EOLIAN_TYPE_CLASS
|| tp->type == EOLIAN_TYPE_VOID)
&& tp->is_const
&& ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(NULL, tp)))
&& ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(NULL, tp, EINA_FALSE)))
{
eina_strbuf_append(buf, "const ");
}

View File

@ -200,7 +200,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
const Eolian_Unit *src = tp->base.unit;
char buf[256];
if (tp->owned && !database_type_is_ownable(src, tp))
if (tp->owned && !database_type_is_ownable(src, tp, EINA_FALSE))
{
snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->base.name);
return _obj_error(&tp->base, buf);
@ -209,7 +209,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
if (tp->is_ptr && !tp->legacy)
{
tp->is_ptr = EINA_FALSE;
Eina_Bool still_ownable = database_type_is_ownable(src, tp);
Eina_Bool still_ownable = database_type_is_ownable(src, tp, EINA_FALSE);
tp->is_ptr = EINA_TRUE;
if (still_ownable)
{
@ -238,9 +238,9 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
{
if (!_validate_type(vals, itp))
return EINA_FALSE;
if ((kwid >= KW_accessor) && (kwid <= KW_list))
if ((kwid >= KW_accessor) && (kwid <= KW_list) && (kwid != KW_future))
{
if (!database_type_is_ownable(src, itp))
if (!database_type_is_ownable(src, itp, EINA_TRUE))
{
snprintf(buf, sizeof(buf),
"%s cannot contain value types (%s)",

View File

@ -718,7 +718,10 @@ parse_type_void(Eo_Lexer *ls)
{
int bline = ls->line_number, bcol = ls->column;
check_next(ls, '<');
def->base_type = eo_lexer_type_release(ls, parse_type(ls));
if (tpid == KW_future)
def->base_type = eo_lexer_type_release(ls, parse_type_void(ls));
else
def->base_type = eo_lexer_type_release(ls, parse_type(ls));
if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
eo_lexer_get(ls);
if (tpid == KW_hash)

View File

@ -407,7 +407,7 @@ void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp);
Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp);
Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp, Eina_Bool allow_void);
/* expressions */