forked from enlightenment/efl
eolian: contain master state in a larger structure
This commit is contained in:
parent
53aa99550d
commit
e83e089765
|
@ -84,6 +84,12 @@ extern "C" {
|
|||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
/* State information
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
typedef struct _Eolian Eolian;
|
||||
|
||||
/* Class type used to extract information on classes
|
||||
*
|
||||
* @ingroup Eolian
|
||||
|
@ -523,30 +529,31 @@ EAPI int eolian_init(void);
|
|||
EAPI int eolian_shutdown(void);
|
||||
|
||||
/*
|
||||
* @brief Create a new primary unit for Eolian state.
|
||||
* @brief Create a new Eolian state.
|
||||
*
|
||||
* This creates a new Eolian state that consists of a "master unit" with
|
||||
* the same address (therefore, you can cast it to Eolian_Unit) plus extra
|
||||
* state information.
|
||||
*
|
||||
* 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).
|
||||
* @return A new state (or NULL on failure).
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eolian_Unit *eolian_new(void);
|
||||
EAPI Eolian *eolian_new(void);
|
||||
|
||||
/*
|
||||
* @brief Free a master unit.
|
||||
* @brief Free an Eolian state.
|
||||
*
|
||||
* 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.
|
||||
* You can use this to free an Eolian state.
|
||||
*
|
||||
* If the input is NULL, this function has no effect.
|
||||
*
|
||||
* @param[in] unit the master unit to free
|
||||
* @param[in] unit the state to free
|
||||
*
|
||||
*/
|
||||
EAPI void eolian_free(Eolian_Unit *unit);
|
||||
EAPI void eolian_free(Eolian *state);
|
||||
|
||||
/*
|
||||
* @brief Scan the given directory (recursively) and search for .eo and
|
||||
|
|
|
@ -636,21 +636,25 @@ database_unit_del(Eolian_Unit *unit)
|
|||
eina_hash_free(unit->enums);
|
||||
}
|
||||
|
||||
EAPI Eolian_Unit *
|
||||
EAPI Eolian *
|
||||
eolian_new(void)
|
||||
{
|
||||
Eolian_Unit *nunit = calloc(1, sizeof(Eolian_Unit));
|
||||
if (!nunit)
|
||||
Eolian *state = calloc(1, sizeof(Eolian));
|
||||
if (!state)
|
||||
return NULL;
|
||||
|
||||
database_unit_init(nunit, NULL);
|
||||
return nunit;
|
||||
database_unit_init(&state->unit, NULL);
|
||||
return state;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
eolian_free(Eolian_Unit *unit)
|
||||
eolian_free(Eolian *state)
|
||||
{
|
||||
database_unit_del(unit);
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
database_unit_del(&state->unit);
|
||||
free(state);
|
||||
}
|
||||
|
||||
#define EO_SUFFIX ".eo"
|
||||
|
|
|
@ -59,6 +59,23 @@ extern Eina_Hash *_parsingeos;
|
|||
/* for deferred dependency parsing */
|
||||
extern Eina_Hash *_defereos;
|
||||
|
||||
struct _Eolian_Unit
|
||||
{
|
||||
Eolian_Unit *parent;
|
||||
Eina_Hash *children;
|
||||
Eina_Hash *classes;
|
||||
Eina_Hash *globals;
|
||||
Eina_Hash *constants;
|
||||
Eina_Hash *aliases;
|
||||
Eina_Hash *structs;
|
||||
Eina_Hash *enums;
|
||||
};
|
||||
|
||||
struct _Eolian
|
||||
{
|
||||
Eolian_Unit unit;
|
||||
};
|
||||
|
||||
typedef struct _Eolian_Object
|
||||
{
|
||||
const char *file;
|
||||
|
@ -294,18 +311,6 @@ struct _Eolian_Variable
|
|||
Eina_Bool is_extern :1;
|
||||
};
|
||||
|
||||
struct _Eolian_Unit
|
||||
{
|
||||
Eolian_Unit *parent;
|
||||
Eina_Hash *children;
|
||||
Eina_Hash *classes;
|
||||
Eina_Hash *globals;
|
||||
Eina_Hash *constants;
|
||||
Eina_Hash *aliases;
|
||||
Eina_Hash *structs;
|
||||
Eina_Hash *enums;
|
||||
};
|
||||
|
||||
int database_init(void);
|
||||
int database_shutdown(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue