summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 15:06:54 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-06 15:07:31 +0100
commit9a5c3cfbe273a359e4d1cc607d54ae49b7121353 (patch)
tree13eef3fa54de8428d07c13ac15e8035d52b9538d /src
parenta39d2e8fe5dc1da9903b2a6e7b9d079dd6621aa0 (diff)
eolian: remove internal state struct (rely on external Eolian state)
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_class_api.c18
-rw-r--r--src/lib/eolian/database_type.c24
-rw-r--r--src/lib/eolian/database_type_api.c54
-rw-r--r--src/lib/eolian/database_validate.c12
-rw-r--r--src/lib/eolian/database_var.c22
-rw-r--r--src/lib/eolian/database_var_api.c35
-rw-r--r--src/lib/eolian/eo_lexer.c19
-rw-r--r--src/lib/eolian/eo_lexer.h4
-rw-r--r--src/lib/eolian/eo_parser.c32
-rw-r--r--src/lib/eolian/eo_parser.h2
-rw-r--r--src/lib/eolian/eolian_database.c111
-rw-r--r--src/lib/eolian/eolian_database.h16
12 files changed, 171 insertions, 178 deletions
diff --git a/src/lib/eolian/database_class_api.c b/src/lib/eolian/database_class_api.c
index da43d05e5b..ae151f4e82 100644
--- a/src/lib/eolian/database_class_api.c
+++ b/src/lib/eolian/database_class_api.c
@@ -32,23 +32,21 @@ eolian_class_namespaces_get(const Eolian_Class *cl)
32} 32}
33 33
34EAPI const Eolian_Class * 34EAPI const Eolian_Class *
35eolian_class_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 35eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name)
36 const char *class_name)
37{ 36{
38 if (!_state) return NULL; 37 if (!unit) return NULL;
39 Eina_Stringshare *shr = eina_stringshare_add(class_name); 38 Eina_Stringshare *shr = eina_stringshare_add(class_name);
40 Eolian_Class *cl = eina_hash_find(_state->unit.classes, shr); 39 Eolian_Class *cl = eina_hash_find(unit->state->unit.classes, shr);
41 eina_stringshare_del(shr); 40 eina_stringshare_del(shr);
42 return cl; 41 return cl;
43} 42}
44 43
45EAPI const Eolian_Class * 44EAPI const Eolian_Class *
46eolian_class_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 45eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name)
47 const char *file_name)
48{ 46{
49 if (!_state) return NULL; 47 if (!unit) return NULL;
50 Eina_Stringshare *shr = eina_stringshare_add(file_name); 48 Eina_Stringshare *shr = eina_stringshare_add(file_name);
51 Eolian_Class *cl = eina_hash_find(_state->classes_f, shr); 49 Eolian_Class *cl = eina_hash_find(unit->state->classes_f, shr);
52 eina_stringshare_del(shr); 50 eina_stringshare_del(shr);
53 return cl; 51 return cl;
54} 52}
@@ -61,9 +59,9 @@ eolian_class_type_get(const Eolian_Class *cl)
61} 59}
62 60
63EAPI Eina_Iterator * 61EAPI Eina_Iterator *
64eolian_all_classes_get(const Eolian_Unit *unit EINA_UNUSED) 62eolian_all_classes_get(const Eolian_Unit *unit)
65{ 63{
66 return (_state ? eina_hash_iterator_data_new(_state->unit.classes) : NULL); 64 return (unit ? eina_hash_iterator_data_new(unit->state->unit.classes) : NULL);
67} 65}
68 66
69EAPI const Eolian_Documentation * 67EAPI const Eolian_Documentation *
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 347a6ba0b9..5258709d1a 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -41,30 +41,30 @@ database_typedecl_del(Eolian_Typedecl *tp)
41} 41}
42 42
43void 43void
44database_type_add(Eolian_Typedecl *def) 44database_type_add(Eolian *state, Eolian_Typedecl *def)
45{ 45{
46 eina_hash_set(_state->unit.aliases, def->full_name, def); 46 eina_hash_set(state->unit.aliases, def->full_name, def);
47 eina_hash_set(_state->aliases_f, def->base.file, eina_list_append 47 eina_hash_set(state->aliases_f, def->base.file, eina_list_append
48 ((Eina_List*)eina_hash_find(_state->aliases_f, def->base.file), 48 ((Eina_List*)eina_hash_find(state->aliases_f, def->base.file),
49 def)); 49 def));
50 database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def); 50 database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def);
51} 51}
52 52
53void 53void
54database_struct_add(Eolian_Typedecl *tp) 54database_struct_add(Eolian *state, Eolian_Typedecl *tp)
55{ 55{
56 eina_hash_set(_state->unit.structs, tp->full_name, tp); 56 eina_hash_set(state->unit.structs, tp->full_name, tp);
57 eina_hash_set(_state->structs_f, tp->base.file, eina_list_append 57 eina_hash_set(state->structs_f, tp->base.file, eina_list_append
58 ((Eina_List*)eina_hash_find(_state->structs_f, tp->base.file), tp)); 58 ((Eina_List*)eina_hash_find(state->structs_f, tp->base.file), tp));
59 database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp); 59 database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
60} 60}
61 61
62void 62void
63database_enum_add(Eolian_Typedecl *tp) 63database_enum_add(Eolian *state, Eolian_Typedecl *tp)
64{ 64{
65 eina_hash_set(_state->unit.enums, tp->full_name, tp); 65 eina_hash_set(state->unit.enums, tp->full_name, tp);
66 eina_hash_set(_state->enums_f, tp->base.file, eina_list_append 66 eina_hash_set(state->enums_f, tp->base.file, eina_list_append
67 ((Eina_List*)eina_hash_find(_state->enums_f, tp->base.file), tp)); 67 ((Eina_List*)eina_hash_find(state->enums_f, tp->base.file), tp));
68 database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp); 68 database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
69} 69}
70 70
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 20ba88a609..5edaed94af 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -7,93 +7,87 @@
7#include "eo_lexer.h" 7#include "eo_lexer.h"
8 8
9EAPI const Eolian_Typedecl * 9EAPI const Eolian_Typedecl *
10eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 10eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name)
11 const char *name)
12{ 11{
13 if (!_state) return NULL; 12 if (!unit) return NULL;
14 Eina_Stringshare *shr = eina_stringshare_add(name); 13 Eina_Stringshare *shr = eina_stringshare_add(name);
15 Eolian_Typedecl *tp = eina_hash_find(_state->unit.aliases, shr); 14 Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.aliases, shr);
16 eina_stringshare_del(shr); 15 eina_stringshare_del(shr);
17 if (!tp) return NULL; 16 if (!tp) return NULL;
18 return tp; 17 return tp;
19} 18}
20 19
21EAPI const Eolian_Typedecl * 20EAPI const Eolian_Typedecl *
22eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 21eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name)
23 const char *name)
24{ 22{
25 if (!_state) return NULL; 23 if (!unit) return NULL;
26 Eina_Stringshare *shr = eina_stringshare_add(name); 24 Eina_Stringshare *shr = eina_stringshare_add(name);
27 Eolian_Typedecl *tp = eina_hash_find(_state->unit.structs, shr); 25 Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.structs, shr);
28 eina_stringshare_del(shr); 26 eina_stringshare_del(shr);
29 if (!tp) return NULL; 27 if (!tp) return NULL;
30 return tp; 28 return tp;
31} 29}
32 30
33EAPI const Eolian_Typedecl * 31EAPI const Eolian_Typedecl *
34eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 32eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name)
35 const char *name)
36{ 33{
37 if (!_state) return NULL; 34 if (!unit) return NULL;
38 Eina_Stringshare *shr = eina_stringshare_add(name); 35 Eina_Stringshare *shr = eina_stringshare_add(name);
39 Eolian_Typedecl *tp = eina_hash_find(_state->unit.enums, shr); 36 Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.enums, shr);
40 eina_stringshare_del(shr); 37 eina_stringshare_del(shr);
41 if (!tp) return NULL; 38 if (!tp) return NULL;
42 return tp; 39 return tp;
43} 40}
44 41
45EAPI Eina_Iterator * 42EAPI Eina_Iterator *
46eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 43eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname)
47 const char *fname)
48{ 44{
49 if (!_state) return NULL; 45 if (!unit) return NULL;
50 Eina_Stringshare *shr = eina_stringshare_add(fname); 46 Eina_Stringshare *shr = eina_stringshare_add(fname);
51 Eina_List *l = eina_hash_find(_state->aliases_f, shr); 47 Eina_List *l = eina_hash_find(unit->state->aliases_f, shr);
52 eina_stringshare_del(shr); 48 eina_stringshare_del(shr);
53 if (!l) return NULL; 49 if (!l) return NULL;
54 return eina_list_iterator_new(l); 50 return eina_list_iterator_new(l);
55} 51}
56 52
57EAPI Eina_Iterator * 53EAPI Eina_Iterator *
58eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 54eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname)
59 const char *fname)
60{ 55{
61 if (!_state) return NULL; 56 if (!unit) return NULL;
62 Eina_Stringshare *shr = eina_stringshare_add(fname); 57 Eina_Stringshare *shr = eina_stringshare_add(fname);
63 Eina_List *l = eina_hash_find(_state->structs_f, shr); 58 Eina_List *l = eina_hash_find(unit->state->structs_f, shr);
64 eina_stringshare_del(shr); 59 eina_stringshare_del(shr);
65 if (!l) return NULL; 60 if (!l) return NULL;
66 return eina_list_iterator_new(l); 61 return eina_list_iterator_new(l);
67} 62}
68 63
69EAPI Eina_Iterator * 64EAPI Eina_Iterator *
70eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 65eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname)
71 const char *fname)
72{ 66{
73 if (!_state) return NULL; 67 if (!unit) return NULL;
74 Eina_Stringshare *shr = eina_stringshare_add(fname); 68 Eina_Stringshare *shr = eina_stringshare_add(fname);
75 Eina_List *l = eina_hash_find(_state->enums_f, shr); 69 Eina_List *l = eina_hash_find(unit->state->enums_f, shr);
76 eina_stringshare_del(shr); 70 eina_stringshare_del(shr);
77 if (!l) return NULL; 71 if (!l) return NULL;
78 return eina_list_iterator_new(l); 72 return eina_list_iterator_new(l);
79} 73}
80 74
81EAPI Eina_Iterator * 75EAPI Eina_Iterator *
82eolian_typedecl_all_aliases_get(const Eolian_Unit *unit EINA_UNUSED) 76eolian_typedecl_all_aliases_get(const Eolian_Unit *unit)
83{ 77{
84 return (_state ? eina_hash_iterator_data_new(_state->unit.aliases) : NULL); 78 return (unit ? eina_hash_iterator_data_new(unit->state->unit.aliases) : NULL);
85} 79}
86 80
87EAPI Eina_Iterator * 81EAPI Eina_Iterator *
88eolian_typedecl_all_structs_get(const Eolian_Unit *unit EINA_UNUSED) 82eolian_typedecl_all_structs_get(const Eolian_Unit *unit)
89{ 83{
90 return (_state ? eina_hash_iterator_data_new(_state->unit.structs) : NULL); 84 return (unit ? eina_hash_iterator_data_new(unit->state->unit.structs) : NULL);
91} 85}
92 86
93EAPI Eina_Iterator * 87EAPI Eina_Iterator *
94eolian_typedecl_all_enums_get(const Eolian_Unit *unit EINA_UNUSED) 88eolian_typedecl_all_enums_get(const Eolian_Unit *unit)
95{ 89{
96 return (_state ? eina_hash_iterator_data_new(_state->unit.enums) : NULL); 90 return (unit ? eina_hash_iterator_data_new(unit->state->unit.enums) : NULL);
97} 91}
98 92
99EAPI Eolian_Type_Type 93EAPI Eolian_Type_Type
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 6ecafb532e..e4cf4ca16a 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -513,7 +513,7 @@ _var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
513} 513}
514 514
515Eina_Bool 515Eina_Bool
516database_validate(const Eolian_Unit *src) 516database_validate(Eolian *state, const Eolian_Unit *src)
517{ 517{
518 Eolian_Class *cl; 518 Eolian_Class *cl;
519 519
@@ -528,23 +528,23 @@ database_validate(const Eolian_Unit *src)
528 528
529 Cb_Ret rt = { src, EINA_TRUE }; 529 Cb_Ret rt = { src, EINA_TRUE };
530 530
531 eina_hash_foreach(_state->unit.aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt); 531 eina_hash_foreach(state->unit.aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
532 if (!rt.succ) 532 if (!rt.succ)
533 return EINA_FALSE; 533 return EINA_FALSE;
534 534
535 eina_hash_foreach(_state->unit.structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt); 535 eina_hash_foreach(state->unit.structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
536 if (!rt.succ) 536 if (!rt.succ)
537 return EINA_FALSE; 537 return EINA_FALSE;
538 538
539 eina_hash_foreach(_state->unit.enums, (Eina_Hash_Foreach)_typedecl_map_cb, &rt); 539 eina_hash_foreach(state->unit.enums, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
540 if (!rt.succ) 540 if (!rt.succ)
541 return EINA_FALSE; 541 return EINA_FALSE;
542 542
543 eina_hash_foreach(_state->unit.globals, (Eina_Hash_Foreach)_var_map_cb, &rt); 543 eina_hash_foreach(state->unit.globals, (Eina_Hash_Foreach)_var_map_cb, &rt);
544 if (!rt.succ) 544 if (!rt.succ)
545 return EINA_FALSE; 545 return EINA_FALSE;
546 546
547 eina_hash_foreach(_state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt); 547 eina_hash_foreach(state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
548 if (!rt.succ) 548 if (!rt.succ)
549 return EINA_FALSE; 549 return EINA_FALSE;
550 550
diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c
index 0441d427f9..b14a99a2fa 100644
--- a/src/lib/eolian/database_var.c
+++ b/src/lib/eolian/database_var.c
@@ -23,28 +23,28 @@ database_var_del(Eolian_Variable *var)
23} 23}
24 24
25static void 25static void
26database_var_global_add(Eolian_Variable *var) 26database_var_global_add(Eolian *state, Eolian_Variable *var)
27{ 27{
28 eina_hash_set(_state->unit.globals, var->full_name, var); 28 eina_hash_set(state->unit.globals, var->full_name, var);
29 eina_hash_set(_state->globals_f, var->base.file, eina_list_append 29 eina_hash_set(state->globals_f, var->base.file, eina_list_append
30 ((Eina_List*)eina_hash_find(_state->globals_f, var->base.file), var)); 30 ((Eina_List*)eina_hash_find(state->globals_f, var->base.file), var));
31 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var); 31 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
32} 32}
33 33
34static void 34static void
35database_var_constant_add(Eolian_Variable *var) 35database_var_constant_add(Eolian *state, Eolian_Variable *var)
36{ 36{
37 eina_hash_set(_state->unit.constants, var->full_name, var); 37 eina_hash_set(state->unit.constants, var->full_name, var);
38 eina_hash_set(_state->constants_f, var->base.file, eina_list_append 38 eina_hash_set(state->constants_f, var->base.file, eina_list_append
39 ((Eina_List*)eina_hash_find(_state->constants_f, var->base.file), var)); 39 ((Eina_List*)eina_hash_find(state->constants_f, var->base.file), var));
40 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var); 40 database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
41} 41}
42 42
43void 43void
44database_var_add(Eolian_Variable *var) 44database_var_add(Eolian *state, Eolian_Variable *var)
45{ 45{
46 if (var->type == EOLIAN_VAR_GLOBAL) 46 if (var->type == EOLIAN_VAR_GLOBAL)
47 database_var_global_add(var); 47 database_var_global_add(state, var);
48 else 48 else
49 database_var_constant_add(var); 49 database_var_constant_add(state, var);
50} 50}
diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c
index e8a58d3e20..a0d0e4ec1a 100644
--- a/src/lib/eolian/database_var_api.c
+++ b/src/lib/eolian/database_var_api.c
@@ -6,61 +6,58 @@
6#include "eolian_database.h" 6#include "eolian_database.h"
7 7
8EAPI const Eolian_Variable * 8EAPI const Eolian_Variable *
9eolian_variable_global_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 9eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name)
10 const char *name)
11{ 10{
12 if (!_state) return NULL; 11 if (!unit) return NULL;
13 Eina_Stringshare *shr = eina_stringshare_add(name); 12 Eina_Stringshare *shr = eina_stringshare_add(name);
14 Eolian_Variable *v = eina_hash_find(_state->unit.globals, shr); 13 Eolian_Variable *v = eina_hash_find(unit->state->unit.globals, shr);
15 eina_stringshare_del(shr); 14 eina_stringshare_del(shr);
16 return v; 15 return v;
17} 16}
18 17
19EAPI const Eolian_Variable * 18EAPI const Eolian_Variable *
20eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED, 19eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name)
21 const char *name)
22{ 20{
23 if (!_state) return NULL; 21 if (!unit) return NULL;
24 Eina_Stringshare *shr = eina_stringshare_add(name); 22 Eina_Stringshare *shr = eina_stringshare_add(name);
25 Eolian_Variable *v = eina_hash_find(_state->unit.constants, shr); 23 Eolian_Variable *v = eina_hash_find(unit->state->unit.constants, shr);
26 eina_stringshare_del(shr); 24 eina_stringshare_del(shr);
27 return v; 25 return v;
28} 26}
29 27
30EAPI Eina_Iterator * 28EAPI Eina_Iterator *
31eolian_variable_globals_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 29eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname)
32 const char *fname)
33{ 30{
34 if (!_state) return NULL; 31 if (!unit) return NULL;
35 Eina_Stringshare *shr = eina_stringshare_add(fname); 32 Eina_Stringshare *shr = eina_stringshare_add(fname);
36 Eina_List *l = eina_hash_find(_state->globals_f, shr); 33 Eina_List *l = eina_hash_find(unit->state->globals_f, shr);
37 eina_stringshare_del(shr); 34 eina_stringshare_del(shr);
38 if (!l) return NULL; 35 if (!l) return NULL;
39 return eina_list_iterator_new(l); 36 return eina_list_iterator_new(l);
40} 37}
41 38
42EAPI Eina_Iterator * 39EAPI Eina_Iterator *
43eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED, 40eolian_variable_constants_get_by_file(const Eolian_Unit *unit,
44 const char *fname) 41 const char *fname)
45{ 42{
46 if (!_state) return NULL; 43 if (!unit) return NULL;
47 Eina_Stringshare *shr = eina_stringshare_add(fname); 44 Eina_Stringshare *shr = eina_stringshare_add(fname);
48 Eina_List *l = eina_hash_find(_state->constants_f, shr); 45 Eina_List *l = eina_hash_find(unit->state->constants_f, shr);
49 eina_stringshare_del(shr); 46 eina_stringshare_del(shr);
50 if (!l) return NULL; 47 if (!l) return NULL;
51 return eina_list_iterator_new(l); 48 return eina_list_iterator_new(l);
52} 49}
53 50
54EAPI Eina_Iterator * 51EAPI Eina_Iterator *
55eolian_variable_all_constants_get(const Eolian_Unit *unit EINA_UNUSED) 52eolian_variable_all_constants_get(const Eolian_Unit *unit)
56{ 53{
57 return (_state ? eina_hash_iterator_data_new(_state->unit.constants) : NULL); 54 return (unit ? eina_hash_iterator_data_new(unit->state->unit.constants) : NULL);
58} 55}
59 56
60EAPI Eina_Iterator * 57EAPI Eina_Iterator *
61eolian_variable_all_globals_get(const Eolian_Unit *unit EINA_UNUSED) 58eolian_variable_all_globals_get(const Eolian_Unit *unit)
62{ 59{
63 return (_state ? eina_hash_iterator_data_new(_state->unit.globals) : NULL); 60 return (unit ? eina_hash_iterator_data_new(unit->state->unit.globals) : NULL);
64} 61}
65 62
66EAPI Eolian_Variable_Type 63EAPI Eolian_Variable_Type
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 71942504dd..9594d4a4b6 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -261,7 +261,7 @@ enum Doc_Tokens {
261}; 261};
262 262
263static void 263static void
264doc_ref_class(const char *cname) 264doc_ref_class(Eo_Lexer *ls, const char *cname)
265{ 265{
266 size_t clen = strlen(cname); 266 size_t clen = strlen(cname);
267 char *buf = alloca(clen + 4); 267 char *buf = alloca(clen + 4);
@@ -275,7 +275,7 @@ doc_ref_class(const char *cname)
275 *p = tolower(*p); 275 *p = tolower(*p);
276 } 276 }
277 memcpy(buf + clen, ".eo", sizeof(".eo")); 277 memcpy(buf + clen, ".eo", sizeof(".eo"));
278 const char *eop = eina_hash_find(_state->filenames_eo, buf); 278 const char *eop = eina_hash_find(ls->state->filenames_eo, buf);
279 if (!eop) 279 if (!eop)
280 return; 280 return;
281 eina_hash_set(_defereos, buf, eop); 281 eina_hash_set(_defereos, buf, eop);
@@ -303,14 +303,14 @@ doc_ref(Eo_Lexer *ls)
303 buf[rlen] = '\0'; 303 buf[rlen] = '\0';
304 304
305 /* actual full class name */ 305 /* actual full class name */
306 doc_ref_class(buf); 306 doc_ref_class(ls, buf);
307 307
308 /* method name at the end */ 308 /* method name at the end */
309 char *end = strrchr(buf, '.'); 309 char *end = strrchr(buf, '.');
310 if (!end) 310 if (!end)
311 return; 311 return;
312 *end = '\0'; 312 *end = '\0';
313 doc_ref_class(buf); 313 doc_ref_class(ls, buf);
314 314
315 /* .get or .set at the end, handle possible property */ 315 /* .get or .set at the end, handle possible property */
316 if (strcmp(end + 1, "get") && strcmp(end + 1, "set")) 316 if (strcmp(end + 1, "get") && strcmp(end + 1, "set"))
@@ -319,7 +319,7 @@ doc_ref(Eo_Lexer *ls)
319 if (!end) 319 if (!end)
320 return; 320 return;
321 *end = '\0'; 321 *end = '\0';
322 doc_ref_class(buf); 322 doc_ref_class(ls, buf);
323} 323}
324 324
325static int 325static int
@@ -1014,7 +1014,7 @@ get_filename(Eo_Lexer *ls)
1014} 1014}
1015 1015
1016static void 1016static void
1017eo_lexer_set_input(Eo_Lexer *ls, const char *source) 1017eo_lexer_set_input(Eo_Lexer *ls, Eolian *state, const char *source)
1018{ 1018{
1019 Eina_File *f = eina_file_open(source, EINA_FALSE); 1019 Eina_File *f = eina_file_open(source, EINA_FALSE);
1020 if (!f) 1020 if (!f)
@@ -1023,6 +1023,7 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
1023 longjmp(ls->err_jmp, EINA_TRUE); 1023 longjmp(ls->err_jmp, EINA_TRUE);
1024 } 1024 }
1025 ls->lookahead.token = -1; 1025 ls->lookahead.token = -1;
1026 ls->state = state;
1026 ls->buff = eina_strbuf_new(); 1027 ls->buff = eina_strbuf_new();
1027 ls->handle = f; 1028 ls->handle = f;
1028 ls->stream = eina_file_map_all(f, EINA_FILE_RANDOM); 1029 ls->stream = eina_file_map_all(f, EINA_FILE_RANDOM);
@@ -1045,7 +1046,7 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
1045 next_char(ls); 1046 next_char(ls);
1046 1047
1047 Eolian_Unit *ncunit = calloc(1, sizeof(Eolian_Unit)); 1048 Eolian_Unit *ncunit = calloc(1, sizeof(Eolian_Unit));
1048 database_unit_init(ncunit, ls->filename); 1049 database_unit_init(state, ncunit, ls->filename);
1049 eina_hash_add(_units, ls->filename, ncunit); 1050 eina_hash_add(_units, ls->filename, ncunit);
1050} 1051}
1051 1052
@@ -1112,13 +1113,13 @@ eo_lexer_free(Eo_Lexer *ls)
1112} 1113}
1113 1114
1114Eo_Lexer * 1115Eo_Lexer *
1115eo_lexer_new(const char *source) 1116eo_lexer_new(Eolian *state, const char *source)
1116{ 1117{
1117 volatile Eo_Lexer *ls = calloc(1, sizeof(Eo_Lexer)); 1118 volatile Eo_Lexer *ls = calloc(1, sizeof(Eo_Lexer));
1118 1119
1119 if (!setjmp(((Eo_Lexer *)(ls))->err_jmp)) 1120 if (!setjmp(((Eo_Lexer *)(ls))->err_jmp))
1120 { 1121 {
1121 eo_lexer_set_input((Eo_Lexer *) ls, source); 1122 eo_lexer_set_input((Eo_Lexer *) ls, state, source);
1122 return (Eo_Lexer *) ls; 1123 return (Eo_Lexer *) ls;
1123 } 1124 }
1124 eo_lexer_free((Eo_Lexer *) ls); 1125 eo_lexer_free((Eo_Lexer *) ls);
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index b911ddb5f6..e6f3249dcd 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -166,6 +166,8 @@ typedef struct _Eo_Lexer
166 /* points to the current line being lexed, used by error messages to 166 /* points to the current line being lexed, used by error messages to
167 * display the current line with a caret at the respective column */ 167 * display the current line with a caret at the respective column */
168 const char *stream_line; 168 const char *stream_line;
169 /* a pointer to the state this lexer belongs to */
170 Eolian *state;
169 /* this is jumped to when an error happens */ 171 /* this is jumped to when an error happens */
170 jmp_buf err_jmp; 172 jmp_buf err_jmp;
171 173
@@ -187,7 +189,7 @@ typedef struct _Eo_Lexer
187 189
188int eo_lexer_init (void); 190int eo_lexer_init (void);
189int eo_lexer_shutdown (void); 191int eo_lexer_shutdown (void);
190Eo_Lexer *eo_lexer_new (const char *source); 192Eo_Lexer *eo_lexer_new (Eolian *state, const char *source);
191void eo_lexer_free (Eo_Lexer *ls); 193void eo_lexer_free (Eo_Lexer *ls);
192/* gets a regular token, singlechar or one of TOK_something */ 194/* gets a regular token, singlechar or one of TOK_something */
193int eo_lexer_get (Eo_Lexer *ls); 195int eo_lexer_get (Eo_Lexer *ls);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index daf64cbcdb..887bfd3fdf 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -528,7 +528,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
528 } 528 }
529 check_match(ls, '}', '{', bline, bcolumn); 529 check_match(ls, '}', '{', bline, bcolumn);
530 FILL_BASE(def->base, ls, line, column); 530 FILL_BASE(def->base, ls, line, column);
531 if (name) database_struct_add(def); 531 if (name) database_struct_add(ls->state, def);
532 return def; 532 return def;
533} 533}
534 534
@@ -640,7 +640,7 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
640 } 640 }
641 check_match(ls, '}', '{', bline, bcolumn); 641 check_match(ls, '}', '{', bline, bcolumn);
642 FILL_BASE(def->base, ls, line, column); 642 FILL_BASE(def->base, ls, line, column);
643 if (name) database_enum_add(def); 643 if (name) database_enum_add(ls->state, def);
644 return def; 644 return def;
645} 645}
646 646
@@ -683,7 +683,7 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
683 if (eina_hash_find(_parsingeos, fname)) 683 if (eina_hash_find(_parsingeos, fname))
684 return NULL; 684 return NULL;
685 Eolian_Class *cl = NULL; 685 Eolian_Class *cl = NULL;
686 if (!eo_parser_database_fill(fname, EINA_FALSE, &cl) || !cl) 686 if (!eo_parser_database_fill(ls->state, fname, EINA_FALSE, &cl) || !cl)
687 { 687 {
688 char buf[PATH_MAX]; 688 char buf[PATH_MAX];
689 eo_lexer_context_restore(ls); 689 eo_lexer_context_restore(ls);
@@ -822,7 +822,7 @@ parse_type_void(Eo_Lexer *ls)
822 fnm = database_class_to_filename(nm); 822 fnm = database_class_to_filename(nm);
823 if (!compare_class_file(bnm, fnm)) 823 if (!compare_class_file(bnm, fnm))
824 { 824 {
825 const char *fname = eina_hash_find(_state->filenames_eo, fnm); 825 const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
826 eina_stringshare_del(bnm); 826 eina_stringshare_del(bnm);
827 free(fnm); 827 free(fnm);
828 if (fname) 828 if (fname)
@@ -1530,7 +1530,7 @@ parse_part(Eo_Lexer *ls)
1530 if (!compare_class_file(bnm, fnm)) 1530 if (!compare_class_file(bnm, fnm))
1531 { 1531 {
1532 Eolian_Class *dep = NULL; 1532 Eolian_Class *dep = NULL;
1533 const char *fname = eina_hash_find(_state->filenames_eo, fnm); 1533 const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
1534 eina_stringshare_del(bnm); 1534 eina_stringshare_del(bnm);
1535 free(fnm); 1535 free(fnm);
1536 if (fname) 1536 if (fname)
@@ -2038,7 +2038,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2038 eo_lexer_syntax_error(ls, ebuf); 2038 eo_lexer_syntax_error(ls, ebuf);
2039 return; /* unreachable (longjmp above), make static analysis shut up */ 2039 return; /* unreachable (longjmp above), make static analysis shut up */
2040 } 2040 }
2041 fname = eina_hash_find(_state->filenames_eo, fnm); 2041 fname = eina_hash_find(ls->state->filenames_eo, fnm);
2042 free(fnm); 2042 free(fnm);
2043 if (!fname) 2043 if (!fname)
2044 { 2044 {
@@ -2177,11 +2177,11 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2177 check(ls, TOK_VALUE); 2177 check(ls, TOK_VALUE);
2178 eina_strbuf_append(buf, ls->t.value.s); 2178 eina_strbuf_append(buf, ls->t.value.s);
2179 eina_strbuf_append(buf, ".eot"); 2179 eina_strbuf_append(buf, ".eot");
2180 if (!(found = eina_hash_find(_state->filenames_eot, eina_strbuf_string_get(buf)))) 2180 if (!(found = eina_hash_find(ls->state->filenames_eot, eina_strbuf_string_get(buf))))
2181 { 2181 {
2182 size_t buflen = eina_strbuf_length_get(buf); 2182 size_t buflen = eina_strbuf_length_get(buf);
2183 eina_strbuf_remove(buf, buflen - 1, buflen); 2183 eina_strbuf_remove(buf, buflen - 1, buflen);
2184 if (!(found = eina_hash_find(_state->filenames_eo, eina_strbuf_string_get(buf)))) 2184 if (!(found = eina_hash_find(ls->state->filenames_eo, eina_strbuf_string_get(buf))))
2185 { 2185 {
2186 pop_strbuf(ls); 2186 pop_strbuf(ls);
2187 snprintf(errbuf, sizeof(errbuf), 2187 snprintf(errbuf, sizeof(errbuf),
@@ -2197,20 +2197,20 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2197 } 2197 }
2198 case KW_type: 2198 case KW_type:
2199 { 2199 {
2200 database_type_add(parse_typedef(ls)); 2200 database_type_add(ls->state, parse_typedef(ls));
2201 pop_typedecl(ls); 2201 pop_typedecl(ls);
2202 break; 2202 break;
2203 } 2203 }
2204 case KW_function: 2204 case KW_function:
2205 { 2205 {
2206 database_type_add(parse_function_pointer(ls)); 2206 database_type_add(ls->state, parse_function_pointer(ls));
2207 pop_typedecl(ls); 2207 pop_typedecl(ls);
2208 break; 2208 break;
2209 } 2209 }
2210 case KW_const: 2210 case KW_const:
2211 case KW_var: 2211 case KW_var:
2212 { 2212 {
2213 database_var_add(parse_variable(ls, ls->t.kw == KW_var)); 2213 database_var_add(ls->state, parse_variable(ls, ls->t.kw == KW_var));
2214 eolian_object_ref(&ls->tmp.var->base); 2214 eolian_object_ref(&ls->tmp.var->base);
2215 ls->tmp.var = NULL; 2215 ls->tmp.var = NULL;
2216 break; 2216 break;
@@ -2253,7 +2253,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2253 eo_lexer_get(ls); 2253 eo_lexer_get(ls);
2254 FILL_DOC(ls, def, doc); 2254 FILL_DOC(ls, def, doc);
2255 FILL_BASE(def->base, ls, line, col); 2255 FILL_BASE(def->base, ls, line, col);
2256 database_struct_add(def); 2256 database_struct_add(ls->state, def);
2257 pop_typedecl(ls); 2257 pop_typedecl(ls);
2258 break; 2258 break;
2259 } 2259 }
@@ -2497,7 +2497,7 @@ end:
2497} 2497}
2498 2498
2499Eina_Bool 2499Eina_Bool
2500eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **fcl) 2500eo_parser_database_fill(Eolian *state, const char *filename, Eina_Bool eot, Eolian_Class **fcl)
2501{ 2501{
2502 Eolian_Class *cl = eina_hash_find(_parsedeos, filename); 2502 Eolian_Class *cl = eina_hash_find(_parsedeos, filename);
2503 if (cl) 2503 if (cl)
@@ -2508,7 +2508,7 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **fcl)
2508 2508
2509 eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE); 2509 eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE);
2510 2510
2511 Eo_Lexer *ls = eo_lexer_new(filename); 2511 Eo_Lexer *ls = eo_lexer_new(state, filename);
2512 if (!ls) 2512 if (!ls)
2513 { 2513 {
2514 _eolian_log("unable to create lexer for file '%s'", filename); 2514 _eolian_log("unable to create lexer for file '%s'", filename);
@@ -2537,8 +2537,8 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **fcl)
2537 if (!_db_fill_ctors(cl)) 2537 if (!_db_fill_ctors(cl))
2538 goto error; 2538 goto error;
2539 2539
2540 eina_hash_set(_state->unit.classes, cl->full_name, cl); 2540 eina_hash_set(ls->state->unit.classes, cl->full_name, cl);
2541 eina_hash_set(_state->classes_f, cl->base.file, cl); 2541 eina_hash_set(ls->state->classes_f, cl->base.file, cl);
2542 eolian_object_ref(&cl->base); 2542 eolian_object_ref(&cl->base);
2543 2543
2544 if (fcl) *fcl = cl; 2544 if (fcl) *fcl = cl;
diff --git a/src/lib/eolian/eo_parser.h b/src/lib/eolian/eo_parser.h
index 7179107803..8196c5bf9d 100644
--- a/src/lib/eolian/eo_parser.h
+++ b/src/lib/eolian/eo_parser.h
@@ -3,6 +3,6 @@
3 3
4#include "eo_lexer.h" 4#include "eo_lexer.h"
5 5
6Eina_Bool eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **cl); 6Eina_Bool eo_parser_database_fill(Eolian *state, const char *filename, Eina_Bool eot, Eolian_Class **cl);
7 7
8#endif /* __EO_PARSER_H__ */ \ No newline at end of file 8#endif /* __EO_PARSER_H__ */ \ No newline at end of file
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 6db5c0553c..7f7c5a2788 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -19,8 +19,6 @@ Eina_Hash *_defereos = NULL;
19 19
20static Eolian_Unit *_cunit = NULL; 20static Eolian_Unit *_cunit = NULL;
21 21
22Eolian *_state = NULL;
23
24static int _database_init_count = 0; 22static int _database_init_count = 0;
25 23
26static void 24static void
@@ -40,7 +38,6 @@ database_init()
40 _parsingeos = eina_hash_string_small_new(NULL); 38 _parsingeos = eina_hash_string_small_new(NULL);
41 _defereos = eina_hash_string_small_new(NULL); 39 _defereos = eina_hash_string_small_new(NULL);
42 _units = eina_hash_stringshared_new(EINA_FREE_CB(database_unit_del)); 40 _units = eina_hash_stringshared_new(EINA_FREE_CB(database_unit_del));
43 _state = eolian_new();
44 return ++_database_init_count; 41 return ++_database_init_count;
45} 42}
46 43
@@ -56,7 +53,6 @@ database_shutdown()
56 53
57 if (_database_init_count == 0) 54 if (_database_init_count == 0)
58 { 55 {
59 eolian_free(_state); _state = NULL;
60 eina_hash_free(_decls ); _decls = NULL; 56 eina_hash_free(_decls ); _decls = NULL;
61 eina_hash_free(_declsf ); _declsf = NULL; 57 eina_hash_free(_declsf ); _declsf = NULL;
62 eina_hash_free(_parsedeos ); _parsedeos = NULL; 58 eina_hash_free(_parsedeos ); _parsedeos = NULL;
@@ -562,8 +558,10 @@ eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
562} 558}
563 559
564void 560void
565database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname) 561database_unit_init(Eolian *state, Eolian_Unit *unit, Eina_Stringshare *fname)
566{ 562{
563 unit->state = state;
564
567 if (fname) 565 if (fname)
568 { 566 {
569 Eolian_Unit *ocunit = _cunit; 567 Eolian_Unit *ocunit = _cunit;
@@ -605,7 +603,7 @@ eolian_new(void)
605 if (!state) 603 if (!state)
606 return NULL; 604 return NULL;
607 605
608 database_unit_init(&state->unit, NULL); 606 database_unit_init(state, &state->unit, NULL);
609 607
610 state->filenames_eo = eina_hash_string_small_new(free); 608 state->filenames_eo = eina_hash_string_small_new(free);
611 state->filenames_eot = eina_hash_string_small_new(free); 609 state->filenames_eot = eina_hash_string_small_new(free);
@@ -651,17 +649,18 @@ join_path(const char *path, const char *file)
651static void 649static void
652_scan_cb(const char *name, const char *path, void *data EINA_UNUSED) 650_scan_cb(const char *name, const char *path, void *data EINA_UNUSED)
653{ 651{
652 Eolian *state = data;
654 Eina_Bool is_eo = eina_str_has_suffix(name, EO_SUFFIX); 653 Eina_Bool is_eo = eina_str_has_suffix(name, EO_SUFFIX);
655 if (!is_eo && !eina_str_has_suffix(name, EOT_SUFFIX)) return; 654 if (!is_eo && !eina_str_has_suffix(name, EOT_SUFFIX)) return;
656 eina_hash_add(is_eo ? _state->filenames_eo : _state->filenames_eot, 655 eina_hash_add(is_eo ? state->filenames_eo : state->filenames_eot,
657 eina_stringshare_add(name), join_path(path, name)); 656 eina_stringshare_add(name), join_path(path, name));
658} 657}
659 658
660EAPI Eina_Bool 659EAPI Eina_Bool
661eolian_directory_scan(Eolian *state EINA_UNUSED, const char *dir) 660eolian_directory_scan(Eolian *state, const char *dir)
662{ 661{
663 if (!dir) return EINA_FALSE; 662 if (!dir || !state) return EINA_FALSE;
664 eina_file_dir_list(dir, EINA_TRUE, _scan_cb, NULL); 663 eina_file_dir_list(dir, EINA_TRUE, _scan_cb, state);
665 return EINA_TRUE; 664 return EINA_TRUE;
666} 665}
667 666
@@ -695,7 +694,7 @@ database_class_to_filename(const char *cname)
695} 694}
696 695
697static Eina_Bool 696static Eina_Bool
698_eolian_file_parse_nodep(const char *filepath) 697_eolian_file_parse_nodep(Eolian *state, const char *filepath)
699{ 698{
700 Eina_Bool is_eo; 699 Eina_Bool is_eo;
701 const char *eopath; 700 const char *eopath;
@@ -707,18 +706,18 @@ _eolian_file_parse_nodep(const char *filepath)
707 _eolian_log("file '%s' doesn't have a correct extension", filepath); 706 _eolian_log("file '%s' doesn't have a correct extension", filepath);
708 return EINA_FALSE; 707 return EINA_FALSE;
709 } 708 }
710 if (!(eopath = eina_hash_find(is_eo ? _state->filenames_eo : _state->filenames_eot, filepath))) 709 if (!(eopath = eina_hash_find(is_eo ? state->filenames_eo : state->filenames_eot, filepath)))
711 { 710 {
712 char *vpath = eina_file_path_sanitize(filepath); 711 char *vpath = eina_file_path_sanitize(filepath);
713 Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo, NULL); 712 Eina_Bool ret = eo_parser_database_fill(state, vpath, !is_eo, NULL);
714 free(vpath); 713 free(vpath);
715 return ret; 714 return ret;
716 } 715 }
717 return eo_parser_database_fill(eopath, !is_eo, NULL); 716 return eo_parser_database_fill(state, eopath, !is_eo, NULL);
718} 717}
719 718
720static Eina_Bool 719static Eina_Bool
721_parse_deferred() 720_parse_deferred(Eolian *state)
722{ 721{
723 Eina_Hash *defer = _defereos; 722 Eina_Hash *defer = _defereos;
724 if (!defer || !eina_hash_population(defer)) 723 if (!defer || !eina_hash_population(defer))
@@ -729,7 +728,7 @@ _parse_deferred()
729 const char *dep; 728 const char *dep;
730 EINA_ITERATOR_FOREACH(itr, dep) 729 EINA_ITERATOR_FOREACH(itr, dep)
731 { 730 {
732 if (!_eolian_file_parse_nodep(dep)) 731 if (!_eolian_file_parse_nodep(state, dep))
733 { 732 {
734 eina_iterator_free(itr); 733 eina_iterator_free(itr);
735 eina_hash_free_buckets(_defereos); 734 eina_hash_free_buckets(_defereos);
@@ -740,98 +739,102 @@ _parse_deferred()
740 eina_iterator_free(itr); 739 eina_iterator_free(itr);
741 eina_hash_free(defer); 740 eina_hash_free(defer);
742 /* in case more deps were queued in, parse them */ 741 /* in case more deps were queued in, parse them */
743 return _parse_deferred(); 742 return _parse_deferred(state);
744} 743}
745 744
746static Eolian_Unit unit_tmp;
747
748EAPI const Eolian_Unit * 745EAPI const Eolian_Unit *
749eolian_file_parse(Eolian *state EINA_UNUSED, const char *filepath) 746eolian_file_parse(Eolian *state, const char *filepath)
750{ 747{
751 if (!_eolian_file_parse_nodep(filepath)) 748 if (!_eolian_file_parse_nodep(state, filepath))
752 return NULL; 749 return NULL;
753 if (!_parse_deferred()) 750 if (!_parse_deferred(state))
754 return NULL; 751 return NULL;
755 /* FIXME: pass unit properly */ 752 /* FIXME: pass unit properly */
756 if (!database_validate(NULL)) 753 if (!database_validate(state, &state->unit))
757 return NULL; 754 return NULL;
758 return &unit_tmp; 755 return &state->unit;
759} 756}
760 757
758typedef struct _Parse_Data
759{
760 Eolian *state;
761 Eina_Bool ret;
762} Parse_Data;
763
761static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 764static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
762{ 765{
763 Eina_Bool *ret = fdata; 766 Parse_Data *pd = fdata;
764 if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE, NULL); 767 if (pd->ret) pd->ret = eo_parser_database_fill(pd->state, data, EINA_TRUE, NULL);
765 if (*ret) *ret = _parse_deferred(); 768 if (pd->ret) pd->ret = _parse_deferred(pd->state);
766 return *ret; 769 return pd->ret;
767} 770}
768 771
769EAPI Eina_Bool 772EAPI Eina_Bool
770eolian_all_eot_files_parse(Eolian *state EINA_UNUSED) 773eolian_all_eot_files_parse(Eolian *state)
771{ 774{
772 Eina_Bool ret = EINA_TRUE; 775 Parse_Data pd = { state, EINA_TRUE };
773 776
774 if (_database_init_count <= 0) 777 if (_database_init_count <= 0)
775 return EINA_FALSE; 778 return EINA_FALSE;
776 779
777 eina_hash_foreach(_state->filenames_eot, _tfile_parse, &ret); 780 eina_hash_foreach(state->filenames_eot, _tfile_parse, &pd);
778 781
779 /* FIXME: pass unit properly */ 782 /* FIXME: pass unit properly */
780 if (ret && !database_validate(NULL)) 783 if (pd.ret && !database_validate(state, &state->unit))
781 return EINA_FALSE; 784 return EINA_FALSE;
782 785
783 return ret; 786 return pd.ret;
784} 787}
785 788
786static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 789static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
787{ 790{
788 Eina_Bool *ret = fdata; 791 Parse_Data *pd = fdata;
789 if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE, NULL); 792 if (pd->ret) pd->ret = eo_parser_database_fill(pd->state, data, EINA_FALSE, NULL);
790 if (*ret) *ret = _parse_deferred(); 793 if (pd->ret) pd->ret = _parse_deferred(pd->state);
791 return *ret; 794 return pd->ret;
792} 795}
793 796
794EAPI Eina_Bool 797EAPI Eina_Bool
795eolian_all_eo_files_parse(Eolian *state EINA_UNUSED) 798eolian_all_eo_files_parse(Eolian *state)
796{ 799{
797 Eina_Bool ret = EINA_TRUE; 800 Parse_Data pd = { state, EINA_TRUE };
798 801
799 if (_database_init_count <= 0) 802 if (_database_init_count <= 0)
800 return EINA_FALSE; 803 return EINA_FALSE;
801 804
802 eina_hash_foreach(_state->filenames_eo, _file_parse, &ret); 805 eina_hash_foreach(state->filenames_eo, _file_parse, &pd);
803 806
804 /* FIXME: pass unit properly */ 807 /* FIXME: pass unit properly */
805 if (ret && !database_validate(NULL)) 808 if (pd.ret && !database_validate(state, &state->unit))
806 return EINA_FALSE; 809 return EINA_FALSE;
807 810
808 return ret; 811 return pd.ret;
809} 812}
810 813
811EAPI Eina_Iterator * 814EAPI Eina_Iterator *
812eolian_all_eot_files_get(Eolian *state EINA_UNUSED) 815eolian_all_eot_files_get(Eolian *state)
813{ 816{
814 if (!_state) return NULL; 817 if (!state) return NULL;
815 return eina_hash_iterator_key_new(_state->filenames_eot); 818 return eina_hash_iterator_key_new(state->filenames_eot);
816} 819}
817 820
818EAPI Eina_Iterator * 821EAPI Eina_Iterator *
819eolian_all_eo_files_get(Eolian *state EINA_UNUSED) 822eolian_all_eo_files_get(Eolian *state)
820{ 823{
821 if (!_state) return NULL; 824 if (!state) return NULL;
822 return eina_hash_iterator_key_new(_state->filenames_eo); 825 return eina_hash_iterator_key_new(state->filenames_eo);
823} 826}
824 827
825EAPI Eina_Iterator * 828EAPI Eina_Iterator *
826eolian_all_eot_file_paths_get(Eolian *state EINA_UNUSED) 829eolian_all_eot_file_paths_get(Eolian *state)
827{ 830{
828 if (!_state) return NULL; 831 if (!state) return NULL;
829 return eina_hash_iterator_data_new(_state->filenames_eot); 832 return eina_hash_iterator_data_new(state->filenames_eot);
830} 833}
831 834
832EAPI Eina_Iterator * 835EAPI Eina_Iterator *
833eolian_all_eo_file_paths_get(Eolian *state EINA_UNUSED) 836eolian_all_eo_file_paths_get(Eolian *state)
834{ 837{
835 if (!_state) return NULL; 838 if (!state) return NULL;
836 return eina_hash_iterator_data_new(_state->filenames_eo); 839 return eina_hash_iterator_data_new(state->filenames_eo);
837} 840}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 529681de3f..c59e6e69bd 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -44,11 +44,9 @@ extern Eina_Hash *_parsingeos;
44/* for deferred dependency parsing */ 44/* for deferred dependency parsing */
45extern Eina_Hash *_defereos; 45extern Eina_Hash *_defereos;
46 46
47/* TODO: remove */
48extern Eolian *_state;
49
50struct _Eolian_Unit 47struct _Eolian_Unit
51{ 48{
49 Eolian *state;
52 Eolian_Unit *parent; 50 Eolian_Unit *parent;
53 Eina_Hash *children; 51 Eina_Hash *children;
54 Eina_Hash *classes; 52 Eina_Hash *classes;
@@ -326,21 +324,21 @@ int database_init(void);
326int database_shutdown(void); 324int database_shutdown(void);
327 325
328char *database_class_to_filename(const char *cname); 326char *database_class_to_filename(const char *cname);
329Eina_Bool database_validate(const Eolian_Unit *src); 327Eina_Bool database_validate(Eolian *state, const Eolian_Unit *src);
330 328
331void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type, 329void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
332 Eina_Stringshare *file, void *ptr); 330 Eina_Stringshare *file, void *ptr);
333 331
334void database_doc_del(Eolian_Documentation *doc); 332void database_doc_del(Eolian_Documentation *doc);
335 333
336void database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname); 334void database_unit_init(Eolian *state, Eolian_Unit *unit, Eina_Stringshare *fname);
337void database_unit_del(Eolian_Unit *unit); 335void database_unit_del(Eolian_Unit *unit);
338 336
339/* types */ 337/* types */
340 338
341void database_type_add(Eolian_Typedecl *def); 339void database_type_add(Eolian *state, Eolian_Typedecl *def);
342void database_struct_add(Eolian_Typedecl *tp); 340void database_struct_add(Eolian *state, Eolian_Typedecl *tp);
343void database_enum_add(Eolian_Typedecl *tp); 341void database_enum_add(Eolian *state, Eolian_Typedecl *tp);
344void database_type_del(Eolian_Type *tp); 342void database_type_del(Eolian_Type *tp);
345void database_typedecl_del(Eolian_Typedecl *tp); 343void database_typedecl_del(Eolian_Typedecl *tp);
346 344
@@ -358,7 +356,7 @@ void database_expr_print(Eolian_Expression *expr);
358/* variables */ 356/* variables */
359 357
360void database_var_del(Eolian_Variable *var); 358void database_var_del(Eolian_Variable *var);
361void database_var_add(Eolian_Variable *var); 359void database_var_add(Eolian *state, Eolian_Variable *var);
362 360
363/* classes */ 361/* classes */
364void database_class_del(Eolian_Class *cl); 362void database_class_del(Eolian_Class *cl);