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 756099 - g_main_context_query(): Annotate @n_fds as (in) parameter
g_main_context_query(): Annotate @n_fds as (in) parameter
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: introspection
2.46.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-10-05 22:54 UTC by Mikhail Zabaluev
Modified: 2015-10-15 21:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g_main_context_query(): Annotate @n_fds as (in) parameter (923 bytes, patch)
2015-10-05 22:54 UTC, Mikhail Zabaluev
committed Details | Review

Description Mikhail Zabaluev 2015-10-05 22:54:22 UTC
The default is picked up as (out), which is bogus.
Comment 1 Mikhail Zabaluev 2015-10-05 22:54:26 UTC
Created attachment 312698 [details] [review]
g_main_context_query(): Annotate @n_fds as (in) parameter
Comment 2 Emmanuele Bassi (:ebassi) 2015-10-05 23:08:16 UTC
Review of attachment 312698 [details] [review]:

::: glib/gmain.c
@@ +3520,3 @@
  * @fds: (out caller-allocates) (array length=n_fds): location to
  *       store #GPollFD records that need to be polled.
+ * @n_fds: (in): length of @fds.

Ugh, this API is awful. It's getgrouplist(), only dumber.

Yes, technically speaking this is an in argument. In practice, though, we'd need a different function that used a callee-allocated array and returned the size of it.

Anyway, this is okay.
Comment 3 Emmanuele Bassi (:ebassi) 2015-10-05 23:08:50 UTC
To be fair, I'm not even sure how language bindings are supposed to wrap this function correctly.
Comment 4 Mikhail Zabaluev 2015-10-06 00:56:30 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #3)
> To be fair, I'm not even sure how language bindings are supposed to wrap
> this function correctly.

The array is caller-allocated, so it should be doable.

But I'm mostly beating around odd C type annotations to make sure low-level Rust bindings can be generated correctly with less manual labour. One flavour of oddity is when C types for (out) parameters don't look like pointers.
Comment 5 Mikhail Zabaluev 2015-10-15 21:11:01 UTC
Attachment 312698 [details] pushed as 75eaf50 - g_main_context_query(): Annotate @n_fds as (in) parameter