Update all non-mutable slices into Rust to use AllocCopy

This commit migrates all non-mutable slices incoming into Rust to use
the standard `AllocCopy` binding instead of using a custom `Slice`
binding defined by `wasm-bindgen`. This is done by freeing the memory
from Rust rather than freeing the memory from JS. We can't do this for
mutable slices yet but otherwise this should be working well!
This commit is contained in:
Alex Crichton
2019-06-25 05:44:32 -07:00
parent e16dd15697
commit b9c27b93a5
3 changed files with 65 additions and 65 deletions

View File

@ -153,7 +153,7 @@ impl<'a, 'b> Incoming<'a, 'b> {
// Similar to `AllocCopy`, except that we deallocate in a finally
// block.
NonstandardIncoming::Slice { kind, val, mutable } => {
NonstandardIncoming::MutableSlice { kind, val } => {
let (expr, ty) = self.standard_typed(val)?;
assert_eq!(ty, ast::WebidlScalarType::Any.into());
let func = self.cx.pass_to_wasm_function(*kind)?;
@ -162,7 +162,7 @@ impl<'a, 'b> Incoming<'a, 'b> {
.prelude(&format!("const ptr{} = {}({});", i, func, expr));
self.js
.prelude(&format!("const len{} = WASM_VECTOR_LEN;", i));
self.finally_free_slice(&expr, i, *kind, *mutable)?;
self.finally_free_slice(&expr, i, *kind, true)?;
self.js.typescript_required(kind.js_ty());
return Ok(vec![format!("ptr{}", i), format!("len{}", i)]);
}