libgda r3229 - in trunk: . doc/C/tmpl libgda libgda-report/engine libgda-xslt libgda/binreloc libgda/handlers libgda/sqlite providers/mysql providers/postgres providers/skel-implementation/capi tests/meta-store



Author: vivien
Date: Tue Oct  7 13:08:52 2008
New Revision: 3229
URL: http://svn.gnome.org/viewvc/libgda?rev=3229&view=rev

Log:
2008-10-07  Vivien Malerba <malerba gnome-db org>

	* libgda/gda-server-operation.c: code cleanup
	* libgda/gda-column.c:
	* libgda/gda-holder.c:
	* libgda/gda-meta-struct.c:
	* libgda/gda-attributes-manager.[ch]: optionnally specify a callback function
	called whenever an attribute is changed
	* libgda/gda-data-model-import.c: renamed the GDA_TYPE_<col nb> option to
	G_TYPE_<col nb>
	* libgda/binreloc/Makefile.am:
	* libgda/binreloc/gda-binreloc.c: possible fix for bug #541991 (comment 2)

2008-10-07  Johannes Schmid  <johannes schmid openismus com>

	* libgda-report/engine/gda-report-engine.c (value_to_node):
	* libgda-xslt/sql_backend.c (value_to_xmlchar):
	* libgda/gda-data-model-import.c (init_csv_import):
	* libgda/gda-easy.c (gda_get_default_handler):
	* libgda/gda-holder.c (gda_holder_class_init),
	(gda_holder_new_inline), (gda_holder_set_property),
	(gda_holder_get_property):
	* libgda/gda-server-provider-extra.c
	(gda_server_provider_get_data_handler_default):
	* libgda/gda-set.c (gda_set_new_inline),
	(gda_set_set_holder_value):
	* libgda/gda-value.c (set_from_string), (gda_value_differ),
	(gda_value_compare):
	* libgda/handlers/gda-handler-type.c (gda_handler_type_init),
	(gda_handler_type_get_value_from_sql),
	(gda_handler_type_get_value_from_str):
	* libgda/sqlite/gda-sqlite-provider.c
	(gda_sqlite_provider_get_default_dbms_type):
	* libgda/sqlite/virtual/gda-vprovider-data-model.c (virtualCreate):
	* providers/mysql/gda-mysql-provider.c
	(gda_mysql_provider_get_default_dbms_type):
	* providers/postgres/gda-postgres-provider.c
	(gda_postgres_provider_get_default_dbms_type):
	* providers/postgres/gda-postgres-recordset.c (set_value):
	* providers/skel-implementation/capi/gda-capi-provider.c
	(gda_capi_provider_get_default_dbms_type):
	#537159: Use GType instead of ulong/gint to represent GTypes


Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/doc/C/tmpl/gda-attributes-manager.sgml
   trunk/libgda-report/engine/gda-report-engine.c
   trunk/libgda-xslt/sql_backend.c
   trunk/libgda/binreloc/Makefile.am
   trunk/libgda/binreloc/gda-binreloc.c
   trunk/libgda/gda-attributes-manager.c
   trunk/libgda/gda-attributes-manager.h
   trunk/libgda/gda-column.c
   trunk/libgda/gda-data-model-import.c
   trunk/libgda/gda-easy.c
   trunk/libgda/gda-holder.c
   trunk/libgda/gda-meta-struct.c
   trunk/libgda/gda-server-operation.c
   trunk/libgda/gda-server-provider-extra.c
   trunk/libgda/gda-set.c
   trunk/libgda/gda-value.c
   trunk/libgda/handlers/gda-handler-numerical.c
   trunk/libgda/handlers/gda-handler-type.c
   trunk/libgda/sqlite/gda-sqlite-provider.c
   trunk/providers/mysql/gda-mysql-provider.c
   trunk/providers/postgres/gda-postgres-provider.c
   trunk/providers/postgres/gda-postgres-recordset.c
   trunk/providers/skel-implementation/capi/gda-capi-provider.c
   trunk/tests/meta-store/common.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Tue Oct  7 13:08:52 2008
@@ -10,7 +10,7 @@
  - Lots of improvements to the SQL console (gda-sql-4.0)
  - Lots of small bug fixes (Johannes Schmid, Vivien Malerba)
  - Lots of documentation improvements
- - bug fixes: #508407, #552708, #90751
+ - bug fixes: #508407, #552708, #90751, #401442
 
 libgda 3.99.4, 2008-09-16
 

Modified: trunk/doc/C/tmpl/gda-attributes-manager.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-attributes-manager.sgml	(original)
+++ trunk/doc/C/tmpl/gda-attributes-manager.sgml	Tue Oct  7 13:08:52 2008
@@ -77,6 +77,8 @@
 </para>
 
 @for_objects: 
+ signal_func: 
+ signal_data: 
 @Returns: 
 
 

Modified: trunk/libgda-report/engine/gda-report-engine.c
==============================================================================
--- trunk/libgda-report/engine/gda-report-engine.c	(original)
+++ trunk/libgda-report/engine/gda-report-engine.c	Tue Oct  7 13:08:52 2008
@@ -1122,7 +1122,9 @@
 			g_hash_table_insert (data_handlers, (gpointer) GDA_TYPE_TIMESTAMP, gda_handler_time_new ());
 			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_CHAR, gda_handler_numerical_new ());
 			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_UCHAR, gda_handler_numerical_new ());
-			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_ULONG, gda_handler_type_new ());
+			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_ULONG, gda_handler_numerical_new ());
+			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_LONG, gda_handler_numerical_new ());
+			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_GTYPE, gda_handler_type_new ());
 			g_hash_table_insert (data_handlers, (gpointer) G_TYPE_UINT, gda_handler_numerical_new ());
 		}
 

Modified: trunk/libgda-xslt/sql_backend.c
==============================================================================
--- trunk/libgda-xslt/sql_backend.c	(original)
+++ trunk/libgda-xslt/sql_backend.c	Tue Oct  7 13:08:52 2008
@@ -650,6 +650,10 @@
 		g_hash_table_insert (data_handlers, (gpointer) G_TYPE_UCHAR,
 				     gda_handler_numerical_new ());
 		g_hash_table_insert (data_handlers, (gpointer) G_TYPE_ULONG,
+				     gda_handler_numerical_new ());
+		g_hash_table_insert (data_handlers, (gpointer) G_TYPE_LONG,
+				     gda_handler_numerical_new ());
+		g_hash_table_insert (data_handlers, (gpointer) G_TYPE_GTYPE,
 				     gda_handler_type_new ());
 		g_hash_table_insert (data_handlers, (gpointer) G_TYPE_UINT,
 				     gda_handler_numerical_new ());

Modified: trunk/libgda/binreloc/Makefile.am
==============================================================================
--- trunk/libgda/binreloc/Makefile.am	(original)
+++ trunk/libgda/binreloc/Makefile.am	Tue Oct  7 13:08:52 2008
@@ -5,7 +5,8 @@
 	-I$(top_builddir) \
 	$(LIBGDA_CFLAGS) \
 	$(BINRELOC_CFLAGS) \
-	-DLIBGDAPREFIX=\""$(prefix)"\"
+	-DLIBGDAPREFIX=\""$(prefix)"\" \
+	-DLIBGDASYSCONF=\""$(sysconfdir)"\"
 
 noinst_LTLIBRARIES = libgda_binreloc-4.0.la
 

Modified: trunk/libgda/binreloc/gda-binreloc.c
==============================================================================
--- trunk/libgda/binreloc/gda-binreloc.c	(original)
+++ trunk/libgda/binreloc/gda-binreloc.c	Tue Oct  7 13:08:52 2008
@@ -100,13 +100,15 @@
 		prefix_dir_name = "libexec";
 		break;
 	case GDA_ETC_DIR:
-		prefix_dir_name = "etc";
+		prefix_dir_name = NULL;
 		break;
 	}
 
 #ifdef GDA_DEBUG_NO
 	g_print ("%s ()\n", __FUNCTION__);
 #endif
+
+
 	/* prefix part */
 #ifdef G_OS_WIN32
 	/* Get from location of libgda DLL */
@@ -135,7 +137,10 @@
 	else
 		g_warning ("Could not get PREFIX (using Mac OS X Carbon)");
 #else
-	prefix = _gda_gbr_find_prefix (LIBGDAPREFIX);
+	if (where == GDA_ETC_DIR)
+		prefix = _gda_gbr_find_prefix (LIBGDASYSCONF);
+	else
+		prefix = _gda_gbr_find_prefix (LIBGDAPREFIX);
 #endif
 	if (!prefix || !*prefix)
 		return NULL;

Modified: trunk/libgda/gda-attributes-manager.c
==============================================================================
--- trunk/libgda/gda-attributes-manager.c	(original)
+++ trunk/libgda/gda-attributes-manager.c	Tue Oct  7 13:08:52 2008
@@ -39,8 +39,10 @@
 static void obj_destroyed_cb (Key *key, GObject *where_the_object_was);
 
 struct _GdaAttributesManager {
-	gboolean    for_objects; /* TRUE if key->data are GObjects */
-	GHashTable *hash; /* key = a Key pointer, value = a GValue */
+	gboolean                    for_objects; /* TRUE if key->data are GObjects */
+	GdaAttributesManagerSignal  signal_func;
+	gpointer                    signal_data;
+	GHashTable                 *hash; /* key = a Key pointer, value = a GValue */
 };
 
 static guint
@@ -73,6 +75,8 @@
 /**
  * gda_attributes_manager_new
  * @for_objects: set to TRUE if attributes will be set on objects.
+ * @signal_func: a function to be called whenever an attribute changes on an object (if @for_objects is TRUE), or %NULL
+ * @signal_data: user data passed as last argument of @signal_func when it is called
  *
  * Creates a new #GdaAttributesManager, which can store (name, value) attributes for pointers or GObject objects
  * (in the latter case, the attibutes are destroyed when objects are also destroyed).
@@ -80,13 +84,15 @@
  * Returns: the new #GdaAttributesManager
  */
 GdaAttributesManager *
-gda_attributes_manager_new (gboolean for_objects)
+gda_attributes_manager_new (gboolean for_objects, GdaAttributesManagerSignal signal_func, gpointer signal_data)
 {
 	GdaAttributesManager *mgr;
 
 	mgr = g_new0 (GdaAttributesManager, 1);
 	mgr->hash = g_hash_table_new_full (hash_func, equal_func, (GDestroyNotify) key_free, (GDestroyNotify) gda_value_free);
 	mgr->for_objects = for_objects;
+	mgr->signal_func = signal_func;
+	mgr->signal_data = signal_data;
 
 	return mgr;
 }
@@ -126,21 +132,23 @@
 		key = g_new (Key, 1);
 		key->mgr = mgr;
 		key->ptr = ptr;
-		key->att_name = att_name; /* NOT duplicated */
+		key->att_name = (gchar*) att_name; /* NOT duplicated */
 		key->att_name_destroy = destroy;
 		if (mgr->for_objects) 
 			g_object_weak_ref (G_OBJECT (key->ptr), (GWeakNotify) obj_destroyed_cb, key);
 		if (steal_value)
-			g_hash_table_insert (mgr->hash, key, value);
+			g_hash_table_insert (mgr->hash, key, (GValue*) value);
 		else
 			g_hash_table_insert (mgr->hash, key, gda_value_copy (value));
 	}
 	else {
 		Key key;
 		key.ptr = ptr;
-		key.att_name = att_name;
+		key.att_name = (gchar*) att_name;
 		g_hash_table_remove (mgr->hash, &key);
 	}
+	if (mgr->signal_func && mgr->for_objects)
+		mgr->signal_func ((GObject*) ptr, att_name, value, mgr->signal_data);
 }
 
 /**

Modified: trunk/libgda/gda-attributes-manager.h
==============================================================================
--- trunk/libgda/gda-attributes-manager.h	(original)
+++ trunk/libgda/gda-attributes-manager.h	Tue Oct  7 13:08:52 2008
@@ -30,8 +30,10 @@
 /* main struct */
 typedef struct _GdaAttributesManager GdaAttributesManager;
 typedef void (*GdaAttributesManagerFunc) (const gchar *att_name, const GValue *value, gpointer data);
+typedef void (*GdaAttributesManagerSignal) (GObject *obj, const gchar *att_name, const GValue *value, gpointer data);
 
-GdaAttributesManager *gda_attributes_manager_new         (gboolean for_objects);
+GdaAttributesManager *gda_attributes_manager_new         (gboolean for_objects, 
+							  GdaAttributesManagerSignal signal_func, gpointer signal_data);
 void                  gda_attributes_manager_free        (GdaAttributesManager *mgr);
 
 void                  gda_attributes_manager_set         (GdaAttributesManager *mgr, gpointer ptr,

Modified: trunk/libgda/gda-column.c
==============================================================================
--- trunk/libgda/gda-column.c	(original)
+++ trunk/libgda/gda-column.c	Tue Oct  7 13:08:52 2008
@@ -159,7 +159,7 @@
 	object_class->finalize = gda_column_finalize;
 
 	/* extra */
-	gda_column_attributes_manager = gda_attributes_manager_new (TRUE);
+	gda_column_attributes_manager = gda_attributes_manager_new (TRUE, NULL, NULL);
 }
 
 static void

Modified: trunk/libgda/gda-data-model-import.c
==============================================================================
--- trunk/libgda/gda-data-model-import.c	(original)
+++ trunk/libgda/gda-data-model-import.c	Tue Oct  7 13:08:52 2008
@@ -682,7 +682,7 @@
  *         <listitem><para>SEPARATOR (string): specifies the CSV separator (comma as default)</para></listitem>
  *         <listitem><para>QUOTE (string): specifies the character used to as quote park (double quote as default)</para></listitem>
  *         <listitem><para>TITLE_AS_FIRST_LINE (boolean): consider that the first line of the file contains columns' titles</para></listitem>
- *         <listitem><para>DBMS_TYPE_&lt;column number&gt; (string): specifies the type of value expected in column &lt;column number&gt;</para></listitem>
+ *         <listitem><para>G_TYPE_&lt;column number&gt; (GType): specifies the type of value expected in column &lt;column number&gt;</para></listitem>
  *      </itemizedlist>
  *   </para></listitem>
  *   <listitem><para>Other formats: no option</para></listitem>
@@ -826,29 +826,22 @@
 		gda_column_set_g_type (column, G_TYPE_STRING);
 		if (model->priv->options) {
 			gchar *pname;
-			const gchar *dbms_t;
 			const GValue *value;
 			
-			pname = g_strdup_printf ("GDA_TYPE_%d", col);
+			pname = g_strdup_printf ("G_TYPE_%d", col);
 			value = gda_set_get_holder_value (model->priv->options, pname);
 			if (value && !gda_value_is_null ((GValue *) value)) {
-				if (!gda_value_isa ((GValue *) value, G_TYPE_ULONG))
-					g_warning (_("The '%s' parameter must hold a "
-						     "gda type value, ignored."), pname);
+				if (!gda_value_isa ((GValue *) value, G_TYPE_GTYPE))
+					g_warning (_("The '%s' option must hold a "
+						     "GType value, ignored."), pname);
 				else {
 					GType gtype;
 					
-					gtype = g_value_get_ulong ((GValue *) value);
+					gtype = g_value_get_gtype ((GValue *) value);
 					gda_column_set_g_type (column, gtype);
 				}
 			}
 			g_free (pname);
-			
-			pname = g_strdup_printf ("DBMS_TYPE_%d", col);
-			dbms_t = find_option_as_string (model, pname);
-			if (dbms_t) 
-				gda_column_set_dbms_type (column, dbms_t);
-			g_free (pname);
 		}
 	}
 

Modified: trunk/libgda/gda-easy.c
==============================================================================
--- trunk/libgda/gda-easy.c	(original)
+++ trunk/libgda/gda-easy.c	Tue Oct  7 13:08:52 2008
@@ -476,7 +476,9 @@
                 g_hash_table_insert (hash, (gpointer) GDA_TYPE_TIMESTAMP, gda_handler_time_new_no_locale ());
                 g_hash_table_insert (hash, (gpointer) G_TYPE_CHAR, gda_handler_numerical_new ());
                 g_hash_table_insert (hash, (gpointer) G_TYPE_UCHAR, gda_handler_numerical_new ());
-                g_hash_table_insert (hash, (gpointer) G_TYPE_ULONG, gda_handler_type_new ());
+                g_hash_table_insert (hash, (gpointer) G_TYPE_ULONG, gda_handler_numerical_new ());
+                g_hash_table_insert (hash, (gpointer) G_TYPE_LONG, gda_handler_numerical_new ());
+                g_hash_table_insert (hash, (gpointer) G_TYPE_GTYPE, gda_handler_type_new ());
                 g_hash_table_insert (hash, (gpointer) G_TYPE_UINT, gda_handler_numerical_new ());
 	}
 	g_static_mutex_unlock (&mutex);

Modified: trunk/libgda/gda-holder.c
==============================================================================
--- trunk/libgda/gda-holder.c	(original)
+++ trunk/libgda/gda-holder.c	Tue Oct  7 13:08:52 2008
@@ -162,6 +162,12 @@
 }
 
 static void
+holder_attribute_set_cb (GObject *obj, const gchar *att_name, const GValue *value, gpointer data)
+{
+	g_signal_emit (obj, gda_holder_signals[ATT_CHANGED], 0, att_name, value);
+}
+
+static void
 gda_holder_class_init (GdaHolderClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -231,11 +237,9 @@
 	g_object_class_install_property (object_class, PROP_DESCR,
 					 g_param_spec_string ("description", NULL, NULL, NULL, 
 							      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
-        g_object_class_install_property (object_class, PROP_GDA_TYPE,
-                                         g_param_spec_ulong ("g-type", NULL, NULL,
-							   0, G_MAXULONG, GDA_TYPE_NULL,
-							   (G_PARAM_READABLE | 
-							    G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
+	g_object_class_install_property (object_class, PROP_GDA_TYPE,
+					 g_param_spec_gtype ("g-type", NULL, NULL, G_TYPE_NONE, 
+							     (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 	g_object_class_install_property (object_class, PROP_NOT_NULL,
 					 g_param_spec_boolean ("not-null", NULL, NULL, FALSE,
 							       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
@@ -257,7 +261,7 @@
 							   (G_PARAM_READABLE | G_PARAM_WRITABLE)));
 	
 	/* extra */
-	gda_holder_attributes_manager = gda_attributes_manager_new (TRUE);
+	gda_holder_attributes_manager = gda_attributes_manager_new (TRUE, holder_attribute_set_cb, NULL);
 }
 
 static void
@@ -294,11 +298,7 @@
 GdaHolder *
 gda_holder_new (GType type)
 {
-	GObject   *obj;
-
-        obj = g_object_new (GDA_TYPE_HOLDER, "g-type", type, NULL);
-
-        return (GdaHolder *) obj;
+	return (GdaHolder*) g_object_new (GDA_TYPE_HOLDER, "g-type", type, NULL);
 }
 
 /**
@@ -434,6 +434,12 @@
 			g_value_set_float (value, va_arg (ap, double));
 		else if (type == G_TYPE_DOUBLE)
 			g_value_set_double (value, va_arg (ap, gdouble));
+		else if (type == G_TYPE_GTYPE)
+			g_value_set_gtype (value, va_arg (ap, GType));
+		else if (type == G_TYPE_LONG)
+			g_value_set_long (value, va_arg (ap, glong));
+		else if (type == G_TYPE_ULONG)
+			g_value_set_ulong (value, va_arg (ap, gulong));
 		else if (type == GDA_TYPE_NUMERIC)
 			gda_value_set_numeric (value, va_arg (ap, GdaNumeric *));
 		else if (type == G_TYPE_DATE)
@@ -537,7 +543,7 @@
 			break;
 		case PROP_GDA_TYPE:
 			if (holder->priv->g_type == GDA_TYPE_NULL)
-				holder->priv->g_type = g_value_get_ulong (value);
+				holder->priv->g_type = g_value_get_gtype (value);
 			else
 				g_warning (_("The 'g-type' property cannot be changed"));
 			break;
@@ -609,7 +615,7 @@
 				g_value_set_string (value, NULL);
 			break;
 		case PROP_GDA_TYPE:
-			g_value_set_ulong (value, holder->priv->g_type);
+			g_value_set_gtype (value, holder->priv->g_type);
 			break;
 		case PROP_NOT_NULL:
 			g_value_set_boolean (value, gda_holder_get_not_null (holder));
@@ -1681,5 +1687,4 @@
 		return;
 
 	gda_attributes_manager_set (gda_holder_attributes_manager, holder, attribute, value);
-	g_signal_emit (holder, gda_holder_signals[ATT_CHANGED], 0, attribute, value);
 }

Modified: trunk/libgda/gda-meta-struct.c
==============================================================================
--- trunk/libgda/gda-meta-struct.c	(original)
+++ trunk/libgda/gda-meta-struct.c	Tue Oct  7 13:08:52 2008
@@ -144,7 +144,7 @@
 	object_class->finalize = gda_meta_struct_finalize;
 
 	/* extra */
-	att_mgr = gda_attributes_manager_new (FALSE);
+	att_mgr = gda_attributes_manager_new (FALSE, NULL, NULL);
 }
 
 

Modified: trunk/libgda/gda-server-operation.c
==============================================================================
--- trunk/libgda/gda-server-operation.c	(original)
+++ trunk/libgda/gda-server-operation.c	Tue Oct  7 13:08:52 2008
@@ -298,19 +298,14 @@
 	case GDA_SERVER_OPERATION_NODE_SEQUENCE: {
 		GSList *list;
 
-		list = node->d.seq.seq_tmpl;
-		while (list) {
+		for (list = node->d.seq.seq_tmpl; list; list = list->next)
 			node_destroy (op, NODE (list->data));
-			list = g_slist_next (list);
-		}
 		g_slist_free (node->d.seq.seq_tmpl);
 
-		list = node->d.seq.seq_items;
-		while (list) {
+		for (list = node->d.seq.seq_items; list; list = list->next)
 			node_destroy (op, NODE (list->data));
-			list = g_slist_next (list);
-		}
 		g_slist_free (node->d.seq.seq_items);
+
 		g_free (node->d.seq.name);
 		g_free (node->d.seq.descr);
 		break;
@@ -318,11 +313,8 @@
 	case GDA_SERVER_OPERATION_NODE_SEQUENCE_ITEM: {
 		GSList *list;
 
-		list = node->d.seq_item_nodes;
-		while (list) {
+		for (list = node->d.seq_item_nodes; list; list = list->next)
 			node_destroy (op, NODE (list->data));
-			list = g_slist_next (list);
-		}
 		g_slist_free (node->d.seq_item_nodes);
 		break;
 	}
@@ -352,14 +344,15 @@
 	if (!path || !*path || (*path != '/'))
 		return NULL;
 
-	list = op->priv->allnodes;
-	while (list && !node) {
+	for (list = op->priv->allnodes; list; list = list->next) {
 		gchar *str;
 		str = node_get_complete_path (op, NODE (list->data));
-		if (!strcmp (str, path))
+		if (!strcmp (str, path)) {
 			node = NODE (list->data);
+			g_free (str);
+			break;
+		}
 		g_free (str);
-		list = list->next;
 	}
 	/*g_print ("%s(%s) => %p\n", __FUNCTION__, path, node);*/
 	return node;
@@ -638,7 +631,7 @@
 		}
 	}
 
-	if (op->priv->xml_spec_doc && op->priv->cnc_set && op->priv->prov_set) {
+	if (!op->priv->topnodes && op->priv->xml_spec_doc && op->priv->cnc_set && op->priv->prov_set) {
 		/* load XML file */
 		GError *lerror = NULL;
 		op->priv->topnodes = load_xml_spec (op, xmlDocGetRootElement (op->priv->xml_spec_doc), NULL, &lerror);
@@ -1201,8 +1194,7 @@
 	complete_path = node_get_complete_path (op, opnode);
 	switch (opnode->type) {
 	case GDA_SERVER_OPERATION_NODE_PARAMLIST:
-		list = opnode->d.plist->holders;
-		while (list) {
+		for (list = opnode->d.plist->holders; list; list = list->next) {
 			gchar *path;
 			const GValue *value;
 			gchar *str;
@@ -1222,8 +1214,6 @@
 			path = g_strdup_printf ("%s/%s", complete_path, gda_holder_get_id (GDA_HOLDER (list->data)));
 			xmlSetProp(node, (xmlChar*)"path", (xmlChar*)path);
 			g_free (path);
-
-			list = g_slist_next (list);
 		}
 		break;
 	case GDA_SERVER_OPERATION_NODE_DATA_MODEL:
@@ -1460,12 +1450,9 @@
 	g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
 	g_return_val_if_fail (op->priv, NULL);	
 
-	list = op->priv->topnodes;
-	retval = g_new0 (gchar *, g_slist_length (list) + 1);
-	while (list) {
+	retval = g_new0 (gchar *, g_slist_length (op->priv->topnodes) + 1);
+	for (list = op->priv->topnodes; list; list = list->next)
 		retval [i++] = node_get_complete_path (op, NODE (list->data));
-		list = g_slist_next (list);
-	}
 
 	return retval;
 }
@@ -1612,11 +1599,8 @@
 		list = node->d.seq_item_nodes;
 	i = 0;
 	retval = g_new0 (gchar *, g_slist_length (list) + 1);
-	while (list) {
+	for (; list; list = list->next, i++)
 		retval [i] = node_get_complete_path (op, NODE (list->data));
-		i++;
-		list = g_slist_next (list);
-	}
 
 	return retval;
 }

Modified: trunk/libgda/gda-server-provider-extra.c
==============================================================================
--- trunk/libgda/gda-server-provider-extra.c	(original)
+++ trunk/libgda/gda-server-provider-extra.c	Tue Oct  7 13:08:52 2008
@@ -123,7 +123,9 @@
 	    (type == GDA_TYPE_USHORT) ||
 	    (type == G_TYPE_CHAR) ||
 	    (type == G_TYPE_UCHAR) ||
-	    (type == G_TYPE_UINT)) {
+	    (type == G_TYPE_UINT) ||
+	    (type == G_TYPE_LONG) ||
+	    (type == G_TYPE_ULONG)) {
 		dh = gda_server_provider_handler_find (provider, NULL, type, NULL);
 		if (!dh) {
 			dh = gda_handler_numerical_new ();
@@ -138,6 +140,8 @@
 			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_CHAR, NULL);
 			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_UCHAR, NULL);
 			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_UINT, NULL);
+			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_ULONG, NULL);
+			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_LONG, NULL);
 			g_object_unref (dh);
 		}
 	}
@@ -168,11 +172,11 @@
 			g_object_unref (dh);
 		}
 	}
-	else if (type == G_TYPE_ULONG) {
+	else if (type == G_TYPE_GTYPE) {
 		dh = gda_server_provider_handler_find (provider, NULL, type, NULL);
 		if (!dh) {
 			dh = gda_handler_type_new ();
-			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_ULONG, NULL);
+			gda_server_provider_handler_declare (provider, dh, NULL, G_TYPE_GTYPE, NULL);
 			g_object_unref (dh);
 		}
 	}

Modified: trunk/libgda/gda-set.c
==============================================================================
--- trunk/libgda/gda-set.c	(original)
+++ trunk/libgda/gda-set.c	Tue Oct  7 13:08:52 2008
@@ -451,6 +451,8 @@
 			g_value_set_long (value, va_arg (ap, glong));
 		else if (type == G_TYPE_ULONG)
 			g_value_set_ulong (value, va_arg (ap, gulong));
+		else if (type == G_TYPE_GTYPE)
+			g_value_set_gtype (value, va_arg(ap, GType));
 		else {
 			g_warning (_("%s() does not handle values of type '%s'."),
 				   __FUNCTION__, g_type_name (type));
@@ -549,6 +551,8 @@
 		g_value_set_long (value, va_arg (ap, glong));
 	else if (type == G_TYPE_ULONG)
 		g_value_set_ulong (value, va_arg (ap, gulong));
+	else if (type == G_TYPE_GTYPE)
+		g_value_set_gtype (value, va_arg (ap, GType));	
 	else {
 		g_set_error (error, 0, 0,
 			     _("%s() does not handle values of type '%s'."),

Modified: trunk/libgda/gda-value.c
==============================================================================
--- trunk/libgda/gda-value.c	(original)
+++ trunk/libgda/gda-value.c	Tue Oct  7 13:08:52 2008
@@ -193,17 +193,30 @@
 		gda_value_set_null (value);
 		retval = TRUE;
 	}
-	else if (type == G_TYPE_ULONG) {
-		if (gda_g_type_from_string (as_string) != 0) 
-			g_value_set_ulong (value, gda_g_type_from_string (as_string));
-		else {
-			gulong ulvalue;
-
-			ulvalue = strtoul (as_string, endptr, 10);
-			if (*as_string!=0 && **endptr==0) {
-				g_value_set_ulong (value, ulvalue);
-				retval = TRUE;
-			}
+	else if (type == G_TYPE_GTYPE) {
+		if (gda_g_type_from_string (as_string) != 0) {
+			g_value_set_gtype (value, gda_g_type_from_string (as_string));
+			retval = TRUE;
+		}
+	}
+	else if (type == G_TYPE_ULONG)
+	{
+		gulong ulvalue;
+		
+		ulvalue = strtoul (as_string, endptr, 10);
+		if (*as_string!=0 && **endptr==0) {
+			g_value_set_ulong (value, ulvalue);
+			retval = TRUE;
+		}
+	}
+	else if (type == G_TYPE_LONG)
+	{
+		glong lvalue;
+		
+		lvalue = strtol (as_string, endptr, 10);
+		if (*as_string!=0 && **endptr==0) {
+			g_value_set_long (value, lvalue);
+			retval = TRUE;
 		}
 	}
 	else if (type == GDA_TYPE_BINARY) {
@@ -1982,7 +1995,8 @@
 		 (type == G_TYPE_CHAR) ||
 		 (type == G_TYPE_UCHAR) ||
 		 (type == G_TYPE_LONG) ||
-		 (type == G_TYPE_ULONG))
+		 (type == G_TYPE_ULONG) ||
+		 (type == G_TYPE_GTYPE))
 		/* values here ARE different because otherwise the bcmp() at the beginning would
 		 * already have retruned */
 		return 1;
@@ -2261,6 +2275,12 @@
 		return (i1 > i2) ? 1 : ((i1 == i2) ? 0 : -1);
 	}
 
+	else if (type == G_TYPE_GTYPE) {
+		GType t1 = g_value_get_gtype (value1);
+		GType t2 = g_value_get_gtype (value2);
+		return (t1 > t2) ? 1 : ((t1 == t2) ? 0: -1);
+	}
+
 	g_warning ("%s() cannot handle values of type %s", __FUNCTION__, g_type_name (G_VALUE_TYPE (value1)));
 
 	return 0;

Modified: trunk/libgda/handlers/gda-handler-numerical.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-numerical.c	(original)
+++ trunk/libgda/handlers/gda-handler-numerical.c	Tue Oct  7 13:08:52 2008
@@ -120,8 +120,8 @@
 	/* Private structure */
 	hdl->priv = g_new0 (GdaHandlerNumericalPriv, 1);
 	hdl->priv->detailled_descr = "";
-	hdl->priv->nb_g_types = 11;
-	hdl->priv->valid_g_types = g_new0 (GType, 11);
+	hdl->priv->nb_g_types = 13;
+	hdl->priv->valid_g_types = g_new0 (GType, hdl->priv->nb_g_types);
 	hdl->priv->valid_g_types[0] = G_TYPE_INT64;
 	hdl->priv->valid_g_types[1] = G_TYPE_DOUBLE;
 	hdl->priv->valid_g_types[2] = G_TYPE_INT;
@@ -133,6 +133,8 @@
         hdl->priv->valid_g_types[8] = GDA_TYPE_USHORT;
         hdl->priv->valid_g_types[9] = G_TYPE_UCHAR;
 	hdl->priv->valid_g_types[10] = G_TYPE_UINT;
+	hdl->priv->valid_g_types[11] = G_TYPE_ULONG;
+	hdl->priv->valid_g_types[12] = G_TYPE_LONG;
 
 	g_object_set_data (G_OBJECT (hdl), "name", "InternalNumerical");
 	g_object_set_data (G_OBJECT (hdl), "descr", _("Numerical representation"));
@@ -306,6 +308,14 @@
 		value = g_value_init (g_new0 (GValue, 1), G_TYPE_UINT);
 		g_value_set_uint (value, strtoul (str, NULL, 10));
 	}
+	else if (type == G_TYPE_ULONG) {
+		value = g_value_init (g_new0 (GValue, 1), G_TYPE_ULONG);
+		g_value_set_ulong (value, strtoul (str, NULL, 10));
+	}
+	else if (type == G_TYPE_LONG) {
+		value = g_value_init (g_new0 (GValue, 1), G_TYPE_LONG);
+		g_value_set_long (value, strtol (str, NULL, 10));
+	}
 	else
 		g_assert_not_reached ();
 

Modified: trunk/libgda/handlers/gda-handler-type.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-type.c	(original)
+++ trunk/libgda/handlers/gda-handler-type.c	Tue Oct  7 13:08:52 2008
@@ -119,7 +119,7 @@
 	hdl->priv->detailled_descr = _("Gda type handler");
 	hdl->priv->nb_g_types = 1;
 	hdl->priv->valid_g_types = g_new0 (GType, 1);
-	hdl->priv->valid_g_types[0] = G_TYPE_ULONG;
+	hdl->priv->valid_g_types[0] = G_TYPE_GTYPE;
 
 	g_object_set_data (G_OBJECT (hdl), "descr", "InternalType");
 	g_object_set_data (G_OBJECT (hdl), "descr", _("Gda type representation"));
@@ -234,7 +234,7 @@
 			str[i-1] = 0;
 			type = gda_g_type_from_string (str+1);
 			g_free (str);
-			value = g_value_init (g_new0 (GValue, 1), G_TYPE_ULONG);
+			value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
 			g_value_set_ulong (value, type);
 		}
 	}
@@ -255,7 +255,7 @@
 	g_return_val_if_fail (hdl->priv, NULL);
 
 	vtype = gda_g_type_from_string (str);
-	value = g_value_init (g_new0 (GValue, 1), G_TYPE_ULONG);
+	value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
 	g_value_set_ulong (value, vtype);
 
 	return value;

Modified: trunk/libgda/sqlite/gda-sqlite-provider.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-provider.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-provider.c	Tue Oct  7 13:08:52 2008
@@ -1189,8 +1189,9 @@
 	    (type == G_TYPE_CHAR) ||
 	    (type == G_TYPE_UCHAR) ||
 	    (type == G_TYPE_ULONG) ||
+	    (type == G_TYPE_LONG) ||
 	    (type == G_TYPE_UINT) ||
-	    (type == G_TYPE_UINT64)) 
+	    (type == G_TYPE_UINT64))
 		return "integer";
 
 	if (type == GDA_TYPE_BINARY)
@@ -1203,7 +1204,8 @@
 	    (type == G_TYPE_OBJECT) ||
 	    (type == GDA_TYPE_LIST) ||
 	    (type == G_TYPE_STRING) ||
-	    (type == G_TYPE_INVALID))
+	    (type == G_TYPE_INVALID) ||
+	    (type == G_TYPE_GTYPE))
 		return "string";
 
 	if ((type == G_TYPE_DOUBLE) ||

Modified: trunk/providers/mysql/gda-mysql-provider.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-provider.c	(original)
+++ trunk/providers/mysql/gda-mysql-provider.c	Tue Oct  7 13:08:52 2008
@@ -1068,7 +1068,7 @@
 	    (type == G_TYPE_UCHAR) ||
 	    (type == G_TYPE_ULONG) ||
 	    (type == G_TYPE_UINT) ||
-	    (type == G_TYPE_UINT64)) 
+	    (type == G_TYPE_UINT64))
 		return "integer";
 
 	if ((type == GDA_TYPE_BINARY) ||
@@ -1085,7 +1085,8 @@
 	    (type == G_TYPE_STRING) ||
 	    (type == GDA_TYPE_TIME) ||
 	    (type == GDA_TYPE_TIMESTAMP) ||
-	    (type == G_TYPE_INVALID))
+	    (type == G_TYPE_INVALID) ||
+	    (type == G_TYPE_GTYPE))
 		return "string";
 
 	if ((type == G_TYPE_DOUBLE) ||

Modified: trunk/providers/postgres/gda-postgres-provider.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-provider.c	(original)
+++ trunk/providers/postgres/gda-postgres-provider.c	Tue Oct  7 13:08:52 2008
@@ -1566,6 +1566,8 @@
                 return "smallint";
         if (type == G_TYPE_ULONG)
                 return "int8";
+        if (type == G_TYPE_GTYPE)
+                return "varchar";
         if (type == G_TYPE_UINT)
                 return "int4";
         if (type == G_TYPE_INVALID)

Modified: trunk/providers/postgres/gda-postgres-recordset.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-recordset.c	(original)
+++ trunk/providers/postgres/gda-postgres-recordset.c	Tue Oct  7 13:08:52 2008
@@ -606,16 +606,30 @@
 
 	if (type == G_TYPE_BOOLEAN)
 		g_value_set_boolean (value, (*thevalue == 't') ? TRUE : FALSE);
-	else if (type == G_TYPE_STRING)
+	else if (type == G_TYPE_STRING) 
 		g_value_set_string (value, thevalue);
+	else if (type == G_TYPE_INT)
+		g_value_set_int (value, atol (thevalue));
+	else if (type == G_TYPE_DATE) {
+		GDate date;
+		if (!gda_parse_iso8601_date (&date, thevalue)) 
+			g_warning (_("Invalid date '%s' (date format should be YYYY-MM-DD)"), thevalue);
+		else
+			g_value_set_boxed (value, &date);
+	}
+	else if (type == GDA_TYPE_TIME) {
+		GdaTime timegda;
+		if (!gda_parse_iso8601_time (&timegda, thevalue)) 
+			g_warning (_("Invalid time '%s' (time format should be HH:MM:SS[.ms])"), thevalue);
+		else
+			gda_value_set_time (value, &timegda);
+	}
 	else if (type == G_TYPE_INT64)
 		g_value_set_int64 (value, atoll (thevalue));
 	else if (type == G_TYPE_ULONG)
 		g_value_set_ulong (value, atoll (thevalue));
 	else if (type == G_TYPE_LONG)
 		g_value_set_ulong (value, atoll (thevalue));
-	else if (type == G_TYPE_INT)
-		g_value_set_int (value, atol (thevalue));
 	else if (type == GDA_TYPE_SHORT)
 		gda_value_set_short (value, atoi (thevalue));
 	else if (type == G_TYPE_FLOAT) {
@@ -636,13 +650,6 @@
 		gda_value_set_numeric (value, &numeric);
 		g_free (numeric.number);
 	}
-	else if (type == G_TYPE_DATE) {
-		GDate date;
-		if (!gda_parse_iso8601_date (&date, thevalue)) 
-			g_warning (_("Invalid date '%s' (date format should be YYYY-MM-DD)"), thevalue);
-		else
-			g_value_set_boxed (value, &date);
-	}
 	else if (type == GDA_TYPE_GEOMETRIC_POINT) {
 		GdaGeometricPoint point;
 		make_point (&point, thevalue);
@@ -656,13 +663,6 @@
 		else
 			gda_value_set_timestamp (value, &timestamp);
 	}
-	else if (type == GDA_TYPE_TIME) {
-		GdaTime timegda;
-		if (!gda_parse_iso8601_time (&timegda, thevalue)) 
-			g_warning (_("Invalid time '%s' (time format should be HH:MM:SS[.ms])"), thevalue);
-		else
-			gda_value_set_time (value, &timegda);
-	}
 	else if (type == GDA_TYPE_BINARY) {
 		/*
 		 * Requires PQunescapeBytea in libpq (present since 7.3.x)
@@ -689,8 +689,8 @@
 
 		gda_value_take_blob (value, blob);
 	}
-	else if (type == G_TYPE_STRING) 
-		g_value_set_string (value, thevalue);
+	else if (type == G_TYPE_GTYPE)
+		g_value_set_gtype (value, atoul (thevalue));
 	else {
 		g_warning ("Type %s not translated for value '%s' => set as string", g_type_name (type), thevalue);
 		gda_value_reset_with_type (value, G_TYPE_STRING);

Modified: trunk/providers/skel-implementation/capi/gda-capi-provider.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-provider.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-provider.c	Tue Oct  7 13:08:52 2008
@@ -824,7 +824,7 @@
 	    (type == G_TYPE_UCHAR) ||
 	    (type == G_TYPE_ULONG) ||
 	    (type == G_TYPE_UINT) ||
-	    (type == G_TYPE_UINT64)) 
+	    (type == G_TYPE_UINT64))
 		return "integer";
 
 	if ((type == GDA_TYPE_BINARY) ||
@@ -841,7 +841,8 @@
 	    (type == G_TYPE_STRING) ||
 	    (type == GDA_TYPE_TIME) ||
 	    (type == GDA_TYPE_TIMESTAMP) ||
-	    (type == G_TYPE_INVALID))
+	    (type == G_TYPE_INVALID) ||
+	    (type == G_TYPE_GTYPE))
 		return "string";
 
 	if ((type == G_TYPE_DOUBLE) ||

Modified: trunk/tests/meta-store/common.c
==============================================================================
--- trunk/tests/meta-store/common.c	(original)
+++ trunk/tests/meta-store/common.c	Tue Oct  7 13:08:52 2008
@@ -128,13 +128,13 @@
 		GValue *v;
 		gchar *id;
 		
-		holder = gda_holder_new (G_TYPE_ULONG);
-		id = g_strdup_printf ("GDA_TYPE_%d", cnum);
+		holder = gda_holder_new (G_TYPE_GTYPE);
+		id = g_strdup_printf ("G_TYPE_%d", cnum);
 		g_object_set (G_OBJECT (holder), "id", id, NULL);
 		g_free (id);
 		
-		v = gda_value_new (G_TYPE_ULONG);
-		g_value_set_ulong (v, gda_g_type_from_string (va_arg (args, gchar*)));
+		v = gda_value_new (G_TYPE_GTYPE);
+		g_value_set_gtype (v, gda_g_type_from_string (va_arg (args, gchar*)));
 		if (! gda_holder_take_value (holder, v, NULL)) {
 			va_end (args);
 			g_object_unref (holder);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]