summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian_mono.cc
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-06 13:27:27 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-06 19:11:13 -0300
commit3861f8b01d9dd213fd966b178dcdaf71110e2d76 (patch)
tree48d101af5ab2abb6d94bb0c8909e4eb8624776ac /src/bin/eolian_mono/eolian_mono.cc
parentc5ff7f0f4687ccbd670a8094288eae1d6c536809 (diff)
eolian_mono: Fix build after Eolian_State
Summary: eolian_mono now properly fills Eolian Unit when calling eolian_cxx classes and functions. Reviewers: felipealmeida Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5614
Diffstat (limited to 'src/bin/eolian_mono/eolian_mono.cc')
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index 220f1e43c4..43eebfc1f2 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -40,6 +40,8 @@ struct options_type
40 std::string in_file; 40 std::string in_file;
41 std::string out_file; 41 std::string out_file;
42 std::string dllimport; 42 std::string dllimport;
43 mutable Eolian* state;
44 mutable Eolian_Unit const* unit;
43 int v_major; 45 int v_major;
44 int v_minor; 46 int v_minor;
45 std::map<const std::string, std::string> references_map; 47 std::map<const std::string, std::string> references_map;
@@ -97,8 +99,8 @@ run(options_type const& opts)
97 const Eolian_Typedecl *tp = NULL; 99 const Eolian_Typedecl *tp = NULL;
98 char* dup = strdup(opts.in_file.c_str()); 100 char* dup = strdup(opts.in_file.c_str());
99 std::string basename_input = basename(dup); 101 std::string basename_input = basename(dup);
100 klass = ::eolian_class_get_by_file(NULL, basename_input.c_str()); 102 klass = ::eolian_class_get_by_file(opts.unit, basename_input.c_str());
101 aliases= ::eolian_typedecl_aliases_get_by_file(NULL, basename_input.c_str()); 103 aliases= ::eolian_typedecl_aliases_get_by_file(opts.unit, basename_input.c_str());
102 free(dup); 104 free(dup);
103 105
104 std::string class_file_name = opts.out_file; 106 std::string class_file_name = opts.out_file;
@@ -139,7 +141,7 @@ run(options_type const& opts)
139 continue; 141 continue;
140 142
141 const Eolian_Function *fp = eolian_typedecl_function_pointer_get(tp); 143 const Eolian_Function *fp = eolian_typedecl_function_pointer_get(tp);
142 efl::eolian::grammar::attributes::function_def function_def(fp, EOLIAN_FUNCTION_POINTER, NULL); 144 efl::eolian::grammar::attributes::function_def function_def(fp, EOLIAN_FUNCTION_POINTER, opts.unit);
143 std::vector<std::string> namespaces; 145 std::vector<std::string> namespaces;
144 146
145 for (efl::eina::iterator<const char> namespace_iterator(::eolian_typedecl_namespaces_get(tp)), namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 147 for (efl::eina::iterator<const char> namespace_iterator(::eolian_typedecl_namespaces_get(tp)), namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -156,7 +158,7 @@ run(options_type const& opts)
156 158
157 if (klass) 159 if (klass)
158 { 160 {
159 efl::eolian::grammar::attributes::klass_def klass_def(klass, NULL); 161 efl::eolian::grammar::attributes::klass_def klass_def(klass, opts.unit);
160 std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def}; 162 std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def};
161 163
162 if (!eolian_mono::klass 164 if (!eolian_mono::klass
@@ -167,20 +169,20 @@ run(options_type const& opts)
167 } 169 }
168 //else 170 //else
169 { 171 {
170 for (efl::eina::iterator<const Eolian_Typedecl> enum_iterator( ::eolian_typedecl_enums_get_by_file(NULL, basename_input.c_str())) 172 for (efl::eina::iterator<const Eolian_Typedecl> enum_iterator( ::eolian_typedecl_enums_get_by_file(opts.unit, basename_input.c_str()))
171 , enum_last; enum_iterator != enum_last; ++enum_iterator) 173 , enum_last; enum_iterator != enum_last; ++enum_iterator)
172 { 174 {
173 efl::eolian::grammar::attributes::enum_def enum_(&*enum_iterator); 175 efl::eolian::grammar::attributes::enum_def enum_(&*enum_iterator, opts.unit);
174 if (!eolian_mono::enum_definition.generate(iterator, enum_, efl::eolian::grammar::context_null())) 176 if (!eolian_mono::enum_definition.generate(iterator, enum_, efl::eolian::grammar::context_null()))
175 { 177 {
176 throw std::runtime_error("Failed to generate enum"); 178 throw std::runtime_error("Failed to generate enum");
177 } 179 }
178 } 180 }
179 181
180 for (efl::eina::iterator<const Eolian_Typedecl> struct_iterator( ::eolian_typedecl_structs_get_by_file(NULL, basename_input.c_str())) 182 for (efl::eina::iterator<const Eolian_Typedecl> struct_iterator( ::eolian_typedecl_structs_get_by_file(opts.unit, basename_input.c_str()))
181 , struct_last; struct_iterator != struct_last; ++struct_iterator) 183 , struct_last; struct_iterator != struct_last; ++struct_iterator)
182 { 184 {
183 efl::eolian::grammar::attributes::struct_def struct_(&*struct_iterator); 185 efl::eolian::grammar::attributes::struct_def struct_(&*struct_iterator, opts.unit);
184 if (!eolian_mono::struct_definition.generate(iterator, struct_, efl::eolian::grammar::context_null())) 186 if (!eolian_mono::struct_definition.generate(iterator, struct_, efl::eolian::grammar::context_null()))
185 { 187 {
186 throw std::runtime_error("Failed to generate struct"); 188 throw std::runtime_error("Failed to generate struct");
@@ -191,17 +193,31 @@ run(options_type const& opts)
191} 193}
192 194
193static void 195static void
196state_init(options_type const& opts)
197{
198 Eolian *eos = ::eolian_new();
199 if (!eos)
200 {
201 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain)
202 << "Eolian failed creating state";
203 assert(false && "Error creating state");
204 }
205 opts.state = eos;
206 opts.unit = (Eolian_Unit*)eos;
207}
208
209static void
194database_load(options_type const& opts) 210database_load(options_type const& opts)
195{ 211{
196 for (auto src : opts.include_dirs) 212 for (auto src : opts.include_dirs)
197 { 213 {
198 if (!::eolian_directory_scan(src.c_str())) 214 if (!::eolian_directory_scan(opts.state, src.c_str()))
199 { 215 {
200 EINA_CXX_DOM_LOG_WARN(eolian_mono::domain) 216 EINA_CXX_DOM_LOG_WARN(eolian_mono::domain)
201 << "Couldn't load eolian from '" << src << "'."; 217 << "Couldn't load eolian from '" << src << "'.";
202 } 218 }
203 } 219 }
204 if (!::eolian_all_eot_files_parse()) 220 if (!::eolian_all_eot_files_parse(opts.state))
205 { 221 {
206 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) 222 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain)
207 << "Eolian failed parsing eot files"; 223 << "Eolian failed parsing eot files";
@@ -213,7 +229,7 @@ database_load(options_type const& opts)
213 << "No input file."; 229 << "No input file.";
214 assert(false && "Error parsing input file"); 230 assert(false && "Error parsing input file");
215 } 231 }
216 if (!::eolian_file_parse(opts.in_file.c_str())) 232 if (!::eolian_file_parse(opts.state, opts.in_file.c_str()))
217 { 233 {
218 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) 234 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain)
219 << "Failed parsing: " << opts.in_file << "."; 235 << "Failed parsing: " << opts.in_file << ".";
@@ -352,6 +368,7 @@ int main(int argc, char **argv)
352 efl::eina::eina_init eina_init; 368 efl::eina::eina_init eina_init;
353 efl::eolian::eolian_init eolian_init; 369 efl::eolian::eolian_init eolian_init;
354 eolian_mono::options_type opts = opts_get(argc, argv); 370 eolian_mono::options_type opts = opts_get(argc, argv);
371 eolian_mono::state_init(opts);
355 eolian_mono::database_load(opts); 372 eolian_mono::database_load(opts);
356 eolian_mono::run(opts); 373 eolian_mono::run(opts);
357 } 374 }