diff options
author | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2015-05-20 15:15:53 +0100 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2015-05-20 15:23:33 +0100 |
commit | dc4c0c64f8e73622c4e5290f12e67c6db32ccb1b (patch) | |
tree | ba2fdbde1fe3f14a5a33d42b3a25eaa64692bb19 | |
parent | 5ca43e58c020932b8cd89b7b1641a4879243258f (diff) |
eolian: unify inherits and dependencies for parsing purposes
-rw-r--r-- | src/lib/eolian/eo_parser.c | 62 | ||||
-rw-r--r-- | src/lib/eolian/eolian_database.c | 25 |
2 files changed, 46 insertions, 41 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 66886f6ced..34bf9b2145 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c | |||
@@ -181,22 +181,6 @@ parse_name(Eo_Lexer *ls, Eina_Strbuf *buf) | |||
181 | } | 181 | } |
182 | 182 | ||
183 | static void | 183 | static void |
184 | parse_name_list(Eo_Lexer *ls, Eina_List **out) | ||
185 | { | ||
186 | Eina_Strbuf *buf = push_strbuf(ls); | ||
187 | parse_name(ls, buf); | ||
188 | *out = eina_list_append(*out, | ||
189 | eina_stringshare_add(eina_strbuf_string_get(buf))); | ||
190 | while (test_next(ls, ',')) | ||
191 | { | ||
192 | parse_name(ls, buf); | ||
193 | *out = eina_list_append(*out, | ||
194 | eina_stringshare_add(eina_strbuf_string_get(buf))); | ||
195 | } | ||
196 | pop_strbuf(ls); | ||
197 | } | ||
198 | |||
199 | static void | ||
200 | _fill_name(const char *input, Eina_Stringshare **full_name, | 184 | _fill_name(const char *input, Eina_Stringshare **full_name, |
201 | Eina_Stringshare **name, Eina_List **namespaces) | 185 | Eina_Stringshare **name, Eina_List **namespaces) |
202 | { | 186 | { |
@@ -830,8 +814,7 @@ parse_type_void(Eo_Lexer *ls) | |||
830 | free(fnm); | 814 | free(fnm); |
831 | if (fname) | 815 | if (fname) |
832 | { | 816 | { |
833 | if (!eolian_class_get_by_name(nm)) | 817 | _append_dep(ls, fname, nm, dline, dcol); |
834 | _append_dep(ls, fname, nm, dline, dcol); | ||
835 | def->type = EOLIAN_TYPE_CLASS; | 818 | def->type = EOLIAN_TYPE_CLASS; |
836 | } | 819 | } |
837 | } | 820 | } |
@@ -1733,6 +1716,41 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type) | |||
1733 | } | 1716 | } |
1734 | 1717 | ||
1735 | static void | 1718 | static void |
1719 | _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf) | ||
1720 | { | ||
1721 | int dline = ls->line_number, dcol = ls->column; | ||
1722 | const char *fname, *iname; | ||
1723 | char *fnm; | ||
1724 | eina_strbuf_reset(buf); | ||
1725 | eo_lexer_context_push(ls); | ||
1726 | parse_name(ls, buf); | ||
1727 | iname = eina_strbuf_string_get(buf); | ||
1728 | fnm = database_class_to_filename(iname); | ||
1729 | if (compare_class_file(fnm, ls->filename)) | ||
1730 | { | ||
1731 | char ebuf[PATH_MAX]; | ||
1732 | free(fnm); | ||
1733 | eo_lexer_context_restore(ls); | ||
1734 | snprintf(ebuf, sizeof(ebuf), "class '%s' cannot inherit from itself", | ||
1735 | iname); | ||
1736 | eo_lexer_syntax_error(ls, ebuf); | ||
1737 | } | ||
1738 | fname = eina_hash_find(_filenames, fnm); | ||
1739 | free(fnm); | ||
1740 | if (!fname) | ||
1741 | { | ||
1742 | char ebuf[PATH_MAX]; | ||
1743 | eo_lexer_context_restore(ls); | ||
1744 | snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'", iname); | ||
1745 | eo_lexer_syntax_error(ls, ebuf); | ||
1746 | } | ||
1747 | _append_dep(ls, fname, iname, dline, dcol); | ||
1748 | ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, | ||
1749 | eina_stringshare_add(iname)); | ||
1750 | eo_lexer_context_pop(ls); | ||
1751 | } | ||
1752 | |||
1753 | static void | ||
1736 | parse_class(Eo_Lexer *ls, Eolian_Class_Type type) | 1754 | parse_class(Eo_Lexer *ls, Eolian_Class_Type type) |
1737 | { | 1755 | { |
1738 | Eolian_Declaration *decl; | 1756 | Eolian_Declaration *decl; |
@@ -1774,7 +1792,13 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type) | |||
1774 | col = ls->column; | 1792 | col = ls->column; |
1775 | check_next(ls, '('); | 1793 | check_next(ls, '('); |
1776 | if (ls->t.token != ')') | 1794 | if (ls->t.token != ')') |
1777 | parse_name_list(ls, &ls->tmp.kls->inherits); | 1795 | { |
1796 | Eina_Strbuf *ibuf = push_strbuf(ls); | ||
1797 | _inherit_dep(ls, ibuf); | ||
1798 | while (test_next(ls, ',')) | ||
1799 | _inherit_dep(ls, ibuf); | ||
1800 | pop_strbuf(ls); | ||
1801 | } | ||
1778 | check_match(ls, ')', '(', line, col); | 1802 | check_match(ls, ')', '(', line, col); |
1779 | } | 1803 | } |
1780 | line = ls->line_number; | 1804 | line = ls->line_number; |
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 9e71ec0140..9d8f1518f8 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c | |||
@@ -264,10 +264,10 @@ eolian_eo_file_parse(const char *filepath) | |||
264 | } | 264 | } |
265 | } | 265 | } |
266 | free(bfiledup); | 266 | free(bfiledup); |
267 | /* parse dependencies first */ | 267 | /* parse dependencies first (that includes inherits) */ |
268 | depl = eina_hash_find(_depclasses, eolian_class_file_get(class)); | 268 | depl = eina_hash_find(_depclasses, eolian_class_file_get(class)); |
269 | if (!depl) | 269 | if (!depl) |
270 | goto inherits; | 270 | goto impls; |
271 | eina_hash_set(_depclasses, eolian_class_file_get(class), NULL); | 271 | eina_hash_set(_depclasses, eolian_class_file_get(class), NULL); |
272 | EINA_LIST_FREE(depl, dep) | 272 | EINA_LIST_FREE(depl, dep) |
273 | { | 273 | { |
@@ -287,26 +287,7 @@ free: | |||
287 | } | 287 | } |
288 | if (failed_dep) | 288 | if (failed_dep) |
289 | goto error; | 289 | goto error; |
290 | /* and then inherits */ | 290 | impls: |
291 | inherits: | ||
292 | itr = eolian_class_inherits_get(class); | ||
293 | EINA_ITERATOR_FOREACH(itr, inherit_name) | ||
294 | { | ||
295 | if (!eolian_class_get_by_name(inherit_name)) | ||
296 | { | ||
297 | char *filename = database_class_to_filename(inherit_name); | ||
298 | filepath = eina_hash_find(_filenames, filename); | ||
299 | free(filename); | ||
300 | if (!filepath) | ||
301 | { | ||
302 | fprintf(stderr, "eolian: unable to find a file for class '%s'\n", | ||
303 | inherit_name); | ||
304 | goto error; | ||
305 | } | ||
306 | if (!eolian_eo_file_parse(filepath)) goto error; | ||
307 | } | ||
308 | } | ||
309 | eina_iterator_free(itr); | ||
310 | itr = eolian_class_implements_get(class); | 291 | itr = eolian_class_implements_get(class); |
311 | EINA_ITERATOR_FOREACH(itr, impl) | 292 | EINA_ITERATOR_FOREACH(itr, impl) |
312 | { | 293 | { |