summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 14:24:16 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 15:07:31 +0100
commita39d2e8fe5dc1da9903b2a6e7b9d079dd6621aa0 (patch)
treeb3a8eec01c678a2a6be72ff423f856f1eb008556 /src
parenta25327c62e38afa52b62b70c184fd6d2c217d99a (diff)
eolian: move filenames hashes to state
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/eo_lexer.c2
-rw-r--r--src/lib/eolian/eo_parser.c10
-rw-r--r--src/lib/eolian/eolian_database.c33
-rw-r--r--src/lib/eolian/eolian_database.h6
4 files changed, 24 insertions, 27 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index e7ed6b1b20..71942504dd 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -275,7 +275,7 @@ doc_ref_class(const char *cname)
275 *p = tolower(*p); 275 *p = tolower(*p);
276 } 276 }
277 memcpy(buf + clen, ".eo", sizeof(".eo")); 277 memcpy(buf + clen, ".eo", sizeof(".eo"));
278 const char *eop = eina_hash_find(_filenames, buf); 278 const char *eop = eina_hash_find(_state->filenames_eo, buf);
279 if (!eop) 279 if (!eop)
280 return; 280 return;
281 eina_hash_set(_defereos, buf, eop); 281 eina_hash_set(_defereos, buf, eop);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 8d24dd3c67..daf64cbcdb 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -822,7 +822,7 @@ parse_type_void(Eo_Lexer *ls)
822 fnm = database_class_to_filename(nm); 822 fnm = database_class_to_filename(nm);
823 if (!compare_class_file(bnm, fnm)) 823 if (!compare_class_file(bnm, fnm))
824 { 824 {
825 const char *fname = eina_hash_find(_filenames, fnm); 825 const char *fname = eina_hash_find(_state->filenames_eo, fnm);
826 eina_stringshare_del(bnm); 826 eina_stringshare_del(bnm);
827 free(fnm); 827 free(fnm);
828 if (fname) 828 if (fname)
@@ -1530,7 +1530,7 @@ parse_part(Eo_Lexer *ls)
1530 if (!compare_class_file(bnm, fnm)) 1530 if (!compare_class_file(bnm, fnm))
1531 { 1531 {
1532 Eolian_Class *dep = NULL; 1532 Eolian_Class *dep = NULL;
1533 const char *fname = eina_hash_find(_filenames, fnm); 1533 const char *fname = eina_hash_find(_state->filenames_eo, fnm);
1534 eina_stringshare_del(bnm); 1534 eina_stringshare_del(bnm);
1535 free(fnm); 1535 free(fnm);
1536 if (fname) 1536 if (fname)
@@ -2038,7 +2038,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2038 eo_lexer_syntax_error(ls, ebuf); 2038 eo_lexer_syntax_error(ls, ebuf);
2039 return; /* unreachable (longjmp above), make static analysis shut up */ 2039 return; /* unreachable (longjmp above), make static analysis shut up */
2040 } 2040 }
2041 fname = eina_hash_find(_filenames, fnm); 2041 fname = eina_hash_find(_state->filenames_eo, fnm);
2042 free(fnm); 2042 free(fnm);
2043 if (!fname) 2043 if (!fname)
2044 { 2044 {
@@ -2177,11 +2177,11 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2177 check(ls, TOK_VALUE); 2177 check(ls, TOK_VALUE);
2178 eina_strbuf_append(buf, ls->t.value.s); 2178 eina_strbuf_append(buf, ls->t.value.s);
2179 eina_strbuf_append(buf, ".eot"); 2179 eina_strbuf_append(buf, ".eot");
2180 if (!(found = eina_hash_find(_tfilenames, eina_strbuf_string_get(buf)))) 2180 if (!(found = eina_hash_find(_state->filenames_eot, eina_strbuf_string_get(buf))))
2181 { 2181 {
2182 size_t buflen = eina_strbuf_length_get(buf); 2182 size_t buflen = eina_strbuf_length_get(buf);
2183 eina_strbuf_remove(buf, buflen - 1, buflen); 2183 eina_strbuf_remove(buf, buflen - 1, buflen);
2184 if (!(found = eina_hash_find(_filenames, eina_strbuf_string_get(buf)))) 2184 if (!(found = eina_hash_find(_state->filenames_eo, eina_strbuf_string_get(buf))))
2185 { 2185 {
2186 pop_strbuf(ls); 2186 pop_strbuf(ls);
2187 snprintf(errbuf, sizeof(errbuf), 2187 snprintf(errbuf, sizeof(errbuf),
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 3ed3d6777a..6db5c0553c 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -8,8 +8,6 @@
8#include "eolian_database.h" 8#include "eolian_database.h"
9#include "eolian_priv.h" 9#include "eolian_priv.h"
10 10
11Eina_Hash *_filenames = NULL;
12Eina_Hash *_tfilenames = NULL;
13Eina_Hash *_decls = NULL; 11Eina_Hash *_decls = NULL;
14Eina_Hash *_declsf = NULL; 12Eina_Hash *_declsf = NULL;
15Eina_Hash *_units = NULL; 13Eina_Hash *_units = NULL;
@@ -36,8 +34,6 @@ database_init()
36{ 34{
37 if (_database_init_count > 0) return ++_database_init_count; 35 if (_database_init_count > 0) return ++_database_init_count;
38 eina_init(); 36 eina_init();
39 _filenames = eina_hash_string_small_new(free);
40 _tfilenames = eina_hash_string_small_new(free);
41 _decls = eina_hash_stringshared_new(free); 37 _decls = eina_hash_stringshared_new(free);
42 _declsf = eina_hash_stringshared_new(_hashlist_free); 38 _declsf = eina_hash_stringshared_new(_hashlist_free);
43 _parsedeos = eina_hash_string_small_new(NULL); 39 _parsedeos = eina_hash_string_small_new(NULL);
@@ -61,8 +57,6 @@ database_shutdown()
61 if (_database_init_count == 0) 57 if (_database_init_count == 0)
62 { 58 {
63 eolian_free(_state); _state = NULL; 59 eolian_free(_state); _state = NULL;
64 eina_hash_free(_filenames ); _filenames = NULL;
65 eina_hash_free(_tfilenames); _tfilenames = NULL;
66 eina_hash_free(_decls ); _decls = NULL; 60 eina_hash_free(_decls ); _decls = NULL;
67 eina_hash_free(_declsf ); _declsf = NULL; 61 eina_hash_free(_declsf ); _declsf = NULL;
68 eina_hash_free(_parsedeos ); _parsedeos = NULL; 62 eina_hash_free(_parsedeos ); _parsedeos = NULL;
@@ -613,6 +607,9 @@ eolian_new(void)
613 607
614 database_unit_init(&state->unit, NULL); 608 database_unit_init(&state->unit, NULL);
615 609
610 state->filenames_eo = eina_hash_string_small_new(free);
611 state->filenames_eot = eina_hash_string_small_new(free);
612
616 state->classes_f = eina_hash_stringshared_new(NULL); 613 state->classes_f = eina_hash_stringshared_new(NULL);
617 state->aliases_f = eina_hash_stringshared_new(_hashlist_free); 614 state->aliases_f = eina_hash_stringshared_new(_hashlist_free);
618 state->structs_f = eina_hash_stringshared_new(_hashlist_free); 615 state->structs_f = eina_hash_stringshared_new(_hashlist_free);
@@ -656,7 +653,7 @@ _scan_cb(const char *name, const char *path, void *data EINA_UNUSED)
656{ 653{
657 Eina_Bool is_eo = eina_str_has_suffix(name, EO_SUFFIX); 654 Eina_Bool is_eo = eina_str_has_suffix(name, EO_SUFFIX);
658 if (!is_eo && !eina_str_has_suffix(name, EOT_SUFFIX)) return; 655 if (!is_eo && !eina_str_has_suffix(name, EOT_SUFFIX)) return;
659 eina_hash_add(is_eo ? _filenames : _tfilenames, 656 eina_hash_add(is_eo ? _state->filenames_eo : _state->filenames_eot,
660 eina_stringshare_add(name), join_path(path, name)); 657 eina_stringshare_add(name), join_path(path, name));
661} 658}
662 659
@@ -710,7 +707,7 @@ _eolian_file_parse_nodep(const char *filepath)
710 _eolian_log("file '%s' doesn't have a correct extension", filepath); 707 _eolian_log("file '%s' doesn't have a correct extension", filepath);
711 return EINA_FALSE; 708 return EINA_FALSE;
712 } 709 }
713 if (!(eopath = eina_hash_find(is_eo ? _filenames : _tfilenames, filepath))) 710 if (!(eopath = eina_hash_find(is_eo ? _state->filenames_eo : _state->filenames_eot, filepath)))
714 { 711 {
715 char *vpath = eina_file_path_sanitize(filepath); 712 char *vpath = eina_file_path_sanitize(filepath);
716 Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo, NULL); 713 Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo, NULL);
@@ -777,7 +774,7 @@ eolian_all_eot_files_parse(Eolian *state EINA_UNUSED)
777 if (_database_init_count <= 0) 774 if (_database_init_count <= 0)
778 return EINA_FALSE; 775 return EINA_FALSE;
779 776
780 eina_hash_foreach(_tfilenames, _tfile_parse, &ret); 777 eina_hash_foreach(_state->filenames_eot, _tfile_parse, &ret);
781 778
782 /* FIXME: pass unit properly */ 779 /* FIXME: pass unit properly */
783 if (ret && !database_validate(NULL)) 780 if (ret && !database_validate(NULL))
@@ -802,7 +799,7 @@ eolian_all_eo_files_parse(Eolian *state EINA_UNUSED)
802 if (_database_init_count <= 0) 799 if (_database_init_count <= 0)
803 return EINA_FALSE; 800 return EINA_FALSE;
804 801
805 eina_hash_foreach(_filenames, _file_parse, &ret); 802 eina_hash_foreach(_state->filenames_eo, _file_parse, &ret);
806 803
807 /* FIXME: pass unit properly */ 804 /* FIXME: pass unit properly */
808 if (ret && !database_validate(NULL)) 805 if (ret && !database_validate(NULL))
@@ -814,27 +811,27 @@ eolian_all_eo_files_parse(Eolian *state EINA_UNUSED)
814EAPI Eina_Iterator * 811EAPI Eina_Iterator *
815eolian_all_eot_files_get(Eolian *state EINA_UNUSED) 812eolian_all_eot_files_get(Eolian *state EINA_UNUSED)
816{ 813{
817 if (!_tfilenames) return NULL; 814 if (!_state) return NULL;
818 return eina_hash_iterator_key_new(_tfilenames); 815 return eina_hash_iterator_key_new(_state->filenames_eot);
819} 816}
820 817
821EAPI Eina_Iterator * 818EAPI Eina_Iterator *
822eolian_all_eo_files_get(Eolian *state EINA_UNUSED) 819eolian_all_eo_files_get(Eolian *state EINA_UNUSED)
823{ 820{
824 if (!_filenames) return NULL; 821 if (!_state) return NULL;
825 return eina_hash_iterator_key_new(_filenames); 822 return eina_hash_iterator_key_new(_state->filenames_eo);
826} 823}
827 824
828EAPI Eina_Iterator * 825EAPI Eina_Iterator *
829eolian_all_eot_file_paths_get(Eolian *state EINA_UNUSED) 826eolian_all_eot_file_paths_get(Eolian *state EINA_UNUSED)
830{ 827{
831 if (!_tfilenames) return NULL; 828 if (!_state) return NULL;
832 return eina_hash_iterator_data_new(_tfilenames); 829 return eina_hash_iterator_data_new(_state->filenames_eot);
833} 830}
834 831
835EAPI Eina_Iterator * 832EAPI Eina_Iterator *
836eolian_all_eo_file_paths_get(Eolian *state EINA_UNUSED) 833eolian_all_eo_file_paths_get(Eolian *state EINA_UNUSED)
837{ 834{
838 if (!_filenames) return NULL; 835 if (!_state) return NULL;
839 return eina_hash_iterator_data_new(_filenames); 836 return eina_hash_iterator_data_new(_state->filenames_eo);
840} 837}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 3bc701c0fc..529681de3f 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -31,9 +31,6 @@ extern Eina_Prefix *_eolian_prefix;
31#endif 31#endif
32#define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__) 32#define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__)
33 33
34extern Eina_Hash *_filenames; /* Hash: filename without extension -> full path */
35extern Eina_Hash *_tfilenames;
36
37/* a hash holding all declarations, for redef checking etc */ 34/* a hash holding all declarations, for redef checking etc */
38extern Eina_Hash *_decls; 35extern Eina_Hash *_decls;
39extern Eina_Hash *_declsf; 36extern Eina_Hash *_declsf;
@@ -66,6 +63,9 @@ struct _Eolian
66{ 63{
67 Eolian_Unit unit; 64 Eolian_Unit unit;
68 65
66 Eina_Hash *filenames_eo; /* filename to full path mapping */
67 Eina_Hash *filenames_eot;
68
69 Eina_Hash *classes_f; 69 Eina_Hash *classes_f;
70 Eina_Hash *aliases_f; 70 Eina_Hash *aliases_f;
71 Eina_Hash *structs_f; 71 Eina_Hash *structs_f;