summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-08 14:43:19 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-13 23:58:47 +0200
commit2a9be1f5bed19ec109044f4bba40e96c33a6a5a7 (patch)
tree03d68629b37b9c38a4c47a833f86fae39c6c859a /src
parenta0adca9cb98296b274e7502313f928d506eb9676 (diff)
eolian: move terminated_array typecheck to validate pass
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_validate.c24
-rw-r--r--src/lib/eolian/eo_parser.c21
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)
128} 128}
129 129
130static Eina_Bool 130static Eina_Bool
131_type_is_terminatable(const Eolian_Type *tp)
132{
133 if (database_type_is_ownable(tp))
134 return EINA_TRUE;
135 if (tp->type == EOLIAN_TYPE_REGULAR)
136 {
137 int kwid = eo_lexer_keyword_str_to_id(tp->name);
138 /* don't include bool, it only has 2 values so it's useless */
139 return (kwid >= KW_byte && kwid < KW_bool);
140 }
141 return EINA_FALSE;
142}
143
144static Eina_Bool
131_validate_type(const Eolian_Type *tp) 145_validate_type(const Eolian_Type *tp)
132{ 146{
133 char buf[256]; 147 char buf[256];
@@ -160,8 +174,16 @@ _validate_type(const Eolian_Type *tp)
160 } 174 }
161 return _validate_typedecl(tpp); 175 return _validate_typedecl(tpp);
162 } 176 }
163 case EOLIAN_TYPE_STATIC_ARRAY:
164 case EOLIAN_TYPE_TERMINATED_ARRAY: 177 case EOLIAN_TYPE_TERMINATED_ARRAY:
178 if (!_type_is_terminatable(tp->base_type))
179 {
180 snprintf(buf, sizeof(buf),
181 "invalid base type '%s' for terminated array",
182 tp->base_type->full_name);
183 return _type_error(tp, buf);
184 }
185 return _validate_type(tp->base_type);
186 case EOLIAN_TYPE_STATIC_ARRAY:
165 return _validate_type(tp->base_type); 187 return _validate_type(tp->base_type);
166 case EOLIAN_TYPE_CLASS: 188 case EOLIAN_TYPE_CLASS:
167 { 189 {
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)
684 } 684 }
685} 685}
686 686
687static Eina_Bool
688_type_is_terminatable(Eolian_Type *tp)
689{
690 if (database_type_is_ownable(tp))
691 return EINA_TRUE;
692 if (tp->type == EOLIAN_TYPE_REGULAR)
693 {
694 int kwid = eo_lexer_keyword_str_to_id(tp->name);
695 /* don't include bool, it only has 2 values so it's useless */
696 return (kwid >= KW_byte && kwid < KW_bool);
697 }
698 return EINA_FALSE;
699}
700
701static Eolian_Type * 687static Eolian_Type *
702parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray) 688parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
703{ 689{
@@ -814,14 +800,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
814 def->type = EOLIAN_TYPE_TERMINATED_ARRAY; 800 def->type = EOLIAN_TYPE_TERMINATED_ARRAY;
815 eo_lexer_get(ls); 801 eo_lexer_get(ls);
816 check_next(ls, '<'); 802 check_next(ls, '<');
817 eo_lexer_context_push(ls);
818 def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE); 803 def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
819 if (!_type_is_terminatable(def->base_type))
820 {
821 eo_lexer_context_restore(ls);
822 eo_lexer_syntax_error(ls, "terminatable type expected");
823 }
824 eo_lexer_context_pop(ls);
825 pop_type(ls); 804 pop_type(ls);
826 check_next(ls, '>'); 805 check_next(ls, '>');
827 } 806 }