Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WebAssembly.Global #2595

Merged
merged 5 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
alexcrichton marked this conversation as resolved.
Show resolved Hide resolved
#[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