From: Daniel Kolesa Date: Thu, 11 Sep 2014 10:48:38 +0000 (+0100) Subject: eolian: simplify more fill code X-Git-Tag: v1.12.0-alpha1~374 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44cecb6a87d7a2d7c781e613619b97c74e3f1eea;p=platform%2Fupstream%2Fefl.git eolian: simplify more fill code --- diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c index 0d8db23..2db65a6 100644 --- a/src/lib/eolian/database_fill.c +++ b/src/lib/eolian/database_fill.c @@ -207,9 +207,7 @@ _db_fill_class(Eolian_Class *cl) 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) @@ -229,31 +227,20 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot) 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: diff --git a/src/lib/eolian/eo_definitions.c b/src/lib/eolian/eo_definitions.c index 15bbd5b..470f7e0 100644 --- a/src/lib/eolian/eo_definitions.c +++ b/src/lib/eolian/eo_definitions.c @@ -10,6 +10,7 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp) Eolian_Function_Parameter *par; Eolian_Type *tp; Eolian_Variable *var; + Eolian_Class *cl; const char *s; 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) if (s) eina_stringshare_del(s); + + EINA_LIST_FREE(tmp->classes, cl) + database_class_del(cl); } diff --git a/src/lib/eolian/eo_definitions.h b/src/lib/eolian/eo_definitions.h index 4f20843..abc1a6c 100644 --- a/src/lib/eolian/eo_definitions.h +++ b/src/lib/eolian/eo_definitions.h @@ -10,6 +10,7 @@ typedef struct _Eo_Lexer_Temps { + Eina_List *classes; Eina_List *str_bufs; Eina_List *params; Eina_Stringshare *legacy_def; diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 75ce0a4..781937a 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -703,8 +703,6 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source) 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); @@ -712,22 +710,7 @@ eo_lexer_free(Eo_Lexer *ls) 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); } diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index 9557270..b406515 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -86,20 +86,6 @@ typedef struct _Eo_Token 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; @@ -151,13 +137,11 @@ typedef struct _Eo_Lexer /* 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); diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 9665af7..5faa499 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -142,15 +142,6 @@ pop_str(Eo_Lexer *ls) 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) { @@ -2029,7 +2020,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot) } 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; }