summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-23 15:25:32 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-23 15:25:55 +0100
commit39820fb5f58ea9528982d8ee63f37be0639f57a1 (patch)
tree768e6f55f4281428421404e4ccb8a74c4fd3fe51
parent1a7dabeb74fa6a039b431b0e8442f43ead15282e (diff)
eolian: simplify adding/refcounting objects
-rw-r--r--src/lib/eolian/database_type.c9
-rw-r--r--src/lib/eolian/database_var.c6
-rw-r--r--src/lib/eolian/eo_parser.c3
-rw-r--r--src/lib/eolian/eolian_database.c3
-rw-r--r--src/lib/eolian/eolian_database.h6
5 files changed, 13 insertions, 14 deletions
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 052a2ea577..1b881be415 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -43,8 +43,7 @@ database_typedecl_del(Eolian_Typedecl *tp)
43void 43void
44database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp) 44database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
45{ 45{
46 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.aliases); 46 EOLIAN_OBJECT_ADD(unit, tp->full_name, tp, aliases);
47 eolian_object_add(&tp->base, tp->full_name, unit->aliases);
48 eina_hash_set(unit->state->aliases_f, tp->base.file, eina_list_append 47 eina_hash_set(unit->state->aliases_f, tp->base.file, eina_list_append
49 ((Eina_List*)eina_hash_find(unit->state->aliases_f, tp->base.file), 48 ((Eina_List*)eina_hash_find(unit->state->aliases_f, tp->base.file),
50 tp)); 49 tp));
@@ -54,8 +53,7 @@ database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
54void 53void
55database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp) 54database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
56{ 55{
57 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.structs); 56 EOLIAN_OBJECT_ADD(unit, tp->full_name, tp, structs);
58 eolian_object_add(&tp->base, tp->full_name, unit->structs);
59 eina_hash_set(unit->state->structs_f, tp->base.file, eina_list_append 57 eina_hash_set(unit->state->structs_f, tp->base.file, eina_list_append
60 ((Eina_List*)eina_hash_find(unit->state->structs_f, tp->base.file), tp)); 58 ((Eina_List*)eina_hash_find(unit->state->structs_f, tp->base.file), tp));
61 database_decl_add(unit, tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp); 59 database_decl_add(unit, tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
@@ -64,8 +62,7 @@ database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
64void 62void
65database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp) 63database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
66{ 64{
67 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.enums); 65 EOLIAN_OBJECT_ADD(unit, tp->full_name, tp, enums);
68 eolian_object_add(&tp->base, tp->full_name, unit->enums);
69 eina_hash_set(unit->state->enums_f, tp->base.file, eina_list_append 66 eina_hash_set(unit->state->enums_f, tp->base.file, eina_list_append
70 ((Eina_List*)eina_hash_find(unit->state->enums_f, tp->base.file), tp)); 67 ((Eina_List*)eina_hash_find(unit->state->enums_f, tp->base.file), tp));
71 database_decl_add(unit, tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp); 68 database_decl_add(unit, tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c
index c33df7261d..4afc703277 100644
--- a/src/lib/eolian/database_var.c
+++ b/src/lib/eolian/database_var.c
@@ -25,8 +25,7 @@ database_var_del(Eolian_Variable *var)
25static void 25static void
26database_var_global_add(Eolian_Unit *unit, Eolian_Variable *var) 26database_var_global_add(Eolian_Unit *unit, Eolian_Variable *var)
27{ 27{
28 eolian_object_add(&var->base, var->full_name, unit->state->unit.globals); 28 EOLIAN_OBJECT_ADD(unit, var->full_name, var, globals);
29 eolian_object_add(&var->base, var->full_name, unit->globals);
30 eina_hash_set(unit->state->globals_f, var->base.file, eina_list_append 29 eina_hash_set(unit->state->globals_f, var->base.file, eina_list_append
31 ((Eina_List*)eina_hash_find(unit->state->globals_f, var->base.file), var)); 30 ((Eina_List*)eina_hash_find(unit->state->globals_f, var->base.file), var));
32 database_decl_add(unit, var->full_name, EOLIAN_DECL_VAR, var->base.file, var); 31 database_decl_add(unit, var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
@@ -35,8 +34,7 @@ database_var_global_add(Eolian_Unit *unit, Eolian_Variable *var)
35static void 34static void
36database_var_constant_add(Eolian_Unit *unit, Eolian_Variable *var) 35database_var_constant_add(Eolian_Unit *unit, Eolian_Variable *var)
37{ 36{
38 eolian_object_add(&var->base, var->full_name, unit->state->unit.constants); 37 EOLIAN_OBJECT_ADD(unit, var->full_name, var, constants);
39 eolian_object_add(&var->base, var->full_name, unit->constants);
40 eina_hash_set(unit->state->constants_f, var->base.file, eina_list_append 38 eina_hash_set(unit->state->constants_f, var->base.file, eina_list_append
41 ((Eina_List*)eina_hash_find(unit->state->constants_f, var->base.file), var)); 39 ((Eina_List*)eina_hash_find(unit->state->constants_f, var->base.file), var));
42 database_decl_add(unit, var->full_name, EOLIAN_DECL_VAR, var->base.file, var); 40 database_decl_add(unit, var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 7d9eaad525..6ed90395d3 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2285,8 +2285,7 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
2285 } 2285 }
2286 ls->tmp.kls = NULL; 2286 ls->tmp.kls = NULL;
2287 2287
2288 eolian_object_add(&cl->base, cl->full_name, ls->unit->classes); 2288 EOLIAN_OBJECT_ADD(ls->unit, cl->full_name, cl, classes);
2289 eolian_object_add(&cl->base, cl->full_name, ls->state->unit.classes);
2290 eina_hash_set(ls->state->classes_f, cl->base.file, cl); 2289 eina_hash_set(ls->state->classes_f, cl->base.file, cl);
2291 2290
2292done: 2291done:
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index e5b816e18f..ab58486b46 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -20,8 +20,7 @@ database_decl_add(Eolian_Unit *unit, Eina_Stringshare *name,
20 decl->type = type; 20 decl->type = type;
21 decl->name = name; 21 decl->name = name;
22 decl->data = ptr; 22 decl->data = ptr;
23 eolian_object_add(&decl->base, name, unit->state->unit.decls); 23 EOLIAN_OBJECT_ADD(unit, name, decl, decls);
24 eolian_object_add(&decl->base, name, unit->decls);
25 eina_hash_set(unit->state->decls_f, file, eina_list_append 24 eina_hash_set(unit->state->decls_f, file, eina_list_append
26 ((Eina_List*)eina_hash_find(unit->state->decls_f, file), decl)); 25 ((Eina_List*)eina_hash_find(unit->state->decls_f, file), decl));
27} 26}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 3e87e9c933..58fd1c8d16 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -91,6 +91,12 @@ eolian_object_add(Eolian_Object *obj, Eina_Stringshare *name, Eina_Hash *hash)
91 eolian_object_ref(obj); 91 eolian_object_ref(obj);
92} 92}
93 93
94#define EOLIAN_OBJECT_ADD(tunit, name, obj, memb) \
95{ \
96 eolian_object_add(&obj->base, name, tunit->state->unit.memb); \
97 eolian_object_add(&obj->base, name, tunit->memb); \
98}
99
94struct _Eolian_Documentation 100struct _Eolian_Documentation
95{ 101{
96 Eolian_Object base; 102 Eolian_Object base;