eolian: move constants to temporary state
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 6 Dec 2017 13:17:59 +0000 (14:17 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 6 Dec 2017 14:07:31 +0000 (15:07 +0100)
src/lib/eolian/database_validate.c
src/lib/eolian/database_var.c
src/lib/eolian/database_var_api.c
src/lib/eolian/eolian_database.c
src/lib/eolian/eolian_database.h

index beea545..6ecafb5 100644 (file)
@@ -544,7 +544,7 @@ database_validate(const Eolian_Unit *src)
    if (!rt.succ)
      return EINA_FALSE;
 
-   eina_hash_foreach(_constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
+   eina_hash_foreach(_state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
    if (!rt.succ)
      return EINA_FALSE;
 
index ea7f901..0441d42 100644 (file)
@@ -34,9 +34,9 @@ database_var_global_add(Eolian_Variable *var)
 static void
 database_var_constant_add(Eolian_Variable *var)
 {
-   eina_hash_set(_constants, var->full_name, var);
-   eina_hash_set(_constantsf, var->base.file, eina_list_append
-                 ((Eina_List*)eina_hash_find(_constantsf, var->base.file), var));
+   eina_hash_set(_state->unit.constants, var->full_name, var);
+   eina_hash_set(_state->constants_f, var->base.file, eina_list_append
+                 ((Eina_List*)eina_hash_find(_state->constants_f, var->base.file), var));
    database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
 }
 
index 6123ee0..e8a58d3 100644 (file)
@@ -20,9 +20,9 @@ EAPI const Eolian_Variable *
 eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
                                      const char *name)
 {
-   if (!_constants) return NULL;
+   if (!_state) return NULL;
    Eina_Stringshare *shr = eina_stringshare_add(name);
-   Eolian_Variable *v = eina_hash_find(_constants, shr);
+   Eolian_Variable *v = eina_hash_find(_state->unit.constants, shr);
    eina_stringshare_del(shr);
    return v;
 }
@@ -43,9 +43,9 @@ EAPI Eina_Iterator *
 eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
                                       const char *fname)
 {
-   if (!_constantsf) return NULL;
+   if (!_state) return NULL;
    Eina_Stringshare *shr = eina_stringshare_add(fname);
-   Eina_List *l = eina_hash_find(_constantsf, shr);
+   Eina_List *l = eina_hash_find(_state->constants_f, shr);
    eina_stringshare_del(shr);
    if (!l) return NULL;
    return eina_list_iterator_new(l);
@@ -54,7 +54,7 @@ eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
 EAPI Eina_Iterator *
 eolian_variable_all_constants_get(const Eolian_Unit *unit EINA_UNUSED)
 {
-   return (_constants ? eina_hash_iterator_data_new(_constants) : NULL);
+   return (_state ? eina_hash_iterator_data_new(_state->unit.constants) : NULL);
 }
 
 EAPI Eina_Iterator *
index 5826905..3ed3d67 100644 (file)
@@ -8,8 +8,6 @@
 #include "eolian_database.h"
 #include "eolian_priv.h"
 
-Eina_Hash *_constants  = NULL;
-Eina_Hash *_constantsf = NULL;
 Eina_Hash *_filenames  = NULL;
 Eina_Hash *_tfilenames = NULL;
 Eina_Hash *_decls      = NULL;
@@ -38,8 +36,6 @@ database_init()
 {
    if (_database_init_count > 0) return ++_database_init_count;
    eina_init();
-   _constants  = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
-   _constantsf = eina_hash_stringshared_new(_hashlist_free);
    _filenames  = eina_hash_string_small_new(free);
    _tfilenames = eina_hash_string_small_new(free);
    _decls      = eina_hash_stringshared_new(free);
@@ -65,8 +61,6 @@ database_shutdown()
    if (_database_init_count == 0)
      {
         eolian_free(_state); _state = NULL;
-        eina_hash_free(_constants ); _constants  = NULL;
-        eina_hash_free(_constantsf); _constantsf = NULL;
         eina_hash_free(_filenames ); _filenames  = NULL;
         eina_hash_free(_tfilenames); _tfilenames = NULL;
         eina_hash_free(_decls     ); _decls      = NULL;
@@ -619,11 +613,12 @@ eolian_new(void)
 
    database_unit_init(&state->unit, NULL);
 
-   state->classes_f = eina_hash_stringshared_new(NULL);
-   state->aliases_f = eina_hash_stringshared_new(_hashlist_free);
-   state->structs_f = eina_hash_stringshared_new(_hashlist_free);
-   state->enums_f   = eina_hash_stringshared_new(_hashlist_free);
-   state->globals_f = eina_hash_stringshared_new(_hashlist_free);
+   state->classes_f   = eina_hash_stringshared_new(NULL);
+   state->aliases_f   = eina_hash_stringshared_new(_hashlist_free);
+   state->structs_f   = eina_hash_stringshared_new(_hashlist_free);
+   state->enums_f     = eina_hash_stringshared_new(_hashlist_free);
+   state->globals_f   = eina_hash_stringshared_new(_hashlist_free);
+   state->constants_f = eina_hash_stringshared_new(_hashlist_free);
 
    return state;
 }
index fc77356..3bc701c 100644 (file)
@@ -31,8 +31,6 @@ extern Eina_Prefix *_eolian_prefix;
 #endif
 #define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__)
 
-extern Eina_Hash *_constants;
-extern Eina_Hash *_constantsf;
 extern Eina_Hash *_filenames; /* Hash: filename without extension -> full path */
 extern Eina_Hash *_tfilenames;
 
@@ -73,6 +71,7 @@ struct _Eolian
    Eina_Hash *structs_f;
    Eina_Hash *enums_f;
    Eina_Hash *globals_f;
+   Eina_Hash *constants_f;
 };
 
 typedef struct _Eolian_Object