mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-16 06:21:22 +00:00
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:
@ -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)]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user