summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/bin/eolian/main.c9
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc23
-rw-r--r--src/bindings/luajit/eolian.lua96
-rw-r--r--src/lib/eolian/Eolian.h116
-rw-r--r--src/lib/eolian/eolian_database.c20
-rw-r--r--src/scripts/elua/modules/lualian.lua16
-rw-r--r--src/tests/eolian/eolian_parsing.c119
7 files changed, 258 insertions, 141 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 }
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index b0c0f7c67e..b7d4d6ec0d 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -13,6 +13,7 @@ ffi.cdef [[
13 typedef unsigned char Eina_Bool; 13 typedef unsigned char Eina_Bool;
14 typedef struct _Eina_Iterator Eina_Iterator; 14 typedef struct _Eina_Iterator Eina_Iterator;
15 15
16 typedef struct _Eolian Eolian;
16 typedef struct _Eolian_Class Eolian_Class; 17 typedef struct _Eolian_Class Eolian_Class;
17 typedef struct _Eolian_Function Eolian_Function; 18 typedef struct _Eolian_Function Eolian_Function;
18 typedef struct _Eolian_Type Eolian_Type; 19 typedef struct _Eolian_Type Eolian_Type;
@@ -284,17 +285,19 @@ ffi.cdef [[
284 const char *text, *text_end; 285 const char *text, *text_end;
285 } Eolian_Doc_Token; 286 } Eolian_Doc_Token;
286 287
287 const Eolian_Unit *eolian_file_parse(const char *filepath);
288 Eina_Iterator *eolian_all_eo_file_paths_get(void);
289 Eina_Iterator *eolian_all_eot_file_paths_get(void);
290 Eina_Iterator *eolian_all_eo_files_get(void);
291 Eina_Iterator *eolian_all_eot_files_get(void);
292 int eolian_init(void); 288 int eolian_init(void);
293 int eolian_shutdown(void); 289 int eolian_shutdown(void);
294 Eina_Bool eolian_directory_scan(const char *dir); 290 Eolian *eolian_new(void);
295 Eina_Bool eolian_system_directory_scan(); 291 void eolian_free(Eolian *state);
296 Eina_Bool eolian_all_eo_files_parse(); 292 const Eolian_Unit *eolian_file_parse(Eolian *state, const char *filepath);
297 Eina_Bool eolian_all_eot_files_parse(); 293 Eina_Iterator *eolian_all_eo_file_paths_get(Eolian *state);
294 Eina_Iterator *eolian_all_eot_file_paths_get(Eolian *state);
295 Eina_Iterator *eolian_all_eo_files_get(Eolian *state);
296 Eina_Iterator *eolian_all_eot_files_get(Eolian *state);
297 Eina_Bool eolian_directory_scan(Eolian *state, const char *dir);
298 Eina_Bool eolian_system_directory_scan(Eolian *state);
299 Eina_Bool eolian_all_eo_files_parse(Eolian *state);
300 Eina_Bool eolian_all_eot_files_parse(Eolian *state);
298 const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name); 301 const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name);
299 const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name); 302 const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name);
300 const char *eolian_class_file_get(const Eolian_Class *klass); 303 const char *eolian_class_file_get(const Eolian_Class *klass);
@@ -509,44 +512,59 @@ M.object_scope = {
509 PROTECTED = 3 512 PROTECTED = 3
510} 513}
511 514
512M.directory_scan = function(dir) 515ffi.metatype("Eolian", {
513 return eolian.eolian_directory_scan(dir) ~= 0 516 __index = {
514end 517 directory_scan = function(self, dir)
518 return eolian.eolian_directory_scan(self, dir) ~= 0
519 end,
515 520
516M.system_directory_scan = function() 521 system_directory_scan = function(self)
517 return eolian.eolian_system_directory_scan() ~= 0 522 return eolian.eolian_system_directory_scan(self) ~= 0
518end 523 end,
519 524
520M.file_parse = function(fpath) 525 file_parse = function(self, fpath)
521 local v = eolian.eolian_file_parse(fpath) 526 local v = eolian.eolian_file_parse(self, fpath)
522 if v == nil then 527 if v == nil then
523 return nil 528 return nil
524 end 529 end
525 return v 530 return v
526end 531 end,
527 532
528M.all_eo_files_parse = function() 533 all_eo_files_parse = function(self)
529 return eolian.eolian_all_eo_files_parse() ~= 0 534 return eolian.eolian_all_eo_files_parse(self) ~= 0
530end 535 end,
531 536
532M.all_eot_files_parse = function() 537 all_eot_files_parse = function(self)
533 return eolian.eolian_all_eot_files_parse() ~= 0 538 return eolian.eolian_all_eot_files_parse(self) ~= 0
534end 539 end,
535 540
536M.all_eo_file_paths_get = function() 541 all_eo_file_paths_get = function(self)
537 return iterator.String_Iterator(eolian.eolian_all_eo_file_paths_get()) 542 return iterator.String_Iterator(eolian.eolian_all_eo_file_paths_get(self))
538end 543 end,
539 544
540M.all_eot_file_paths_get = function() 545 all_eot_file_paths_get = function(self)
541 return iterator.String_Iterator(eolian.eolian_all_eot_file_paths_get()) 546 return iterator.String_Iterator(eolian.eolian_all_eot_file_paths_get(self))
542end 547 end,
543 548
544M.all_eo_files_get = function() 549 all_eo_files_get = function(self)
545 return iterator.String_Iterator(eolian.eolian_all_eo_files_get()) 550 return iterator.String_Iterator(eolian.eolian_all_eo_files_get(self))
546end 551 end,
552
553 all_eot_files_get = function(self)
554 return iterator.String_Iterator(eolian.eolian_all_eot_files_get(self))
555 end,
556
557 unit_get = function(self)
558 return ffi.cast("Eolian_Unit *", self)
559 end
560 },
561 __gc = function(self)
562 eolian.eolian_free(self)
563 end
564})
547 565
548M.all_eot_files_get = function() 566M.new = function()
549 return iterator.String_Iterator(eolian.eolian_all_eot_files_get()) 567 return eolian.eolian_new()
550end 568end
551 569
552M.declaration_type = { 570M.declaration_type = {
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 0e8b9d59c7..bfb8c5387a 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -456,11 +456,53 @@ typedef struct _Eolian_Doc_Token
456} Eolian_Doc_Token; 456} Eolian_Doc_Token;
457 457
458/* 458/*
459 * @brief Init Eolian.
460 *
461 * @ingroup Eolian
462 */
463EAPI int eolian_init(void);
464
465/*
466 * @brief Shutdown Eolian.
467 *
468 * @ingroup Eolian
469 */
470EAPI int eolian_shutdown(void);
471
472/*
473 * @brief Create a new Eolian state.
474 *
475 * This creates a new Eolian state that consists of a "master unit" with
476 * the same address (therefore, you can cast it to Eolian_Unit) plus extra
477 * state information.
478 *
479 * You need to free this with eolian_free once you're done.
480 *
481 * @return A new state (or NULL on failure).
482 *
483 * @ingroup Eolian
484 */
485EAPI Eolian *eolian_new(void);
486
487/*
488 * @brief Free an Eolian state.
489 *
490 * You can use this to free an Eolian state.
491 *
492 * If the input is NULL, this function has no effect.
493 *
494 * @param[in] state the state to free
495 *
496 */
497EAPI void eolian_free(Eolian *state);
498
499/*
459 * @brief Parse the given .eo or .eot file and fill the database. 500 * @brief Parse the given .eo or .eot file and fill the database.
460 * 501 *
461 * The input can be either a full path to the file or only a filename. 502 * The input can be either a full path to the file or only a filename.
462 * If it's a filename, it must be scanned for first. 503 * If it's a filename, it must be scanned for first.
463 * 504 *
505 * @param[in] state The Eolian state.
464 * @param[in] filepath Path to the file to parse. 506 * @param[in] filepath Path to the file to parse.
465 * @return The unit corresponding to the parsed file or NULL. 507 * @return The unit corresponding to the parsed file or NULL.
466 * 508 *
@@ -468,92 +510,59 @@ typedef struct _Eolian_Doc_Token
468 * 510 *
469 * @ingroup Eolian 511 * @ingroup Eolian
470 */ 512 */
471EAPI const Eolian_Unit *eolian_file_parse(const char *filepath); 513EAPI const Eolian_Unit *eolian_file_parse(Eolian *state, const char *filepath);
472 514
473/* 515/*
474 * @brief Get an iterator to all .eo file names with paths. 516 * @brief Get an iterator to all .eo file names with paths.
475 * 517 *
518 * @param[in] state The Eolian state.
519 *
476 * @see eolian_all_eo_files_get 520 * @see eolian_all_eo_files_get
477 * @see eolian_all_eot_file_paths_get 521 * @see eolian_all_eot_file_paths_get
478 * @see eolian_all_eot_files_get 522 * @see eolian_all_eot_files_get
479 * 523 *
480 * @ingroup Eolian 524 * @ingroup Eolian
481 */ 525 */
482EAPI Eina_Iterator *eolian_all_eo_file_paths_get(void); 526EAPI Eina_Iterator *eolian_all_eo_file_paths_get(Eolian *state);
483 527
484/* 528/*
485 * @brief Get an iterator to all .eot file names with paths. 529 * @brief Get an iterator to all .eot file names with paths.
486 * 530 *
531 * @param[in] state The Eolian state.
532 *
487 * @see eolian_all_eo_files_get 533 * @see eolian_all_eo_files_get
488 * @see eolian_all_eo_file_paths_get 534 * @see eolian_all_eo_file_paths_get
489 * @see eolian_all_eot_files_get 535 * @see eolian_all_eot_files_get
490 * 536 *
491 * @ingroup Eolian 537 * @ingroup Eolian
492 */ 538 */
493EAPI Eina_Iterator *eolian_all_eot_file_paths_get(void); 539EAPI Eina_Iterator *eolian_all_eot_file_paths_get(Eolian *state);
494 540
495/* 541/*
496 * @brief Get an iterator to all .eo file names (without paths). 542 * @brief Get an iterator to all .eo file names (without paths).
497 * 543 *
544 * @param[in] state The Eolian state.
545 *
498 * @see eolian_all_eo_file_paths_get 546 * @see eolian_all_eo_file_paths_get
499 * @see eolian_all_eot_file_paths_get 547 * @see eolian_all_eot_file_paths_get
500 * @see eolian_all_eot_files_get 548 * @see eolian_all_eot_files_get
501 * 549 *
502 * @ingroup Eolian 550 * @ingroup Eolian
503 */ 551 */
504EAPI Eina_Iterator *eolian_all_eo_files_get(void); 552EAPI Eina_Iterator *eolian_all_eo_files_get(Eolian *state);
505 553
506/* 554/*
507 * @brief Get an iterator to all .eot file names (without paths). 555 * @brief Get an iterator to all .eot file names (without paths).
508 * 556 *
557 * @param[in] state The Eolian state.
558 *
509 * @see eolian_all_eo_file_paths_get 559 * @see eolian_all_eo_file_paths_get
510 * @see eolian_all_eot_file_paths_get 560 * @see eolian_all_eot_file_paths_get
511 * @see eolian_all_eo_files_get 561 * @see eolian_all_eo_files_get
512 * 562 *
513 * @ingroup Eolian 563 * @ingroup Eolian
514 */ 564 */
515EAPI Eina_Iterator *eolian_all_eot_files_get(void); 565EAPI Eina_Iterator *eolian_all_eot_files_get(Eolian *state);
516
517/*
518 * @brief Init Eolian.
519 *
520 * @ingroup Eolian
521 */
522EAPI int eolian_init(void);
523
524/*
525 * @brief Shutdown Eolian.
526 *
527 * @ingroup Eolian
528 */
529EAPI int eolian_shutdown(void);
530
531/*
532 * @brief Create a new Eolian state.
533 *
534 * This creates a new Eolian state that consists of a "master unit" with
535 * the same address (therefore, you can cast it to Eolian_Unit) plus extra
536 * state information.
537 *
538 * You need to free this with eolian_free once you're done.
539 *
540 * @return A new state (or NULL on failure).
541 *
542 * @ingroup Eolian
543 */
544EAPI Eolian *eolian_new(void);
545
546/*
547 * @brief Free an Eolian state.
548 *
549 * You can use this to free an Eolian state.
550 *
551 * If the input is NULL, this function has no effect.
552 *
553 * @param[in] unit the state to free
554 *
555 */
556EAPI void eolian_free(Eolian *state);
557 566
558/* 567/*
559 * @brief Scan the given directory (recursively) and search for .eo and 568 * @brief Scan the given directory (recursively) and search for .eo and
@@ -561,6 +570,7 @@ EAPI void eolian_free(Eolian *state);
561 * 570 *
562 * The found files are just open to extract the class name. 571 * The found files are just open to extract the class name.
563 * 572 *
573 * @param[in] state The Eolian state.
564 * @param[in] dir the directory to scan 574 * @param[in] dir the directory to scan
565 * @return EINA_TRUE on success, EINA_FALSE otherwise. 575 * @return EINA_TRUE on success, EINA_FALSE otherwise.
566 * 576 *
@@ -568,24 +578,28 @@ EAPI void eolian_free(Eolian *state);
568 * 578 *
569 * @ingroup Eolian 579 * @ingroup Eolian
570 */ 580 */
571EAPI Eina_Bool eolian_directory_scan(const char *dir); 581EAPI Eina_Bool eolian_directory_scan(Eolian *state, const char *dir);
572 582
573/* 583/*
574 * @brief Scan the system directory (recursively) and search for .eo and 584 * @brief Scan the system directory (recursively) and search for .eo and
575 * .eot files. 585 * .eot files.
576 * 586 *
587 * @param[in] state The Eolian state.
588 *
577 * @return EINA_TRUE on success, EINA_FALSE otherwise. 589 * @return EINA_TRUE on success, EINA_FALSE otherwise.
578 * 590 *
579 * @see eolian_directory_scan 591 * @see eolian_directory_scan
580 * 592 *
581 * @ingroup Eolian 593 * @ingroup Eolian
582 */ 594 */
583EAPI Eina_Bool eolian_system_directory_scan(void); 595EAPI Eina_Bool eolian_system_directory_scan(Eolian *state);
584 596
585/* 597/*
586 * @brief Force parsing of all the .eo files located in the directories 598 * @brief Force parsing of all the .eo files located in the directories
587 * given in eolian_directory_scan.. 599 * given in eolian_directory_scan..
588 * 600 *
601 * @param[in] state The Eolian state.
602 *
589 * @return EINA_TRUE on success, EINA_FALSE otherwise. 603 * @return EINA_TRUE on success, EINA_FALSE otherwise.
590 * 604 *
591 * @see eolian_directory_scan 605 * @see eolian_directory_scan
@@ -593,12 +607,14 @@ EAPI Eina_Bool eolian_system_directory_scan(void);
593 * 607 *
594 * @ingroup Eolian 608 * @ingroup Eolian
595 */ 609 */
596EAPI Eina_Bool eolian_all_eo_files_parse(void); 610EAPI Eina_Bool eolian_all_eo_files_parse(Eolian *state);
597 611
598/* 612/*
599 * @brief Force parsing of all the .eot files located in the directories 613 * @brief Force parsing of all the .eot files located in the directories
600 * given in eolian_directory_scan.. 614 * given in eolian_directory_scan..
601 * 615 *
616 * @param[in] state The Eolian state.
617 *
602 * @return EINA_TRUE on success, EINA_FALSE otherwise. 618 * @return EINA_TRUE on success, EINA_FALSE otherwise.
603 * 619 *
604 * @see eolian_directory_scan 620 * @see eolian_directory_scan
@@ -606,7 +622,7 @@ EAPI Eina_Bool eolian_all_eo_files_parse(void);
606 * 622 *
607 * @ingroup Eolian 623 * @ingroup Eolian
608 */ 624 */
609EAPI Eina_Bool eolian_all_eot_files_parse(void); 625EAPI Eina_Bool eolian_all_eot_files_parse(Eolian *state);
610 626
611/* 627/*
612 * @brief Gets a class by its name 628 * @brief Gets a class by its name
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index e68e9d3b0a..0a6601b539 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -685,7 +685,7 @@ _scan_cb(const char *name, const char *path, void *data EINA_UNUSED)
685} 685}
686 686
687EAPI Eina_Bool 687EAPI Eina_Bool
688eolian_directory_scan(const char *dir) 688eolian_directory_scan(Eolian *state EINA_UNUSED, const char *dir)
689{ 689{
690 if (!dir) return EINA_FALSE; 690 if (!dir) return EINA_FALSE;
691 eina_file_dir_list(dir, EINA_TRUE, _scan_cb, NULL); 691 eina_file_dir_list(dir, EINA_TRUE, _scan_cb, NULL);
@@ -693,13 +693,13 @@ eolian_directory_scan(const char *dir)
693} 693}
694 694
695EAPI Eina_Bool 695EAPI Eina_Bool
696eolian_system_directory_scan() 696eolian_system_directory_scan(Eolian *state)
697{ 697{
698 Eina_Bool ret; 698 Eina_Bool ret;
699 Eina_Strbuf *buf = eina_strbuf_new(); 699 Eina_Strbuf *buf = eina_strbuf_new();
700 eina_strbuf_append(buf, eina_prefix_data_get(_eolian_prefix)); 700 eina_strbuf_append(buf, eina_prefix_data_get(_eolian_prefix));
701 eina_strbuf_append(buf, "/include"); 701 eina_strbuf_append(buf, "/include");
702 ret = eolian_directory_scan(eina_strbuf_string_get(buf)); 702 ret = eolian_directory_scan(state, eina_strbuf_string_get(buf));
703 eina_strbuf_free(buf); 703 eina_strbuf_free(buf);
704 return ret; 704 return ret;
705} 705}
@@ -773,7 +773,7 @@ _parse_deferred()
773static Eolian_Unit unit_tmp; 773static Eolian_Unit unit_tmp;
774 774
775EAPI const Eolian_Unit * 775EAPI const Eolian_Unit *
776eolian_file_parse(const char *filepath) 776eolian_file_parse(Eolian *state EINA_UNUSED, const char *filepath)
777{ 777{
778 if (!_eolian_file_parse_nodep(filepath)) 778 if (!_eolian_file_parse_nodep(filepath))
779 return NULL; 779 return NULL;
@@ -794,7 +794,7 @@ static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key
794} 794}
795 795
796EAPI Eina_Bool 796EAPI Eina_Bool
797eolian_all_eot_files_parse() 797eolian_all_eot_files_parse(Eolian *state EINA_UNUSED)
798{ 798{
799 Eina_Bool ret = EINA_TRUE; 799 Eina_Bool ret = EINA_TRUE;
800 800
@@ -819,7 +819,7 @@ static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key
819} 819}
820 820
821EAPI Eina_Bool 821EAPI Eina_Bool
822eolian_all_eo_files_parse() 822eolian_all_eo_files_parse(Eolian *state EINA_UNUSED)
823{ 823{
824 Eina_Bool ret = EINA_TRUE; 824 Eina_Bool ret = EINA_TRUE;
825 825
@@ -836,28 +836,28 @@ eolian_all_eo_files_parse()
836} 836}
837 837
838EAPI Eina_Iterator * 838EAPI Eina_Iterator *
839eolian_all_eot_files_get(void) 839eolian_all_eot_files_get(Eolian *state EINA_UNUSED)
840{ 840{
841 if (!_tfilenames) return NULL; 841 if (!_tfilenames) return NULL;
842 return eina_hash_iterator_key_new(_tfilenames); 842 return eina_hash_iterator_key_new(_tfilenames);
843} 843}
844 844
845EAPI Eina_Iterator * 845EAPI Eina_Iterator *
846eolian_all_eo_files_get(void) 846eolian_all_eo_files_get(Eolian *state EINA_UNUSED)
847{ 847{
848 if (!_filenames) return NULL; 848 if (!_filenames) return NULL;
849 return eina_hash_iterator_key_new(_filenames); 849 return eina_hash_iterator_key_new(_filenames);
850} 850}
851 851
852EAPI Eina_Iterator * 852EAPI Eina_Iterator *
853eolian_all_eot_file_paths_get(void) 853eolian_all_eot_file_paths_get(Eolian *state EINA_UNUSED)
854{ 854{
855 if (!_tfilenames) return NULL; 855 if (!_tfilenames) return NULL;
856 return eina_hash_iterator_data_new(_tfilenames); 856 return eina_hash_iterator_data_new(_tfilenames);
857} 857}
858 858
859EAPI Eina_Iterator * 859EAPI Eina_Iterator *
860eolian_all_eo_file_paths_get(void) 860eolian_all_eo_file_paths_get(Eolian *state EINA_UNUSED)
861{ 861{
862 if (!_filenames) return NULL; 862 if (!_filenames) return NULL;
863 return eina_hash_iterator_data_new(_filenames); 863 return eina_hash_iterator_data_new(_filenames);
diff --git a/src/scripts/elua/modules/lualian.lua b/src/scripts/elua/modules/lualian.lua
index 035c24db96..3864bd1d02 100644
--- a/src/scripts/elua/modules/lualian.lua
+++ b/src/scripts/elua/modules/lualian.lua
@@ -16,6 +16,14 @@ local obj_scope = eolian.object_scope
16local param_dir = eolian.parameter_dir 16local param_dir = eolian.parameter_dir
17 17
18local gen_unit 18local gen_unit
19local gen_state
20
21local get_state = function()
22 if not gen_state then
23 gen_state = eolian.new()
24 end
25 return assert(gen_state, "could not create eolian state")
26end
19 27
20cutil.init_module(function() 28cutil.init_module(function()
21 dom = log.Domain("lualian") 29 dom = log.Domain("lualian")
@@ -683,21 +691,21 @@ local gen_class = function(klass)
683end 691end
684 692
685M.include_dir = function(dir) 693M.include_dir = function(dir)
686 if not eolian.directory_scan(dir) then 694 if not get_state():directory_scan(dir) then
687 error("Failed including directory: " .. dir) 695 error("Failed including directory: " .. dir)
688 end 696 end
689end 697end
690 698
691M.load_eot_files = function() 699M.load_eot_files = function()
692 return eolian.all_eot_files_parse() 700 return get_state():all_eot_files_parse()
693end 701end
694 702
695M.system_directory_scan = function() 703M.system_directory_scan = function()
696 return eolian.system_directory_scan() 704 return get_state():system_directory_scan()
697end 705end
698 706
699M.generate = function(fname, fstream) 707M.generate = function(fname, fstream)
700 local unit = eolian.file_parse(fname) 708 local unit = get_state():file_parse(fname)
701 if unit == nil then 709 if unit == nil then
702 error("Failed parsing file: " .. fname) 710 error("Failed parsing file: " .. fname)
703 end 711 end
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index ce18e4e137..788ca774c3 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -23,9 +23,10 @@ START_TEST(eolian_namespaces)
23 void *dummy; 23 void *dummy;
24 24
25 eolian_init(); 25 eolian_init();
26 Eolian *eos = eolian_new();
26 /* Parsing */ 27 /* Parsing */
27 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 28 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
28 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo"))); 29 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/nmsp1_class1.eo")));
29 30
30 /* Classes existence */ 31 /* Classes existence */
31 fail_if(!(class11 = eolian_class_get_by_name(unit, "nmsp1.class1"))); 32 fail_if(!(class11 = eolian_class_get_by_name(unit, "nmsp1.class1")));
@@ -89,6 +90,7 @@ START_TEST(eolian_namespaces)
89 fail_if(eina_iterator_next(iter, &dummy)); 90 fail_if(eina_iterator_next(iter, &dummy));
90 eina_iterator_free(iter); 91 eina_iterator_free(iter);
91 92
93 eolian_free(eos);
92 eolian_shutdown(); 94 eolian_shutdown();
93} 95}
94END_TEST 96END_TEST
@@ -104,8 +106,10 @@ START_TEST(eolian_events)
104 void *dummy; 106 void *dummy;
105 107
106 eolian_init(); 108 eolian_init();
109 Eolian *eos = eolian_new();
107 /* Parsing */ 110 /* Parsing */
108 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/events.eo"))); 111 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
112 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/events.eo")));
109 113
110 /* Class */ 114 /* Class */
111 fail_if(!(class = eolian_class_get_by_name(unit, "Events"))); 115 fail_if(!(class = eolian_class_get_by_name(unit, "Events")));
@@ -162,6 +166,7 @@ START_TEST(eolian_events)
162 fail_if(!eolian_class_event_get_by_name(class, "clicked,double")); 166 fail_if(!eolian_class_event_get_by_name(class, "clicked,double"));
163 fail_if(eolian_class_event_get_by_name(class, "clicked,triple")); 167 fail_if(eolian_class_event_get_by_name(class, "clicked,triple"));
164 168
169 eolian_free(eos);
165 eolian_shutdown(); 170 eolian_shutdown();
166} 171}
167END_TEST 172END_TEST
@@ -176,9 +181,10 @@ START_TEST(eolian_override)
176 const Eolian_Unit *unit; 181 const Eolian_Unit *unit;
177 182
178 eolian_init(); 183 eolian_init();
184 Eolian *eos = eolian_new();
179 /* Parsing */ 185 /* Parsing */
180 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 186 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
181 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/override.eo"))); 187 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/override.eo")));
182 188
183 /* Class */ 189 /* Class */
184 fail_if(!(class = eolian_class_get_by_name(unit, "Override"))); 190 fail_if(!(class = eolian_class_get_by_name(unit, "Override")));
@@ -220,6 +226,7 @@ START_TEST(eolian_override)
220 226
221 eina_iterator_free(iter); 227 eina_iterator_free(iter);
222 228
229 eolian_free(eos);
223 eolian_shutdown(); 230 eolian_shutdown();
224} 231}
225END_TEST 232END_TEST
@@ -231,14 +238,17 @@ START_TEST(eolian_consts)
231 const Eolian_Unit *unit; 238 const Eolian_Unit *unit;
232 239
233 eolian_init(); 240 eolian_init();
241 Eolian *eos = eolian_new();
234 /* Parsing */ 242 /* Parsing */
235 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"))); 243 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
244 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/consts.eo")));
236 fail_if(!(class = eolian_class_get_by_name(unit, "Consts"))); 245 fail_if(!(class = eolian_class_get_by_name(unit, "Consts")));
237 246
238 /* Method */ 247 /* Method */
239 fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD))); 248 fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
240 fail_if(EINA_FALSE == eolian_function_object_is_const(fid)); 249 fail_if(EINA_FALSE == eolian_function_object_is_const(fid));
241 250
251 eolian_free(eos);
242 eolian_shutdown(); 252 eolian_shutdown();
243} 253}
244END_TEST 254END_TEST
@@ -255,9 +265,10 @@ START_TEST(eolian_ctor_dtor)
255 void *dummy; 265 void *dummy;
256 266
257 eolian_init(); 267 eolian_init();
268 Eolian *eos = eolian_new();
258 /* Parsing */ 269 /* Parsing */
259 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 270 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
260 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo"))); 271 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/ctor_dtor.eo")));
261 fail_if(!(class = eolian_class_get_by_name(unit, "Ctor_Dtor"))); 272 fail_if(!(class = eolian_class_get_by_name(unit, "Ctor_Dtor")));
262 fail_if(!(base = eolian_class_get_by_name(unit, "Base"))); 273 fail_if(!(base = eolian_class_get_by_name(unit, "Base")));
263 274
@@ -307,6 +318,7 @@ START_TEST(eolian_ctor_dtor)
307 fail_if(eina_iterator_next(iter, &dummy)); 318 fail_if(eina_iterator_next(iter, &dummy));
308 eina_iterator_free(iter); 319 eina_iterator_free(iter);
309 320
321 eolian_free(eos);
310 eolian_shutdown(); 322 eolian_shutdown();
311} 323}
312END_TEST 324END_TEST
@@ -322,8 +334,10 @@ START_TEST(eolian_typedef)
322 const char *file; 334 const char *file;
323 335
324 eolian_init(); 336 eolian_init();
337 Eolian *eos = eolian_new();
325 /* Parsing */ 338 /* Parsing */
326 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo"))); 339 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
340 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/typedef.eo")));
327 341
328 /* Check that the class Dummy is still readable */ 342 /* Check that the class Dummy is still readable */
329 fail_if(!(class = eolian_class_get_by_name(unit, "Typedef"))); 343 fail_if(!(class = eolian_class_get_by_name(unit, "Typedef")));
@@ -388,6 +402,7 @@ START_TEST(eolian_typedef)
388 fail_if(!eina_iterator_next(iter, (void**)&tdl)); 402 fail_if(!eina_iterator_next(iter, (void**)&tdl));
389 fail_if(eina_iterator_next(iter, (void**)&tdl)); 403 fail_if(eina_iterator_next(iter, (void**)&tdl));
390 404
405 eolian_free(eos);
391 eolian_shutdown(); 406 eolian_shutdown();
392} 407}
393END_TEST 408END_TEST
@@ -404,8 +419,10 @@ START_TEST(eolian_complex_type)
404 void *dummy; 419 void *dummy;
405 420
406 eolian_init(); 421 eolian_init();
422 Eolian *eos = eolian_new();
407 /* Parsing */ 423 /* Parsing */
408 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"))); 424 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
425 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/complex_type.eo")));
409 fail_if(!(class = eolian_class_get_by_name(unit, "Complex_Type"))); 426 fail_if(!(class = eolian_class_get_by_name(unit, "Complex_Type")));
410 427
411 /* Properties return type */ 428 /* Properties return type */
@@ -474,6 +491,7 @@ START_TEST(eolian_complex_type)
474 fail_if(strcmp(type_name, "char *")); 491 fail_if(strcmp(type_name, "char *"));
475 eina_stringshare_del(type_name); 492 eina_stringshare_del(type_name);
476 493
494 eolian_free(eos);
477 eolian_shutdown(); 495 eolian_shutdown();
478} 496}
479END_TEST 497END_TEST
@@ -485,8 +503,10 @@ START_TEST(eolian_scope)
485 const Eolian_Unit *unit; 503 const Eolian_Unit *unit;
486 504
487 eolian_init(); 505 eolian_init();
506 Eolian *eos = eolian_new();
488 /* Parsing */ 507 /* Parsing */
489 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"))); 508 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
509 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/scope.eo")));
490 fail_if(!(class = eolian_class_get_by_name(unit, "Scope"))); 510 fail_if(!(class = eolian_class_get_by_name(unit, "Scope")));
491 511
492 /* Property scope */ 512 /* Property scope */
@@ -507,6 +527,7 @@ START_TEST(eolian_scope)
507 fail_if(!(fid = eolian_class_function_get_by_name(class, "foobar", EOLIAN_METHOD))); 527 fail_if(!(fid = eolian_class_function_get_by_name(class, "foobar", EOLIAN_METHOD)));
508 fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC); 528 fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC);
509 529
530 eolian_free(eos);
510 eolian_shutdown(); 531 eolian_shutdown();
511} 532}
512END_TEST 533END_TEST
@@ -525,8 +546,10 @@ START_TEST(eolian_simple_parsing)
525 void *dummy; 546 void *dummy;
526 547
527 eolian_init(); 548 eolian_init();
549 Eolian *eos = eolian_new();
528 /* Parsing */ 550 /* Parsing */
529 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"))); 551 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
552 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/class_simple.eo")));
530 fail_if(!(class = eolian_class_get_by_name(unit, "Class_Simple"))); 553 fail_if(!(class = eolian_class_get_by_name(unit, "Class_Simple")));
531 fail_if(eolian_class_get_by_file(unit, "class_simple.eo") != class); 554 fail_if(eolian_class_get_by_file(unit, "class_simple.eo") != class);
532 fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo")); 555 fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo"));
@@ -643,6 +666,7 @@ START_TEST(eolian_simple_parsing)
643 fail_if(eolian_function_is_beta(fid)); 666 fail_if(eolian_function_is_beta(fid));
644 fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD))); 667 fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
645 668
669 eolian_free(eos);
646 eolian_shutdown(); 670 eolian_shutdown();
647} 671}
648END_TEST 672END_TEST
@@ -659,9 +683,11 @@ START_TEST(eolian_struct)
659 const char *file; 683 const char *file;
660 684
661 eolian_init(); 685 eolian_init();
686 Eolian *eos = eolian_new();
662 687
663 /* Parsing */ 688 /* Parsing */
664 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/struct.eo"))); 689 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
690 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/struct.eo")));
665 691
666 /* Check that the class Dummy is still readable */ 692 /* Check that the class Dummy is still readable */
667 fail_if(!(class = eolian_class_get_by_name(unit, "Struct"))); 693 fail_if(!(class = eolian_class_get_by_name(unit, "Struct")));
@@ -713,6 +739,7 @@ START_TEST(eolian_struct)
713 fail_if(!(tdl = eolian_type_typedecl_get(type))); 739 fail_if(!(tdl = eolian_type_typedecl_get(type)));
714 fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); 740 fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
715 741
742 eolian_free(eos);
716 eolian_shutdown(); 743 eolian_shutdown();
717} 744}
718END_TEST 745END_TEST
@@ -724,9 +751,11 @@ START_TEST(eolian_extern)
724 const Eolian_Unit *unit; 751 const Eolian_Unit *unit;
725 752
726 eolian_init(); 753 eolian_init();
754 Eolian *eos = eolian_new();
727 755
728 /* Parsing */ 756 /* Parsing */
729 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/extern.eo"))); 757 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
758 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/extern.eo")));
730 759
731 /* Check that the class Dummy is still readable */ 760 /* Check that the class Dummy is still readable */
732 fail_if(!(class = eolian_class_get_by_name(unit, "Extern"))); 761 fail_if(!(class = eolian_class_get_by_name(unit, "Extern")));
@@ -748,6 +777,7 @@ START_TEST(eolian_extern)
748 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Y"))); 777 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Y")));
749 fail_if(!eolian_typedecl_is_extern(tdl)); 778 fail_if(!eolian_typedecl_is_extern(tdl));
750 779
780 eolian_free(eos);
751 eolian_shutdown(); 781 eolian_shutdown();
752} 782}
753END_TEST 783END_TEST
@@ -763,9 +793,11 @@ START_TEST(eolian_var)
763 const char *name; 793 const char *name;
764 794
765 eolian_init(); 795 eolian_init();
796 Eolian *eos = eolian_new();
766 797
767 /* Parsing */ 798 /* Parsing */
768 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo"))); 799 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
800 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/var.eo")));
769 801
770 /* Check that the class Dummy is still readable */ 802 /* Check that the class Dummy is still readable */
771 fail_if(!(class = eolian_class_get_by_name(unit, "Var"))); 803 fail_if(!(class = eolian_class_get_by_name(unit, "Var")));
@@ -813,6 +845,7 @@ START_TEST(eolian_var)
813 fail_if(strcmp(name, "double")); 845 fail_if(strcmp(name, "double"));
814 fail_if(eolian_variable_value_get(var)); 846 fail_if(eolian_variable_value_get(var));
815 847
848 eolian_free(eos);
816 eolian_shutdown(); 849 eolian_shutdown();
817} 850}
818END_TEST 851END_TEST
@@ -831,9 +864,11 @@ START_TEST(eolian_enum)
831 Eolian_Value v; 864 Eolian_Value v;
832 865
833 eolian_init(); 866 eolian_init();
867 Eolian *eos = eolian_new();
834 868
835 /* Parsing */ 869 /* Parsing */
836 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo"))); 870 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
871 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/enum.eo")));
837 872
838 /* Check that the class Dummy is still readable */ 873 /* Check that the class Dummy is still readable */
839 fail_if(!(class = eolian_class_get_by_name(unit, "Enum"))); 874 fail_if(!(class = eolian_class_get_by_name(unit, "Enum")));
@@ -914,6 +949,7 @@ START_TEST(eolian_enum)
914 fail_if(v.type != EOLIAN_EXPR_INT); 949 fail_if(v.type != EOLIAN_EXPR_INT);
915 fail_if(v.value.i != 5); 950 fail_if(v.value.i != 5);
916 951
952 eolian_free(eos);
917 eolian_shutdown(); 953 eolian_shutdown();
918} 954}
919END_TEST 955END_TEST
@@ -925,8 +961,10 @@ START_TEST(eolian_class_funcs)
925 const Eolian_Unit *unit; 961 const Eolian_Unit *unit;
926 962
927 eolian_init(); 963 eolian_init();
964 Eolian *eos = eolian_new();
928 /* Parsing */ 965 /* Parsing */
929 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo"))); 966 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
967 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/class_funcs.eo")));
930 fail_if(!(class = eolian_class_get_by_name(unit, "Class_Funcs"))); 968 fail_if(!(class = eolian_class_get_by_name(unit, "Class_Funcs")));
931 969
932 /* Class properties */ 970 /* Class properties */
@@ -950,6 +988,7 @@ START_TEST(eolian_class_funcs)
950 fail_if(eolian_function_is_class(fid)); 988 fail_if(eolian_function_is_class(fid));
951 fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PROTECTED); 989 fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PROTECTED);
952 990
991 eolian_free(eos);
953 eolian_shutdown(); 992 eolian_shutdown();
954} 993}
955END_TEST 994END_TEST
@@ -962,9 +1001,11 @@ START_TEST(eolian_free_func)
962 const Eolian_Unit *unit; 1001 const Eolian_Unit *unit;
963 1002
964 eolian_init(); 1003 eolian_init();
1004 Eolian *eos = eolian_new();
965 1005
966 /* Parsing */ 1006 /* Parsing */
967 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo"))); 1007 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1008 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/free_func.eo")));
968 1009
969 /* Check that the class Dummy is still readable */ 1010 /* Check that the class Dummy is still readable */
970 fail_if(!(class = eolian_class_get_by_name(unit, "Free_Func"))); 1011 fail_if(!(class = eolian_class_get_by_name(unit, "Free_Func")));
@@ -996,6 +1037,7 @@ START_TEST(eolian_free_func)
996 fail_if(!(type = eolian_typedecl_base_type_get(tdl))); 1037 fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
997 fail_if(strcmp(eolian_type_free_func_get(type), "ptr_free")); 1038 fail_if(strcmp(eolian_type_free_func_get(type), "ptr_free"));
998 1039
1040 eolian_free(eos);
999 eolian_shutdown(); 1041 eolian_shutdown();
1000} 1042}
1001END_TEST 1043END_TEST
@@ -1009,9 +1051,11 @@ START_TEST(eolian_null)
1009 Eina_Iterator *iter; 1051 Eina_Iterator *iter;
1010 1052
1011 eolian_init(); 1053 eolian_init();
1054 Eolian *eos = eolian_new();
1012 1055
1013 /* Parsing */ 1056 /* Parsing */
1014 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/null.eo"))); 1057 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1058 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/null.eo")));
1015 1059
1016 fail_if(!(class = eolian_class_get_by_name(unit, "Null"))); 1060 fail_if(!(class = eolian_class_get_by_name(unit, "Null")));
1017 fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD))); 1061 fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
@@ -1045,6 +1089,7 @@ START_TEST(eolian_null)
1045 fail_if(eina_iterator_next(iter, (void**)&param)); 1089 fail_if(eina_iterator_next(iter, (void**)&param));
1046 eina_iterator_free(iter); 1090 eina_iterator_free(iter);
1047 1091
1092 eolian_free(eos);
1048 eolian_shutdown(); 1093 eolian_shutdown();
1049} 1094}
1050END_TEST 1095END_TEST
@@ -1056,10 +1101,11 @@ START_TEST(eolian_import)
1056 const Eolian_Unit *unit; 1101 const Eolian_Unit *unit;
1057 1102
1058 eolian_init(); 1103 eolian_init();
1104 Eolian *eos = eolian_new();
1059 1105
1060 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1106 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1061 1107
1062 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/import.eo"))); 1108 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/import.eo")));
1063 fail_if(!(class = eolian_class_get_by_name(unit, "Import"))); 1109 fail_if(!(class = eolian_class_get_by_name(unit, "Import")));
1064 1110
1065 fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Imported"))); 1111 fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Imported")));
@@ -1068,6 +1114,7 @@ START_TEST(eolian_import)
1068 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Imported_Struct"))); 1114 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Imported_Struct")));
1069 fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot")); 1115 fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
1070 1116
1117 eolian_free(eos);
1071 eolian_shutdown(); 1118 eolian_shutdown();
1072} 1119}
1073END_TEST 1120END_TEST
@@ -1082,10 +1129,11 @@ START_TEST(eolian_decl)
1082 Eina_Iterator *itr; 1129 Eina_Iterator *itr;
1083 1130
1084 eolian_init(); 1131 eolian_init();
1132 Eolian *eos = eolian_new();
1085 1133
1086 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1134 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1087 1135
1088 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/decl.eo"))); 1136 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/decl.eo")));
1089 fail_if(!(class = eolian_class_get_by_name(unit, "Decl"))); 1137 fail_if(!(class = eolian_class_get_by_name(unit, "Decl")));
1090 1138
1091 fail_if(!(itr = eolian_declarations_get_by_file("decl.eo"))); 1139 fail_if(!(itr = eolian_declarations_get_by_file("decl.eo")));
@@ -1130,6 +1178,7 @@ START_TEST(eolian_decl)
1130 fail_if(!(decl = eolian_declaration_get_by_name("A"))); 1178 fail_if(!(decl = eolian_declaration_get_by_name("A")));
1131 fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_STRUCT); 1179 fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_STRUCT);
1132 1180
1181 eolian_free(eos);
1133 eolian_shutdown(); 1182 eolian_shutdown();
1134} 1183}
1135END_TEST 1184END_TEST
@@ -1149,10 +1198,11 @@ START_TEST(eolian_docs)
1149 Eina_Iterator *itr; 1198 Eina_Iterator *itr;
1150 1199
1151 eolian_init(); 1200 eolian_init();
1201 Eolian *eos = eolian_new();
1152 1202
1153 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1203 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1154 1204
1155 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo"))); 1205 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/docs.eo")));
1156 1206
1157 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Foo"))); 1207 fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Foo")));
1158 fail_if(!(doc = eolian_typedecl_documentation_get(tdl))); 1208 fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
@@ -1374,6 +1424,7 @@ START_TEST(eolian_docs)
1374 "Event docs.")); 1424 "Event docs."));
1375 fail_if(eolian_documentation_description_get(doc)); 1425 fail_if(eolian_documentation_description_get(doc));
1376 1426
1427 eolian_free(eos);
1377 eolian_shutdown(); 1428 eolian_shutdown();
1378} 1429}
1379END_TEST 1430END_TEST
@@ -1391,11 +1442,12 @@ START_TEST(eolian_function_types)
1391 void *dummy; 1442 void *dummy;
1392 1443
1393 eolian_init(); 1444 eolian_init();
1445 Eolian *eos = eolian_new();
1394 1446
1395 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1447 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1396 1448
1397 /* Parsing */ 1449 /* Parsing */
1398 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/function_types.eot"))); 1450 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/function_types.eot")));
1399 1451
1400 /* void func(void); */ 1452 /* void func(void); */
1401 fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "VoidFunc"))); 1453 fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "VoidFunc")));
@@ -1500,6 +1552,7 @@ START_TEST(eolian_function_types)
1500 1552
1501 fail_if(eina_iterator_next(iter, &dummy)); 1553 fail_if(eina_iterator_next(iter, &dummy));
1502 1554
1555 eolian_free(eos);
1503 eolian_shutdown(); 1556 eolian_shutdown();
1504} 1557}
1505END_TEST 1558END_TEST
@@ -1517,10 +1570,11 @@ START_TEST(eolian_function_as_arguments)
1517 void *dummy; 1570 void *dummy;
1518 1571
1519 eolian_init(); 1572 eolian_init();
1573 Eolian *eos = eolian_new();
1520 1574
1521 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1575 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1522 1576
1523 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/function_as_argument.eo"))); 1577 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/function_as_argument.eo")));
1524 1578
1525 fail_if(!(cls = eolian_class_get_by_name(unit, "Function_As_Argument"))); 1579 fail_if(!(cls = eolian_class_get_by_name(unit, "Function_As_Argument")));
1526 1580
@@ -1540,6 +1594,7 @@ START_TEST(eolian_function_as_arguments)
1540 1594
1541 fail_if(eina_iterator_next(iter, &dummy)); 1595 fail_if(eina_iterator_next(iter, &dummy));
1542 1596
1597 eolian_free(eos);
1543 eolian_shutdown(); 1598 eolian_shutdown();
1544} 1599}
1545END_TEST 1600END_TEST
@@ -1557,10 +1612,11 @@ START_TEST(eolian_parts)
1557 }; 1612 };
1558 1613
1559 eolian_init(); 1614 eolian_init();
1615 Eolian *eos = eolian_new();
1560 1616
1561 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1617 fail_if(!eolian_directory_scan(eos, PACKAGE_DATA_DIR"/data"));
1562 1618
1563 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/parts.eo"))); 1619 fail_if(!(unit = eolian_file_parse(eos, PACKAGE_DATA_DIR"/data/parts.eo")));
1564 1620
1565 fail_if(!(cls = eolian_class_get_by_name(unit, "Parts"))); 1621 fail_if(!(cls = eolian_class_get_by_name(unit, "Parts")));
1566 1622
@@ -1585,6 +1641,7 @@ START_TEST(eolian_parts)
1585 } 1641 }
1586 eina_iterator_free(iter); 1642 eina_iterator_free(iter);
1587 1643
1644 eolian_free(eos);
1588 eolian_shutdown(); 1645 eolian_shutdown();
1589} 1646}
1590END_TEST 1647END_TEST