summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-21 17:59:39 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-22 11:19:22 +0100
commit665b88204cae45a9aae7c1bdcdd4fbf1e2ac6fcb (patch)
tree184c6dfff38f6665fd1c45263185fcd36cd3b723
parent7b5a73b96765223ffcf1f74a7733beda655c33a0 (diff)
eolian: store types/typedecls in units
-rw-r--r--src/lib/eolian/database_type.c35
-rw-r--r--src/lib/eolian/eo_parser.c12
-rw-r--r--src/lib/eolian/eolian_database.h6
3 files changed, 27 insertions, 26 deletions
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 29da94cc86..d8954ec5ae 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -41,31 +41,34 @@ database_typedecl_del(Eolian_Typedecl *tp)
41} 41}
42 42
43void 43void
44database_type_add(Eolian *state, Eolian_Typedecl *def) 44database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
45{ 45{
46 eina_hash_set(state->unit.aliases, def->full_name, def); 46 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.aliases);
47 eina_hash_set(state->aliases_f, def->base.file, eina_list_append 47 eolian_object_add(&tp->base, tp->full_name, unit->aliases);
48 ((Eina_List*)eina_hash_find(state->aliases_f, def->base.file), 48 eina_hash_set(unit->state->aliases_f, tp->base.file, eina_list_append
49 def)); 49 ((Eina_List*)eina_hash_find(unit->state->aliases_f, tp->base.file),
50 database_decl_add(state, def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def); 50 tp));
51 database_decl_add(unit->state, tp->full_name, EOLIAN_DECL_ALIAS, tp->base.file, tp);
51} 52}
52 53
53void 54void
54database_struct_add(Eolian *state, Eolian_Typedecl *tp) 55database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
55{ 56{
56 eina_hash_set(state->unit.structs, tp->full_name, tp); 57 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.structs);
57 eina_hash_set(state->structs_f, tp->base.file, eina_list_append 58 eolian_object_add(&tp->base, tp->full_name, unit->structs);
58 ((Eina_List*)eina_hash_find(state->structs_f, tp->base.file), tp)); 59 eina_hash_set(unit->state->structs_f, tp->base.file, eina_list_append
59 database_decl_add(state, tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp); 60 ((Eina_List*)eina_hash_find(unit->state->structs_f, tp->base.file), tp));
61 database_decl_add(unit->state, tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
60} 62}
61 63
62void 64void
63database_enum_add(Eolian *state, Eolian_Typedecl *tp) 65database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
64{ 66{
65 eina_hash_set(state->unit.enums, tp->full_name, tp); 67 eolian_object_add(&tp->base, tp->full_name, unit->state->unit.enums);
66 eina_hash_set(state->enums_f, tp->base.file, eina_list_append 68 eolian_object_add(&tp->base, tp->full_name, unit->enums);
67 ((Eina_List*)eina_hash_find(state->enums_f, tp->base.file), tp)); 69 eina_hash_set(unit->state->enums_f, tp->base.file, eina_list_append
68 database_decl_add(state, tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp); 70 ((Eina_List*)eina_hash_find(unit->state->enums_f, tp->base.file), tp));
71 database_decl_add(unit->state, tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
69} 72}
70 73
71Eina_Bool 74Eina_Bool
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 3f888c5dc7..4a4757a949 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -131,14 +131,12 @@ push_typedecl(Eo_Lexer *ls)
131static void 131static void
132pop_type(Eo_Lexer *ls) 132pop_type(Eo_Lexer *ls)
133{ 133{
134 eolian_object_ref((Eolian_Object *)eina_list_data_get(ls->tmp.type_defs));
135 ls->tmp.type_defs = eina_list_remove_list(ls->tmp.type_defs, ls->tmp.type_defs); 134 ls->tmp.type_defs = eina_list_remove_list(ls->tmp.type_defs, ls->tmp.type_defs);
136} 135}
137 136
138static void 137static void
139pop_typedecl(Eo_Lexer *ls) 138pop_typedecl(Eo_Lexer *ls)
140{ 139{
141 eolian_object_ref((Eolian_Object *)eina_list_data_get(ls->tmp.type_decls));
142 ls->tmp.type_decls = eina_list_remove_list(ls->tmp.type_decls, ls->tmp.type_decls); 140 ls->tmp.type_decls = eina_list_remove_list(ls->tmp.type_decls, ls->tmp.type_decls);
143} 141}
144 142
@@ -528,7 +526,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
528 } 526 }
529 check_match(ls, '}', '{', bline, bcolumn); 527 check_match(ls, '}', '{', bline, bcolumn);
530 FILL_BASE(def->base, ls, line, column); 528 FILL_BASE(def->base, ls, line, column);
531 if (name) database_struct_add(ls->state, def); 529 if (name) database_struct_add(ls->unit, def);
532 return def; 530 return def;
533} 531}
534 532
@@ -640,7 +638,7 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
640 } 638 }
641 check_match(ls, '}', '{', bline, bcolumn); 639 check_match(ls, '}', '{', bline, bcolumn);
642 FILL_BASE(def->base, ls, line, column); 640 FILL_BASE(def->base, ls, line, column);
643 if (name) database_enum_add(ls->state, def); 641 if (name) database_enum_add(ls->unit, def);
644 return def; 642 return def;
645} 643}
646 644
@@ -2154,13 +2152,13 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2154 } 2152 }
2155 case KW_type: 2153 case KW_type:
2156 { 2154 {
2157 database_type_add(ls->state, parse_typedef(ls)); 2155 database_type_add(ls->unit, parse_typedef(ls));
2158 pop_typedecl(ls); 2156 pop_typedecl(ls);
2159 break; 2157 break;
2160 } 2158 }
2161 case KW_function: 2159 case KW_function:
2162 { 2160 {
2163 database_type_add(ls->state, parse_function_pointer(ls)); 2161 database_type_add(ls->unit, parse_function_pointer(ls));
2164 pop_typedecl(ls); 2162 pop_typedecl(ls);
2165 break; 2163 break;
2166 } 2164 }
@@ -2210,7 +2208,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2210 eo_lexer_get(ls); 2208 eo_lexer_get(ls);
2211 FILL_DOC(ls, def, doc); 2209 FILL_DOC(ls, def, doc);
2212 FILL_BASE(def->base, ls, line, col); 2210 FILL_BASE(def->base, ls, line, col);
2213 database_struct_add(ls->state, def); 2211 database_struct_add(ls->unit, def);
2214 pop_typedecl(ls); 2212 pop_typedecl(ls);
2215 break; 2213 break;
2216 } 2214 }
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index e7ae5f1bb3..c8cc6dd0fb 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -344,9 +344,9 @@ void database_unit_del(Eolian_Unit *unit);
344 344
345/* types */ 345/* types */
346 346
347void database_type_add(Eolian *state, Eolian_Typedecl *def); 347void database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp);
348void database_struct_add(Eolian *state, Eolian_Typedecl *tp); 348void database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp);
349void database_enum_add(Eolian *state, Eolian_Typedecl *tp); 349void database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp);
350void database_type_del(Eolian_Type *tp); 350void database_type_del(Eolian_Type *tp);
351void database_typedecl_del(Eolian_Typedecl *tp); 351void database_typedecl_del(Eolian_Typedecl *tp);
352 352