forked from enlightenment/efl
eolian: simplify more fill code
This commit is contained in:
parent
68ba2f6791
commit
44cecb6a87
|
@ -207,9 +207,7 @@ _db_fill_class(Eolian_Class *cl)
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
||||||
{
|
{
|
||||||
Eina_List *k;
|
Eolian_Class *cl;
|
||||||
Eo_Node *nd;
|
|
||||||
Eina_Bool has_class = EINA_FALSE;
|
|
||||||
|
|
||||||
Eo_Lexer *ls = eo_lexer_new(filename);
|
Eo_Lexer *ls = eo_lexer_new(filename);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
|
@ -229,31 +227,20 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
||||||
|
|
||||||
if (eot) goto done;
|
if (eot) goto done;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ls->nodes, k, nd) if (nd->type == NODE_CLASS)
|
if (!eina_list_count(ls->tmp.classes))
|
||||||
{
|
|
||||||
has_class = EINA_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!has_class)
|
|
||||||
{
|
{
|
||||||
ERR("No classes for file %s", filename);
|
ERR("No classes for file %s", filename);
|
||||||
eo_lexer_free(ls);
|
eo_lexer_free(ls);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ls->nodes, k, nd)
|
while (ls->tmp.classes)
|
||||||
{
|
{
|
||||||
switch (nd->type)
|
cl = eina_list_data_get(ls->tmp.classes);
|
||||||
{
|
if (!_db_fill_class(cl))
|
||||||
case NODE_CLASS:
|
goto error;
|
||||||
if (!_db_fill_class(nd->def_class))
|
ls->tmp.classes = eina_list_remove_list(ls->tmp.classes,
|
||||||
goto error;
|
ls->tmp.classes);
|
||||||
nd->def_class = NULL;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -10,6 +10,7 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp)
|
||||||
Eolian_Function_Parameter *par;
|
Eolian_Function_Parameter *par;
|
||||||
Eolian_Type *tp;
|
Eolian_Type *tp;
|
||||||
Eolian_Variable *var;
|
Eolian_Variable *var;
|
||||||
|
Eolian_Class *cl;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
EINA_LIST_FREE(tmp->str_bufs, buf)
|
EINA_LIST_FREE(tmp->str_bufs, buf)
|
||||||
|
@ -50,4 +51,7 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp)
|
||||||
|
|
||||||
EINA_LIST_FREE(tmp->strs, s)
|
EINA_LIST_FREE(tmp->strs, s)
|
||||||
if (s) eina_stringshare_del(s);
|
if (s) eina_stringshare_del(s);
|
||||||
|
|
||||||
|
EINA_LIST_FREE(tmp->classes, cl)
|
||||||
|
database_class_del(cl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
typedef struct _Eo_Lexer_Temps
|
typedef struct _Eo_Lexer_Temps
|
||||||
{
|
{
|
||||||
|
Eina_List *classes;
|
||||||
Eina_List *str_bufs;
|
Eina_List *str_bufs;
|
||||||
Eina_List *params;
|
Eina_List *params;
|
||||||
Eina_Stringshare *legacy_def;
|
Eina_Stringshare *legacy_def;
|
||||||
|
|
|
@ -703,8 +703,6 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
|
||||||
void
|
void
|
||||||
eo_lexer_free(Eo_Lexer *ls)
|
eo_lexer_free(Eo_Lexer *ls)
|
||||||
{
|
{
|
||||||
Eo_Node *nd;
|
|
||||||
|
|
||||||
if (!ls) return;
|
if (!ls) return;
|
||||||
if (ls->source ) eina_stringshare_del(ls->source);
|
if (ls->source ) eina_stringshare_del(ls->source);
|
||||||
if (ls->filename) eina_stringshare_del(ls->filename);
|
if (ls->filename) eina_stringshare_del(ls->filename);
|
||||||
|
@ -712,22 +710,7 @@ eo_lexer_free(Eo_Lexer *ls)
|
||||||
if (ls->handle ) eina_file_close (ls->handle);
|
if (ls->handle ) eina_file_close (ls->handle);
|
||||||
|
|
||||||
eo_lexer_context_clear(ls);
|
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);
|
eo_definitions_temps_free(&ls->tmp);
|
||||||
|
|
||||||
free(ls);
|
free(ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,20 +86,6 @@ typedef struct _Eo_Token
|
||||||
Eolian_Value_Union value;
|
Eolian_Value_Union value;
|
||||||
} Eo_Token;
|
} 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
|
typedef struct _Lexer_Ctx
|
||||||
{
|
{
|
||||||
int line, column;
|
int line, column;
|
||||||
|
@ -151,13 +137,11 @@ typedef struct _Eo_Lexer
|
||||||
/* saved context info */
|
/* saved context info */
|
||||||
Eina_List *saved_ctxs;
|
Eina_List *saved_ctxs;
|
||||||
|
|
||||||
/* represents the results of parsing */
|
|
||||||
Eina_List *nodes;
|
|
||||||
/* represents the temporaries, every object that is allocated by the
|
/* represents the temporaries, every object that is allocated by the
|
||||||
* parser is temporarily put here so the resources can be reclaimed in
|
* 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
|
* 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 */
|
* position (e.g. as part of another struct, or into nodes */
|
||||||
Eo_Lexer_Temps tmp;
|
Eo_Lexer_Temps tmp;
|
||||||
} Eo_Lexer;
|
} Eo_Lexer;
|
||||||
|
|
||||||
int eo_lexer_init (void);
|
int eo_lexer_init (void);
|
||||||
|
|
|
@ -142,15 +142,6 @@ pop_str(Eo_Lexer *ls)
|
||||||
ls->tmp.strs = eina_list_remove_list(ls->tmp.strs, ls->tmp.strs);
|
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
|
static Eina_Bool
|
||||||
compare_class_file(const char *fn_ext, const char *fn_noext)
|
compare_class_file(const char *fn_ext, const char *fn_noext)
|
||||||
{
|
{
|
||||||
|
@ -2029,7 +2020,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
||||||
}
|
}
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
found_class:
|
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;
|
ls->tmp.kls = NULL;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue