GNOME Bugzilla – Bug 584528
Usage of (allow-none) for return values?
Last modified: 2015-02-07 16:59:32 UTC
Currently we don't allow (allow-none) for the return value, e.g. I think we just implicitly assume that the return value can always be NULL. While this is probably the right default, it would be useful to be able to specify that a function can never return NULL. This applies to e.g. g_object_new(). Another example /** * foo_bar_get_baz: * @bar: A #FooBar. * * Gets the #FooBaz object associated with @bar. * * Returns: (never-none): A #FooBaz. Free with g_object_unref(). */ FooBaz * foo_bar_get_baz (FooBar *bar) { return bar->priv->baz; } This is useful in at least a couple of cases - Bindings can handle the cases earlier where a method returns NULL and it shouldn't - Things like C++ can return a reference instead of a pointer (however I'm not sure this even a good idea - then again, my C++ knowledge is rather rusty) However, maybe this is not useful at all. But I thought I'd file a bug anyway.
*** This bug has been marked as a duplicate of bug 626395 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]