summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-05 16:40:04 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-05 16:41:42 +0100
commit8a1f93f698315b43de28b755bce5fc9a4d85d59a (patch)
tree7b5c181026830c880b6853806657a53157c4d5dc /src/bin
parent67e1c2ab8818eda7d88ac61741824b1a903bc69d (diff)
eolian: pass state where necessary
This modifies the API so that global state removal is made possible. It's still used internally for now but externally the state is contained.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/main.c9
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc23
2 files changed, 25 insertions, 7 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index fdb5ca2568..92643c6f7e 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -430,6 +430,8 @@ main(int argc, char **argv)
430 eina_init(); 430 eina_init();
431 eolian_init(); 431 eolian_init();
432 432
433 Eolian *eos = eolian_new();
434
433 const char *dom = "eolian_gen"; 435 const char *dom = "eolian_gen";
434 _eolian_gen_log_dom = eina_log_domain_register(dom, EINA_COLOR_GREEN); 436 _eolian_gen_log_dom = eina_log_domain_register(dom, EINA_COLOR_GREEN);
435 if (_eolian_gen_log_dom < 0) 437 if (_eolian_gen_log_dom < 0)
@@ -530,7 +532,7 @@ main(int argc, char **argv)
530 532
531 if (scan_system) 533 if (scan_system)
532 { 534 {
533 if (!eolian_system_directory_scan()) 535 if (!eolian_system_directory_scan(eos))
534 { 536 {
535 fprintf(stderr, "eolian: could not scan system directory\n"); 537 fprintf(stderr, "eolian: could not scan system directory\n");
536 goto end; 538 goto end;
@@ -540,14 +542,14 @@ main(int argc, char **argv)
540 const char *inc; 542 const char *inc;
541 EINA_LIST_FREE(includes, inc) 543 EINA_LIST_FREE(includes, inc)
542 { 544 {
543 if (!eolian_directory_scan(inc)) 545 if (!eolian_directory_scan(eos, inc))
544 { 546 {
545 fprintf(stderr, "eolian: could not scan '%s'\n", inc); 547 fprintf(stderr, "eolian: could not scan '%s'\n", inc);
546 goto end; 548 goto end;
547 } 549 }
548 } 550 }
549 551
550 const Eolian_Unit *src = eolian_file_parse(input); 552 const Eolian_Unit *src = eolian_file_parse(eos, input);
551 if (!src) 553 if (!src)
552 { 554 {
553 fprintf(stderr, "eolian: could not parse file '%s'\n", input); 555 fprintf(stderr, "eolian: could not parse file '%s'\n", input);
@@ -589,6 +591,7 @@ end:
589 free(outs[i]); 591 free(outs[i]);
590 free(basen); 592 free(basen);
591 593
594 eolian_free(eos);
592 eolian_shutdown(); 595 eolian_shutdown();
593 eina_shutdown(); 596 eina_shutdown();
594 597
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index 134700ae6c..fac96da5e2 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -34,6 +34,7 @@ struct options_type
34{ 34{
35 std::vector<std::string> include_dirs; 35 std::vector<std::string> include_dirs;
36 std::vector<std::string> in_files; 36 std::vector<std::string> in_files;
37 mutable Eolian* state;
37 mutable Eolian_Unit const* unit; 38 mutable Eolian_Unit const* unit;
38 std::string out_file; 39 std::string out_file;
39 bool main_header; 40 bool main_header;
@@ -298,7 +299,7 @@ run(options_type const& opts)
298 299
299 for(auto&& name : opts.in_files) 300 for(auto&& name : opts.in_files)
300 { 301 {
301 Eolian_Unit const* unit = ::eolian_file_parse(name.c_str()); 302 Eolian_Unit const* unit = ::eolian_file_parse(opts.state, name.c_str());
302 if(!unit) 303 if(!unit)
303 { 304 {
304 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 305 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
@@ -346,17 +347,30 @@ run(options_type const& opts)
346} 347}
347 348
348static void 349static void
350state_init(options_type const& opts)
351{
352 Eolian *eos = ::eolian_new();
353 if (!eos)
354 {
355 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
356 << "Eolian failed creating state";
357 assert(false && "Error creating Eolian state");
358 }
359 opts.state = eos;
360}
361
362static void
349database_load(options_type const& opts) 363database_load(options_type const& opts)
350{ 364{
351 for (auto src : opts.include_dirs) 365 for (auto src : opts.include_dirs)
352 { 366 {
353 if (!::eolian_directory_scan(src.c_str())) 367 if (!::eolian_directory_scan(opts.state, src.c_str()))
354 { 368 {
355 EINA_CXX_DOM_LOG_WARN(eolian_cxx::domain) 369 EINA_CXX_DOM_LOG_WARN(eolian_cxx::domain)
356 << "Couldn't load eolian from '" << src << "'."; 370 << "Couldn't load eolian from '" << src << "'.";
357 } 371 }
358 } 372 }
359 if (!::eolian_all_eot_files_parse()) 373 if (!::eolian_all_eot_files_parse(opts.state))
360 { 374 {
361 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 375 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
362 << "Eolian failed parsing eot files"; 376 << "Eolian failed parsing eot files";
@@ -368,7 +382,7 @@ database_load(options_type const& opts)
368 << "No input file."; 382 << "No input file.";
369 assert(false && "Error parsing input file"); 383 assert(false && "Error parsing input file");
370 } 384 }
371 if (!opts.main_header && !::eolian_file_parse(opts.in_files[0].c_str())) 385 if (!opts.main_header && !::eolian_file_parse(opts.state, opts.in_files[0].c_str()))
372 { 386 {
373 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 387 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
374 << "Failed parsing: " << opts.in_files[0] << "."; 388 << "Failed parsing: " << opts.in_files[0] << ".";
@@ -480,6 +494,7 @@ int main(int argc, char **argv)
480 efl::eina::eina_init eina_init; 494 efl::eina::eina_init eina_init;
481 efl::eolian::eolian_init eolian_init; 495 efl::eolian::eolian_init eolian_init;
482 eolian_cxx::options_type opts = opts_get(argc, argv); 496 eolian_cxx::options_type opts = opts_get(argc, argv);
497 eolian_cxx::state_init(opts);
483 eolian_cxx::database_load(opts); 498 eolian_cxx::database_load(opts);
484 eolian_cxx::run(opts); 499 eolian_cxx::run(opts);
485 } 500 }