forked from enlightenment/efl
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.
This commit is contained in:
parent
93492bcc3b
commit
6abb24b717
|
@ -1043,6 +1043,10 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
|
||||||
if (ls->current != 0xBF)
|
if (ls->current != 0xBF)
|
||||||
return;
|
return;
|
||||||
next_char(ls);
|
next_char(ls);
|
||||||
|
|
||||||
|
Eolian_Unit *ncunit = calloc(1, sizeof(Eolian_Unit));
|
||||||
|
database_unit_init(ncunit, ls->filename);
|
||||||
|
eina_hash_add(_units, ls->filename, ncunit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -31,6 +31,8 @@ Eina_Hash *_parsingeos = NULL;
|
||||||
|
|
||||||
Eina_Hash *_defereos = NULL;
|
Eina_Hash *_defereos = NULL;
|
||||||
|
|
||||||
|
static Eolian_Unit *_cunit = NULL;
|
||||||
|
|
||||||
static int _database_init_count = 0;
|
static int _database_init_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -598,8 +600,35 @@ eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
database_unit_del(Eolian_Unit *unit EINA_UNUSED)
|
database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
|
||||||
{
|
{
|
||||||
|
Eolian_Unit *ocunit = _cunit;
|
||||||
|
unit->parent = ocunit;
|
||||||
|
if (ocunit)
|
||||||
|
eina_hash_add(ocunit->children, fname, unit);
|
||||||
|
|
||||||
|
unit->children = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->classes = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->globals = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->constants = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->aliases = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->structs = eina_hash_stringshared_new(NULL);
|
||||||
|
unit->enums = eina_hash_stringshared_new(NULL);
|
||||||
|
_cunit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
database_unit_del(Eolian_Unit *unit)
|
||||||
|
{
|
||||||
|
if (!unit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eina_hash_free(unit->classes);
|
||||||
|
eina_hash_free(unit->globals);
|
||||||
|
eina_hash_free(unit->constants);
|
||||||
|
eina_hash_free(unit->aliases);
|
||||||
|
eina_hash_free(unit->structs);
|
||||||
|
eina_hash_free(unit->enums);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EO_SUFFIX ".eo"
|
#define EO_SUFFIX ".eo"
|
||||||
|
|
|
@ -48,6 +48,9 @@ extern Eina_Hash *_tfilenames;
|
||||||
|
|
||||||
/* a hash holding all declarations, for redef checking etc */
|
/* a hash holding all declarations, for redef checking etc */
|
||||||
extern Eina_Hash *_decls;
|
extern Eina_Hash *_decls;
|
||||||
|
extern Eina_Hash *_declsf;
|
||||||
|
|
||||||
|
extern Eina_Hash *_units;
|
||||||
|
|
||||||
/* holds parsed/currently parsing eot files to keep track */
|
/* holds parsed/currently parsing eot files to keep track */
|
||||||
extern Eina_Hash *_parsedeos;
|
extern Eina_Hash *_parsedeos;
|
||||||
|
@ -293,13 +296,14 @@ struct _Eolian_Variable
|
||||||
|
|
||||||
struct _Eolian_Unit
|
struct _Eolian_Unit
|
||||||
{
|
{
|
||||||
Eina_List *dependencies;
|
Eolian_Unit *parent;
|
||||||
Eina_List *classes;
|
Eina_Hash *children;
|
||||||
Eina_List *globals;
|
Eina_Hash *classes;
|
||||||
Eina_List *constants;
|
Eina_Hash *globals;
|
||||||
Eina_List *aliases;
|
Eina_Hash *constants;
|
||||||
Eina_List *structs;
|
Eina_Hash *aliases;
|
||||||
Eina_List *enums;
|
Eina_Hash *structs;
|
||||||
|
Eina_Hash *enums;
|
||||||
};
|
};
|
||||||
|
|
||||||
int database_init(void);
|
int database_init(void);
|
||||||
|
@ -313,6 +317,7 @@ void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
|
||||||
|
|
||||||
void database_doc_del(Eolian_Documentation *doc);
|
void database_doc_del(Eolian_Documentation *doc);
|
||||||
|
|
||||||
|
void database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname);
|
||||||
void database_unit_del(Eolian_Unit *unit);
|
void database_unit_del(Eolian_Unit *unit);
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
|
|
Loading…
Reference in New Issue