GDK_PIXMAP_HBITMAP macro



While porting gtk-1.3.15 to Win32, I've run across a curious macro.

(taken from various sources, trying to understand how this macro is built)
typedef unsigned long   gulong;
typedef gulong          GType;
GType gdk_drawable_impl_win32_get_type (void);
#define GDK_TYPE_DRAWABLE_IMPL_WIN32  (gdk_drawable_impl_win32_get_type ())
#define GDK_PIXMAP_HBITMAP(pixmap)
(GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)pixmap)->impl)->handle)


and an offending line of code (one of many):
gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);

So, what is happening here is:
we get the unsigned long return value from
gdk_drawable_impl_win32_get_type(). That function registers a static struct
that includes some initialization routines. The return value from the init
is what is returned from gdk_drawable_impl_win32_get_type().

The macro translates to something like:
gdk_win32_handle_table_insert (((gdk_drawable_impl_win32_get_type
())(((GdkPixmapObject *)pixmap)->impl)->handle), pixmap);

which is really bizarre. Casting the pixmap handle to a return value from a
function? The return is a value, not a type used for casting.

There is probably a lot more going on here than I am competent to
understand. Could someone elaborate on this or verify that it is in fact a
bug in the win32 code?





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