Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove (closure) annotations #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

A6GibKm
Copy link
Contributor

@A6GibKm A6GibKm commented Jan 11, 2025

The (closure) annotation should go in the callback parameter, e.g.

* @callback: (scope async) (closure data): a callback ...

however gobject-introspection will automatically pick up a parameter called data as the parameter of the callback.

Fixes the warnings:

[36/45] Generating libportal/Xdp-1.0.gir with a custom command (wrapped by meson to set env)
../libportal/account.c:209: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/background.c:329: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/background.c:399: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/camera.c:218: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/dynamic-launcher.c:236: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/email.c:308: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:245: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:353: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:446: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inhibit.c:218: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inhibit.c:569: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inputcapture.c:727: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/location.c:330: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/notification.c:723: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/openuri.c:277: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/openuri.c:344: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/print.c:280: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/print.c:358: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:460: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:530: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:570: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:808: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/screenshot.c:224: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/screenshot.c:288: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/spawn.c:203: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/trash.c:128: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/updates.c:208: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/updates.c:391: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/wallpaper.c:286: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters

@A6GibKm
Copy link
Contributor Author

A6GibKm commented Jan 11, 2025

cc: @ebassi, the warning is a bit confusing, it makes me thing that the closure annotation should indeed go in the callback's parameter (data) instead of the callback parameter (callback) .

@ebassi
Copy link

ebassi commented Jan 11, 2025

It doesn't say "the callback's parameter", though. The warning says: "the callback parameter", i.e. the parameter that is a callback.

We cannot put a whole treatise into a warning: people already don't read them as is.

@ebassi
Copy link

ebassi commented Jan 11, 2025

however gobject-introspection will automatically pick up a parameter called data as the parameter of the callback.

It actually picks up anything that ends with data, and is a gpointer, though the documented rule is to use user_data as the name of a closure argument.

The `(closure)` annotation should go in the callback parameter, e.g.

`* @callback: (scope async) (closure data): a callback ...`

however gobject-introspection will automatically pick up gpointer
parameters ending in `data` as the parameter of the callback.

Fixes the warnings:

```
[36/45] Generating libportal/Xdp-1.0.gir with a custom command (wrapped by meson to set env)
../libportal/account.c:209: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/background.c:329: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/background.c:399: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/camera.c:218: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/dynamic-launcher.c:236: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/email.c:308: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:245: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:353: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/filechooser.c:446: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inhibit.c:218: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inhibit.c:569: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/inputcapture.c:727: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/location.c:330: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/notification.c:723: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/openuri.c:277: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/openuri.c:344: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/print.c:280: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/print.c:358: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:460: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:530: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:570: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/remote.c:808: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/screenshot.c:224: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/screenshot.c:288: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/spawn.c:203: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/trash.c:128: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/updates.c:208: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/updates.c:391: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
../libportal/wallpaper.c:286: Warning: Xdp: invalid "closure" annotation: only valid on callback parameters
```
@A6GibKm A6GibKm force-pushed the remove-closure-annotations branch from 1519b25 to c749f8c Compare January 11, 2025 16:39
@A6GibKm
Copy link
Contributor Author

A6GibKm commented Jan 11, 2025

however gobject-introspection will automatically pick up a parameter called data as the parameter of the callback.

It actually picks up anything that ends with data, and is a gpointer, though the documented rule is to use user_data as the name of a closure argument.

I updated the commit description, would it be better if I renamed them to user_data instead?

@ebassi
Copy link

ebassi commented Jan 11, 2025

I updated the commit description, would it be better if I renamed them to user_data instead?

It's fine either way; user_data is generally more idiomatic of GLib-based libraries, but it's not fundamental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants