mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
js-sys: Expose bindings to WebAssembly.Table.prototype.set
Part of #275
This commit is contained in:
@ -3076,6 +3076,13 @@ pub mod WebAssembly {
|
||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
|
||||
#[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
|
||||
pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
|
||||
|
||||
/// The `set()` prototype method of the `WebAssembly.Table` object mutates a
|
||||
/// reference stored at a given index to a different value.
|
||||
///
|
||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
|
||||
#[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
|
||||
pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
|
||||
}
|
||||
|
||||
// WebAssembly.Memory
|
||||
|
@ -133,6 +133,9 @@ fn table() {
|
||||
|
||||
table.grow(1).unwrap();
|
||||
assert_eq!(table.length(), 2);
|
||||
|
||||
let f = table.get(0).unwrap();
|
||||
table.set(1, &f).unwrap();
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
|
Reference in New Issue
Block a user