summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 14:17:59 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 15:07:31 +0100
commita25327c62e38afa52b62b70c184fd6d2c217d99a (patch)
tree33049ff4a3b52ab450725c6e0911bdf20a893408 /src
parent21db23f702c9cd0592774c6f5526ecebdc8cf817 (diff)
eolian: move constants to temporary state
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_validate.c2
-rw-r--r--src/lib/eolian/database_var.c6
-rw-r--r--src/lib/eolian/database_var_api.c10
-rw-r--r--src/lib/eolian/eolian_database.c17
-rw-r--r--src/lib/eolian/eolian_database.h3
5 files changed, 16 insertions, 22 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index beea545404..6ecafb532e 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -544,7 +544,7 @@ database_validate(const Eolian_Unit *src)
544 if (!rt.succ) 544 if (!rt.succ)
545 return EINA_FALSE; 545 return EINA_FALSE;
546 546
547 eina_hash_foreach(_constants, (Eina_Hash_Foreach)_var_map_cb, &rt); 547 eina_hash_foreach(_state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
548 if (!rt.succ) 548 if (!rt.succ)
549 return EINA_FALSE; 549 return EINA_FALSE;
550 550
diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c
index ea7f9015f2..0441d427f9 100644
--- a/src/lib/eolian/database_var.c
+++ b/src/lib/eolian/database_var.c
@@ -34,9 +34,9 @@ database_var_global_add(Eolian_Variable *var)
34static void 34static void
35database_var_constant_add(Eolian_Variable *var) 35database_var_constant_add(Eolian_Variable *var)
36{ 36{
37 eina_hash_set(_constants, var->full_name, var); 37 eina_hash_set(_state->unit.constants, var->full_name, var);
38 eina_hash_set(_constantsf, var->base.file, eina_list_append 38 eina_hash_set(_state->constants_f, var->base.file, eina_list_append
39 ((Eina_List*)eina_hash_find(_constantsf, var->base.file), var)); 39 ((Eina_List*)eina_hash_find(_state->constants_f, var->base.file), var));
40 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var); 40 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
41} 41}
42 42
diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c
index 6123ee027e..e8a58d3e20 100644
--- a/src/lib/eolian/database_var_api.c
+++ b/src/lib/eolian/database_var_api.c
@@ -20,9 +20,9 @@ EAPI const Eolian_Variable *
20eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 20eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
21 const char *name) 21 const char *name)
22{ 22{
23 if (!_constants) return NULL; 23 if (!_state) return NULL;
24 Eina_Stringshare *shr = eina_stringshare_add(name); 24 Eina_Stringshare *shr = eina_stringshare_add(name);
25 Eolian_Variable *v = eina_hash_find(_constants, shr); 25 Eolian_Variable *v = eina_hash_find(_state->unit.constants, shr);
26 eina_stringshare_del(shr); 26 eina_stringshare_del(shr);
27 return v; 27 return v;
28} 28}
@@ -43,9 +43,9 @@ EAPI Eina_Iterator *
43eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 43eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
44 const char *fname) 44 const char *fname)
45{ 45{
46 if (!_constantsf) return NULL; 46 if (!_state) return NULL;
47 Eina_Stringshare *shr = eina_stringshare_add(fname); 47 Eina_Stringshare *shr = eina_stringshare_add(fname);
48 Eina_List *l = eina_hash_find(_constantsf, shr); 48 Eina_List *l = eina_hash_find(_state->constants_f, shr);
49 eina_stringshare_del(shr); 49 eina_stringshare_del(shr);
50 if (!l) return NULL; 50 if (!l) return NULL;
51 return eina_list_iterator_new(l); 51 return eina_list_iterator_new(l);
@@ -54,7 +54,7 @@ eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
54EAPI Eina_Iterator * 54EAPI Eina_Iterator *
55eolian_variable_all_constants_get(const Eolian_Unit *unit EINA_UNUSED) 55eolian_variable_all_constants_get(const Eolian_Unit *unit EINA_UNUSED)
56{ 56{
57 return (_constants ? eina_hash_iterator_data_new(_constants) : NULL); 57 return (_state ? eina_hash_iterator_data_new(_state->unit.constants) : NULL);
58} 58}
59 59
60EAPI Eina_Iterator * 60EAPI Eina_Iterator *
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 582690582d..3ed3d6777a 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 *_constants = NULL;
12Eina_Hash *_constantsf = NULL;
13Eina_Hash *_filenames = NULL; 11Eina_Hash *_filenames = NULL;
14Eina_Hash *_tfilenames = NULL; 12Eina_Hash *_tfilenames = NULL;
15Eina_Hash *_decls = NULL; 13Eina_Hash *_decls = NULL;
@@ -38,8 +36,6 @@ database_init()
38{ 36{
39 if (_database_init_count > 0) return ++_database_init_count; 37 if (_database_init_count > 0) return ++_database_init_count;
40 eina_init(); 38 eina_init();
41 _constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
42 _constantsf = eina_hash_stringshared_new(_hashlist_free);
43 _filenames = eina_hash_string_small_new(free); 39 _filenames = eina_hash_string_small_new(free);
44 _tfilenames = eina_hash_string_small_new(free); 40 _tfilenames = eina_hash_string_small_new(free);
45 _decls = eina_hash_stringshared_new(free); 41 _decls = eina_hash_stringshared_new(free);
@@ -65,8 +61,6 @@ database_shutdown()
65 if (_database_init_count == 0) 61 if (_database_init_count == 0)
66 { 62 {
67 eolian_free(_state); _state = NULL; 63 eolian_free(_state); _state = NULL;
68 eina_hash_free(_constants ); _constants = NULL;
69 eina_hash_free(_constantsf); _constantsf = NULL;
70 eina_hash_free(_filenames ); _filenames = NULL; 64 eina_hash_free(_filenames ); _filenames = NULL;
71 eina_hash_free(_tfilenames); _tfilenames = NULL; 65 eina_hash_free(_tfilenames); _tfilenames = NULL;
72 eina_hash_free(_decls ); _decls = NULL; 66 eina_hash_free(_decls ); _decls = NULL;
@@ -619,11 +613,12 @@ eolian_new(void)
619 613
620 database_unit_init(&state->unit, NULL); 614 database_unit_init(&state->unit, NULL);
621 615
622 state->classes_f = eina_hash_stringshared_new(NULL); 616 state->classes_f = eina_hash_stringshared_new(NULL);
623 state->aliases_f = eina_hash_stringshared_new(_hashlist_free); 617 state->aliases_f = eina_hash_stringshared_new(_hashlist_free);
624 state->structs_f = eina_hash_stringshared_new(_hashlist_free); 618 state->structs_f = eina_hash_stringshared_new(_hashlist_free);
625 state->enums_f = eina_hash_stringshared_new(_hashlist_free); 619 state->enums_f = eina_hash_stringshared_new(_hashlist_free);
626 state->globals_f = eina_hash_stringshared_new(_hashlist_free); 620 state->globals_f = eina_hash_stringshared_new(_hashlist_free);
621 state->constants_f = eina_hash_stringshared_new(_hashlist_free);
627 622
628 return state; 623 return state;
629} 624}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index fc7735600c..3bc701c0fc 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -31,8 +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 *_constants;
35extern Eina_Hash *_constantsf;
36extern Eina_Hash *_filenames; /* Hash: filename without extension -> full path */ 34extern Eina_Hash *_filenames; /* Hash: filename without extension -> full path */
37extern Eina_Hash *_tfilenames; 35extern Eina_Hash *_tfilenames;
38 36
@@ -73,6 +71,7 @@ struct _Eolian
73 Eina_Hash *structs_f; 71 Eina_Hash *structs_f;
74 Eina_Hash *enums_f; 72 Eina_Hash *enums_f;
75 Eina_Hash *globals_f; 73 Eina_Hash *globals_f;
74 Eina_Hash *constants_f;
76}; 75};
77 76
78typedef struct _Eolian_Object 77typedef struct _Eolian_Object