summaryrefslogtreecommitdiff
path: root/src/lib/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-09-06 15:08:27 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-06 15:14:20 +0200
commiteb25e92770f9524e2921a512a326aea202e4b032 (patch)
tree9ebce4a88bc51f271b35a33436fede609bf09cca /src/lib/eolian
parent690dd5d33a39aec8537dbab3321a75e506b306de (diff)
downloadefl-eb25e92770f9524e2921a512a326aea202e4b032.tar.gz
eolian: change composite syntax from block to inheritance section
This makes more sense as these are related to inheritance tree. Therefore, change while we still can. Fixes T8183
Diffstat (limited to 'src/lib/eolian')
-rw-r--r--src/lib/eolian/eo_parser.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 04a16c2502..975c2a880b 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1959,43 +1959,6 @@ parse_parts(Eo_Lexer *ls)
}
static void
-parse_composite(Eo_Lexer *ls)
-{
- int line, col;
- if (ls->klass->type == EOLIAN_CLASS_INTERFACE)
- eo_lexer_syntax_error(ls, "composite section not allowed in interfaces");
- eo_lexer_get(ls);
- line = ls->line_number, col = ls->column;
- check_next(ls, '{');
- while (ls->t.token != '}')
- {
- Eina_Strbuf *buf = eina_strbuf_new();
- eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
- eo_lexer_context_push(ls);
- parse_name(ls, buf);
- const char *nm = eina_strbuf_string_get(buf);
- char *fnm = database_class_to_filename(nm);
- if (!eina_hash_find(ls->state->filenames_eo, fnm))
- {
- free(fnm);
- char ebuf[PATH_MAX];
- eo_lexer_context_restore(ls);
- snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm);
- eo_lexer_syntax_error(ls, ebuf);
- return;
- }
- /* do not introduce a dependency */
- database_defer(ls->state, fnm, EINA_FALSE);
- free(fnm);
- ls->klass->composite = eina_list_append(ls->klass->composite,
- eina_stringshare_add(nm));
- eo_lexer_dtor_pop(ls);
- check_next(ls, ';');
- }
- check_match(ls, '}', '{', line, col);
-}
-
-static void
parse_implements(Eo_Lexer *ls, Eina_Bool iface)
{
int line, col;
@@ -2065,7 +2028,6 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
has_data = EINA_FALSE,
has_methods = EINA_FALSE,
has_parts = EINA_FALSE,
- has_composite = EINA_FALSE,
has_implements = EINA_FALSE,
has_constructors = EINA_FALSE,
has_events = EINA_FALSE;
@@ -2112,10 +2074,6 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
CASE_LOCK(ls, parts, "parts definition")
parse_parts(ls);
break;
- case KW_composite:
- CASE_LOCK(ls, composite, "composite definition")
- parse_composite(ls);
- break;
case KW_implements:
CASE_LOCK(ls, implements, "implements definition")
parse_implements(ls, type == EOLIAN_CLASS_INTERFACE);
@@ -2200,6 +2158,7 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
const char *required;
char *fnm;
+ eina_strbuf_reset(buf);
eo_lexer_context_push(ls);
parse_name(ls, buf);
required = eina_strbuf_string_get(buf);
@@ -2213,6 +2172,31 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
}
static void
+_composite_add(Eo_Lexer *ls, Eina_Strbuf *buf)
+{
+ eina_strbuf_reset(buf);
+ eo_lexer_context_push(ls);
+ parse_name(ls, buf);
+ const char *nm = eina_strbuf_string_get(buf);
+ char *fnm = database_class_to_filename(nm);
+ if (!eina_hash_find(ls->state->filenames_eo, fnm))
+ {
+ free(fnm);
+ char ebuf[PATH_MAX];
+ eo_lexer_context_restore(ls);
+ snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm);
+ eo_lexer_syntax_error(ls, ebuf);
+ return;
+ }
+ /* do not introduce a dependency */
+ database_defer(ls->state, fnm, EINA_FALSE);
+ free(fnm);
+ ls->klass->composite = eina_list_append(ls->klass->composite,
+ eina_stringshare_add(nm));
+ eo_lexer_context_pop(ls);
+}
+
+static void
parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
{
const char *bnm;
@@ -2312,6 +2296,17 @@ tags_done:
_inherit_dep(ls, ibuf, EINA_FALSE);
while (test_next(ls, ','));
}
+
+ if (ls->t.kw == KW_composite)
+ {
+ if (type == EOLIAN_CLASS_INTERFACE)
+ eo_lexer_syntax_error(ls, "composite not allowed in interfaces");
+ eo_lexer_get(ls);
+ do
+ _composite_add(ls, ibuf);
+ while (test_next(ls, ','));
+ }
+
eo_lexer_dtor_pop(ls);
}
inherit_done: