summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-03 21:10:44 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-05 16:41:42 +0100
commit53aa99550d5b3351d85f3031e6a5baa34be38756 (patch)
tree829bfa2112e39730be4d3c1efd0784d4ba31cbca
parent6abb24b717b2dbedfa1fca168f2193d2a481c1f7 (diff)
eolian: add API for master unit creation
-rw-r--r--src/lib/eolian/Eolian.h26
-rw-r--r--src/lib/eolian/eolian_database.c32
2 files changed, 53 insertions, 5 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 6774d6b6b4..d11d4f3904 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -523,6 +523,32 @@ EAPI int eolian_init(void);
523EAPI int eolian_shutdown(void); 523EAPI int eolian_shutdown(void);
524 524
525/* 525/*
526 * @brief Create a new primary unit for Eolian state.
527 *
528 * This creates a nameless "master unit" which holds all Eolian state.
529 * You need to free this with eolian_free once you're done.
530 *
531 * @return A new master unit (or NULL on failure).
532 *
533 * @ingroup Eolian
534 */
535EAPI Eolian_Unit *eolian_new(void);
536
537/*
538 * @brief Free a master unit.
539 *
540 * You can use this to free an Eolian state. Do not EVER use this to free
541 * any unit other than master unit, as these are managed by the master unit
542 * and freeing them would result in incorrect behavior.
543 *
544 * If the input is NULL, this function has no effect.
545 *
546 * @param[in] unit the master unit to free
547 *
548 */
549EAPI void eolian_free(Eolian_Unit *unit);
550
551/*
526 * @brief Scan the given directory (recursively) and search for .eo and 552 * @brief Scan the given directory (recursively) and search for .eo and
527 * .eot files. 553 * .eot files.
528 * 554 *
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 59cebfa202..80af933947 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -602,10 +602,13 @@ eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
602void 602void
603database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname) 603database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
604{ 604{
605 Eolian_Unit *ocunit = _cunit; 605 if (fname)
606 unit->parent = ocunit; 606 {
607 if (ocunit) 607 Eolian_Unit *ocunit = _cunit;
608 eina_hash_add(ocunit->children, fname, unit); 608 unit->parent = ocunit;
609 if (ocunit)
610 eina_hash_add(ocunit->children, fname, unit);
611 }
609 612
610 unit->children = eina_hash_stringshared_new(NULL); 613 unit->children = eina_hash_stringshared_new(NULL);
611 unit->classes = eina_hash_stringshared_new(NULL); 614 unit->classes = eina_hash_stringshared_new(NULL);
@@ -614,7 +617,9 @@ database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
614 unit->aliases = eina_hash_stringshared_new(NULL); 617 unit->aliases = eina_hash_stringshared_new(NULL);
615 unit->structs = eina_hash_stringshared_new(NULL); 618 unit->structs = eina_hash_stringshared_new(NULL);
616 unit->enums = eina_hash_stringshared_new(NULL); 619 unit->enums = eina_hash_stringshared_new(NULL);
617 _cunit = unit; 620
621 if (fname)
622 _cunit = unit;
618} 623}
619 624
620void 625void
@@ -631,6 +636,23 @@ database_unit_del(Eolian_Unit *unit)
631 eina_hash_free(unit->enums); 636 eina_hash_free(unit->enums);
632} 637}
633 638
639EAPI Eolian_Unit *
640eolian_new(void)
641{
642 Eolian_Unit *nunit = calloc(1, sizeof(Eolian_Unit));
643 if (!nunit)
644 return NULL;
645
646 database_unit_init(nunit, NULL);
647 return nunit;
648}
649
650EAPI void
651eolian_free(Eolian_Unit *unit)
652{
653 database_unit_del(unit);
654}
655
634#define EO_SUFFIX ".eo" 656#define EO_SUFFIX ".eo"
635#define EOT_SUFFIX ".eot" 657#define EOT_SUFFIX ".eot"
636 658