-
Notifications
You must be signed in to change notification settings - Fork 284
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
typed array APIs #72
Comments
@dherman By using Here is a code example with
|
This deserves an RFC, and we should also think about whether we want to offer a way to get the different typed views on an ArrayBuffer directly within Rust. Right now you can hack your way to doing this with some buffer.grab(|mut slice| {
let len = slice.len();
let raw = slice.as_mut_ptr();
let mut slice: CMutSlice<f32> = unsafe { CMutSlice::new(mem::transmute(raw), len / 4) };
slice[0] = 1.8;
slice[1] = 13.4;
}); I think it's important to be able to do this with an ArrayBuffer, without having to require the JS to pass you a view of the right type. Maybe the best way to do this is for the |
@dherman Is there a way to do that from a buffer that was created in JS and passed as argument? At least for reading. |
@ffflorian Excellent work! Isn't that benchmark a little unfair? If I'm reading correctly, you are comparing an ECMAScripten compilation to pure JS against a native implementation. How does it compare against something that uses native bindings like |
I don't know, back then in February, |
This has been designed and implemented with RFC neon-bindings/rfcs#44! 🎉 |
Create object types for all the typed array types:
neon::js::binary::Int8Array
neon::js::binary::Uint8Array
neon::js::binary::Uint8ClampedArray
neon::js::binary::Int16Array
neon::js::binary::Uint16Array
neon::js::binary::Int32Array
neon::js::binary::Uint32Array
neon::js::binary::Float32Array
neon::js::binary::Float64Array
The text was updated successfully, but these errors were encountered: