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)
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)
1959} 1959}
1960 1960
1961static void 1961static void
1962parse_composite(Eo_Lexer *ls)
1963{
1964 int line, col;
1965 if (ls->klass->type == EOLIAN_CLASS_INTERFACE)
1966 eo_lexer_syntax_error(ls, "composite section not allowed in interfaces");
1967 eo_lexer_get(ls);
1968 line = ls->line_number, col = ls->column;
1969 check_next(ls, '{');
1970 while (ls->t.token != '}')
1971 {
1972 Eina_Strbuf *buf = eina_strbuf_new();
1973 eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
1974 eo_lexer_context_push(ls);
1975 parse_name(ls, buf);
1976 const char *nm = eina_strbuf_string_get(buf);
1977 char *fnm = database_class_to_filename(nm);
1978 if (!eina_hash_find(ls->state->filenames_eo, fnm))
1979 {
1980 free(fnm);
1981 char ebuf[PATH_MAX];
1982 eo_lexer_context_restore(ls);
1983 snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm);
1984 eo_lexer_syntax_error(ls, ebuf);
1985 return;
1986 }
1987 /* do not introduce a dependency */
1988 database_defer(ls->state, fnm, EINA_FALSE);
1989 free(fnm);
1990 ls->klass->composite = eina_list_append(ls->klass->composite,
1991 eina_stringshare_add(nm));
1992 eo_lexer_dtor_pop(ls);
1993 check_next(ls, ';');
1994 }
1995 check_match(ls, '}', '{', line, col);
1996}
1997
1998static void
1999parse_implements(Eo_Lexer *ls, Eina_Bool iface) 1962parse_implements(Eo_Lexer *ls, Eina_Bool iface)
2000{ 1963{
2001 int line, col; 1964 int line, col;
@@ -2065,7 +2028,6 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
2065 has_data = EINA_FALSE, 2028 has_data = EINA_FALSE,
2066 has_methods = EINA_FALSE, 2029 has_methods = EINA_FALSE,
2067 has_parts = EINA_FALSE, 2030 has_parts = EINA_FALSE,
2068 has_composite = EINA_FALSE,
2069 has_implements = EINA_FALSE, 2031 has_implements = EINA_FALSE,
2070 has_constructors = EINA_FALSE, 2032 has_constructors = EINA_FALSE,
2071 has_events = EINA_FALSE; 2033 has_events = EINA_FALSE;
@@ -2112,10 +2074,6 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
2112 CASE_LOCK(ls, parts, "parts definition") 2074 CASE_LOCK(ls, parts, "parts definition")
2113 parse_parts(ls); 2075 parse_parts(ls);
2114 break; 2076 break;
2115 case KW_composite:
2116 CASE_LOCK(ls, composite, "composite definition")
2117 parse_composite(ls);
2118 break;
2119 case KW_implements: 2077 case KW_implements:
2120 CASE_LOCK(ls, implements, "implements definition") 2078 CASE_LOCK(ls, implements, "implements definition")
2121 parse_implements(ls, type == EOLIAN_CLASS_INTERFACE); 2079 parse_implements(ls, type == EOLIAN_CLASS_INTERFACE);
@@ -2200,6 +2158,7 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2200 const char *required; 2158 const char *required;
2201 char *fnm; 2159 char *fnm;
2202 2160
2161 eina_strbuf_reset(buf);
2203 eo_lexer_context_push(ls); 2162 eo_lexer_context_push(ls);
2204 parse_name(ls, buf); 2163 parse_name(ls, buf);
2205 required = eina_strbuf_string_get(buf); 2164 required = eina_strbuf_string_get(buf);
@@ -2213,6 +2172,31 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2213} 2172}
2214 2173
2215static void 2174static void
2175_composite_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2176{
2177 eina_strbuf_reset(buf);
2178 eo_lexer_context_push(ls);
2179 parse_name(ls, buf);
2180 const char *nm = eina_strbuf_string_get(buf);
2181 char *fnm = database_class_to_filename(nm);
2182 if (!eina_hash_find(ls->state->filenames_eo, fnm))
2183 {
2184 free(fnm);
2185 char ebuf[PATH_MAX];
2186 eo_lexer_context_restore(ls);
2187 snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm);
2188 eo_lexer_syntax_error(ls, ebuf);
2189 return;
2190 }
2191 /* do not introduce a dependency */
2192 database_defer(ls->state, fnm, EINA_FALSE);
2193 free(fnm);
2194 ls->klass->composite = eina_list_append(ls->klass->composite,
2195 eina_stringshare_add(nm));
2196 eo_lexer_context_pop(ls);
2197}
2198
2199static void
2216parse_class(Eo_Lexer *ls, Eolian_Class_Type type) 2200parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
2217{ 2201{
2218 const char *bnm; 2202 const char *bnm;
@@ -2312,6 +2296,17 @@ tags_done:
2312 _inherit_dep(ls, ibuf, EINA_FALSE); 2296 _inherit_dep(ls, ibuf, EINA_FALSE);
2313 while (test_next(ls, ',')); 2297 while (test_next(ls, ','));
2314 } 2298 }
2299
2300 if (ls->t.kw == KW_composite)
2301 {
2302 if (type == EOLIAN_CLASS_INTERFACE)
2303 eo_lexer_syntax_error(ls, "composite not allowed in interfaces");
2304 eo_lexer_get(ls);
2305 do
2306 _composite_add(ls, ibuf);
2307 while (test_next(ls, ','));
2308 }
2309
2315 eo_lexer_dtor_pop(ls); 2310 eo_lexer_dtor_pop(ls);
2316 } 2311 }
2317inherit_done: 2312inherit_done: