Re: [gnome-db] Please, tell me any thing about GdaValue & GValue work



On 6/24/05, Daniel Espinosa <esodan gmail com> wrote:
> A type G_VALUE_TYPE_NULL  and G_VALUE_TYPE_UNKNOWN, correspondig with
> the G_TYPE_NONE and G_TYPE_INVALID respectibaly, are an uninstantable
> types, and correspond to an unset (uninitialiced) GValue; but when you
> try G_VALUE_TYPE(value) and the is unset value, it returns
> G_TYPE_NONE.
> 
> Then in the function gda_value_get_type could return
> GDA_VALUE_TYPE_NULL when the value is uninitialized or resently
> created with value = g_new0(GValue,1)

Good idea.

> 
> I don't know how is used the GDA_VALUE_TYPE_UNKNOWN in GDA, but in the
> case of GValue you never have an unknown type stored, becouse you
> can't initiate with this type. If you use gda_value_new_null it MUST
> return an uninitaliced GValue.

AFAIK GDA_VALUE_TYPE_UNKNOWN is used only to report errors (with the
g_return_val_if_fail() macro), so it's never meant to be used to store
a value.

> 
> The is necesary to delete the line: g_value_init(value,
> G_VALUE_TYPE_NULL) to have:
> 
>         GdaValue *value;
>         value = g_new0 (GdaValue, 1);
>         value->value = g_new0(GValue, 1);
>         return value;
> 
> What is your opinion?
> 

Ok, I'll test it soon.

Another question (forgive me if it has already been asked, but I'm
lazy to search back in the archives): why did you have to create
GdaValue as a
typedef struct {
        GValue *value;
        glong binary_length;
} GdaValue;

and not something like
typedef struct {
        GValue value;
        glong binary_length;
} GdaValue;

note the difference is that in the second form, GdaValue is a GValue
directly which simplifies things greatly?

Thanks,

Vivien



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