diff options
author | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2017-09-08 14:43:19 +0200 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2017-09-13 23:58:47 +0200 |
commit | 2a9be1f5bed19ec109044f4bba40e96c33a6a5a7 (patch) | |
tree | 03d68629b37b9c38a4c47a833f86fae39c6c859a | |
parent | a0adca9cb98296b274e7502313f928d506eb9676 (diff) | |
download | efl-2a9be1f5bed19ec109044f4bba40e96c33a6a5a7.tar.gz |
eolian: move terminated_array typecheck to validate pass
-rw-r--r-- | src/lib/eolian/database_validate.c | 24 | ||||
-rw-r--r-- | src/lib/eolian/eo_parser.c | 21 |
2 files changed, 23 insertions, 22 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c index a177443313..9519dee508 100644 --- a/src/lib/eolian/database_validate.c +++ b/src/lib/eolian/database_validate.c @@ -128,6 +128,20 @@ _validate_typedecl(const Eolian_Typedecl *tp) } static Eina_Bool +_type_is_terminatable(const Eolian_Type *tp) +{ + if (database_type_is_ownable(tp)) + return EINA_TRUE; + if (tp->type == EOLIAN_TYPE_REGULAR) + { + int kwid = eo_lexer_keyword_str_to_id(tp->name); + /* don't include bool, it only has 2 values so it's useless */ + return (kwid >= KW_byte && kwid < KW_bool); + } + return EINA_FALSE; +} + +static Eina_Bool _validate_type(const Eolian_Type *tp) { char buf[256]; @@ -160,8 +174,16 @@ _validate_type(const Eolian_Type *tp) } return _validate_typedecl(tpp); } - case EOLIAN_TYPE_STATIC_ARRAY: case EOLIAN_TYPE_TERMINATED_ARRAY: + if (!_type_is_terminatable(tp->base_type)) + { + snprintf(buf, sizeof(buf), + "invalid base type '%s' for terminated array", + tp->base_type->full_name); + return _type_error(tp, buf); + } + return _validate_type(tp->base_type); + case EOLIAN_TYPE_STATIC_ARRAY: return _validate_type(tp->base_type); case EOLIAN_TYPE_CLASS: { diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index a0e5c83c2c..5a3599f9c0 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -684,20 +684,6 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name) } } -static Eina_Bool -_type_is_terminatable(Eolian_Type *tp) -{ - if (database_type_is_ownable(tp)) - return EINA_TRUE; - if (tp->type == EOLIAN_TYPE_REGULAR) - { - int kwid = eo_lexer_keyword_str_to_id(tp->name); - /* don't include bool, it only has 2 values so it's useless */ - return (kwid >= KW_byte && kwid < KW_bool); - } - return EINA_FALSE; -} - static Eolian_Type * parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray) { @@ -814,14 +800,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray) def->type = EOLIAN_TYPE_TERMINATED_ARRAY; eo_lexer_get(ls); check_next(ls, '<'); - eo_lexer_context_push(ls); def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE); - if (!_type_is_terminatable(def->base_type)) - { - eo_lexer_context_restore(ls); - eo_lexer_syntax_error(ls, "terminatable type expected"); - } - eo_lexer_context_pop(ls); pop_type(ls); check_next(ls, '>'); } |