-
Notifications
You must be signed in to change notification settings - Fork 105
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
Doubles: gdnative type hint break stubs #649
Comments
I believe this is related to #633. I'm pretty sure, that since Godot knows what The documentation should be updated to explicitly list doubling natives (which always use the double strategy INCLUDE_NATIVE). A couple examples of what you shouldn't do might be useful too. |
Yes, I agree, #633 is related to this. It would be great to cover this problem in the documentation. Right now it seems that the only workaround to this problem is to use custom type wrappers. In the example, class_name MyStreamPeerTCP
var peer: StreamPeerTCP
func _init() -> void:
self.peer = StreamPeerTCP.new()
func connect_to_host(host: String, ip: int) -> int:
return peer.connect_to_host(host, ip) Or don't use type hints in the project... |
I'm not sure when Godot started punching through to underlying implementation on typed variables but it feels like a recent change based on related issues being opened in GUT. Maybe it's just that more people are doing it. As Godot gets better at doing this kind of optimization, doubling native objects and methods is not working as expected more often. A new approach might be needed. Instead of fixing doubles of native things, maybe we could remove typed variables and parameters in a special kind of double. When creating a double GUT dynamically generates a script that inherits from the object being doubled and generates wrappers for all the methods. The wrapper methods do not have typed parameters, but all the class variables retain their typing. The If the doubler completely rewrote the source, removing typed variables/parameters then you could create a double that avoids the punch through. There could also a be a ton of issues doing this that I'm just not thinking of right now. Maybe the Godot devs would be open to some way of forcing a Native object to use local versions of methods. This seems highly unlikely, but it would solve the problem. Maybe an annotation that didn't work with release builds. Maybe a lot of things. |
Versions
The Bug
Using
gdscript
type hints forgdnative
object breaks stubs for doubles.Honestly, I have no idea why. Probably some engine optimizations. Everything works fine for custom types, problems only with
gdnative
types. During debugging, with a typed instance, there is no further work with the GUT framework - the value is returned immediately (without steps inside GUT or stubs or something else). So I think it's an engine issue.This may be a problem similar to #490 and #482, but I'm not sure.
Steps To Reproduce
typed_result
is not equal42
.The text was updated successfully, but these errors were encountered: