GNOME Bugzilla – Bug 784676
vala does not handle G-I for which self can be nullable
Last modified: 2018-05-22 15:50:20 UTC
Some C API for objects allow NULL for the interface functions to use a fallback implementation. Setting (nullable) for @self in that API causes incompatible signatures in interface implementations in Vala. This should be safe, as by design, you can't ever jump into vala code with a NULL instance. Example: /** * foo_do_something: * @self: (nullable): A #Foo or %NULL * * Do something. If foo is %NULL, a fallback implementation * is provided. */ void foo_do_something (Foo *foo) { if (foo) FOO_GET_IFACE (foo)->do_something (foo); else do_fallback (); }
Created attachment 359029 [details] [review] vala: Methods annotated with NullableInstance allow "this == null"
Could you provide an actual project with GIR file for this?
Created attachment 359034 [details] [review] vala: Methods annotated with NullableInstance allow "this == null" If a method is suppose to allow a null-instance then don't perform the usual type-/null-check. Make girparse able to recognize nullable instance-parameters and add support for boolean "nullable-instance" metadata.
Created attachment 359035 [details] [review] vala: Methods annotated with NullableInstance allow "this == null" If a method is suppose to allow a null-instance then don't perform the usual type-/null-check. Make girparse able to recognize nullable instance-parameters and add support for boolean "nullable-instance" metadata.
https://git.gnome.org/browse/gnome-builder/commit/?id=5373d8a was what was breaking before, but I can't seem to replicate it at all. So I'm a bit at a loss of how it was breaking before. Lets see if any if any distros complain about builds, but since this seems to work I have no more issues.
Created attachment 359040 [details] [review] vala: Methods annotated with NullableInstance allow "this == null" If a method is suppose to allow a null-instance then don't perform the usual type-/null-check. Make girparse able to recognize nullable instance-parameters and add support for boolean "nullable-instance" metadata.
Created attachment 359041 [details] [review] Regenerate GIR-based bindings
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/589.