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 634838 - giscanner does not handle gintptr and guintptr types.
giscanner does not handle gintptr and guintptr types.
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-11-14 18:34 UTC by Pavel Holejsovsky
Modified: 2015-02-07 17:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Introduce gintptr and guintptr aliases. (789 bytes, patch)
2010-11-14 18:35 UTC, Pavel Holejsovsky
reviewed Details | Review
Teaches giscanner and girwriter to handle g[u]intptr types. (1.26 KB, patch)
2010-12-07 09:45 UTC, Pavel Holejsovsky
reviewed Details | Review
Adds support for gintptr and guintptr types. (1.25 KB, patch)
2010-12-08 20:44 UTC, Pavel Holejsovsky
none Details | Review
Add support for g[u]intptr into scanner and girparser (3.41 KB, patch)
2010-12-09 10:20 UTC, Pavel Holejsovsky
none Details | Review
Adds support for g[u]intptr and makes g[s]size fundamental types. (4.68 KB, patch)
2010-12-09 10:27 UTC, Pavel Holejsovsky
none Details | Review
Add support for g[u]intptr into scanner and girparser (6.62 KB, patch)
2010-12-14 15:34 UTC, Pavel Holejsovsky
accepted-commit_now Details | Review

Description Pavel Holejsovsky 2010-11-14 18:34:22 UTC
Attached patch fixes that.  Note that it will provide incorrect results on Win64 (and other platforms where sizeof(long) < sizeof(void*)), but it is already incorrect in case of gsize and gssize.
Comment 1 Pavel Holejsovsky 2010-11-14 18:35:15 UTC
Created attachment 174449 [details] [review]
Introduce gintptr and guintptr aliases.
Comment 2 Colin Walters 2010-12-06 18:06:14 UTC
Review of attachment 174449 [details] [review]:

Hmm...actually, can you try a patch to just make size_t and both of these fundamental instead of aliases?  girepository/girparser.c already handles gsize/gssize.  You'd need to add gintptr/guintptr there too.  I forget honestly why I didn't do that in the first place.

The trend I've been going towards is that the typelib is alias-free; in other words, if some C API uses gssize_t, from the typelib you get e.g. GI_TYPE_TAG_UINT32 if the machine is 32 bit.
Comment 3 Pavel Holejsovsky 2010-12-07 09:45:16 UTC
Created attachment 175992 [details] [review]
Teaches giscanner and girwriter to handle g[u]intptr types.
Comment 4 Pavel Holejsovsky 2010-12-07 09:46:17 UTC
Thanks for the review, makes sense.  Is new patch (in comment #3) OK?
Comment 5 Colin Walters 2010-12-07 14:42:41 UTC
Review of attachment 175992 [details] [review]:

::: giscanner/ast.py
@@ +256,3 @@
 type_names['gssize'] = TYPE_LONG
+type_names['gintptr'] = TYPE_LONG
+type_names['guintptr'] = TYPE_ULONG

Hm, this wasn't what I meant actually.  You need to delete all 4 lines here so that it makes it out to the .gir.
Comment 6 Pavel Holejsovsky 2010-12-07 15:44:51 UTC
(In reply to comment #5)
> Review of attachment 175992 [details] [review]:
> 
> ::: giscanner/ast.py
> @@ +256,3 @@
>  type_names['gssize'] = TYPE_LONG
> +type_names['gintptr'] = TYPE_LONG
> +type_names['guintptr'] = TYPE_ULONG
> 
> Hm, this wasn't what I meant actually.  You need to delete all 4 lines here so
> that it makes it out to the .gir.

I will try later (out of time now), but if I remember correctly, the .gir produced without those 2 lines had functions with gintptr arguments marked as introspectable="0".  So something more has to happen than just deleting these 4 lines.  Will investigate...
Comment 7 Pavel Holejsovsky 2010-12-08 20:44:15 UTC
Created attachment 176096 [details] [review]
Adds support for gintptr and guintptr types.

Small update, fixes wrong signed/unsigned flagging in girwriter declarations.
Comment 8 Pavel Holejsovsky 2010-12-08 20:52:10 UTC
(In reply to comment #5)
> Review of attachment 175992 [details] [review] [details]:
> 
> ::: giscanner/ast.py
> @@ +256,3 @@
>  type_names['gssize'] = TYPE_LONG
> +type_names['gintptr'] = TYPE_LONG
> +type_names['guintptr'] = TYPE_ULONG
> 
> Hm, this wasn't what I meant actually.  You need to delete all 4 lines here so
> that it makes it out to the .gir.

TBH, I'm not sure what you mean.  Just removing those 4 lines yields scanner which produces
<type c:type="gsize"/>
types and marks methods with such arguments as introspectable="0".  On the other hand, leaving ast.py patch as is results in:
<type name="gulong" c:type="gsize"/>
and going to typelib and back through g-ir-generate (on linux x86-64) there is
<type name="guint64"/>
which looks to me like the desired behavior.
Comment 9 Pavel Holejsovsky 2010-12-09 10:20:18 UTC
Created attachment 176121 [details] [review]
Add support for g[u]intptr into scanner and girparser

Hopefully this time I understood better what you mean.  This patch makes g[s]size and g[u]intptr fundamental, so that in scanned gir they appear like this:
<type name="gsize" c:type="gsize"/>

while in from-typelib-generated gir there is 
<type name="guint64"/>

instead.

I also had to replace g_str_has_prefix() with plain strcmp(), because g_str_had_prefix() incorrectly chose 'gint' for 'gintptr' type (because 'gint' is prefix of 'gintptr').
Comment 10 Pavel Holejsovsky 2010-12-09 10:27:08 UTC
Created attachment 176123 [details] [review]
Adds support for g[u]intptr and makes g[s]size fundamental types.

The same patch as previous one + fix of the tests.
Comment 11 Pavel Holejsovsky 2010-12-14 15:34:26 UTC
Created attachment 176410 [details] [review]
Add support for g[u]intptr into scanner and girparser

The same as previous patch, but fixes tests (hopefully all of them) in the testsuite.
Comment 12 Colin Walters 2011-01-13 15:08:55 UTC
Review of attachment 176410 [details] [review]:

Looks right.
Comment 13 André Klapper 2015-02-07 17:03:36 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]