summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-11-08 16:12:40 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-11-08 16:12:40 +0100
commit5c2611d93a58bff942e49202053cad3e0090540d (patch)
treece46d09a007fdbd572612443f9081b7433c806e6
parent7a7abb043add0af083c46305824d8c341daf2374 (diff)
eolian: simplify dependency parsing and cut down on hash lookups
-rw-r--r--src/lib/eolian/eo_parser.c35
-rw-r--r--src/lib/eolian/eo_parser.h2
-rw-r--r--src/lib/eolian/eolian_database.c8
3 files changed, 24 insertions, 21 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index da03709c38..db8878a5c7 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -672,18 +672,20 @@ parse_struct_attrs(Eo_Lexer *ls, Eina_Bool is_enum, Eina_Bool *is_extern,
672 } 672 }
673} 673}
674 674
675static void 675static Eolian_Class *
676_parse_dep(Eo_Lexer *ls, const char *fname, const char *name) 676_parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
677{ 677{
678 if (eina_hash_find(_parsingeos, fname)) 678 if (eina_hash_find(_parsingeos, fname))
679 return; 679 return NULL;
680 if (!eo_parser_database_fill(fname, EINA_FALSE)) 680 Eolian_Class *cl = NULL;
681 if (!eo_parser_database_fill(fname, EINA_FALSE, &cl) || !cl)
681 { 682 {
682 char buf[PATH_MAX]; 683 char buf[PATH_MAX];
683 eo_lexer_context_restore(ls); 684 eo_lexer_context_restore(ls);
684 snprintf(buf, sizeof(buf), "error parsing dependency '%s'", name); 685 snprintf(buf, sizeof(buf), "error parsing dependency '%s'", name);
685 eo_lexer_syntax_error(ls, buf); 686 eo_lexer_syntax_error(ls, buf);
686 } 687 }
688 return cl;
687} 689}
688 690
689static Eolian_Type * 691static Eolian_Type *
@@ -1515,13 +1517,12 @@ parse_part(Eo_Lexer *ls)
1515 char *fnm = database_class_to_filename(nm); 1517 char *fnm = database_class_to_filename(nm);
1516 if (!compare_class_file(bnm, fnm)) 1518 if (!compare_class_file(bnm, fnm))
1517 { 1519 {
1520 Eolian_Class *dep = NULL;
1518 const char *fname = eina_hash_find(_filenames, fnm); 1521 const char *fname = eina_hash_find(_filenames, fnm);
1519 eina_stringshare_del(bnm); 1522 eina_stringshare_del(bnm);
1520 free(fnm); 1523 free(fnm);
1521 if (fname) 1524 if (fname)
1522 _parse_dep(ls, fname, nm); 1525 dep = _parse_dep(ls, fname, nm);
1523 /* FIXME: pass unit properly */
1524 Eolian_Class *dep = (Eolian_Class *)eolian_class_get_by_name(NULL, nm);
1525 if (!dep) 1526 if (!dep)
1526 { 1527 {
1527 char ebuf[PATH_MAX]; 1528 char ebuf[PATH_MAX];
@@ -2031,9 +2032,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2031 snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'", iname); 2032 snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'", iname);
2032 eo_lexer_syntax_error(ls, ebuf); 2033 eo_lexer_syntax_error(ls, ebuf);
2033 } 2034 }
2034 _parse_dep(ls, fname, iname); 2035 Eolian_Class *dep = _parse_dep(ls, fname, iname);
2035 /* FIXME: pass unit properly */
2036 Eolian_Class *dep = (Eolian_Class *)eolian_class_get_by_name(NULL, iname);
2037 if (!dep) 2036 if (!dep)
2038 { 2037 {
2039 char ebuf[PATH_MAX]; 2038 char ebuf[PATH_MAX];
@@ -2185,7 +2184,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2185 eo_lexer_syntax_error(ls, errbuf); 2184 eo_lexer_syntax_error(ls, errbuf);
2186 } 2185 }
2187 pop_strbuf(ls); 2186 pop_strbuf(ls);
2188 if (!eo_parser_database_fill(found, !is_eo)) 2187 if (!eo_parser_database_fill(found, !is_eo, NULL))
2189 { 2188 {
2190 pop_strbuf(ls); 2189 pop_strbuf(ls);
2191 snprintf(errbuf, sizeof(errbuf), 2190 snprintf(errbuf, sizeof(errbuf),
@@ -2498,10 +2497,14 @@ end:
2498} 2497}
2499 2498
2500Eina_Bool 2499Eina_Bool
2501eo_parser_database_fill(const char *filename, Eina_Bool eot) 2500eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **fcl)
2502{ 2501{
2503 if (eina_hash_find(_parsedeos, filename)) 2502 Eolian_Class *cl = eina_hash_find(_parsedeos, filename);
2504 return EINA_TRUE; 2503 if (cl)
2504 {
2505 if (!eot && fcl) *fcl = cl;
2506 return EINA_TRUE;
2507 }
2505 2508
2506 eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE); 2509 eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE);
2507 2510
@@ -2521,8 +2524,6 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
2521 parse_chunk(ls, eot); 2524 parse_chunk(ls, eot);
2522 if (eot) goto done; 2525 if (eot) goto done;
2523 2526
2524 Eolian_Class *cl;
2525
2526 if (!(cl = ls->tmp.kls)) 2527 if (!(cl = ls->tmp.kls))
2527 { 2528 {
2528 _eolian_log("eolian: no class for file '%s'", filename); 2529 _eolian_log("eolian: no class for file '%s'", filename);
@@ -2539,8 +2540,10 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
2539 eina_hash_set(_classes, cl->full_name, cl); 2540 eina_hash_set(_classes, cl->full_name, cl);
2540 eina_hash_set(_classesf, cl->base.file, cl); 2541 eina_hash_set(_classesf, cl->base.file, cl);
2541 2542
2543 if (fcl) *fcl = cl;
2544
2542done: 2545done:
2543 eina_hash_set(_parsedeos, filename, (void *)EINA_TRUE); 2546 eina_hash_set(_parsedeos, filename, eot ? (void *)EINA_TRUE : cl);
2544 eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE); 2547 eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE);
2545 2548
2546 eo_lexer_free(ls); 2549 eo_lexer_free(ls);
diff --git a/src/lib/eolian/eo_parser.h b/src/lib/eolian/eo_parser.h
index 08f5142388..7179107803 100644
--- a/src/lib/eolian/eo_parser.h
+++ b/src/lib/eolian/eo_parser.h
@@ -3,6 +3,6 @@
3 3
4#include "eo_lexer.h" 4#include "eo_lexer.h"
5 5
6Eina_Bool eo_parser_database_fill(const char *filename, Eina_Bool eot); 6Eina_Bool eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **cl);
7 7
8#endif /* __EO_PARSER_H__ */ \ No newline at end of file 8#endif /* __EO_PARSER_H__ */ \ No newline at end of file
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index eacc5b94fb..0141450275 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -682,11 +682,11 @@ _eolian_file_parse_nodep(const char *filepath)
682 if (!(eopath = eina_hash_find(is_eo ? _filenames : _tfilenames, filepath))) 682 if (!(eopath = eina_hash_find(is_eo ? _filenames : _tfilenames, filepath)))
683 { 683 {
684 char *vpath = eina_file_path_sanitize(filepath); 684 char *vpath = eina_file_path_sanitize(filepath);
685 Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo); 685 Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo, NULL);
686 free(vpath); 686 free(vpath);
687 return ret; 687 return ret;
688 } 688 }
689 return eo_parser_database_fill(eopath, !is_eo); 689 return eo_parser_database_fill(eopath, !is_eo, NULL);
690} 690}
691 691
692static Eina_Bool 692static Eina_Bool
@@ -732,7 +732,7 @@ eolian_file_parse(const char *filepath)
732static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 732static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
733{ 733{
734 Eina_Bool *ret = fdata; 734 Eina_Bool *ret = fdata;
735 if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE); 735 if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE, NULL);
736 if (*ret) *ret = _parse_deferred(); 736 if (*ret) *ret = _parse_deferred();
737 return *ret; 737 return *ret;
738} 738}
@@ -756,7 +756,7 @@ eolian_all_eot_files_parse()
756static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 756static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
757{ 757{
758 Eina_Bool *ret = fdata; 758 Eina_Bool *ret = fdata;
759 if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE); 759 if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE, NULL);
760 if (*ret) *ret = _parse_deferred(); 760 if (*ret) *ret = _parse_deferred();
761 return *ret; 761 return *ret;
762} 762}