summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-03 20:57:43 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-05 16:41:42 +0100
commit6abb24b717b2dbedfa1fca168f2193d2a481c1f7 (patch)
tree67fd8d637e8421f032f3a00e5ac36de17afab86e
parent93492bcc3b466404d8c7df2e4fc205aa842f0d67 (diff)
eolian: create an actual unit structure for files
Units now form an actual tree stored in their own hash. This will later replace all global state of Eolian, by introducing a master unit that you will pass around.
-rw-r--r--src/lib/eolian/eo_lexer.c4
-rw-r--r--src/lib/eolian/eolian_database.c31
-rw-r--r--src/lib/eolian/eolian_database.h19
3 files changed, 46 insertions, 8 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 4da3942c51..e7ed6b1b20 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -1043,6 +1043,10 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
1043 if (ls->current != 0xBF) 1043 if (ls->current != 0xBF)
1044 return; 1044 return;
1045 next_char(ls); 1045 next_char(ls);
1046
1047 Eolian_Unit *ncunit = calloc(1, sizeof(Eolian_Unit));
1048 database_unit_init(ncunit, ls->filename);
1049 eina_hash_add(_units, ls->filename, ncunit);
1046} 1050}
1047 1051
1048static void 1052static void
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 0141450275..59cebfa202 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -31,6 +31,8 @@ Eina_Hash *_parsingeos = NULL;
31 31
32Eina_Hash *_defereos = NULL; 32Eina_Hash *_defereos = NULL;
33 33
34static Eolian_Unit *_cunit = NULL;
35
34static int _database_init_count = 0; 36static int _database_init_count = 0;
35 37
36static void 38static void
@@ -598,8 +600,35 @@ eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
598} 600}
599 601
600void 602void
601database_unit_del(Eolian_Unit *unit EINA_UNUSED) 603database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
604{
605 Eolian_Unit *ocunit = _cunit;
606 unit->parent = ocunit;
607 if (ocunit)
608 eina_hash_add(ocunit->children, fname, unit);
609
610 unit->children = eina_hash_stringshared_new(NULL);
611 unit->classes = eina_hash_stringshared_new(NULL);
612 unit->globals = eina_hash_stringshared_new(NULL);
613 unit->constants = eina_hash_stringshared_new(NULL);
614 unit->aliases = eina_hash_stringshared_new(NULL);
615 unit->structs = eina_hash_stringshared_new(NULL);
616 unit->enums = eina_hash_stringshared_new(NULL);
617 _cunit = unit;
618}
619
620void
621database_unit_del(Eolian_Unit *unit)
602{ 622{
623 if (!unit)
624 return;
625
626 eina_hash_free(unit->classes);
627 eina_hash_free(unit->globals);
628 eina_hash_free(unit->constants);
629 eina_hash_free(unit->aliases);
630 eina_hash_free(unit->structs);
631 eina_hash_free(unit->enums);
603} 632}
604 633
605#define EO_SUFFIX ".eo" 634#define EO_SUFFIX ".eo"
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index a8c1dbb637..1ab61b0b66 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -48,6 +48,9 @@ extern Eina_Hash *_tfilenames;
48 48
49/* a hash holding all declarations, for redef checking etc */ 49/* a hash holding all declarations, for redef checking etc */
50extern Eina_Hash *_decls; 50extern Eina_Hash *_decls;
51extern Eina_Hash *_declsf;
52
53extern Eina_Hash *_units;
51 54
52/* holds parsed/currently parsing eot files to keep track */ 55/* holds parsed/currently parsing eot files to keep track */
53extern Eina_Hash *_parsedeos; 56extern Eina_Hash *_parsedeos;
@@ -293,13 +296,14 @@ struct _Eolian_Variable
293 296
294struct _Eolian_Unit 297struct _Eolian_Unit
295{ 298{
296 Eina_List *dependencies; 299 Eolian_Unit *parent;
297 Eina_List *classes; 300 Eina_Hash *children;
298 Eina_List *globals; 301 Eina_Hash *classes;
299 Eina_List *constants; 302 Eina_Hash *globals;
300 Eina_List *aliases; 303 Eina_Hash *constants;
301 Eina_List *structs; 304 Eina_Hash *aliases;
302 Eina_List *enums; 305 Eina_Hash *structs;
306 Eina_Hash *enums;
303}; 307};
304 308
305int database_init(void); 309int database_init(void);
@@ -313,6 +317,7 @@ void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
313 317
314void database_doc_del(Eolian_Documentation *doc); 318void database_doc_del(Eolian_Documentation *doc);
315 319
320void database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname);
316void database_unit_del(Eolian_Unit *unit); 321void database_unit_del(Eolian_Unit *unit);
317 322
318/* types */ 323/* types */