aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-22 15:13:59 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-22 15:37:25 +0100
commitd9a8fe0fca74dcd67190de381fa3ddc339e4cea2 (patch)
treebfa00b46b6abe96247f3ffcc7dbedea4cdabe3aa
parenteolian: flush defer table before parsing (diff)
downloadefl-d9a8fe0fca74dcd67190de381fa3ddc339e4cea2.tar.gz
eolian: add state staging area
This will be used for clean rollbacks on errors.
-rw-r--r--src/lib/eolian/eolian_database.c23
-rw-r--r--src/lib/eolian/eolian_database.h1
2 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 52049fc405..d928e3f456 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -605,6 +605,7 @@ eolian_state_new(void)
state->error = _default_error_cb;
database_unit_init(state, &state->unit, NULL);
+ database_unit_init(state, &state->staging, NULL);
state->filenames_eo = eina_hash_string_small_new(free);
state->filenames_eot = eina_hash_string_small_new(free);
@@ -630,6 +631,7 @@ eolian_state_free(Eolian_State *state)
return;
_unit_contents_del(&state->unit);
+ _unit_contents_del(&state->staging);
eina_hash_free(state->filenames_eo);
eina_hash_free(state->filenames_eot);
@@ -772,6 +774,21 @@ _eolian_file_parse_nodep(Eolian_Unit *parent, const char *filepath)
return eo_parser_database_fill(parent, eopath, !is_eo);
}
+static void
+_state_clean(Eolian_State *state)
+{
+ eina_hash_free_buckets(state->defer);
+
+ Eolian_Unit *st = &state->staging;
+ eina_hash_free_buckets(st->classes);
+ eina_hash_free_buckets(st->globals);
+ eina_hash_free_buckets(st->constants);
+ eina_hash_free_buckets(st->aliases);
+ eina_hash_free_buckets(st->structs);
+ eina_hash_free_buckets(st->enums);
+ eina_hash_free_buckets(st->objects);
+}
+
static Eina_Bool
_parse_deferred(Eolian_Unit *parent)
{
@@ -859,7 +876,7 @@ eolian_state_file_parse(Eolian_State *state, const char *filepath)
if (!state)
return NULL;
- eina_hash_free_buckets(state->defer);
+ _state_clean(state);
Eolian_Unit *ret = _eolian_file_parse_nodep((Eolian_Unit *)state, filepath);
if (!ret)
return NULL;
@@ -897,7 +914,7 @@ eolian_state_all_eot_files_parse(Eolian_State *state)
if (!state)
return EINA_FALSE;
- eina_hash_free_buckets(state->defer);
+ _state_clean(state);
eina_hash_foreach(state->filenames_eot, _tfile_parse, &pd);
if (pd.ret && !database_validate(&state->unit))
@@ -926,7 +943,7 @@ eolian_state_all_eo_files_parse(Eolian_State *state)
if (!state)
return EINA_FALSE;
- eina_hash_free_buckets(state->defer);
+ _state_clean(state);
eina_hash_foreach(state->filenames_eo, _file_parse, &pd);
if (pd.ret && !database_validate(&state->unit))
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 320862c60f..72adf48013 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -50,6 +50,7 @@ struct _Eolian_Unit
struct _Eolian_State
{
Eolian_Unit unit;
+ Eolian_Unit staging;
Eolian_Panic_Cb panic;
Eina_Stringshare *panic_msg;