Skip to content

Commit e4ab260

Browse files
authored
Added WebAssembly.Global (#2595)
* Added WebAssembly Global * Fixed functions based on feedback * Fixed typo * Use without Option to make the PR simpler * Updated async-errors stderror expected number
1 parent 1e41529 commit e4ab260

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

crates/js-sys/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,34 @@ pub mod WebAssembly {
35613561
pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
35623562
}
35633563

3564+
// WebAssembly.Global
3565+
#[wasm_bindgen]
3566+
extern "C" {
3567+
/// The `WebAssembly.Global()` constructor creates a new `Global` object
3568+
/// of the given type and value.
3569+
///
3570+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
3571+
#[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
3572+
#[derive(Clone, Debug, PartialEq, Eq)]
3573+
pub type Global;
3574+
3575+
/// The `WebAssembly.Global()` constructor creates a new `Global` object
3576+
/// of the given type and value.
3577+
///
3578+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
3579+
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
3580+
pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
3581+
3582+
/// The value prototype property of the `WebAssembly.Global` object
3583+
/// returns the value of the global.
3584+
///
3585+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
3586+
#[wasm_bindgen(method, getter, structural, js_namespace = WebAssembly)]
3587+
pub fn value(this: &Global) -> JsValue;
3588+
#[wasm_bindgen(method, setter = value, structural, js_namespace = WebAssembly)]
3589+
pub fn set_value(this: &Global, value: &JsValue);
3590+
}
3591+
35643592
// WebAssembly.Memory
35653593
#[wasm_bindgen]
35663594
extern "C" {

crates/macro/ui-tests/async-errors.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From<BadType>` is not sati
3333
<wasm_bindgen::JsValue as From<&'a T>>
3434
<wasm_bindgen::JsValue as From<&'a str>>
3535
<wasm_bindgen::JsValue as From<MyType>>
36-
and 62 others
36+
and 63 others
3737
= note: required because of the requirements on the impl of `Into<wasm_bindgen::JsValue>` for `BadType`
3838
= note: required because of the requirements on the impl of `IntoJsResult` for `BadType`
3939
= note: required by `into_js_result`

0 commit comments

Comments
 (0)