q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=916c8cb04629b3768874048809f592ef0bf3cfe7

commit 916c8cb04629b3768874048809f592ef0bf3cfe7
Author: Daniel Kolesa <[email protected]>
Date:   Thu Mar 15 13:53:50 2018 +0100

    eolian: unified node allocation api
---
 src/lib/eolian/eo_lexer.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/eolian/eo_lexer.h |  4 ++++
 2 files changed, 55 insertions(+)

diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 4d3f11c345..b1cd08771c 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -1052,12 +1052,60 @@ eo_lexer_set_input(Eo_Lexer *ls, Eolian_State *state, 
const char *source)
    next_char(ls);
 }
 
+Eolian_Object *
+eo_lexer_node_new(Eo_Lexer *ls, size_t objsize)
+{
+   Eolian_Object *obj = calloc(1, objsize);
+   ls->tmp.nodes = eina_list_prepend(ls->tmp.nodes, obj);
+   eolian_object_ref(obj);
+   return obj;
+}
+
+int
+_node_free(Eolian_Object *obj)
+{
+   int rc = obj->refcount;
+#if 0
+   /* for when we have a proper node allocator and collect on shutdown */
+   if (rc > 1)
+     {
+        _eolian_log("node %p (type %d, name %s at %s:%d:%d)"
+                    " dangling ref (count: %d)", obj, obj->type, obj->name,
+                    obj->file, obj->line, obj->column);
+     }
+#endif
+   switch (obj->type)
+     {
+      case EOLIAN_OBJECT_CLASS:
+        database_class_del((Eolian_Class *)obj);
+        break;
+      case EOLIAN_OBJECT_TYPEDECL:
+        database_typedecl_del((Eolian_Typedecl *)obj);
+        break;
+      case EOLIAN_OBJECT_TYPE:
+        database_type_del((Eolian_Type *)obj);
+        break;
+      case EOLIAN_OBJECT_VARIABLE:
+        database_var_del((Eolian_Variable *)obj);
+        break;
+      case EOLIAN_OBJECT_EXPRESSION:
+        database_expr_del((Eolian_Expression *)obj);
+        break;
+      default:
+        /* normally unreachable, just for debug */
+        assert(0);
+        break;
+     }
+   return rc;
+}
+
 static void
 _temps_free(Eo_Lexer_Temps *tmp)
 {
    Eina_Strbuf *buf;
    Eolian_Type *tp;
    Eolian_Typedecl *tpd;
+   Eolian_Object *obj;
    const char *s;
 
    if (tmp->kls)
@@ -1077,6 +1125,9 @@ _temps_free(Eo_Lexer_Temps *tmp)
 
    EINA_LIST_FREE(tmp->strs, s)
      if (s) eina_stringshare_del(s);
+
+   EINA_LIST_FREE(tmp->nodes, obj)
+     _node_free(obj);
 }
 
 static void
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index c99ecd6e8e..d6a53aad55 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -128,6 +128,7 @@ typedef struct _Eo_Lexer_Temps
    Eina_List *type_decls;
    Eina_List *expr_defs;
    Eina_List *strs;
+   Eina_List *nodes;
 } Eo_Lexer_Temps;
 
 /* keeps all lexer state */
@@ -219,4 +220,7 @@ void eo_lexer_context_pop    (Eo_Lexer *ls);
 void eo_lexer_context_restore(Eo_Lexer *ls);
 void eo_lexer_context_clear  (Eo_Lexer *ls);
 
+Eolian_Object *eo_lexer_node_new(Eo_Lexer *ls, size_t objsize);
+
+
 #endif /* __EO_LEXER_H__ */

-- 


Reply via email to