-
Notifications
You must be signed in to change notification settings - Fork 76
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
purego: add float32 and float64 support to callbacks #120
Conversation
This fixes a bug in RegisterFunc which was converting float32 into float64 when the C function expected a float32 argument. This gave unpredictable results. It also makes the behavior of SyscallN more inline with what is expected when calling it with float arguments. It no longer expects them to be float64 and it is up to the caller to convert either float32 or float64 into uintptr. SyscallN will then properly move it into the correct register
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
By the way, Does a calback work even if this mixes float32 and float64 as this arguments?
I'm gonna sleep soon so I'll take a look tomorrow. Good night... |
Yes! I added a test for that case (TestNewCallbackFloat32AndFloat64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
floats and doubles were already implemented in ebitengine#69 ebitengine#120 ebitengine#171 ebitengine#177
This commit adds support for float32 and float64 arguments in C callbacks. It also adds a test to check the maximum number of arguments a callback can have and that it is callback properly by purego. There is also some formatting done to the assembly.