-
Notifications
You must be signed in to change notification settings - Fork 187
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
Handle struct values (non-pointer) #67
Comments
If I understand what you're trying to achieve, this won't work, for the same reason this does not work: http://play.golang.org/p/jMTwpE5bNo Does that make sense? If so, I'll change the topic of this issue as that error message is really bad and should be fixed. |
My point is that this works: http://play.golang.org/p/sbPAvbv6cf |
The original point was about modifying the returned value, which does not work. But yeah, we can allocate a new value and copy it. Somewhat wasteful, but maybe it's worth to make such methods work. |
Yeah, let's do that. Thanks for bringing this up. |
Making Go-QML "convert" return values into set-able types (if they weren't already) makes the QML script side behave more as the same code would work if it was written in Go, so IMO it's worth it. There's already unavoidable overhead in every QML/Go function call boundary and any app where this boundary has a noticeable performance impact would do better in trying to get rid of the QML/Go boundary crossing in the first place. The memory allocation could potentially be partially removed by using reflect.NewAt and keeping a small piece of memory for QML function stack, but I doubt the complexity of that is actually worth the effort :) IIRC I also saw a panic-call when passing a "non-hashable" struct as a function argument or something when skimming the code. Would it be possible to use a similar approach there? |
Yeah, the unhashable note is about the same issue. If we copy the value and get an address for it, both problems will go away. |
Occurs in both v0 and v1:
Yes I understand that it goes away if I do
e.Context().SetVar("blah", &Blah{})
, but that is besides the point.Real use case is a go function that returns a small struct type by value. This value I then want to modify qml side to pass on this modified data to another go function.
The text was updated successfully, but these errors were encountered: