q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=98d25243aa053422307afab579ed59eb29f5b05f

commit 98d25243aa053422307afab579ed59eb29f5b05f
Author: Daniel Kolesa <[email protected]>
Date:   Mon Jun 23 15:38:23 2014 +0100

    eolian: generalized node append
---
 src/lib/eolian/eo_lexer.h  |  1 +
 src/lib/eolian/eo_parser.c | 20 +++++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 11827a3..b8188b2 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -52,6 +52,7 @@ typedef struct _Eo_Node
 {
    unsigned char type;
    union {
+      void         *def;
       Eo_Class_Def *def_class;
       Eo_Type_Def  *def_type;
    };
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 9dfdee0..d30ee08 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -103,6 +103,15 @@ pop_strbuf(Eo_Lexer *ls)
    ls->tmp.str_bufs = eina_list_remove_list(ls->tmp.str_bufs, 
ls->tmp.str_bufs);
 }
 
+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_Strbuf *
 parse_name(Eo_Lexer *ls, Eina_Strbuf *buf)
 {
@@ -852,7 +861,6 @@ parse_class(Eo_Lexer *ls, Eina_Bool allow_ctors, 
Eolian_Class_Type type)
 static void
 parse_unit(Eo_Lexer *ls)
 {
-   Eo_Node *nd;
    switch (ls->t.kw)
      {
         case KW_abstract:
@@ -870,10 +878,7 @@ parse_unit(Eo_Lexer *ls)
         case KW_type:
           {
              parse_typedef(ls);
-             nd = calloc(1, sizeof(Eo_Node));
-             nd->type = NODE_TYPEDEF;
-             nd->def_type = ls->tmp.type_def;
-             ls->nodes = eina_list_append(ls->nodes, nd);
+             append_node(ls, NODE_TYPEDEF, ls->tmp.type_def);
              ls->tmp.type_def = NULL;
              break;
           }
@@ -883,10 +888,7 @@ parse_unit(Eo_Lexer *ls)
      }
    return;
 found_class:
-   nd = calloc(1, sizeof(Eo_Node));
-   nd->type = NODE_CLASS;
-   nd->def_class = ls->tmp.kls;
-   ls->nodes = eina_list_append(ls->nodes, nd);
+   append_node(ls, NODE_CLASS, ls->tmp.kls);
    ls->tmp.kls = NULL;
 }
 

-- 


Reply via email to