-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(ext/ffi): add support for buffer arguments #12335
Conversation
const buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); | ||
dylib.symbols.print_buffer(buffer, buffer.length); |
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.
This is a bit unhandy... I wonder if we could just sniff out length automatically in case of ArrayBuffer
. Though I think users would still have to declare two parameters... @piscisaureus thoughts?
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.
I wonder if we could just sniff out length automatically in case of
ArrayBuffer
It's possible of course to sniff out the length automatically on the JS/Rust side (for Uint8Array too, btw).
However C has no standard data type for passing a (pointer, length) tuple.
So I'd just leave it as-is, FFI users can provide their own convenience wrappers.
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
…)" This reverts commit 3faf75a.
This commit adds support for passing buffer arguments across FFI boundary. Co-authored-by: eliassjogreen <[email protected]> Co-authored-by: Bert Belder <[email protected]>
Forks from #11648