summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2018-05-03 17:10:31 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2018-05-03 17:14:39 +0200
commit3a55fe0bbf2887851f7cbdb828227a3ae74bb0a4 (patch)
tree5cc470a081264b73db73f938d83038f6f86589c4
parentc116695311eef5583fd231158d87354529d866f3 (diff)
eolian: allow void and non-ownable types in future
-rw-r--r--src/lib/eolian/database_expr.c2
-rw-r--r--src/lib/eolian/database_type.c8
-rw-r--r--src/lib/eolian/database_validate.c8
-rw-r--r--src/lib/eolian/eo_parser.c5
-rw-r--r--src/lib/eolian/eolian_database.h2
5 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index 1b38dd4..a03c820 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -610,7 +610,7 @@ database_expr_eval_type(const Eolian_Unit *unit, Eolian_Expression *expr,
610 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data); 610 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data);
611 case EOLIAN_TYPE_REGULAR: 611 case EOLIAN_TYPE_REGULAR:
612 { 612 {
613 if (database_type_is_ownable(unit, type)) 613 if (database_type_is_ownable(unit, type, EINA_FALSE))
614 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data); 614 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL, cb, data);
615 int kw = eo_lexer_keyword_str_to_id(type->base.name); 615 int kw = eo_lexer_keyword_str_to_id(type->base.name);
616 if (!kw || kw < KW_byte || kw >= KW_void) 616 if (!kw || kw < KW_byte || kw >= KW_void)
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index eec9621..31517d6 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -61,7 +61,7 @@ database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
61} 61}
62 62
63Eina_Bool 63Eina_Bool
64database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp) 64database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp, Eina_Bool allow_void)
65{ 65{
66 if (tp->is_ptr) 66 if (tp->is_ptr)
67 return EINA_TRUE; 67 return EINA_TRUE;
@@ -77,11 +77,13 @@ database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp)
77 if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER) 77 if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER)
78 return EINA_TRUE; 78 return EINA_TRUE;
79 if (tpp->type == EOLIAN_TYPEDECL_ALIAS) 79 if (tpp->type == EOLIAN_TYPEDECL_ALIAS)
80 return database_type_is_ownable(unit, tpp->base_type); 80 return database_type_is_ownable(unit, tpp->base_type, allow_void);
81 return EINA_FALSE; 81 return EINA_FALSE;
82 } 82 }
83 return (ct[strlen(ct) - 1] == '*'); 83 return (ct[strlen(ct) - 1] == '*');
84 } 84 }
85 if (allow_void && (tp->type == EOLIAN_TYPE_VOID))
86 return EINA_TRUE;
85 return (tp->type == EOLIAN_TYPE_CLASS); 87 return (tp->type == EOLIAN_TYPE_CLASS);
86} 88}
87 89
@@ -117,7 +119,7 @@ database_type_to_str(const Eolian_Type *tp,
117 || tp->type == EOLIAN_TYPE_CLASS 119 || tp->type == EOLIAN_TYPE_CLASS
118 || tp->type == EOLIAN_TYPE_VOID) 120 || tp->type == EOLIAN_TYPE_VOID)
119 && tp->is_const 121 && tp->is_const
120 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(NULL, tp))) 122 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(NULL, tp, EINA_FALSE)))
121 { 123 {
122 eina_strbuf_append(buf, "const "); 124 eina_strbuf_append(buf, "const ");
123 } 125 }
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 67229ed..15ac575 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -200,7 +200,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
200 const Eolian_Unit *src = tp->base.unit; 200 const Eolian_Unit *src = tp->base.unit;
201 201
202 char buf[256]; 202 char buf[256];
203 if (tp->owned && !database_type_is_ownable(src, tp)) 203 if (tp->owned && !database_type_is_ownable(src, tp, EINA_FALSE))
204 { 204 {
205 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->base.name); 205 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->base.name);
206 return _obj_error(&tp->base, buf); 206 return _obj_error(&tp->base, buf);
@@ -209,7 +209,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
209 if (tp->is_ptr && !tp->legacy) 209 if (tp->is_ptr && !tp->legacy)
210 { 210 {
211 tp->is_ptr = EINA_FALSE; 211 tp->is_ptr = EINA_FALSE;
212 Eina_Bool still_ownable = database_type_is_ownable(src, tp); 212 Eina_Bool still_ownable = database_type_is_ownable(src, tp, EINA_FALSE);
213 tp->is_ptr = EINA_TRUE; 213 tp->is_ptr = EINA_TRUE;
214 if (still_ownable) 214 if (still_ownable)
215 { 215 {
@@ -238,9 +238,9 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
238 { 238 {
239 if (!_validate_type(vals, itp)) 239 if (!_validate_type(vals, itp))
240 return EINA_FALSE; 240 return EINA_FALSE;
241 if ((kwid >= KW_accessor) && (kwid <= KW_list)) 241 if ((kwid >= KW_accessor) && (kwid <= KW_list) && (kwid != KW_future))
242 { 242 {
243 if (!database_type_is_ownable(src, itp)) 243 if (!database_type_is_ownable(src, itp, EINA_TRUE))
244 { 244 {
245 snprintf(buf, sizeof(buf), 245 snprintf(buf, sizeof(buf),
246 "%s cannot contain value types (%s)", 246 "%s cannot contain value types (%s)",
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 24bb072..096a883 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -718,7 +718,10 @@ parse_type_void(Eo_Lexer *ls)
718 { 718 {
719 int bline = ls->line_number, bcol = ls->column; 719 int bline = ls->line_number, bcol = ls->column;
720 check_next(ls, '<'); 720 check_next(ls, '<');
721 def->base_type = eo_lexer_type_release(ls, parse_type(ls)); 721 if (tpid == KW_future)
722 def->base_type = eo_lexer_type_release(ls, parse_type_void(ls));
723 else
724 def->base_type = eo_lexer_type_release(ls, parse_type(ls));
722 if ((def->base_type->owned = (ls->t.kw == KW_at_owned))) 725 if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
723 eo_lexer_get(ls); 726 eo_lexer_get(ls);
724 if (tpid == KW_hash) 727 if (tpid == KW_hash)
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 91cec5c..dfbad0c 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -407,7 +407,7 @@ void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
407 407
408Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp); 408Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp);
409 409
410Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp); 410Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp, Eina_Bool allow_void);
411 411
412/* expressions */ 412/* expressions */
413 413