summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-08 14:22:13 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-13 23:58:47 +0200
commita0adca9cb98296b274e7502313f928d506eb9676 (patch)
tree85b9ac754234d2d4b7dfd0a0b5cd498abb77482b /src
parentc935249d7e3d7324b881105d1edbe749852523f5 (diff)
eolian: move ownable checks to validation stage
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_validate.c10
-rw-r--r--src/lib/eolian/eo_parser.c14
2 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 6df55d4b18..a177443313 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -130,6 +130,14 @@ _validate_typedecl(const Eolian_Typedecl *tp)
130static Eina_Bool 130static Eina_Bool
131_validate_type(const Eolian_Type *tp) 131_validate_type(const Eolian_Type *tp)
132{ 132{
133 char buf[256];
134
135 if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp))
136 {
137 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
138 return _type_error(tp, buf);
139 }
140
133 switch (tp->type) 141 switch (tp->type)
134 { 142 {
135 case EOLIAN_TYPE_VOID: 143 case EOLIAN_TYPE_VOID:
@@ -147,7 +155,6 @@ _validate_type(const Eolian_Type *tp)
147 tpp = eolian_type_typedecl_get(tp); 155 tpp = eolian_type_typedecl_get(tp);
148 if (!tpp) 156 if (!tpp)
149 { 157 {
150 char buf[256];
151 snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name); 158 snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
152 return _type_error(tp, buf); 159 return _type_error(tp, buf);
153 } 160 }
@@ -161,7 +168,6 @@ _validate_type(const Eolian_Type *tp)
161 /* FIXME: pass unit properly */ 168 /* FIXME: pass unit properly */
162 if (!eolian_type_class_get(NULL, tp)) 169 if (!eolian_type_class_get(NULL, tp))
163 { 170 {
164 char buf[256];
165 snprintf(buf, sizeof(buf), "undefined class %s " 171 snprintf(buf, sizeof(buf), "undefined class %s "
166 "(likely wrong namespacing)", tp->full_name); 172 "(likely wrong namespacing)", tp->full_name);
167 return _type_error(tp, buf); 173 return _type_error(tp, buf);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 8e035f672f..a0e5c83c2c 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -739,14 +739,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
739 pline = ls->line_number; 739 pline = ls->line_number;
740 pcolumn = ls->column; 740 pcolumn = ls->column;
741 check_next(ls, '('); 741 check_next(ls, '(');
742 eo_lexer_context_push(ls);
743 def = parse_type_void(ls, allow_ref, EINA_FALSE); 742 def = parse_type_void(ls, allow_ref, EINA_FALSE);
744 if (!database_type_is_ownable(def))
745 {
746 eo_lexer_context_restore(ls);
747 eo_lexer_syntax_error(ls, "ownable type expected");
748 }
749 eo_lexer_context_pop(ls);
750 FILL_BASE(def->base, ls, line, col); 743 FILL_BASE(def->base, ls, line, col);
751 def->is_own = EINA_TRUE; 744 def->is_own = EINA_TRUE;
752 check_match(ls, ')', '(', pline, pcolumn); 745 check_match(ls, ')', '(', pline, pcolumn);
@@ -759,14 +752,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
759 pline = ls->line_number; 752 pline = ls->line_number;
760 pcolumn = ls->column; 753 pcolumn = ls->column;
761 check_next(ls, '('); 754 check_next(ls, '(');
762 eo_lexer_context_push(ls);
763 def = parse_type_void(ls, allow_ref, EINA_FALSE); 755 def = parse_type_void(ls, allow_ref, EINA_FALSE);
764 if (!database_type_is_ownable(def))
765 {
766 eo_lexer_context_restore(ls);
767 eo_lexer_syntax_error(ls, "freeable type expected");
768 }
769 eo_lexer_context_pop(ls);
770 check_next(ls, ','); 756 check_next(ls, ',');
771 check(ls, TOK_VALUE); 757 check(ls, TOK_VALUE);
772 def->freefunc = eina_stringshare_ref(ls->t.value.s); 758 def->freefunc = eina_stringshare_ref(ls->t.value.s);