summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 12:41:29 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 15:36:31 +0100
commite1bcd61bdf964b9e38923bdb590b8f00bfc31876 (patch)
tree611cad5920c3d2c119be8d08471fbcb3193ab2b8
parent6ecad5b873a101c821d337da69bd52d22242325b (diff)
downloadefl-e1bcd61bdf964b9e38923bdb590b8f00bfc31876.tar.gz
eolian: move inherit type checking to validation
-rw-r--r--src/lib/eolian/database_validate.c26
-rw-r--r--src/lib/eolian/eo_parser.c34
2 files changed, 29 insertions, 31 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 6706464172..cf5f741f0b 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -445,6 +445,32 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
EINA_LIST_FOREACH(cl->inherits, l, icl)
{
+ /* first inherit needs some checking done on it */
+ if (l == cl->inherits) switch (cl->type)
+ {
+ case EOLIAN_CLASS_REGULAR:
+ case EOLIAN_CLASS_ABSTRACT:
+ if (icl->type != EOLIAN_CLASS_REGULAR && icl->type != EOLIAN_CLASS_ABSTRACT)
+ {
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "regular classes ('%s') cannot inherit from non-regular classes ('%s')",
+ cl->full_name, icl->full_name);
+ return _obj_error(&cl->base, buf);
+ }
+ break;
+ case EOLIAN_CLASS_MIXIN:
+ case EOLIAN_CLASS_INTERFACE:
+ if (icl->type != EOLIAN_CLASS_MIXIN && icl->type != EOLIAN_CLASS_INTERFACE)
+ {
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "non-regular classes ('%s') cannot inherit from regular classes ('%s')",
+ cl->full_name, icl->full_name);
+ return _obj_error(&cl->base, buf);
+ }
+ break;
+ default:
+ break;
+ }
if (!(res = _validate_class(src, icl, nhash)))
goto freehash;
}
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 882a8bef2c..556ac70785 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2018,8 +2018,7 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
}
static void
-_inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
- Eolian_Class_Type type)
+_inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf)
{
const char *fname, *iname;
char *fnm;
@@ -2056,33 +2055,6 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
eo_lexer_syntax_error(ls, ebuf);
return;
}
- if (check_inherit) switch (type)
- {
- case EOLIAN_CLASS_REGULAR:
- case EOLIAN_CLASS_ABSTRACT:
- if (dep->type != EOLIAN_CLASS_REGULAR && dep->type != EOLIAN_CLASS_ABSTRACT)
- {
- char ebuf[PATH_MAX];
- eo_lexer_context_restore(ls);
- snprintf(ebuf, sizeof(ebuf), "regular classes ('%s') cannot inherit from non-regular classes ('%s')",
- ls->tmp.kls->full_name, iname);
- eo_lexer_syntax_error(ls, ebuf);
- }
- break;
- case EOLIAN_CLASS_MIXIN:
- case EOLIAN_CLASS_INTERFACE:
- if (dep->type != EOLIAN_CLASS_MIXIN && dep->type != EOLIAN_CLASS_INTERFACE)
- {
- char ebuf[PATH_MAX];
- eo_lexer_context_restore(ls);
- snprintf(ebuf, sizeof(ebuf), "non-regular classes ('%s') cannot inherit from regular classes ('%s')",
- ls->tmp.kls->full_name, iname);
- eo_lexer_syntax_error(ls, ebuf);
- }
- break;
- default:
- break;
- }
ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, dep);
dep->toplevel = EINA_FALSE;
eo_lexer_context_pop(ls);
@@ -2133,9 +2105,9 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
if (ls->t.token != ')')
{
Eina_Strbuf *ibuf = push_strbuf(ls);
- _inherit_dep(ls, ibuf, EINA_TRUE, type);
+ _inherit_dep(ls, ibuf);
while (test_next(ls, ','))
- _inherit_dep(ls, ibuf, EINA_FALSE, type);
+ _inherit_dep(ls, ibuf);
pop_strbuf(ls);
}
check_match(ls, ')', '(', line, col);