Re: [gnome-db] New Versions of gda-value.c and gda-value.h
- From: "Vivien Malerba" <vmalerba gmail com>
- To: "Daniel Espinosa" <esodan gmail com>
- Cc: gnome-db-list gnome org
- Subject: Re: [gnome-db] New Versions of gda-value.c and gda-value.h
- Date: Wed, 5 Apr 2006 11:26:00 +0200
On 4/4/06, Daniel Espinosa <esodan gmail com> wrote:
>
> Attached you'll find the modifications in the gda-value.c and gda-value.h,
> is a completly rewrite of the old ones, define the macros for use in the
> GType system.
>
> The code use when possible, the GValue API and register the transform
> functions to convert, for example, from string to Gda type and viceversa; as
> recommended I delete the GdaDate for GDate and not used types (like
> GdaMoney). Most of them, can be added as a derived one from the GType
> existing to manage the conversion correctly.
>
> Please pay attention about I don't define functions to transform the GType
> standar types, like BOOLE and INT, I start in the point that it is exist
> already in the GLib, but to define a new one can create the respective
> functions and register them. The problem is when to register, becouse the
> GType system is initiated by gda_init, and then is there when the new
> transformation functions must be done (before the use of GDA lib API).
There should not be any problem with that because transform functions
are registered the first time each GDA specific type is declared. For
instance the type declaration for timestamp should be like:
GType gda_timestamp_get_type (void) G_GNUC_CONST;
GType
gda_timestamp_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0)) {
type = g_boxed_type_register_static ("GdaTimestamp",
(GBoxedCopyFunc) gda_timestamp_copy,
(GBoxedFreeFunc) gda_timestamp_free);
g_value_register_transform_func(G_TYPE_STRING,
type,
timestamp_to_string);
g_value_register_transform_func(type,
G_TYPE_STRING,
string_to_timestamp);
}
return type;
}
>
> I haven't time to test with the copiler, but to write the core; if it is
> aprobed, I begin to test the GLib standar transformations from the existing
> GType's to G_VALUE_STRING, to validate the result; if it is not acurate as
> the GDA needs, I can create the *_to_string functions to register using
> g_value_register_transform_func,
Great.
>
Just a few remarks:
-> rename TIMEZONE_INVALID to GDA_TIMEZONE_INVALID
-> forget about the gda_value_type_transformable() and
gda_value_transform() functions and use g_value_transform()
-> maybe it would be better to remove the GDA_VALUE_HOLDS_* macros as
they are not really usefull
-> correct the *_get_type() functions as mentionned above for the time stamp
I hope we don't forget anything (anyway if this is the case it will
come up sooner or later!)
Could you also try to give hints about how to migrate the libgda,
libgnomedb, etc code which uses the current version of the GdaValue
API, if possible using regexp replacements? This will greatly help
porting the code.
Thanks,
Vivien
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]