q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=80445f516089b8d29df4b98da9fd91cf0ddecacb

commit 80445f516089b8d29df4b98da9fd91cf0ddecacb
Author: Daniel Kolesa <[email protected]>
Date:   Thu Mar 15 15:42:40 2018 +0100

    eolian: manage class/vars through new node system
---
 src/lib/eolian/eo_lexer.c  | 10 ----------
 src/lib/eolian/eo_lexer.h  | 38 ++++++++++++++++++++++++++++++++++++--
 src/lib/eolian/eo_parser.c | 15 +++++++--------
 3 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 76e076d14a..3600ad1000 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -1111,18 +1111,8 @@ eo_lexer_node_release(Eo_Lexer *ls, Eolian_Object *obj)
 static void
 _temps_free(Eo_Lexer_Temps *tmp)
 {
-   Eolian_Type *tp;
    Eolian_Typedecl *tpd;
 
-   if (tmp->kls)
-     database_class_del(tmp->kls);
-
-   if (tmp->var)
-     database_var_del(tmp->var);
-
-   EINA_LIST_FREE(tmp->type_defs, tp)
-     database_type_del(tp);
-
    EINA_LIST_FREE(tmp->type_decls, tpd)
      database_typedecl_del(tpd);
 }
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 1d6b312d23..03a635de84 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -122,8 +122,6 @@ typedef struct _Lexer_Ctx
 typedef struct _Eo_Lexer_Temps
 {
    Eolian_Class *kls;
-   Eolian_Variable *var;
-   Eina_List *type_defs;
    Eina_List *type_decls;
    Eina_List *expr_defs;
 } Eo_Lexer_Temps;
@@ -241,6 +239,42 @@ eo_lexer_type_release(Eo_Lexer *ls, Eolian_Type *tp)
    return (Eolian_Type *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
 }
 
+static inline Eolian_Typedecl *
+eo_lexer_typedecl_new(Eo_Lexer *ls)
+{
+   return (Eolian_Typedecl *)eo_lexer_node_new(ls, sizeof(Eolian_Typedecl));
+}
+
+static inline Eolian_Typedecl *
+eo_lexer_typedecl_release(Eo_Lexer *ls, Eolian_Typedecl *tp)
+{
+   return (Eolian_Typedecl *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
+}
+
+static inline Eolian_Variable *
+eo_lexer_variable_new(Eo_Lexer *ls)
+{
+   return (Eolian_Variable *)eo_lexer_node_new(ls, sizeof(Eolian_Variable));
+}
+
+static inline Eolian_Variable *
+eo_lexer_variable_release(Eo_Lexer *ls, Eolian_Variable *var)
+{
+   return (Eolian_Variable *)eo_lexer_node_release(ls, (Eolian_Object *)var);
+}
+
+static inline Eolian_Expression *
+eo_lexer_expr_new(Eo_Lexer *ls)
+{
+   return (Eolian_Expression *)eo_lexer_node_new(ls, 
sizeof(Eolian_Expression));
+}
+
+static inline Eolian_Expression *
+eo_lexer_expr_release(Eo_Lexer *ls, Eolian_Expression *expr)
+{
+   return (Eolian_Expression *)eo_lexer_node_release(ls, (Eolian_Object 
*)expr);
+}
+
 /* "stack" management, only to protect against errors (jumps) in parsing */
 void eo_lexer_dtor_push(Eo_Lexer *ls, Eina_Free_Cb free_cb, void *data);
 void eo_lexer_dtor_pop(Eo_Lexer *ls);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 4f21bc7efd..44187f88c2 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -834,9 +834,8 @@ parse_typedef(Eo_Lexer *ls)
 static Eolian_Variable *
 parse_variable(Eo_Lexer *ls, Eina_Bool global)
 {
-   Eolian_Variable *def = calloc(1, sizeof(Eolian_Variable));
+   Eolian_Variable *def = eo_lexer_variable_new(ls);
    Eina_Strbuf *buf;
-   ls->tmp.var = def;
    eo_lexer_get(ls);
    if (ls->t.kw == KW_at_extern)
      {
@@ -2016,7 +2015,7 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
    int line, col;
    Eina_Strbuf *buf = eina_strbuf_new();
    eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
-   ls->klass = (ls->tmp.kls = calloc(1, sizeof(Eolian_Class)));
+   ls->klass = (Eolian_Class *)eo_lexer_node_new(ls, sizeof(Eolian_Class));
    FILL_BASE(ls->klass->base, ls, ls->line_number, ls->column, CLASS);
    eo_lexer_get(ls);
    ls->klass->type = type;
@@ -2128,9 +2127,9 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
       case KW_const:
       case KW_var:
         {
-           database_var_add(ls->unit, parse_variable(ls, ls->t.kw == KW_var));
-           eolian_object_ref(&ls->tmp.var->base);
-           ls->tmp.var = NULL;
+           Eolian_Variable *var = parse_variable(ls, ls->t.kw == KW_var);
+           database_var_add(ls->unit, eo_lexer_variable_release(ls, var));
+           eolian_object_ref(&var->base);
            break;
         }
       case KW_struct:
@@ -2248,10 +2247,10 @@ eo_parser_database_fill(Eolian_Unit *parent, const char 
*filename, Eina_Bool eot
         _eolian_log("eolian: no class for file '%s'", filename);
         goto error;
      }
-   ls->klass = ls->tmp.kls = NULL;
-
+   ls->klass = NULL;
    EOLIAN_OBJECT_ADD(ls->unit, cl->base.name, cl, classes);
    eina_hash_set(ls->state->classes_f, cl->base.file, cl);
+   eo_lexer_node_release(ls, &cl->base);
 
 done:
    ret = ls->unit;

-- 


Reply via email to