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)
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)
445 445
446 EINA_LIST_FOREACH(cl->inherits, l, icl) 446 EINA_LIST_FOREACH(cl->inherits, l, icl)
447 { 447 {
448 /* first inherit needs some checking done on it */
449 if (l == cl->inherits) switch (cl->type)
450 {
451 case EOLIAN_CLASS_REGULAR:
452 case EOLIAN_CLASS_ABSTRACT:
453 if (icl->type != EOLIAN_CLASS_REGULAR && icl->type != EOLIAN_CLASS_ABSTRACT)
454 {
455 char buf[PATH_MAX];
456 snprintf(buf, sizeof(buf), "regular classes ('%s') cannot inherit from non-regular classes ('%s')",
457 cl->full_name, icl->full_name);
458 return _obj_error(&cl->base, buf);
459 }
460 break;
461 case EOLIAN_CLASS_MIXIN:
462 case EOLIAN_CLASS_INTERFACE:
463 if (icl->type != EOLIAN_CLASS_MIXIN && icl->type != EOLIAN_CLASS_INTERFACE)
464 {
465 char buf[PATH_MAX];
466 snprintf(buf, sizeof(buf), "non-regular classes ('%s') cannot inherit from regular classes ('%s')",
467 cl->full_name, icl->full_name);
468 return _obj_error(&cl->base, buf);
469 }
470 break;
471 default:
472 break;
473 }
448 if (!(res = _validate_class(src, icl, nhash))) 474 if (!(res = _validate_class(src, icl, nhash)))
449 goto freehash; 475 goto freehash;
450 } 476 }
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)
2018} 2018}
2019 2019
2020static void 2020static void
2021_inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit, 2021_inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf)
2022 Eolian_Class_Type type)
2023{ 2022{
2024 const char *fname, *iname; 2023 const char *fname, *iname;
2025 char *fnm; 2024 char *fnm;
@@ -2056,33 +2055,6 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2056 eo_lexer_syntax_error(ls, ebuf); 2055 eo_lexer_syntax_error(ls, ebuf);
2057 return; 2056 return;
2058 } 2057 }
2059 if (check_inherit) switch (type)
2060 {
2061 case EOLIAN_CLASS_REGULAR:
2062 case EOLIAN_CLASS_ABSTRACT:
2063 if (dep->type != EOLIAN_CLASS_REGULAR && dep->type != EOLIAN_CLASS_ABSTRACT)
2064 {
2065 char ebuf[PATH_MAX];
2066 eo_lexer_context_restore(ls);
2067 snprintf(ebuf, sizeof(ebuf), "regular classes ('%s') cannot inherit from non-regular classes ('%s')",
2068 ls->tmp.kls->full_name, iname);
2069 eo_lexer_syntax_error(ls, ebuf);
2070 }
2071 break;
2072 case EOLIAN_CLASS_MIXIN:
2073 case EOLIAN_CLASS_INTERFACE:
2074 if (dep->type != EOLIAN_CLASS_MIXIN && dep->type != EOLIAN_CLASS_INTERFACE)
2075 {
2076 char ebuf[PATH_MAX];
2077 eo_lexer_context_restore(ls);
2078 snprintf(ebuf, sizeof(ebuf), "non-regular classes ('%s') cannot inherit from regular classes ('%s')",
2079 ls->tmp.kls->full_name, iname);
2080 eo_lexer_syntax_error(ls, ebuf);
2081 }
2082 break;
2083 default:
2084 break;
2085 }
2086 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, dep); 2058 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, dep);
2087 dep->toplevel = EINA_FALSE; 2059 dep->toplevel = EINA_FALSE;
2088 eo_lexer_context_pop(ls); 2060 eo_lexer_context_pop(ls);
@@ -2133,9 +2105,9 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
2133 if (ls->t.token != ')') 2105 if (ls->t.token != ')')
2134 { 2106 {
2135 Eina_Strbuf *ibuf = push_strbuf(ls); 2107 Eina_Strbuf *ibuf = push_strbuf(ls);
2136 _inherit_dep(ls, ibuf, EINA_TRUE, type); 2108 _inherit_dep(ls, ibuf);
2137 while (test_next(ls, ',')) 2109 while (test_next(ls, ','))
2138 _inherit_dep(ls, ibuf, EINA_FALSE, type); 2110 _inherit_dep(ls, ibuf);
2139 pop_strbuf(ls); 2111 pop_strbuf(ls);
2140 } 2112 }
2141 check_match(ls, ')', '(', line, col); 2113 check_match(ls, ')', '(', line, col);