mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-21 08:41:35 +00:00
Add an accessor for wasm's own memory as a JS object
In addition to closing #495 this'll be useful eventually when instantiating multiple wasm modules from Rust as you'd now be able to acquire a reference to the current module in Rust itself.
This commit is contained in:
@ -437,6 +437,8 @@ externs! {
|
||||
fn __wbindgen_json_parse(ptr: *const u8, len: usize) -> u32;
|
||||
fn __wbindgen_json_serialize(idx: u32, ptr: *mut *mut u8) -> usize;
|
||||
fn __wbindgen_jsval_eq(a: u32, b: u32) -> u32;
|
||||
|
||||
fn __wbindgen_memory() -> u32;
|
||||
}
|
||||
|
||||
impl Clone for JsValue {
|
||||
@ -562,6 +564,13 @@ pub fn throw(s: &str) -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a handle to this wasm instance's `WebAssembly.Memory`
|
||||
pub fn memory() -> JsValue {
|
||||
unsafe {
|
||||
JsValue { idx: __wbindgen_memory() }
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __rt {
|
||||
use core::cell::{Cell, UnsafeCell};
|
||||
|
Reference in New Issue
Block a user