Eina_Bool
eo_parser_database_fill(const char *filename, Eina_Bool eot)
{
- Eina_List *k;
- Eo_Node *nd;
- Eina_Bool has_class = EINA_FALSE;
+ Eolian_Class *cl;
Eo_Lexer *ls = eo_lexer_new(filename);
if (!ls)
if (eot) goto done;
- EINA_LIST_FOREACH(ls->nodes, k, nd) if (nd->type == NODE_CLASS)
- {
- has_class = EINA_TRUE;
- break;
- }
-
- if (!has_class)
+ if (!eina_list_count(ls->tmp.classes))
{
ERR("No classes for file %s", filename);
eo_lexer_free(ls);
return EINA_FALSE;
}
- EINA_LIST_FOREACH(ls->nodes, k, nd)
+ while (ls->tmp.classes)
{
- switch (nd->type)
- {
- case NODE_CLASS:
- if (!_db_fill_class(nd->def_class))
- goto error;
- nd->def_class = NULL;
- break;
- default:
- break;
- }
+ cl = eina_list_data_get(ls->tmp.classes);
+ if (!_db_fill_class(cl))
+ goto error;
+ ls->tmp.classes = eina_list_remove_list(ls->tmp.classes,
+ ls->tmp.classes);
}
done:
Eolian_Function_Parameter *par;
Eolian_Type *tp;
Eolian_Variable *var;
+ Eolian_Class *cl;
const char *s;
EINA_LIST_FREE(tmp->str_bufs, buf)
EINA_LIST_FREE(tmp->strs, s)
if (s) eina_stringshare_del(s);
+
+ EINA_LIST_FREE(tmp->classes, cl)
+ database_class_del(cl);
}
typedef struct _Eo_Lexer_Temps
{
+ Eina_List *classes;
Eina_List *str_bufs;
Eina_List *params;
Eina_Stringshare *legacy_def;
void
eo_lexer_free(Eo_Lexer *ls)
{
- Eo_Node *nd;
-
if (!ls) return;
if (ls->source ) eina_stringshare_del(ls->source);
if (ls->filename) eina_stringshare_del(ls->filename);
if (ls->handle ) eina_file_close (ls->handle);
eo_lexer_context_clear(ls);
-
- EINA_LIST_FREE(ls->nodes, nd)
- {
- switch (nd->type)
- {
- case NODE_CLASS:
- database_class_del(nd->def_class);
- break;
- default:
- break;
- }
- free(nd);
- }
-
eo_definitions_temps_free(&ls->tmp);
-
free(ls);
}
Eolian_Value_Union value;
} Eo_Token;
-enum Nodes
-{
- NODE_CLASS = 0
-};
-
-typedef struct _Eo_Node
-{
- unsigned char type;
- union {
- void *def;
- Eolian_Class *def_class;
- };
-} Eo_Node;
-
typedef struct _Lexer_Ctx
{
int line, column;
/* saved context info */
Eina_List *saved_ctxs;
- /* represents the results of parsing */
- Eina_List *nodes;
/* represents the temporaries, every object that is allocated by the
* parser is temporarily put here so the resources can be reclaimed in
* case of error - and it's nulled when it's written into a more permanent
* position (e.g. as part of another struct, or into nodes */
- Eo_Lexer_Temps tmp;
+ Eo_Lexer_Temps tmp;
} Eo_Lexer;
int eo_lexer_init (void);
ls->tmp.strs = eina_list_remove_list(ls->tmp.strs, ls->tmp.strs);
}
-static void
-append_node(Eo_Lexer *ls, int type, void *def)
-{
- Eo_Node *nd = calloc(1, sizeof(Eo_Node));
- nd->type = type;
- nd->def = def;
- ls->nodes = eina_list_append(ls->nodes, nd);
-}
-
static Eina_Bool
compare_class_file(const char *fn_ext, const char *fn_noext)
{
}
return EINA_FALSE;
found_class:
- append_node(ls, NODE_CLASS, ls->tmp.kls);
+ ls->tmp.classes = eina_list_append(ls->tmp.classes, ls->tmp.kls);
ls->tmp.kls = NULL;
return EINA_TRUE;
}