Skip to content

Commit

Permalink
Added WebAssembly.Global (#2595)
Browse files Browse the repository at this point in the history
* Added WebAssembly Global

* Fixed functions based on feedback

* Fixed typo

* Use without Option to make the PR simpler

* Updated async-errors stderror expected number
  • Loading branch information
syrusakbary authored Jun 22, 2021
1 parent 1e41529 commit e4ab260
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,34 @@ pub mod WebAssembly {
pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
}

// WebAssembly.Global
#[wasm_bindgen]
extern "C" {
/// The `WebAssembly.Global()` constructor creates a new `Global` object
/// of the given type and value.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
#[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type Global;

/// The `WebAssembly.Global()` constructor creates a new `Global` object
/// of the given type and value.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;

/// The value prototype property of the `WebAssembly.Global` object
/// returns the value of the global.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
#[wasm_bindgen(method, getter, structural, js_namespace = WebAssembly)]
pub fn value(this: &Global) -> JsValue;
#[wasm_bindgen(method, setter = value, structural, js_namespace = WebAssembly)]
pub fn set_value(this: &Global, value: &JsValue);
}

// WebAssembly.Memory
#[wasm_bindgen]
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion crates/macro/ui-tests/async-errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From<BadType>` is not sati
<wasm_bindgen::JsValue as From<&'a T>>
<wasm_bindgen::JsValue as From<&'a str>>
<wasm_bindgen::JsValue as From<MyType>>
and 62 others
and 63 others
= note: required because of the requirements on the impl of `Into<wasm_bindgen::JsValue>` for `BadType`
= note: required because of the requirements on the impl of `IntoJsResult` for `BadType`
= note: required by `into_js_result`
Expand Down

0 comments on commit e4ab260

Please sign in to comment.