eolian: add API for master unit creation
This commit is contained in:
parent
6abb24b717
commit
53aa99550d
|
@ -522,6 +522,32 @@ EAPI int eolian_init(void);
|
||||||
*/
|
*/
|
||||||
EAPI int eolian_shutdown(void);
|
EAPI int eolian_shutdown(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Create a new primary unit for Eolian state.
|
||||||
|
*
|
||||||
|
* This creates a nameless "master unit" which holds all Eolian state.
|
||||||
|
* You need to free this with eolian_free once you're done.
|
||||||
|
*
|
||||||
|
* @return A new master unit (or NULL on failure).
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI Eolian_Unit *eolian_new(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Free a master unit.
|
||||||
|
*
|
||||||
|
* You can use this to free an Eolian state. Do not EVER use this to free
|
||||||
|
* any unit other than master unit, as these are managed by the master unit
|
||||||
|
* and freeing them would result in incorrect behavior.
|
||||||
|
*
|
||||||
|
* If the input is NULL, this function has no effect.
|
||||||
|
*
|
||||||
|
* @param[in] unit the master unit to free
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
EAPI void eolian_free(Eolian_Unit *unit);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Scan the given directory (recursively) and search for .eo and
|
* @brief Scan the given directory (recursively) and search for .eo and
|
||||||
* .eot files.
|
* .eot files.
|
||||||
|
|
|
@ -602,10 +602,13 @@ eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok,
|
||||||
void
|
void
|
||||||
database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
|
database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
|
||||||
{
|
{
|
||||||
Eolian_Unit *ocunit = _cunit;
|
if (fname)
|
||||||
unit->parent = ocunit;
|
{
|
||||||
if (ocunit)
|
Eolian_Unit *ocunit = _cunit;
|
||||||
eina_hash_add(ocunit->children, fname, unit);
|
unit->parent = ocunit;
|
||||||
|
if (ocunit)
|
||||||
|
eina_hash_add(ocunit->children, fname, unit);
|
||||||
|
}
|
||||||
|
|
||||||
unit->children = eina_hash_stringshared_new(NULL);
|
unit->children = eina_hash_stringshared_new(NULL);
|
||||||
unit->classes = eina_hash_stringshared_new(NULL);
|
unit->classes = eina_hash_stringshared_new(NULL);
|
||||||
|
@ -614,7 +617,9 @@ database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
|
||||||
unit->aliases = eina_hash_stringshared_new(NULL);
|
unit->aliases = eina_hash_stringshared_new(NULL);
|
||||||
unit->structs = eina_hash_stringshared_new(NULL);
|
unit->structs = eina_hash_stringshared_new(NULL);
|
||||||
unit->enums = eina_hash_stringshared_new(NULL);
|
unit->enums = eina_hash_stringshared_new(NULL);
|
||||||
_cunit = unit;
|
|
||||||
|
if (fname)
|
||||||
|
_cunit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -631,6 +636,23 @@ database_unit_del(Eolian_Unit *unit)
|
||||||
eina_hash_free(unit->enums);
|
eina_hash_free(unit->enums);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eolian_Unit *
|
||||||
|
eolian_new(void)
|
||||||
|
{
|
||||||
|
Eolian_Unit *nunit = calloc(1, sizeof(Eolian_Unit));
|
||||||
|
if (!nunit)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
database_unit_init(nunit, NULL);
|
||||||
|
return nunit;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
eolian_free(Eolian_Unit *unit)
|
||||||
|
{
|
||||||
|
database_unit_del(unit);
|
||||||
|
}
|
||||||
|
|
||||||
#define EO_SUFFIX ".eo"
|
#define EO_SUFFIX ".eo"
|
||||||
#define EOT_SUFFIX ".eot"
|
#define EOT_SUFFIX ".eot"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue