GNOME Bugzilla – Bug 634838
giscanner does not handle gintptr and guintptr types.
Last modified: 2015-02-07 17:03:36 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.
Created attachment 174449 [details] [review] Introduce gintptr and guintptr aliases.
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.
Created attachment 175992 [details] [review] Teaches giscanner and girwriter to handle g[u]intptr types.
Thanks for the review, makes sense. Is new patch (in comment #3) OK?
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.
(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...
Created attachment 176096 [details] [review] Adds support for gintptr and guintptr types. Small update, fixes wrong signed/unsigned flagging in girwriter declarations.
(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.
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').
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.
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.
Review of attachment 176410 [details] [review]: Looks right.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]