summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:10:19 +0000
committerFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:10:19 +0000
commitcd1df0cf8df0b0d6962443ad4ffffb5f2929ddf2 (patch)
tree6ffb9f63762ec87635027b60ba38072f9623cf97 /bindings
parent464dda465452a228d8cf9b625b08f9be28ef96ee (diff)
downloadlasso-cd1df0cf8df0b0d6962443ad4ffffb5f2929ddf2.tar.gz
lasso-cd1df0cf8df0b0d6962443ad4ffffb5f2929ddf2.tar.xz
lasso-cd1df0cf8df0b0d6962443ad4ffffb5f2929ddf2.zip
[project @ fpeters@0d.be-20080410163456-r6a9flm66nhyap6m]
Merge from bdauvergne: factorize the backward compatibility code for GHashTable, fixed placement of declarations. Original author: Frederic Peters <fpeters@0d.be> Date: 2008-04-10 18:34:56.595000+02:00
Diffstat (limited to 'bindings')
-rw-r--r--bindings/Makefile.am4
-rw-r--r--bindings/ghashtable.h81
-rw-r--r--bindings/lang_java_wrapper_top.c72
-rw-r--r--bindings/lang_php5_helpers/wrapper_source_top.c46
-rw-r--r--bindings/lang_python_wrapper_top.c54
5 files changed, 87 insertions, 170 deletions
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index a39b82f2..1432dd8f 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -15,4 +15,6 @@ EXTRA_DIST = bindings.py \
lang_php5_helpers/php_code.py \
lang_php5_helpers/wrapper_header.py \
lang_php5_helpers/wrapper_source.py \
- utility-scripts/error-analyzer.pl
+ utility-scripts/error-analyzer.pl \
+ ghashtable.h
+
diff --git a/bindings/ghashtable.h b/bindings/ghashtable.h
new file mode 100644
index 00000000..e9644755
--- /dev/null
+++ b/bindings/ghashtable.h
@@ -0,0 +1,81 @@
+#ifndef G_HASHTABLE_H
+#define G_HASHTABLE_H 1
+#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
+
+typedef struct _GHashNode GHashNode;
+
+struct _GHashNode
+{
+ gpointer key;
+ gpointer value;
+ GHashNode *next;
+ guint key_hash;
+};
+
+struct _GHashTable
+{
+ gint size;
+ gint nnodes;
+ GHashNode **nodes;
+ GHashFunc hash_func;
+ GEqualFunc key_equal_func;
+ volatile gint ref_count;
+ GDestroyNotify key_destroy_func;
+ GDestroyNotify value_destroy_func;
+};
+
+/* Helper functions to access JNI interface functions */
+#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 12)
+void
+g_hash_table_remove_all (GHashTable *hash_table)
+{
+ g_return_if_fail (hash_table != NULL);
+
+#ifndef G_DISABLE_ASSERT
+ if (hash_table->nnodes != 0)
+ hash_table->version++;
+#endif
+
+ g_hash_table_remove_all_nodes (hash_table, TRUE);
+ g_hash_table_maybe_resize (hash_table);
+}
+#endif
+ /* copy of private struct and g_hash_table_get_keys from GLib internals
+ * (as this function is useful but new in 2.14) */
+
+
+static GList *
+g_hash_table_get_keys (GHashTable *hash_table)
+{
+ GHashNode *node;
+ gint i;
+ GList *retval;
+
+ g_return_val_if_fail (hash_table != NULL, NULL);
+
+ retval = NULL;
+ for (i = 0; i < hash_table->size; i++)
+ for (node = hash_table->nodes[i]; node; node = node->next)
+ retval = g_list_prepend (retval, node->key);
+
+ return retval;
+}
+
+GList *
+g_hash_table_get_values (GHashTable *hash_table)
+{
+ GHashNode *node;
+ gint i;
+ GList *retval;
+
+ g_return_val_if_fail (hash_table != NULL, NULL);
+
+ retval = NULL;
+ for (i = 0; i < hash_table->size; i++)
+ for (node = hash_table->nodes[i]; node; node = node->next)
+ retval = g_list_prepend (retval, node->value);
+
+ return retval;
+}
+#endif
+#endif /* G_HASHTABLE_H */
diff --git a/bindings/lang_java_wrapper_top.c b/bindings/lang_java_wrapper_top.c
index c4055367..daac2b6c 100644
--- a/bindings/lang_java_wrapper_top.c
+++ b/bindings/lang_java_wrapper_top.c
@@ -3,6 +3,7 @@
#include <jni.h>
#include "com_entrouvert_lasso_LassoJNI.h"
#include <string.h>
+#include "../ghashtable.h"
#define LASSO_ROOT "com/entrouvert/lasso/"
#define check_exception (*env)->ExceptionCheck(env)
@@ -75,77 +76,6 @@ static int get_hash_by_name(JNIEnv *env, GHashTable *hashtable, jstring jkey, Co
//#define get_hash_of_strings_by_name(end,hash,key) get_hash_by_name(end,hash,key,(Converter)string_to_jstring)
//#define get_hash_of_objects_by_name(end,hash,key) get_hash_by_name(end,hash,key,(Converter)gobject_to_jobject_and_ref)
-/* Helper functions to access JNI interface functions */
-#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 12)
-void
-g_hash_table_remove_all (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
-
- g_hash_table_remove_all_nodes (hash_table, TRUE);
- g_hash_table_maybe_resize (hash_table);
-}
-#endif
-#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
- /* copy of private struct and g_hash_table_get_keys from GLib internals
- * (as this function is useful but new in 2.14) */
-
-typedef struct _GHashNode GHashNode;
-
-struct _GHashNode
-{
- gpointer key;
- gpointer value;
- GHashNode *next;
- guint key_hash;
-};
-
-struct _GHashTable
-{
- gint size;
- gint nnodes;
- GHashNode **nodes;
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
- volatile gint ref_count;
- GDestroyNotify key_destroy_func;
- GDestroyNotify value_destroy_func;
-};
-
-static GList *
-g_hash_table_get_keys (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->key);
-
- return retval;
-}
-
-GList *
-g_hash_table_get_values (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->value);
-
- return retval;
-}
-#endif
static int
gpointer_equal(gpointer p1, gpointer p2) {
diff --git a/bindings/lang_php5_helpers/wrapper_source_top.c b/bindings/lang_php5_helpers/wrapper_source_top.c
index 5a1ca6fd..34e1e1b0 100644
--- a/bindings/lang_php5_helpers/wrapper_source_top.c
+++ b/bindings/lang_php5_helpers/wrapper_source_top.c
@@ -6,55 +6,11 @@
#undef PACKAGE_VERSION
#include <lasso/lasso.h>
#include "php_lasso.h"
+#include "../ghashtable.h"
/* utility functions */
static void free_glist(GList **list, GFunc free_function);
-#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
- /* copy of private struct and g_hash_table_get_keys from GLib internals
- * (as this function is useful but new in 2.14) */
-
-typedef struct _GHashNode GHashNode;
-
-struct _GHashNode
-{
- gpointer key;
- gpointer value;
- GHashNode *next;
- guint key_hash;
-};
-
-struct _GHashTable
-{
- gint size;
- gint nnodes;
- GHashNode **nodes;
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
- volatile gint ref_count;
- GDestroyNotify key_destroy_func;
- GDestroyNotify value_destroy_func;
-};
-
-static GList *
-g_hash_table_get_keys (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->key);
-
- return retval;
-}
-
-#endif
-
/* Define the Lasso PHP module */
int le_lasso_server;
diff --git a/bindings/lang_python_wrapper_top.c b/bindings/lang_python_wrapper_top.c
index 4ef300a5..dcfa3d52 100644
--- a/bindings/lang_python_wrapper_top.c
+++ b/bindings/lang_python_wrapper_top.c
@@ -2,6 +2,7 @@
#include <structmember.h>
#include <lasso/lasso.h>
#include <lasso_config.h>
+#include "../ghashtable.h"
GQuark lasso_wrapper_key;
@@ -33,59 +34,6 @@ noneRef() {
Py_INCREF(Py_None);
return Py_None;
}
-#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 12)
-void
-g_hash_table_remove_all (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
-
- g_hash_table_remove_all_nodes (hash_table, TRUE);
- g_hash_table_maybe_resize (hash_table);
-}
-#endif
-#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
- /* copy of private struct and g_hash_table_get_keys from GLib internals
- * (as this function is useful but new in 2.14) */
-
-typedef struct _GHashNode GHashNode;
-
-struct _GHashNode
-{
- gpointer key;
- gpointer value;
- GHashNode *next;
- guint key_hash;
-};
-
-struct _GHashTable
-{
- gint size;
- gint nnodes;
- GHashNode **nodes;
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
- volatile gint ref_count;
- GDestroyNotify key_destroy_func;
- GDestroyNotify value_destroy_func;
-};
-
-static GList *
-g_hash_table_get_keys (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->key);
-
- return retval;
-}
-#endif
static PyObject*
get_dict_from_hashtable_of_objects(GHashTable *value)