-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Support void* (Pointer[None]) parameters in bare lambdas and functions #4152
Support void* (Pointer[None]) parameters in bare lambdas and functions #4152
Conversation
Hi @stefandd, The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do. Release notes are added by creating a uniquely named file in the The basic format of the release notes (using markdown) should be:
Thanks. |
Please change the test to a ponyc-run test. We only do error messages tests now that aren't ponyc-run. Let me know if you need any help getting oriented with the ponyc-run tests. |
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.
Like Sean mentioned, can you add the test to the runner? It would also make sense to test that partial application also works with this change, like so:
use @printf[I32](fmt: Pointer[None] tag, ...)
actor Main
new create(env: Env) =>
let cb = this~print()
cb("Hello, world!\n".cstring())
fun @print(fmt: Pointer[None]) =>
@printf(fmt)
Thanks for the test. It does run and print
The compile test I had proposed was not an error message test, was it? Should I simply add an exit code test for that one too, i.e., move both tests to the libponyc-run suite? |
@stefandd No need to capture the output. Take a look at how I did the runner test for my other PR here: https://github.com/ponylang/ponyc/tree/4f64cc5a87ae3e9641e1596d7dddb4f15d737395/test/libponyc-run/ffi-return-arg-reachable The ideal test would show that you're able to any pointer to C using bare lambdas, and that you get something back that makes sense. Edit:
So, for runner tests, we're interested in that the code compiles, and that it does what is supposed to. That's why I mentioned the bit about verifying that the C code works as expected. |
@ergl I combined the test you suggested for the bare functions with one for bare lambdas. It only produces the expected exit code if both pass. Ok so? EDIT: I realize the tests should be in seperate folders for bare lamdas and bare functions... |
@stefandd I don't think this matters too much. I'll be okay with you putting them all in the same test. |
I'd prefer separate tests |
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.
Looks good to me except for some wording and spacing nits.
Unlike conventional FFI functions, bare lambdas
@{(...)}
do so far not supportPointer[None]
parameters, Pony's equivalent of void*, despite the fact that like the former these lambdas are strictly intended for use with FFI calls and callbacks.Therefore, code like this failed to compile:
This commit adds to the bare lambdas and functions the same lenience that conventional FFI functions enjoy: it allows the declaration of
Pointer[None]
parameters that can accept any of the PonyPointer[A]
types.