Re: GType <=> gpointer



On Tue, 3 Feb 2004, muppet wrote:

> 	type = (GType) GPOINTER_TO_UINT
> 			(g_hash_table_lookup (types_by_package, package));

using GPOINTER_TO_UINT() or GUINT_TO_POINTER() is wrong for GType.

> is it more correct to do
>
> 	type = (GType) pointer

yes, use (GType) and (gpointer) directly to cast GTypes along.

> than to use the GPOINTER_TO_UINT macro?  should there be a
> GPOINTER_TO_GTYPE/GTYPE_TO_GPOINTER pair?

> interestingly, the GPOINTER_TO_UINT casts were necessary to get
> gtk2-perl working correctly on x86_64, and seem to have no ill effect
> on mips.

unfortunately, you'll only see the ill effects on sizeof(GType)>sizeof(int)
platforms.

> this also seems to imply that a G_TYPE_UINT column in a TreeModel is
> not sufficient to hold GTypes, nor would G_TYPE_ULONG always suffice.

correct, which is basically why there's a bug in bugzilla about
someone needing to write a G_TYPE_GTYPE.

>
> --
> muppet <scott at asofyet dot org>
>

---
ciaoTJ




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