-
Notifications
You must be signed in to change notification settings - Fork 41
Methods with nullable fundamental return types should return null #868
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
Conversation
5907f49
to
cb25ef0
Compare
0321aee
to
25cf877
Compare
Thank you for the PR. Great to see, that you want to add tests. Before I start a short disclaimer: I'm not very familar with fundamental types. My following remarks could be obviously wrong without me knowing it. Please correct me if I'm wrong. Are you sure this is a minimal implementation for a fundamental type? There are functions like I would suggest to put the definition of the fundamental type into the Did you see the docs for this topic (https://docs.gtk.org/gobject/concepts.html#non-instantiatable-non-classed-fundamental-types) |
...if the pointer returned from native code is NULL. Previously we would just create a managed object around a NULL handle. I've also written unit tests to verify this behaviour. I've also slightly modified the layout of the record return type to managed expression class, to make it more consistent with the other converters.
Yeah this is definitely not a minimal fundamental type. I initially implemented something similar to gchar (using the document that you linked), but I realised that I actually want an intantiatable fundamental type for my tests, as that's the use case that I want to reproduce. I couldn't find an easy way to do that without implementing a reference counter, so I ended up with what we have here, which is loosely based on the gobject implementation. The collect_value function is required in this case (gir complains if it's missing), and although the free_value function could be omitted, I left it in for completeness, in case this fundamental type is used for other tests in the future where it's needed. Thanks for the tip about the |
Which real world fundamental type do you have at hand which is instantiatable so it makes sense to have a test for it? (GObject is not marked as fundamental in the gir file.) Actually the generator currently is not differentiating between instantiatable and non instantiatable fundamental types. As far as I know there is no attribute in the gir file for it? According to the docs I would even doubt that there is something like this? |
In my case it was a GdkEvent. I was calling a method which returns a GdkEvent in some cases, and NULL in some other cases. What I observed was that when NULL was returned on the native side, the bindings were giving me a GdkEvent wrapper around IntPtr.Zero, which is a bit misleading as you might imagine :). |
Yep this is misleading. Do you think it makes a difference wether we define something like From my point of view it should be the same if we have some c api which creates such types. So the question would be why didn't you continue to work on some fundamental type like |
The Regress library from the GObject Introspection test suite has an implementation of a fundamental type that is used on their tests |
Superseeded by #1056 |
Resolves #867
(Edit: Please don't merge yet, I still need to add some tests.)