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

Add bindings for WebAssembly.Tag and WebAssembly.Exception #3484

Merged
merged 5 commits into from
Jun 16, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4467,6 +4467,64 @@ pub mod WebAssembly {
pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
}

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

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

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

/// The `WebAssembly.Exception()` constructor creates a new `Exception` object
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;

/// The `WebAssembly.Exception()` constructor creates a new `Exception` object
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
pub fn new_with_options(
tag: &Tag,
payload: &Array,
options: &Object,
) -> Result<Exception, JsValue>;

/// The `is()` prototype method of the `WebAssembly.Exception` can be used to
/// test if the Exception matches a given tag.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
#[wasm_bindgen(method, js_namespace = WebAssembly)]
pub fn is(this: &Exception, tag: &Tag) -> bool;

/// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
/// to get the value of a specified item in the exception's data arguments
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
#[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
}

// WebAssembly.Global
#[wasm_bindgen]
extern "C" {
Expand Down