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

index 0519eb5..7055a51 100644 (file)
@@ -53,9 +53,9 @@ database_type_add(Eolian_Typedecl *def)
 void
 database_struct_add(Eolian_Typedecl *tp)
 {
-   eina_hash_set(_structs, tp->full_name, tp);
-   eina_hash_set(_structsf, tp->base.file, eina_list_append
-                ((Eina_List*)eina_hash_find(_structsf, tp->base.file), tp));
+   eina_hash_set(_state->unit.structs, tp->full_name, tp);
+   eina_hash_set(_state->structs_f, tp->base.file, eina_list_append
+                ((Eina_List*)eina_hash_find(_state->structs_f, tp->base.file), tp));
    database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
 }
 
index 97b2468..6704b6b 100644 (file)
@@ -22,9 +22,9 @@ EAPI const Eolian_Typedecl *
 eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
                                    const char *name)
 {
-   if (!_structs) return NULL;
+   if (!_state) return NULL;
    Eina_Stringshare *shr = eina_stringshare_add(name);
-   Eolian_Typedecl *tp = eina_hash_find(_structs, shr);
+   Eolian_Typedecl *tp = eina_hash_find(_state->unit.structs, shr);
    eina_stringshare_del(shr);
    if (!tp) return NULL;
    return tp;
@@ -58,9 +58,9 @@ EAPI Eina_Iterator *
 eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
                                     const char *fname)
 {
-   if (!_structsf) return NULL;
+   if (!_state) return NULL;
    Eina_Stringshare *shr = eina_stringshare_add(fname);
-   Eina_List *l = eina_hash_find(_structsf, shr);
+   Eina_List *l = eina_hash_find(_state->structs_f, shr);
    eina_stringshare_del(shr);
    if (!l) return NULL;
    return eina_list_iterator_new(l);
@@ -87,7 +87,7 @@ eolian_typedecl_all_aliases_get(const Eolian_Unit *unit EINA_UNUSED)
 EAPI Eina_Iterator *
 eolian_typedecl_all_structs_get(const Eolian_Unit *unit EINA_UNUSED)
 {
-   return (_structs ? eina_hash_iterator_data_new(_structs) : NULL);
+   return (_state ? eina_hash_iterator_data_new(_state->unit.structs) : NULL);
 }
 
 EAPI Eina_Iterator *
index ff2d6a9..40e4a28 100644 (file)
@@ -532,7 +532,7 @@ database_validate(const Eolian_Unit *src)
    if (!rt.succ)
      return EINA_FALSE;
 
-   eina_hash_foreach(_structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
+   eina_hash_foreach(_state->unit.structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
    if (!rt.succ)
      return EINA_FALSE;
 
index f6dae68..17b2a54 100644 (file)
@@ -8,11 +8,9 @@
 #include "eolian_database.h"
 #include "eolian_priv.h"
 
-Eina_Hash *_structs    = NULL;
 Eina_Hash *_enums      = NULL;
 Eina_Hash *_globals    = NULL;
 Eina_Hash *_constants  = NULL;
-Eina_Hash *_structsf   = NULL;
 Eina_Hash *_enumsf     = NULL;
 Eina_Hash *_globalsf   = NULL;
 Eina_Hash *_constantsf = NULL;
@@ -44,11 +42,9 @@ database_init()
 {
    if (_database_init_count > 0) return ++_database_init_count;
    eina_init();
-   _structs    = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
    _enums      = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
    _globals    = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
    _constants  = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
-   _structsf   = eina_hash_stringshared_new(_hashlist_free);
    _enumsf     = eina_hash_stringshared_new(_hashlist_free);
    _globalsf   = eina_hash_stringshared_new(_hashlist_free);
    _constantsf = eina_hash_stringshared_new(_hashlist_free);
@@ -77,11 +73,9 @@ database_shutdown()
    if (_database_init_count == 0)
      {
         eolian_free(_state); _state = NULL;
-        eina_hash_free(_structs   ); _structs    = NULL;
         eina_hash_free(_enums     ); _enums      = NULL;
         eina_hash_free(_globals   ); _globals    = NULL;
         eina_hash_free(_constants ); _constants  = NULL;
-        eina_hash_free(_structsf  ); _structsf   = NULL;
         eina_hash_free(_enumsf    ); _enumsf     = NULL;
         eina_hash_free(_globalsf  ); _globalsf   = NULL;
         eina_hash_free(_constantsf); _constantsf = NULL;
@@ -639,6 +633,7 @@ eolian_new(void)
 
    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);
 
    return state;
 }
index 7e9c26b..f616a5c 100644 (file)
@@ -31,11 +31,9 @@ extern Eina_Prefix *_eolian_prefix;
 #endif
 #define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__)
 
-extern Eina_Hash *_structs;
 extern Eina_Hash *_enums;
 extern Eina_Hash *_globals;
 extern Eina_Hash *_constants;
-extern Eina_Hash *_structsf;
 extern Eina_Hash *_enumsf;
 extern Eina_Hash *_globalsf;
 extern Eina_Hash *_constantsf;
@@ -76,6 +74,7 @@ struct _Eolian
 
    Eina_Hash *classes_f;
    Eina_Hash *aliases_f;
+   Eina_Hash *structs_f;
 };
 
 typedef struct _Eolian_Object