summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 14:04:58 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 15:07:31 +0100
commit8428eaa66358de6cb96e6177eb3a9d9489847377 (patch)
tree48115a8cc039b0fb2466f8d53d692247900b5b6b /src
parent9fb3abc662459ed2a0080e68d065556a71d7fe49 (diff)
eolian: store aliases in temporary state
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_class_api.c4
-rw-r--r--src/lib/eolian/database_type.c7
-rw-r--r--src/lib/eolian/database_type_api.c10
-rw-r--r--src/lib/eolian/database_validate.c2
-rw-r--r--src/lib/eolian/eolian_database.c7
-rw-r--r--src/lib/eolian/eolian_database.h3
6 files changed, 14 insertions, 19 deletions
diff --git a/src/lib/eolian/database_class_api.c b/src/lib/eolian/database_class_api.c
index 1cc2a2a679..da43d05e5b 100644
--- a/src/lib/eolian/database_class_api.c
+++ b/src/lib/eolian/database_class_api.c
@@ -35,7 +35,7 @@ EAPI const Eolian_Class *
35eolian_class_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 35eolian_class_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
36 const char *class_name) 36 const char *class_name)
37{ 37{
38 if (!_state->unit.classes) return NULL; 38 if (!_state) return NULL;
39 Eina_Stringshare *shr = eina_stringshare_add(class_name); 39 Eina_Stringshare *shr = eina_stringshare_add(class_name);
40 Eolian_Class *cl = eina_hash_find(_state->unit.classes, shr); 40 Eolian_Class *cl = eina_hash_find(_state->unit.classes, shr);
41 eina_stringshare_del(shr); 41 eina_stringshare_del(shr);
@@ -46,7 +46,7 @@ EAPI const Eolian_Class *
46eolian_class_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 46eolian_class_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
47 const char *file_name) 47 const char *file_name)
48{ 48{
49 if (!_state->classes_f) return NULL; 49 if (!_state) return NULL;
50 Eina_Stringshare *shr = eina_stringshare_add(file_name); 50 Eina_Stringshare *shr = eina_stringshare_add(file_name);
51 Eolian_Class *cl = eina_hash_find(_state->classes_f, shr); 51 Eolian_Class *cl = eina_hash_find(_state->classes_f, shr);
52 eina_stringshare_del(shr); 52 eina_stringshare_del(shr);
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index c71a45452b..0519eb5e5c 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -43,9 +43,10 @@ database_typedecl_del(Eolian_Typedecl *tp)
43void 43void
44database_type_add(Eolian_Typedecl *def) 44database_type_add(Eolian_Typedecl *def)
45{ 45{
46 eina_hash_set(_aliases, def->full_name, def); 46 eina_hash_set(_state->unit.aliases, def->full_name, def);
47 eina_hash_set(_aliasesf, def->base.file, eina_list_append 47 eina_hash_set(_state->aliases_f, def->base.file, eina_list_append
48 ((Eina_List*)eina_hash_find(_aliasesf, def->base.file), def)); 48 ((Eina_List*)eina_hash_find(_state->aliases_f, def->base.file),
49 def));
49 database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def); 50 database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def);
50} 51}
51 52
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 5c0c241f6c..97b2468e20 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -10,9 +10,9 @@ EAPI const Eolian_Typedecl *
10eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 10eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
11 const char *name) 11 const char *name)
12{ 12{
13 if (!_aliases) return NULL; 13 if (!_state) return NULL;
14 Eina_Stringshare *shr = eina_stringshare_add(name); 14 Eina_Stringshare *shr = eina_stringshare_add(name);
15 Eolian_Typedecl *tp = eina_hash_find(_aliases, shr); 15 Eolian_Typedecl *tp = eina_hash_find(_state->unit.aliases, shr);
16 eina_stringshare_del(shr); 16 eina_stringshare_del(shr);
17 if (!tp) return NULL; 17 if (!tp) return NULL;
18 return tp; 18 return tp;
@@ -46,9 +46,9 @@ EAPI Eina_Iterator *
46eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 46eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
47 const char *fname) 47 const char *fname)
48{ 48{
49 if (!_aliasesf) return NULL; 49 if (!_state) return NULL;
50 Eina_Stringshare *shr = eina_stringshare_add(fname); 50 Eina_Stringshare *shr = eina_stringshare_add(fname);
51 Eina_List *l = eina_hash_find(_aliasesf, shr); 51 Eina_List *l = eina_hash_find(_state->aliases_f, shr);
52 eina_stringshare_del(shr); 52 eina_stringshare_del(shr);
53 if (!l) return NULL; 53 if (!l) return NULL;
54 return eina_list_iterator_new(l); 54 return eina_list_iterator_new(l);
@@ -81,7 +81,7 @@ eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
81EAPI Eina_Iterator * 81EAPI Eina_Iterator *
82eolian_typedecl_all_aliases_get(const Eolian_Unit *unit EINA_UNUSED) 82eolian_typedecl_all_aliases_get(const Eolian_Unit *unit EINA_UNUSED)
83{ 83{
84 return (_aliases ? eina_hash_iterator_data_new(_aliases) : NULL); 84 return (_state ? eina_hash_iterator_data_new(_state->unit.aliases) : NULL);
85} 85}
86 86
87EAPI Eina_Iterator * 87EAPI Eina_Iterator *
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 0e60aeb50c..ff2d6a9415 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -528,7 +528,7 @@ database_validate(const Eolian_Unit *src)
528 528
529 Cb_Ret rt = { src, EINA_TRUE }; 529 Cb_Ret rt = { src, EINA_TRUE };
530 530
531 eina_hash_foreach(_aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt); 531 eina_hash_foreach(_state->unit.aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
532 if (!rt.succ) 532 if (!rt.succ)
533 return EINA_FALSE; 533 return EINA_FALSE;
534 534
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index cae2de4dae..f6dae686a3 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -8,12 +8,10 @@
8#include "eolian_database.h" 8#include "eolian_database.h"
9#include "eolian_priv.h" 9#include "eolian_priv.h"
10 10
11Eina_Hash *_aliases = NULL;
12Eina_Hash *_structs = NULL; 11Eina_Hash *_structs = NULL;
13Eina_Hash *_enums = NULL; 12Eina_Hash *_enums = NULL;
14Eina_Hash *_globals = NULL; 13Eina_Hash *_globals = NULL;
15Eina_Hash *_constants = NULL; 14Eina_Hash *_constants = NULL;
16Eina_Hash *_aliasesf = NULL;
17Eina_Hash *_structsf = NULL; 15Eina_Hash *_structsf = NULL;
18Eina_Hash *_enumsf = NULL; 16Eina_Hash *_enumsf = NULL;
19Eina_Hash *_globalsf = NULL; 17Eina_Hash *_globalsf = NULL;
@@ -46,12 +44,10 @@ database_init()
46{ 44{
47 if (_database_init_count > 0) return ++_database_init_count; 45 if (_database_init_count > 0) return ++_database_init_count;
48 eina_init(); 46 eina_init();
49 _aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
50 _structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); 47 _structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
51 _enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); 48 _enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
52 _globals = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); 49 _globals = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
53 _constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); 50 _constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
54 _aliasesf = eina_hash_stringshared_new(_hashlist_free);
55 _structsf = eina_hash_stringshared_new(_hashlist_free); 51 _structsf = eina_hash_stringshared_new(_hashlist_free);
56 _enumsf = eina_hash_stringshared_new(_hashlist_free); 52 _enumsf = eina_hash_stringshared_new(_hashlist_free);
57 _globalsf = eina_hash_stringshared_new(_hashlist_free); 53 _globalsf = eina_hash_stringshared_new(_hashlist_free);
@@ -81,12 +77,10 @@ database_shutdown()
81 if (_database_init_count == 0) 77 if (_database_init_count == 0)
82 { 78 {
83 eolian_free(_state); _state = NULL; 79 eolian_free(_state); _state = NULL;
84 eina_hash_free(_aliases ); _aliases = NULL;
85 eina_hash_free(_structs ); _structs = NULL; 80 eina_hash_free(_structs ); _structs = NULL;
86 eina_hash_free(_enums ); _enums = NULL; 81 eina_hash_free(_enums ); _enums = NULL;
87 eina_hash_free(_globals ); _globals = NULL; 82 eina_hash_free(_globals ); _globals = NULL;
88 eina_hash_free(_constants ); _constants = NULL; 83 eina_hash_free(_constants ); _constants = NULL;
89 eina_hash_free(_aliasesf ); _aliasesf = NULL;
90 eina_hash_free(_structsf ); _structsf = NULL; 84 eina_hash_free(_structsf ); _structsf = NULL;
91 eina_hash_free(_enumsf ); _enumsf = NULL; 85 eina_hash_free(_enumsf ); _enumsf = NULL;
92 eina_hash_free(_globalsf ); _globalsf = NULL; 86 eina_hash_free(_globalsf ); _globalsf = NULL;
@@ -644,6 +638,7 @@ eolian_new(void)
644 database_unit_init(&state->unit, NULL); 638 database_unit_init(&state->unit, NULL);
645 639
646 state->classes_f = eina_hash_stringshared_new(NULL); 640 state->classes_f = eina_hash_stringshared_new(NULL);
641 state->aliases_f = eina_hash_stringshared_new(_hashlist_free);
647 642
648 return state; 643 return state;
649} 644}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index e2d1ee936b..7e9c26b80e 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -31,12 +31,10 @@ 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 *_aliases;
35extern Eina_Hash *_structs; 34extern Eina_Hash *_structs;
36extern Eina_Hash *_enums; 35extern Eina_Hash *_enums;
37extern Eina_Hash *_globals; 36extern Eina_Hash *_globals;
38extern Eina_Hash *_constants; 37extern Eina_Hash *_constants;
39extern Eina_Hash *_aliasesf;
40extern Eina_Hash *_structsf; 38extern Eina_Hash *_structsf;
41extern Eina_Hash *_enumsf; 39extern Eina_Hash *_enumsf;
42extern Eina_Hash *_globalsf; 40extern Eina_Hash *_globalsf;
@@ -77,6 +75,7 @@ struct _Eolian
77 Eolian_Unit unit; 75 Eolian_Unit unit;
78 76
79 Eina_Hash *classes_f; 77 Eina_Hash *classes_f;
78 Eina_Hash *aliases_f;
80}; 79};
81 80
82typedef struct _Eolian_Object 81typedef struct _Eolian_Object