Re: [gnome-db] GnomeDbForm
- From: Laurent Sansonetti <laurent datarescue be>
- To: Rodrigo Moya <rodrigo gnome-db org>
- Cc: Paisa Seeluangsawat <paisa unt edu>, GDA <gnome-db-list gnome org>
- Subject: Re: [gnome-db] GnomeDbForm
- Date: Thu, 06 Nov 2003 00:08:58 +0000
On Mon, 2003-11-03 at 22:08, Rodrigo Moya wrote:
> > > Currently and AFAIK, the following classes are missing GLib types:
> > >
> > > - GdaCommand;
> > > - GdaFieldAttributes;
> > > - GdaParameter;
> > > - GdaParameterList;
> > > - GdaQuarkList;
> > > - GdaRow;
> > > - GdaValue.
> > >
> >
> > Any comments on this?
> >
> > I would really like to see GLib types for these classes, so I can work
> > on this, if it's approuved ;)
> >
> oh, yes, of course, it's approved, I was just waiting to have a bit of
> time to do it, so if you want to do it, please go ahead.
OK, here is a first patch, which should work.
Unfortunately my Ruby/Libgda test suite is currently broken, so I
couldn't test the patch deeper. But I did small tests and everything
ran fine.
With this patch, I removed all gboxed code from the Ruby binding. So
cool ;-)
Cheers,
--
Laurent
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.584
diff -u -r1.584 ChangeLog
--- ChangeLog 3 Nov 2003 09:47:09 -0000 1.584
+++ ChangeLog 5 Nov 2003 21:06:40 -0000
@@ -1,3 +1,15 @@
+2003-11-05 Laurent Sansonetti <laurent datarescue be>
+
+ * libgda/gda-command.[ch] (gda_command_get_type, gda_command_copy):
+ * libgda/gda-field.[ch] (gda_field_attributes_get_type):
+ * libgda/gda-parameter.[ch] (gda_parameter_get_type, gda_parameter_copy,
+ gda_parameter_list_get_type, gda_parameter_list_copy):
+ * libgda/gda-quark-list.[ch] (gda_quark_list_get_type,
+ gda_quark_list_copy):
+ * libgda/gda-row.[ch] (gda_row_get_type, gda_row_copy):
+ * libgda/gda-value.[ch] (gda_value_get_gtype):
+ Added missing *_get_type and *_copy functions.
+
2003-11-03 Jonathan Blandford <jrb redhat com>
* libsql/lexer.l: #undef L_SET, since it might be defined when
@@ -5,7 +17,7 @@
2003-10-27 Laurent Sansonetti <laurent datarescue be>
- * libgda/gda-config.[c.h] (gda_config_get_provider_model):
+ * libgda/gda-config.[ch] (gda_config_get_provider_model):
New function.
2003-10-26 Laurent Sansonetti <laurent datarescue be>
Index: libgda/gda-command.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-command.c,v
retrieving revision 1.8
diff -u -r1.8 gda-command.c
--- libgda/gda-command.c 18 Oct 2003 23:03:52 -0000 1.8
+++ libgda/gda-command.c 5 Nov 2003 21:06:40 -0000
@@ -25,6 +25,18 @@
#include <glib/gstrfuncs.h>
#include <libgda/gda-command.h>
+GType
+gda_command_get_type (void)
+{
+ static GType our_type;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaCommand",
+ (GBoxedCopyFunc) gda_command_copy,
+ (GBoxedFreeFunc) gda_command_free);
+ return our_type;
+}
+
/**
* gda_command_new
* @text: the text of the command.
@@ -78,6 +90,26 @@
}
/**
+ * gda_command_copy
+ * @cmd: command to get a copy from.
+ *
+ * Creates a new #GdaCommand from an existing one.
+ *
+ * Returns: a newly allocated #GdaCommand with a copy of the data in @cmd.
+ */
+GdaCommand *
+gda_command_copy (GdaCommand *cmd)
+{
+ g_return_val_if_fail (cmd != NULL, NULL);
+ GdaCommand *new_cmd = gda_command_new (gda_command_get_text (cmd),
+ gda_command_get_command_type (cmd),
+ gda_command_get_options (cmd));
+ gda_command_set_transaction (new_cmd,
+ gda_command_get_transaction (cmd));
+ return new_cmd;
+}
+
+/**
* gda_command_get_text
* @cmd: a #GdaCommand.
*
@@ -218,3 +250,4 @@
else
cmd->xaction = NULL;
}
+
Index: libgda/gda-field.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-field.c,v
retrieving revision 1.11
diff -u -r1.11 gda-field.c
--- libgda/gda-field.c 18 Oct 2003 23:03:52 -0000 1.11
+++ libgda/gda-field.c 5 Nov 2003 21:06:42 -0000
@@ -25,6 +25,18 @@
#include <glib/gstrfuncs.h>
#include <libgda/gda-field.h>
+GType
+gda_field_attributes_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaFieldAttributes",
+ (GBoxedCopyFunc) gda_field_attributes_copy,
+ (GBoxedFreeFunc) gda_field_attributes_free);
+ return our_type;
+}
+
/**
* gda_field_attributes_new
*
@@ -484,3 +496,4 @@
g_free (fa->default_value);
fa->default_value = gda_value_copy (default_value);
}
+
Index: libgda/gda-parameter.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-parameter.c,v
retrieving revision 1.24
diff -u -r1.24 gda-parameter.c
--- libgda/gda-parameter.c 18 Oct 2003 23:03:52 -0000 1.24
+++ libgda/gda-parameter.c 5 Nov 2003 21:06:43 -0000
@@ -30,6 +30,30 @@
GHashTable *hash;
};
+GType
+gda_parameter_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaParameter",
+ (GBoxedCopyFunc) gda_parameter_copy,
+ (GBoxedFreeFunc) gda_parameter_free);
+ return our_type;
+}
+
+GType
+gda_parameter_list_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaParameterList",
+ (GBoxedCopyFunc) gda_parameter_list_copy,
+ (GBoxedFreeFunc) gda_parameter_list_free);
+ return our_type;
+}
+
/*
* Private functions
*/
@@ -177,6 +201,22 @@
}
/**
+ * gda_parameter_copy
+ * @param: parameter to get a copy from.
+ *
+ * Creates a new #GdaParameter from an existing one.
+ *
+ * Returns: a newly allocated #GdaParameter with a copy of the data in @param.
+ */
+GdaParameter *
+gda_parameter_copy (GdaParameter *param)
+{
+ g_return_val_if_fail (param != NULL, NULL);
+ return gda_parameter_new_from_value (gda_parameter_get_name (param),
+ gda_parameter_get_value (param));
+}
+
+/**
* gda_parameter_get_name
* @param: a #GdaParameter object.
*
@@ -266,6 +306,35 @@
g_hash_table_destroy (plist->hash);
g_free (plist);
+}
+
+/**
+ * gda_parameter_list_copy
+ * @plist: parameter list to get a copy from.
+ *
+ * Creates a new #GdaParameterList from an existing one.
+ *
+ * Returns: a newly allocated #GdaParameterList with a copy of the data in @plist.
+ */
+GdaParameterList *
+gda_parameter_list_copy (GdaParameterList *plist)
+{
+ GdaParameterList *new_list;
+ GList *node, *names;
+
+ g_return_val_if_fail (plist != NULL, NULL);
+
+ new_list = gda_parameter_list_new ();
+ names = gda_parameter_list_get_names (plist);
+ for (node = g_list_first (names);
+ node != NULL;
+ node = g_list_next (node)) {
+ GdaParameter *param = gda_parameter_list_find (plist, (const gchar *)node->data);
+ if (param != NULL) /* normally should always be non-null... */
+ gda_parameter_list_add_parameter (new_list, param);
+ }
+ g_list_free (names);
+ return new_list;
}
/**
Index: libgda/gda-quark-list.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-quark-list.c,v
retrieving revision 1.8
diff -u -r1.8 gda-quark-list.c
--- libgda/gda-quark-list.c 18 Oct 2003 23:03:52 -0000 1.8
+++ libgda/gda-quark-list.c 5 Nov 2003 21:06:43 -0000
@@ -30,6 +30,17 @@
GHashTable *hash_table;
};
+GType gda_quark_list_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaQuarkList",
+ (GBoxedCopyFunc) gda_quark_list_copy,
+ (GBoxedFreeFunc) gda_quark_list_free);
+ return our_type;
+}
+
/*
* Private functions
*/
@@ -41,6 +52,14 @@
g_free (value);
}
+static void
+copy_hash_pair (gpointer key, gpointer value, gpointer user_data)
+{
+ g_hash_table_insert ((GHashTable *) user_data,
+ g_strdup ((const char *) key),
+ g_strdup ((const char *) value));
+}
+
/**
* gda_quark_list_new
*
@@ -112,6 +131,29 @@
g_hash_table_destroy (qlist->hash_table);
g_free (qlist);
+}
+
+
+/**
+ * gda_quark_list_copy
+ * @qlist: quark_list to get a copy from.
+ *
+ * Creates a new #GdaQuarkList from an existing one.
+ *
+ * Returns: a newly allocated #GdaQuarkList with a copy of the data in @qlist.
+ */
+GdaQuarkList *
+gda_quark_list_copy (GdaQuarkList *qlist)
+{
+ GdaQuarkList *new_qlist;
+
+ g_return_val_if_fail (qlist != NULL, NULL);
+
+ new_qlist = gda_quark_list_new ();
+ g_hash_table_foreach (qlist->hash_table,
+ copy_hash_pair,
+ new_qlist->hash_table);
+ return new_qlist;
}
/**
Index: libgda/gda-row.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-row.c,v
retrieving revision 1.35
diff -u -r1.35 gda-row.c
--- libgda/gda-row.c 18 Oct 2003 23:03:52 -0000 1.35
+++ libgda/gda-row.c 5 Nov 2003 21:06:44 -0000
@@ -32,6 +32,17 @@
gint nfields;
};
+GType gda_row_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaRow",
+ (GBoxedCopyFunc) gda_row_copy,
+ (GBoxedFreeFunc) gda_row_free);
+ return our_type;
+}
+
/**
* gda_row_new
* @model: the #GdaDataModel this row belongs to.
@@ -105,6 +116,38 @@
gda_value_set_null (&row->fields [i]);
g_free (row->fields);
g_free (row);
+}
+
+/**
+ * gda_row_copy
+ * @row: quark_list to get a copy from.
+ *
+ * Creates a new #GdaRow from an existing one.
+ *
+ * Returns: a newly allocated #GdaRow with a copy of the data in @row.
+ */
+GdaRow *
+gda_row_copy (GdaRow *row)
+{
+ GdaRow *new_row;
+ gint i;
+
+ g_return_val_if_fail (row != NULL, NULL);
+
+ new_row = gda_row_new (row->model, row->nfields);
+ new_row->number = row->number;
+ new_row->id = g_strdup (row->id);
+
+ for (i = 0; i < row->nfields; i++) {
+ GdaValue *value = &row->fields[i];
+ if (value)
+ gda_value_set_from_value (gda_row_get_value (new_row, i),
+ gda_value_copy (value));
+ else
+ gda_value_set_null (gda_row_get_value (new_row, i));
+ }
+
+ return new_row;
}
/**
Index: libgda/gda-value.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-value.c,v
retrieving revision 1.58
diff -u -r1.58 gda-value.c
--- libgda/gda-value.c 18 Oct 2003 23:03:52 -0000 1.58
+++ libgda/gda-value.c 5 Nov 2003 21:06:47 -0000
@@ -36,6 +36,18 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
+GType
+gda_value_get_gtype (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GdaValue",
+ (GBoxedCopyFunc) gda_value_copy,
+ (GBoxedFreeFunc) gda_value_free);
+ return our_type;
+}
+
/*
* Private functions
*/
Index: libgda/gda-command.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-command.h,v
retrieving revision 1.10
diff -u -r1.10 gda-command.h
--- libgda/gda-command.h 23 Aug 2002 11:37:00 -0000 1.10
+++ libgda/gda-command.h 5 Nov 2003 21:06:48 -0000
@@ -53,9 +53,13 @@
GdaTransaction *xaction;
} GdaCommand;
+#define GDA_TYPE_COMMAND (gda_command_get_type ())
+
+GType gda_command_get_type (void);
GdaCommand *gda_command_new (const gchar *text, GdaCommandType type,
GdaCommandOptions options);
void gda_command_free (GdaCommand *cmd);
+GdaCommand *gda_command_copy (GdaCommand *cmd);
const gchar *gda_command_get_text (GdaCommand *cmd);
void gda_command_set_text (GdaCommand *cmd, const gchar *text);
Index: libgda/gda-field.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-field.h,v
retrieving revision 1.9
diff -u -r1.9 gda-field.h
--- libgda/gda-field.h 13 Oct 2003 03:02:01 -0000 1.9
+++ libgda/gda-field.h 5 Nov 2003 21:06:48 -0000
@@ -54,6 +54,9 @@
GdaFieldAttributes *attributes;
} GdaField;
+#define GDA_TYPE_FIELD_ATTRIBUTES (gda_field_attributes_get_type ())
+
+GType gda_field_attributes_get_type (void);
GdaFieldAttributes *gda_field_attributes_new (void);
GdaFieldAttributes *gda_field_attributes_copy (GdaFieldAttributes *fa);
void gda_field_attributes_free (GdaFieldAttributes *fa);
Index: libgda/gda-parameter.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-parameter.h,v
retrieving revision 1.15
diff -u -r1.15 gda-parameter.h
--- libgda/gda-parameter.h 26 May 2003 10:53:23 -0000 1.15
+++ libgda/gda-parameter.h 5 Nov 2003 21:06:48 -0000
@@ -33,11 +33,15 @@
GdaValue *value;
} GdaParameter;
+#define GDA_TYPE_PARAMETER (gda_parameter_get_type())
+
+GType gda_parameter_get_type (void);
GdaParameter *gda_parameter_new_from_value (const gchar *name, GdaValue *value);
GdaParameter *gda_parameter_new_boolean (const gchar *name, gboolean value);
GdaParameter *gda_parameter_new_double (const gchar *name, gdouble value);
GdaParameter *gda_parameter_new_gobject (const gchar *name, const GObject *value);
GdaParameter *gda_parameter_new_string (const gchar *name, const gchar *value);
+GdaParameter *gda_parameter_copy (GdaParameter *param);
void gda_parameter_free (GdaParameter *param);
const gchar *gda_parameter_get_name (GdaParameter *param);
void gda_parameter_set_name (GdaParameter *param, const gchar *name);
@@ -46,8 +50,12 @@
typedef struct _GdaParameterList GdaParameterList;
+#define GDA_TYPE_PARAMETER_LIST (gda_parameter_list_get_type())
+
+GType gda_parameter_list_get_type (void);
GdaParameterList *gda_parameter_list_new (void);
void gda_parameter_list_free (GdaParameterList *plist);
+GdaParameterList *gda_parameter_list_copy (GdaParameterList *plist);
void gda_parameter_list_add_parameter (GdaParameterList *plist,
GdaParameter *param);
GList *gda_parameter_list_get_names (GdaParameterList *plist);
Index: libgda/gda-quark-list.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-quark-list.h,v
retrieving revision 1.6
diff -u -r1.6 gda-quark-list.h
--- libgda/gda-quark-list.h 8 Oct 2003 20:49:03 -0000 1.6
+++ libgda/gda-quark-list.h 5 Nov 2003 21:06:49 -0000
@@ -25,13 +25,18 @@
#include <glib/gmacros.h>
#include <glib/gtypes.h>
+#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _GdaQuarkList GdaQuarkList;
+#define GDA_TYPE_QUARK_LIST (gda_quark_list_get_type())
+
+GType gda_quark_list_get_type (void);
GdaQuarkList *gda_quark_list_new (void);
GdaQuarkList *gda_quark_list_new_from_string (const gchar *string);
+GdaQuarkList *gda_quark_list_copy (GdaQuarkList *qlist);
void gda_quark_list_free (GdaQuarkList *qlist);
void gda_quark_list_add_from_string (GdaQuarkList *qlist,
Index: libgda/gda-row.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-row.h,v
retrieving revision 1.26
diff -u -r1.26 gda-row.h
--- libgda/gda-row.h 12 May 2003 22:58:05 -0000 1.26
+++ libgda/gda-row.h 5 Nov 2003 21:06:49 -0000
@@ -31,16 +31,20 @@
typedef struct _GdaDataModel GdaDataModel;
typedef struct _GdaRow GdaRow;
-GdaRow *gda_row_new (GdaDataModel *model, gint count);
-GdaRow *gda_row_new_from_list (GdaDataModel *model, const GList *values);
-void gda_row_free (GdaRow *row);
-GdaDataModel *gda_row_get_model (GdaRow *row);
-gint gda_row_get_number (GdaRow *row);
-void gda_row_set_number (GdaRow *row, gint number);
-const gchar *gda_row_get_id (GdaRow *row);
-void gda_row_set_id (GdaRow *row, const gchar *id);
-G_CONST_RETURN GdaValue *gda_row_get_value (GdaRow *row, gint num);
-gint gda_row_get_length (GdaRow *row);
+#define GDA_TYPE_ROW (gda_row_get_type())
+
+GType gda_row_get_type (void);
+GdaRow *gda_row_new (GdaDataModel *model, gint count);
+GdaRow *gda_row_new_from_list (GdaDataModel *model, const GList *values);
+GdaRow *gda_row_copy (GdaRow *row);
+void gda_row_free (GdaRow *row);
+GdaDataModel *gda_row_get_model (GdaRow *row);
+gint gda_row_get_number (GdaRow *row);
+void gda_row_set_number (GdaRow *row, gint number);
+const gchar *gda_row_get_id (GdaRow *row);
+void gda_row_set_id (GdaRow *row, const gchar *id);
+G_CONST_RETURN GdaValue *gda_row_get_value (GdaRow *row, gint num);
+gint gda_row_get_length (GdaRow *row);
G_END_DECLS
Index: libgda/gda-value.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-value.h,v
retrieving revision 1.33
diff -u -r1.33 gda-value.h
--- libgda/gda-value.h 15 Aug 2003 19:59:54 -0000 1.33
+++ libgda/gda-value.h 5 Nov 2003 21:06:49 -0000
@@ -135,6 +135,10 @@
glong binary_length;
} GdaValue;
+/* Note: gda_value_get_type is already defined */
+#define GDA_TYPE_VALUE (gda_value_get_gtype())
+
+GType gda_value_get_gtype (void);
GdaValue *gda_value_new_null (void);
GdaValue *gda_value_new_bigint (gint64 val);
GdaValue *gda_value_new_biguint(guint64 val);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]