summaryrefslogtreecommitdiffhomepage
path: root/mixlib
diff options
context:
space:
mode:
Diffstat (limited to 'mixlib')
-rw-r--r--mixlib/mix_symbol_table.c42
-rw-r--r--mixlib/mix_symbol_table.h9
2 files changed, 51 insertions, 0 deletions
diff --git a/mixlib/mix_symbol_table.c b/mixlib/mix_symbol_table.c
index 1045886..d59c396 100644
--- a/mixlib/mix_symbol_table.c
+++ b/mixlib/mix_symbol_table.c
@@ -64,6 +64,48 @@ mix_symbol_table_delete(mix_symbol_table_t *table)
g_hash_table_destroy(table);
}
+/* add/remove symbols from other table */
+static void
+add_symbol_(gpointer symbol, gpointer value, gpointer target)
+{
+ mix_symbol_table_t *t = (mix_symbol_table_t *)target;
+ gchar *s = (gchar *)symbol;
+ mix_word_t v = mix_word_new(GPOINTER_TO_UINT(value));
+ mix_symbol_table_insert (t, s, v);
+}
+
+static void
+remove_symbol_(gpointer symbol, gpointer value, gpointer target)
+{
+ mix_symbol_table_t *t = (mix_symbol_table_t *)target;
+ gchar *s = (gchar *)symbol;
+ mix_symbol_table_remove (t, s);
+}
+
+gboolean
+mix_symbol_table_merge_table (mix_symbol_table_t *table,
+ mix_symbol_table_t *from)
+{
+ g_return_val_if_fail (table != NULL, FALSE);
+ if (from != NULL)
+ {
+ mix_symbol_table_foreach (from, add_symbol_, table);
+ }
+ return TRUE;
+}
+
+gboolean
+mix_symbol_table_substract_table (mix_symbol_table_t *table,
+ mix_symbol_table_t *other)
+{
+ g_return_val_if_fail (table != NULL, FALSE);
+ if (other != NULL)
+ {
+ mix_symbol_table_foreach (other, remove_symbol_, table);
+ }
+ return TRUE;
+}
+
/* Add/remove symbols one by one */
gint
diff --git a/mixlib/mix_symbol_table.h b/mixlib/mix_symbol_table.h
index da9046f..db48ffd 100644
--- a/mixlib/mix_symbol_table.h
+++ b/mixlib/mix_symbol_table.h
@@ -47,6 +47,15 @@ mix_symbol_table_new_from_file(FILE *file);
extern void
mix_symbol_table_delete(mix_symbol_table_t *table);
+/* add/remove symbols from other table */
+extern gboolean
+mix_symbol_table_merge_table (mix_symbol_table_t *table,
+ mix_symbol_table_t *from);
+
+extern gboolean
+mix_symbol_table_substract_table (mix_symbol_table_t *table,
+ mix_symbol_table_t *other);
+
/* Add/remove symbols one by one */
/* possible outcomes: */
enum {