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 729987 - Introspection improvements
Introspection improvements
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks: 729745
 
 
Reported: 2014-05-12 07:50 UTC by Evan Nemerson
Modified: 2014-11-23 14:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add missing (nullable) annotations, assorted minor introspection fixes (21.38 KB, patch)
2014-05-12 07:50 UTC, Evan Nemerson
committed Details | Review
Assorted introspection fixes ported from the Vala metadata (3.75 KB, patch)
2014-05-12 07:53 UTC, Evan Nemerson
needs-work Details | Review
introspection: Fix some g-ir-scanner warnings (3.36 KB, patch)
2014-05-27 00:24 UTC, Evan Nemerson
committed Details | Review
Add missing array annotations for binary data (3.09 KB, patch)
2014-06-11 20:58 UTC, Evan Nemerson
committed Details | Review

Description Evan Nemerson 2014-05-12 07:50:58 UTC
Created attachment 276362 [details] [review]
Add missing (nullable) annotations, assorted minor introspection fixes

Now that bug #660879 has been fixed I'm trying to go through and add the
missing annotations.  This patch mostly adds a bunch of (nullable) annotations, as well as switching some (allow-none) annotations to (nullable) or (optional), and a couple small syntax errors I noticed while putting this together (s/NULL/%NULL/ and similar).
Comment 1 Evan Nemerson 2014-05-12 07:53:02 UTC
Created attachment 276363 [details] [review]
Assorted introspection fixes ported from the Vala metadata

This patch is the result of me going through Vala's metadata and porting what I could to annotations.
Comment 2 Evan Nemerson 2014-05-27 00:24:24 UTC
Created attachment 277248 [details] [review]
introspection: Fix some g-ir-scanner warnings

Some more fixes, from things that g-ir-scanner was warning about.

FWIW, feel free to squash these all into a single commit to reduce noise.
Comment 3 Dan Winship 2014-06-07 12:07:40 UTC
Comment on attachment 276362 [details] [review]
Add missing (nullable) annotations, assorted minor introspection fixes

>- * Return value: (allow-none): the new #SoupAddress
>+ * Return value: (nullable): the new #SoupAddress

That means we lose the annotation with non-bleeding-edge versions of gobject-introspection though...

Maybe that's not a big deal since probably nothing uses it for return-value anyway, and it looks like this patch only touches return values? If so, then ok I guess.
Comment 4 Dan Winship 2014-06-07 12:11:50 UTC
Comment on attachment 276363 [details] [review]
Assorted introspection fixes ported from the Vala metadata

>- * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return
>+ * @params: (element-type utf8 utf8) (out) (transfer full) (optional): return

Here, you definitely need to say "(allow-none) (optional)" for now though, I guess.

Though, in that case, there's not really any point, since both old and new g-i will treat that the same as just "(allow-none)" won't they?

>  * soup_buffer_new:
>  * @use: how @data is to be used by the buffer
>- * @data: data
>+ * @data: (array length=length) (element-type guint8): data
>  * @length: length of @data

This gets overwritten by soup_buffer_new_take() via (rename-to), so any annotations here are irrelevant. (Maybe add (skip) to make it explicit?)
Comment 5 Dan Winship 2014-06-07 12:16:04 UTC
Comment on attachment 277248 [details] [review]
introspection: Fix some g-ir-scanner warnings

>-/*
>+/**
>  * SECTION:soup-proxy-uri-resolver

What does g-i warn about here? This was intentional, to keep the docs out of the GIR file since SoupProxyURIResolver is deprecated now.
Comment 6 Evan Nemerson 2014-06-11 20:51:37 UTC
(In reply to comment #3)
> (From update of attachment 276362 [details] [review])
> >- * Return value: (allow-none): the new #SoupAddress
> >+ * Return value: (nullable): the new #SoupAddress
> 
> That means we lose the annotation with non-bleeding-edge versions of
> gobject-introspection though...
> 
> Maybe that's not a big deal since probably nothing uses it for return-value
> anyway, and it looks like this patch only touches return values? If so, then ok
> I guess.

allow-none was ignored on return values before nullable and optional were added.  I don't just mean nothing used them--the information wasn't even present in the GIR.  Switching to nullable shouldn't mean anything to old G-I, and to new G-I it means you're not using the deprecated syntax anymore.

(In reply to comment #4)
> (From update of attachment 276363 [details] [review])
> >- * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return
> >+ * @params: (element-type utf8 utf8) (out) (transfer full) (optional): return
> 
> Here, you definitely need to say "(allow-none) (optional)" for now though, I
> guess.

You're right.

> Though, in that case, there's not really any point, since both old and new g-i
> will treat that the same as just "(allow-none)" won't they?

The only thing I don't like about just saying (allow-none) is that there are a lot of incorrect (allow-none) annotations on (out) arguments since it was formerly ambiguous whether it mean (optional) or (nullable), so I don't always trust the annotations.  It's not really a big deal, though--I'll attach a version of the patch which just doesn't include this change.

> >  * soup_buffer_new:
> >  * @use: how @data is to be used by the buffer
> >- * @data: data
> >+ * @data: (array length=length) (element-type guint8): data
> >  * @length: length of @data
> 
> This gets overwritten by soup_buffer_new_take() via (rename-to), so any
> annotations here are irrelevant. (Maybe add (skip) to make it explicit?)

We still have a binding for soup_buffer_new in Vala (we un-skip it in metadata), and it would be nice to make use of the annotations.  We also ignore (rename-to) because it would break all the existing bindings (remember, Vala is much older than G-I), and we support a lot of stuff G-I doesn't (like variadic functions) that people tend to add (rename-to) annotations for.

Also, as a C programmer I still prefer the annotations to be there since it makes the documentation a bit easier to read...  instead of having to actually read the documentation I can generally just glance at the annotations and know what is expected.  It's probably not a big deal for this function (transfer annotations are the really helpful ones), but the consistency is nice.

(In reply to comment #5)
> (From update of attachment 277248 [details] [review])
> >-/*
> >+/**
> >  * SECTION:soup-proxy-uri-resolver
> 
> What does g-i warn about here?

It's actually soup_proxy_uri_resolver_get_proxy_uri_async which causes the warning:

    soup-proxy-uri-resolver.h:52: Warning: Soup: soup_proxy_uri_resolver_get_proxy_uri_async: argument callback: Missing (scope) annotation for callback without GDestroyNotify (valid: call, async)

> This was intentional, to keep the docs out of
> the GIR file since SoupProxyURIResolver is deprecated now.

That doesn't really work.  Soup.ProxyURIResolver is still present in the GIR, and get_proxy_uri_sync is even perfectly usable.  get_proxy_uri_async is only unusable (marked as introspectable="0") because of the missing (scope) annotation, not because there are no gtk-doc comments for it.

If you want to hide something from the GIR, you should add (skip) annotations.  That said, they have already been exposed as public API in a stable release, so at this point it probably makes more sense to just make the comments real gtk-doc comments and add Deprecated tags.
Comment 7 Evan Nemerson 2014-06-11 20:58:14 UTC
Created attachment 278291 [details] [review]
Add missing array annotations for binary data

Switches that (optional) annotation back to (allow-none), nothing else changed.
Comment 8 Dan Winship 2014-06-11 21:17:00 UTC
> We still have a binding for soup_buffer_new in Vala

> Also, as a C programmer I still prefer the annotations to be there

OK, makes sense.

> > This was intentional, to keep the docs out of
> > the GIR file since SoupProxyURIResolver is deprecated now.
> 
> That doesn't really work.  Soup.ProxyURIResolver is still present in the GIR

I didn't want to keep the type itself out of the GIR, just its documentation. But that's not a huge deal I guess; the docs aren't in the gtk-doc-generated documentation, which is what everyone really sees anyway.
Comment 9 Dan Winship 2014-11-23 14:46:25 UTC
very belatedly pushed these. thanks

Attachment 276362 [details] pushed as a50ea58 - Add missing (nullable) annotations, assorted minor introspection fixes
Attachment 277248 [details] pushed as 4957820 - introspection: Fix some g-ir-scanner warnings
Attachment 278291 [details] pushed as b24ef29 - Add missing array annotations for binary data