eolian: add API to get full file path of a unit

This is necessary for easy dependency generation, as it is needed
to retrieve a full list of paths that each generated file depends
on.
This commit is contained in:
Daniel Kolesa 2018-10-11 16:35:41 +02:00
parent e6924b9c72
commit c4640d6f40
2 changed files with 26 additions and 0 deletions

View File

@ -909,10 +909,26 @@ EAPI Eina_Iterator *eolian_unit_children_get(const Eolian_Unit *unit);
*
* @param[in] unit The unit.
*
* @see eolian_unit_file_path_get
*
* @ingroup Eolian
*/
EAPI const char *eolian_unit_file_get(const Eolian_Unit *unit);
/*
* @brief Get the full file path a unit is associated with.
*
* This will be `NULL` if not associated with a file (like the master unit
* within `Eolian_State`).
*
* @param[in] unit The unit.
*
* @see eolian_unit_file_get
*
* @ingroup Eolian
*/
EAPI const char *eolian_unit_file_path_get(const Eolian_Unit *unit);
/*
* @brief Get an object in a unit by name.
*

View File

@ -1226,6 +1226,16 @@ eolian_unit_file_get(const Eolian_Unit *unit)
return unit->file;
}
EAPI const char *
eolian_unit_file_path_get(const Eolian_Unit *unit)
{
if (!unit || !unit->file) return NULL;
Eina_Bool is_eo = eina_str_has_suffix(unit->file, EO_SUFFIX);
return eina_hash_find(is_eo
? unit->state->filenames_eo
: unit->state->filenames_eot, unit->file);
}
EAPI const Eolian_Object *
eolian_unit_object_by_name_get(const Eolian_Unit *unit, const char *name)
{