After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 643620 - Use basic types for XID in xlib-2.0.gir
Use basic types for XID in xlib-2.0.gir
Status: RESOLVED OBSOLETE
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-03-01 21:36 UTC by Giovanni Campagna
Modified: 2018-01-24 19:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
xlib: expose useful types for XIDs (2.82 KB, patch)
2011-03-01 21:37 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2011-03-01 21:36:24 UTC
Currently all XLib types are exposed as records, even those that are just uint32_t. Fixing this manually exposes a lot of GdkX11 and ClutterX11 API to language bindings.
Comment 1 Giovanni Campagna 2011-03-01 21:37:11 UTC
Created attachment 182213 [details] [review]
xlib: expose useful types for XIDs

XIDs are just guint32 in the end, there no need to treat them as
boxed. This way instead they're immediately supported in bindings,
making stuff like GdkX11 and ClutterX11 much more useful.
Comment 2 Johan (not receiving bugmail) Dahlin 2011-08-26 10:03:49 UTC
Review of attachment 182213 [details] [review]:

This looks good to me, shouldn't break anything afaict.
Comment 3 Giovanni Campagna 2011-08-26 12:00:57 UTC
Part of the bug was already fixed by someone else, except that it
used gulong instead guint32. I fixed that.
Comment 4 Pavel Holejsovsky 2011-08-26 13:27:53 UTC
Sorry, but IMO the patch is broken.

1) XID is really 64b on 64b system, see snippet from X.h:

Xdef.h, line 61

#ifndef _XTYPEDEF_XID
#  define _XTYPEDEF_XID
#  ifndef _XSERVER64
typedef unsigned long XID;
#  else
typedef CARD32 XID;
#  endif
#endif

X.h, line 58

/*
 * _XSERVER64 must ONLY be defined when compiling X server sources on
 * systems where unsigned long is not 32 bits, must NOT be used in
 * client or library code.
 */
#ifndef _XSERVER64
#  ifndef _XTYPEDEF_XID
#    define _XTYPEDEF_XID
typedef unsigned long XID;
#  endif
#  ifndef _XTYPEDEF_MASK

So for non-XServer code (which we are interested in), XID is always unsigned long. This can be proven by running following little program:

#include <stdio.h>
#include <X11/X.h>

int main() { printf("%d\n", sizeof(XID); return 0; }

This program prints 8 on my F15 x86_64 box

2) There is some bug in scanner's handling of typedefs, scanner somehow fails to follow more than one level of typedef somowhere.  Your patch uses two-level typedef (XID->guint32 and Atom/Colormap/whatever->XID), and it results in following warnings while building gtk+/gdk:

/home/pavel/src/gnome/gtk+/gdk/x11/gdkproperty-x11.c:218: Warning: GdkX11: gdk_x11_atom_to_xatom_for_display: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkproperty-x11.c:461: Warning: GdkX11: gdk_x11_get_xatom_by_name_for_display: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkproperty-x11.c:307: Warning: GdkX11: gdk_x11_atom_to_xatom: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkproperty-x11.c:482: Warning: GdkX11: gdk_x11_get_xatom_by_name: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkmain-x11.c:450: Warning: GdkX11: gdk_x11_get_default_root_xwindow: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkcursor-x11.c:309: Warning: GdkX11: gdk_x11_cursor_get_xcursor: return value: Missing (transfer) annotation
/home/pavel/src/gnome/gtk+/gdk/x11/gdkwindow-x11.c:4747: Warning: GdkX11: gdk_x11_window_get_xid: return value: Missing (transfer) annotation

and the methods metnioned in the warnings are really not introspected.

Sure, it would be nice to fix scanner's bug, but I believe that this patch should be backed out in the meantime.
Comment 5 Giovanni Campagna 2011-08-26 14:48:38 UTC
Ok, I misread the header file. Patch reverted, sorry for the noise.
Comment 6 André Klapper 2015-02-07 17:17:05 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]