GNOME Bugzilla – Bug 560241
Out-arguments should not be marked as being pointers in all cases
Last modified: 2015-02-07 16:54:38 UTC
I think when an out (or in-out) argument has a non-pointer basetype, it should not be marked as a pointer in the typelib, as the pointerness is already implied by it being an out argument, and the "perceived" type is not a pointer. As an example, look at "void gtk_init(int *argc, char ***argv)". Here, "argc" should not be marked as pointer (as it is already marked as an out-argument, which should effectively strip away one level of pointer-indirection).
Created attachment 122615 [details] [review] Don't mark out arguments unconditionally as pointers (against SVN r919) This should fix the issue. As this change does only show up in the typelib and in neither .gir nor .tgir, I could not write a test case.
I guess we have to really sit down and decide what the "point" so to speak of the is_pointer flag is. Right now gjs doesn't call is_pointer anywhere, JGIR has this code: } else if (!type.isPointer() || (tag.equals(TypeTag.UTF8) || tag.equals(TypeTag.FILENAME))) { return toTypeBase(tag); but it could be easily replaced with just checking if the tag < TypeTAG.UTF8. What do you plan to use the is_pointer flag for?
In other words I think we could get rid of g_type_info_is_pointer and instead just have g_type_tag_is_reference (tag) { return tag < GI_TYPE_TAG_UTF8 }. Hm, except for gpointer (admittedly a big exception). What if we also added GI_TYPE_TAG_ANY ?
Basically this would make the GIR and the typelib equivalent instead of having the compiler also parse c:types. I'd like to keep most intelligence in the scanner where we can (so if after discussion there is still a need for is_pointer we could write it in the GIR).
I've just looked over the sbank source code, and barring any misses, I don't currently use the pointer flag except in one place, similiar to what's in JGIR, and I guess it could be similiarly rewritten. However, look at http://bugzilla.gnome.org/show_bug.cgi?id=559601#c4; there, having the is-pointer flag in GIR would help.
For that usage, I propose adding g_field_info_is_reference.
Ok, let's apply this for now; the work to remove is_pointer is in http://bugzilla.gnome.org/show_bug.cgi?id=561099 Committed r927 M ChangeLog M tests/scanner/foo-1.0-expected.tgir M tests/scanner/foo-1.0-expected.gir M tests/scanner/foo.h M giscanner/transformer.py r927 = 8f83c5a81e3a32615be7fed1050daae81a9fcf34 (git-svn)
The patch applied above was actually for bug 559601. This patch however is now in actually as Committed r928 M ChangeLog M girepository/girparser.c r928 = 4e91556ac3d97742265eefa0ab8fdebad2619a43 (git-svn)
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]