diff --git a/CHANGELOG.md b/CHANGELOG.md index df7ad8a6217..8eed5b1fd78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,6 +135,9 @@ * Removed `impl Deref for JsStatic` when compiling with `cfg(target_feature = "atomics")`, which was unsound. [#4057](https://github.com/rustwasm/wasm-bindgen/pull/4057) +* Updated the WebGPU WebIDL to the current draft as of 2024-08-05. + [#4062](https://github.com/rustwasm/wasm-bindgen/pull/4062) + ### Fixed * Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`. diff --git a/crates/cli/tests/reference/raw.js b/crates/cli/tests/reference/raw.js index 3432d150366..6b831debb89 100644 --- a/crates/cli/tests/reference/raw.js +++ b/crates/cli/tests/reference/raw.js @@ -6,26 +6,6 @@ export function __wbg_set_wasm(val) { } -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachedUint8ArrayMemory0 = null; - -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} - const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); @@ -45,6 +25,26 @@ function takeObject(idx) { dropObject(idx); return ret; } + +const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; + +let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachedUint8ArrayMemory0 = null; + +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} /** * @param {number} test * @returns {number} @@ -110,11 +110,11 @@ export function __wbg_test2_39fe629b9aa739cf() { return addHeapObject(ret); }; -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - export function __wbindgen_object_drop_ref(arg0) { takeObject(arg0); }; +export function __wbindgen_throw(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 3572c835e17..9527a00b5a3 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -495,6 +495,8 @@ GpuBufferMapState = [] GpuCanvasAlphaMode = [] GpuCanvasConfiguration = [] GpuCanvasContext = [] +GpuCanvasToneMapping = [] +GpuCanvasToneMappingMode = [] GpuColorDict = [] GpuColorTargetState = [] GpuCommandBuffer = [] diff --git a/crates/web-sys/src/features/gen_GpuAdapter.rs b/crates/web-sys/src/features/gen_GpuAdapter.rs index 760614c78ef..53ac082e5b9 100644 --- a/crates/web-sys/src/features/gen_GpuAdapter.rs +++ b/crates/web-sys/src/features/gen_GpuAdapter.rs @@ -41,6 +41,18 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn limits(this: &GpuAdapter) -> GpuSupportedLimits; #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuAdapterInfo")] + # [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = info)] + #[doc = "Getter for the `info` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/info)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuAdapterInfo`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn info(this: &GpuAdapter) -> GpuAdapterInfo; + #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = isFallbackAdapter)] #[doc = "Getter for the `isFallbackAdapter` field of this object."] #[doc = ""] @@ -61,6 +73,7 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + #[deprecated] pub fn request_adapter_info(this: &GpuAdapter) -> ::js_sys::Promise; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestDevice)] diff --git a/crates/web-sys/src/features/gen_GpuBlendFactor.rs b/crates/web-sys/src/features/gen_GpuBlendFactor.rs index a8de869f3a7..6ae84672461 100644 --- a/crates/web-sys/src/features/gen_GpuBlendFactor.rs +++ b/crates/web-sys/src/features/gen_GpuBlendFactor.rs @@ -24,4 +24,8 @@ pub enum GpuBlendFactor { SrcAlphaSaturated = "src-alpha-saturated", Constant = "constant", OneMinusConstant = "one-minus-constant", + Src1 = "src1", + OneMinusSrc1 = "one-minus-src1", + Src1Alpha = "src1-alpha", + OneMinusSrc1Alpha = "one-minus-src1-alpha", } diff --git a/crates/web-sys/src/features/gen_GpuBuffer.rs b/crates/web-sys/src/features/gen_GpuBuffer.rs index 436ba800c97..2b51482df29 100644 --- a/crates/web-sys/src/features/gen_GpuBuffer.rs +++ b/crates/web-sys/src/features/gen_GpuBuffer.rs @@ -84,7 +84,7 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn destroy(this: &GpuBuffer); #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -93,9 +93,9 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn get_mapped_range(this: &GpuBuffer) -> ::js_sys::ArrayBuffer; + pub fn get_mapped_range(this: &GpuBuffer) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -104,9 +104,12 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn get_mapped_range_with_u32(this: &GpuBuffer, offset: u32) -> ::js_sys::ArrayBuffer; + pub fn get_mapped_range_with_u32( + this: &GpuBuffer, + offset: u32, + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -115,9 +118,12 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn get_mapped_range_with_f64(this: &GpuBuffer, offset: f64) -> ::js_sys::ArrayBuffer; + pub fn get_mapped_range_with_f64( + this: &GpuBuffer, + offset: f64, + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -130,9 +136,9 @@ extern "C" { this: &GpuBuffer, offset: u32, size: u32, - ) -> ::js_sys::ArrayBuffer; + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -145,9 +151,9 @@ extern "C" { this: &GpuBuffer, offset: f64, size: u32, - ) -> ::js_sys::ArrayBuffer; + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -160,9 +166,9 @@ extern "C" { this: &GpuBuffer, offset: u32, size: f64, - ) -> ::js_sys::ArrayBuffer; + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] #[doc = "The `getMappedRange()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] @@ -175,7 +181,7 @@ extern "C" { this: &GpuBuffer, offset: f64, size: f64, - ) -> ::js_sys::ArrayBuffer; + ) -> Result<::js_sys::ArrayBuffer, JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] #[doc = "The `mapAsync()` method."] diff --git a/crates/web-sys/src/features/gen_GpuCanvasConfiguration.rs b/crates/web-sys/src/features/gen_GpuCanvasConfiguration.rs index 220fcebe4d7..956cb9494c3 100644 --- a/crates/web-sys/src/features/gen_GpuCanvasConfiguration.rs +++ b/crates/web-sys/src/features/gen_GpuCanvasConfiguration.rs @@ -75,6 +75,26 @@ extern "C" { #[wasm_bindgen(method, setter = "format")] pub fn set_format(this: &GpuCanvasConfiguration, val: GpuTextureFormat); #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMapping")] + #[doc = "Get the `toneMapping` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuCanvasToneMapping`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + #[wasm_bindgen(method, getter = "toneMapping")] + pub fn get_tone_mapping(this: &GpuCanvasConfiguration) -> Option; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMapping")] + #[doc = "Change the `toneMapping` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuCanvasToneMapping`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + #[wasm_bindgen(method, setter = "toneMapping")] + pub fn set_tone_mapping(this: &GpuCanvasConfiguration, val: &GpuCanvasToneMapping); + #[cfg(web_sys_unstable_apis)] #[doc = "Get the `usage` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`*"] @@ -149,6 +169,13 @@ impl GpuCanvasConfiguration { self } #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMapping")] + #[deprecated = "Use `set_tone_mapping()` instead."] + pub fn tone_mapping(&mut self, val: &GpuCanvasToneMapping) -> &mut Self { + self.set_tone_mapping(val); + self + } + #[cfg(web_sys_unstable_apis)] #[deprecated = "Use `set_usage()` instead."] pub fn usage(&mut self, val: u32) -> &mut Self { self.set_usage(val); diff --git a/crates/web-sys/src/features/gen_GpuCanvasContext.rs b/crates/web-sys/src/features/gen_GpuCanvasContext.rs index c5f50dd5a5b..11b819b44c7 100644 --- a/crates/web-sys/src/features/gen_GpuCanvasContext.rs +++ b/crates/web-sys/src/features/gen_GpuCanvasContext.rs @@ -29,7 +29,7 @@ extern "C" { pub fn canvas(this: &GpuCanvasContext) -> ::js_sys::Object; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuCanvasConfiguration")] - # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = configure)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCanvasContext" , js_name = configure)] #[doc = "The `configure()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure)"] @@ -38,10 +38,13 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn configure(this: &GpuCanvasContext, configuration: &GpuCanvasConfiguration); + pub fn configure( + this: &GpuCanvasContext, + configuration: &GpuCanvasConfiguration, + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuTexture")] - # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = getCurrentTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCanvasContext" , js_name = getCurrentTexture)] #[doc = "The `getCurrentTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/getCurrentTexture)"] @@ -50,7 +53,7 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn get_current_texture(this: &GpuCanvasContext) -> GpuTexture; + pub fn get_current_texture(this: &GpuCanvasContext) -> Result; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = unconfigure)] #[doc = "The `unconfigure()` method."] diff --git a/crates/web-sys/src/features/gen_GpuCanvasToneMapping.rs b/crates/web-sys/src/features/gen_GpuCanvasToneMapping.rs new file mode 100644 index 00000000000..c2fa53c0eff --- /dev/null +++ b/crates/web-sys/src/features/gen_GpuCanvasToneMapping.rs @@ -0,0 +1,64 @@ +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCanvasToneMapping)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCanvasToneMapping` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasToneMapping`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCanvasToneMapping; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMappingMode")] + #[doc = "Get the `mode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasToneMapping`, `GpuCanvasToneMappingMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + #[wasm_bindgen(method, getter = "mode")] + pub fn get_mode(this: &GpuCanvasToneMapping) -> Option; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMappingMode")] + #[doc = "Change the `mode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasToneMapping`, `GpuCanvasToneMappingMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + #[wasm_bindgen(method, setter = "mode")] + pub fn set_mode(this: &GpuCanvasToneMapping, val: GpuCanvasToneMappingMode); +} +#[cfg(web_sys_unstable_apis)] +impl GpuCanvasToneMapping { + #[doc = "Construct a new `GpuCanvasToneMapping`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasToneMapping`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuCanvasToneMappingMode")] + #[deprecated = "Use `set_mode()` instead."] + pub fn mode(&mut self, val: GpuCanvasToneMappingMode) -> &mut Self { + self.set_mode(val); + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for GpuCanvasToneMapping { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_GpuCanvasToneMappingMode.rs b/crates/web-sys/src/features/gen_GpuCanvasToneMappingMode.rs new file mode 100644 index 00000000000..106664a51ad --- /dev/null +++ b/crates/web-sys/src/features/gen_GpuCanvasToneMappingMode.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `GpuCanvasToneMappingMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuCanvasToneMappingMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuCanvasToneMappingMode { + Standard = "standard", + Extended = "extended", +} diff --git a/crates/web-sys/src/features/gen_GpuCommandEncoder.rs b/crates/web-sys/src/features/gen_GpuCommandEncoder.rs index 5e8deb5d8e7..6b1ceef6815 100644 --- a/crates/web-sys/src/features/gen_GpuCommandEncoder.rs +++ b/crates/web-sys/src/features/gen_GpuCommandEncoder.rs @@ -70,7 +70,7 @@ extern "C" { ) -> GpuComputePassEncoder; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuRenderPassDescriptor", feature = "GpuRenderPassEncoder",))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = beginRenderPass)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = beginRenderPass)] #[doc = "The `beginRenderPass()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/beginRenderPass)"] @@ -82,7 +82,7 @@ extern "C" { pub fn begin_render_pass( this: &GpuCommandEncoder, descriptor: &GpuRenderPassDescriptor, - ) -> GpuRenderPassEncoder; + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] @@ -341,7 +341,7 @@ extern "C" { ); #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture",))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] #[doc = "The `copyBufferToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"] @@ -355,14 +355,14 @@ extern "C" { source: &GpuImageCopyBuffer, destination: &GpuImageCopyTexture, copy_size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuExtent3dDict", feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture", ))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] #[doc = "The `copyBufferToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"] @@ -376,10 +376,10 @@ extern "C" { source: &GpuImageCopyBuffer, destination: &GpuImageCopyTexture, copy_size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture",))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] #[doc = "The `copyTextureToBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"] @@ -393,14 +393,14 @@ extern "C" { source: &GpuImageCopyTexture, destination: &GpuImageCopyBuffer, copy_size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuExtent3dDict", feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture", ))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] #[doc = "The `copyTextureToBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"] @@ -414,10 +414,10 @@ extern "C" { source: &GpuImageCopyTexture, destination: &GpuImageCopyBuffer, copy_size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuImageCopyTexture")] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] #[doc = "The `copyTextureToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"] @@ -431,10 +431,10 @@ extern "C" { source: &GpuImageCopyTexture, destination: &GpuImageCopyTexture, copy_size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuExtent3dDict", feature = "GpuImageCopyTexture",))] - # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] #[doc = "The `copyTextureToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"] @@ -448,7 +448,7 @@ extern "C" { source: &GpuImageCopyTexture, destination: &GpuImageCopyTexture, copy_size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuCommandBuffer")] # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = finish)] diff --git a/crates/web-sys/src/features/gen_GpuComputePassEncoder.rs b/crates/web-sys/src/features/gen_GpuComputePassEncoder.rs index 527442433d3..899ecbc8bcb 100644 --- a/crates/web-sys/src/features/gen_GpuComputePassEncoder.rs +++ b/crates/web-sys/src/features/gen_GpuComputePassEncoder.rs @@ -170,7 +170,7 @@ extern "C" { ); #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] @@ -186,10 +186,10 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: u32, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] @@ -205,7 +205,7 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: f64, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = insertDebugMarker)] #[doc = "The `insertDebugMarker()` method."] diff --git a/crates/web-sys/src/features/gen_GpuDevice.rs b/crates/web-sys/src/features/gen_GpuDevice.rs index 4ee8647c8e4..0a06252b1d2 100644 --- a/crates/web-sys/src/features/gen_GpuDevice.rs +++ b/crates/web-sys/src/features/gen_GpuDevice.rs @@ -125,7 +125,7 @@ extern "C" { feature = "GpuBindGroupLayout", feature = "GpuBindGroupLayoutDescriptor", ))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createBindGroupLayout)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createBindGroupLayout)] #[doc = "The `createBindGroupLayout()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBindGroupLayout)"] @@ -137,10 +137,10 @@ extern "C" { pub fn create_bind_group_layout( this: &GpuDevice, descriptor: &GpuBindGroupLayoutDescriptor, - ) -> GpuBindGroupLayout; + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuBuffer", feature = "GpuBufferDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createBuffer)] #[doc = "The `createBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBuffer)"] @@ -149,7 +149,10 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn create_buffer(this: &GpuDevice, descriptor: &GpuBufferDescriptor) -> GpuBuffer; + pub fn create_buffer( + this: &GpuDevice, + descriptor: &GpuBufferDescriptor, + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuCommandEncoder")] # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createCommandEncoder)] @@ -227,7 +230,7 @@ extern "C" { ) -> GpuPipelineLayout; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuQuerySet", feature = "GpuQuerySetDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createQuerySet)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createQuerySet)] #[doc = "The `createQuerySet()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createQuerySet)"] @@ -236,13 +239,16 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn create_query_set(this: &GpuDevice, descriptor: &GpuQuerySetDescriptor) -> GpuQuerySet; + pub fn create_query_set( + this: &GpuDevice, + descriptor: &GpuQuerySetDescriptor, + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuRenderBundleEncoder", feature = "GpuRenderBundleEncoderDescriptor", ))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderBundleEncoder)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createRenderBundleEncoder)] #[doc = "The `createRenderBundleEncoder()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createRenderBundleEncoder)"] @@ -254,10 +260,10 @@ extern "C" { pub fn create_render_bundle_encoder( this: &GpuDevice, descriptor: &GpuRenderBundleEncoderDescriptor, - ) -> GpuRenderBundleEncoder; + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuRenderPipeline", feature = "GpuRenderPipelineDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderPipeline)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createRenderPipeline)] #[doc = "The `createRenderPipeline()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createRenderPipeline)"] @@ -269,7 +275,7 @@ extern "C" { pub fn create_render_pipeline( this: &GpuDevice, descriptor: &GpuRenderPipelineDescriptor, - ) -> GpuRenderPipeline; + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuRenderPipelineDescriptor")] # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderPipelineAsync)] @@ -314,7 +320,7 @@ extern "C" { ) -> GpuSampler; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuShaderModule", feature = "GpuShaderModuleDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createShaderModule)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createShaderModule)] #[doc = "The `createShaderModule()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createShaderModule)"] @@ -326,10 +332,10 @@ extern "C" { pub fn create_shader_module( this: &GpuDevice, descriptor: &GpuShaderModuleDescriptor, - ) -> GpuShaderModule; + ) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuTexture", feature = "GpuTextureDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = createTexture)] #[doc = "The `createTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createTexture)"] @@ -338,7 +344,10 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn create_texture(this: &GpuDevice, descriptor: &GpuTextureDescriptor) -> GpuTexture; + pub fn create_texture( + this: &GpuDevice, + descriptor: &GpuTextureDescriptor, + ) -> Result; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = destroy)] #[doc = "The `destroy()` method."] @@ -355,7 +364,7 @@ extern "C" { feature = "GpuExternalTexture", feature = "GpuExternalTextureDescriptor", ))] - # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = importExternalTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUDevice" , js_name = importExternalTexture)] #[doc = "The `importExternalTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/importExternalTexture)"] @@ -367,7 +376,7 @@ extern "C" { pub fn import_external_texture( this: &GpuDevice, descriptor: &GpuExternalTextureDescriptor, - ) -> GpuExternalTexture; + ) -> Result; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = popErrorScope)] #[doc = "The `popErrorScope()` method."] diff --git a/crates/web-sys/src/features/gen_GpuFeatureName.rs b/crates/web-sys/src/features/gen_GpuFeatureName.rs index 223d0d3ccea..82603e3f165 100644 --- a/crates/web-sys/src/features/gen_GpuFeatureName.rs +++ b/crates/web-sys/src/features/gen_GpuFeatureName.rs @@ -14,6 +14,7 @@ pub enum GpuFeatureName { DepthClipControl = "depth-clip-control", Depth32floatStencil8 = "depth32float-stencil8", TextureCompressionBc = "texture-compression-bc", + TextureCompressionBcSliced3d = "texture-compression-bc-sliced-3d", TextureCompressionEtc2 = "texture-compression-etc2", TextureCompressionAstc = "texture-compression-astc", TimestampQuery = "timestamp-query", @@ -22,4 +23,6 @@ pub enum GpuFeatureName { Rg11b10ufloatRenderable = "rg11b10ufloat-renderable", Bgra8unormStorage = "bgra8unorm-storage", Float32Filterable = "float32-filterable", + ClipDistances = "clip-distances", + DualSourceBlending = "dual-source-blending", } diff --git a/crates/web-sys/src/features/gen_GpuPipelineError.rs b/crates/web-sys/src/features/gen_GpuPipelineError.rs index cfd85856d0f..7fe7c408f2b 100644 --- a/crates/web-sys/src/features/gen_GpuPipelineError.rs +++ b/crates/web-sys/src/features/gen_GpuPipelineError.rs @@ -39,5 +39,20 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn new(message: &str, options: &GpuPipelineErrorInit) -> Result; + pub fn new(options: &GpuPipelineErrorInit) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuPipelineErrorInit")] + #[wasm_bindgen(catch, constructor, js_class = "GPUPipelineError")] + #[doc = "The `new GpuPipelineError(..)` constructor, creating a new instance of `GpuPipelineError`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUPipelineError/GPUPipelineError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineError`, `GpuPipelineErrorInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_message( + message: &str, + options: &GpuPipelineErrorInit, + ) -> Result; } diff --git a/crates/web-sys/src/features/gen_GpuQueue.rs b/crates/web-sys/src/features/gen_GpuQueue.rs index f1c02321b81..501aedbd2fa 100644 --- a/crates/web-sys/src/features/gen_GpuQueue.rs +++ b/crates/web-sys/src/features/gen_GpuQueue.rs @@ -43,7 +43,7 @@ extern "C" { feature = "GpuImageCopyExternalImage", feature = "GpuImageCopyTextureTagged", ))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] #[doc = "The `copyExternalImageToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/copyExternalImageToTexture)"] @@ -57,14 +57,14 @@ extern "C" { source: &GpuImageCopyExternalImage, destination: &GpuImageCopyTextureTagged, copy_size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuExtent3dDict", feature = "GpuImageCopyExternalImage", feature = "GpuImageCopyTextureTagged", ))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] #[doc = "The `copyExternalImageToTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/copyExternalImageToTexture)"] @@ -78,7 +78,7 @@ extern "C" { source: &GpuImageCopyExternalImage, destination: &GpuImageCopyTextureTagged, copy_size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = onSubmittedWorkDone)] #[doc = "The `onSubmittedWorkDone()` method."] @@ -103,7 +103,7 @@ extern "C" { pub fn submit(this: &GpuQueue, command_buffers: &::wasm_bindgen::JsValue); #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -117,10 +117,10 @@ extern "C" { buffer: &GpuBuffer, buffer_offset: u32, data: &::js_sys::Object, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -134,10 +134,10 @@ extern "C" { buffer: &GpuBuffer, buffer_offset: f64, data: &::js_sys::Object, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -151,10 +151,10 @@ extern "C" { buffer: &GpuBuffer, buffer_offset: u32, data: &[u8], - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -168,10 +168,10 @@ extern "C" { buffer: &GpuBuffer, buffer_offset: f64, data: &[u8], - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -186,10 +186,10 @@ extern "C" { buffer_offset: u32, data: &::js_sys::Object, data_offset: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -204,10 +204,10 @@ extern "C" { buffer_offset: f64, data: &::js_sys::Object, data_offset: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -222,10 +222,10 @@ extern "C" { buffer_offset: u32, data: &[u8], data_offset: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -240,10 +240,10 @@ extern "C" { buffer_offset: f64, data: &[u8], data_offset: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -258,10 +258,10 @@ extern "C" { buffer_offset: u32, data: &::js_sys::Object, data_offset: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -276,10 +276,10 @@ extern "C" { buffer_offset: f64, data: &::js_sys::Object, data_offset: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -294,10 +294,10 @@ extern "C" { buffer_offset: u32, data: &[u8], data_offset: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -312,10 +312,10 @@ extern "C" { buffer_offset: f64, data: &[u8], data_offset: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -331,10 +331,10 @@ extern "C" { data: &::js_sys::Object, data_offset: u32, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -350,10 +350,10 @@ extern "C" { data: &::js_sys::Object, data_offset: u32, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -369,10 +369,10 @@ extern "C" { data: &[u8], data_offset: u32, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -388,10 +388,10 @@ extern "C" { data: &[u8], data_offset: u32, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -407,10 +407,10 @@ extern "C" { data: &::js_sys::Object, data_offset: f64, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -426,10 +426,10 @@ extern "C" { data: &::js_sys::Object, data_offset: f64, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -445,10 +445,10 @@ extern "C" { data: &[u8], data_offset: f64, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -464,10 +464,10 @@ extern "C" { data: &[u8], data_offset: f64, size: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -483,10 +483,10 @@ extern "C" { data: &::js_sys::Object, data_offset: u32, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -502,10 +502,10 @@ extern "C" { data: &::js_sys::Object, data_offset: u32, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -521,10 +521,10 @@ extern "C" { data: &[u8], data_offset: u32, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -540,10 +540,10 @@ extern "C" { data: &[u8], data_offset: u32, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -559,10 +559,10 @@ extern "C" { data: &::js_sys::Object, data_offset: f64, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -578,10 +578,10 @@ extern "C" { data: &::js_sys::Object, data_offset: f64, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -597,10 +597,10 @@ extern "C" { data: &[u8], data_offset: f64, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBuffer")] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] #[doc = "The `writeBuffer()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] @@ -616,10 +616,10 @@ extern "C" { data: &[u8], data_offset: f64, size: f64, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuImageCopyTexture", feature = "GpuImageDataLayout",))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeTexture)] #[doc = "The `writeTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] @@ -634,10 +634,10 @@ extern "C" { data: &::js_sys::Object, data_layout: &GpuImageDataLayout, size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuImageCopyTexture", feature = "GpuImageDataLayout",))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeTexture)] #[doc = "The `writeTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] @@ -652,14 +652,14 @@ extern "C" { data: &[u8], data_layout: &GpuImageDataLayout, size: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuExtent3dDict", feature = "GpuImageCopyTexture", feature = "GpuImageDataLayout", ))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeTexture)] #[doc = "The `writeTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] @@ -674,14 +674,14 @@ extern "C" { data: &::js_sys::Object, data_layout: &GpuImageDataLayout, size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(all( feature = "GpuExtent3dDict", feature = "GpuImageCopyTexture", feature = "GpuImageDataLayout", ))] - # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUQueue" , js_name = writeTexture)] #[doc = "The `writeTexture()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] @@ -696,5 +696,5 @@ extern "C" { data: &[u8], data_layout: &GpuImageDataLayout, size: &GpuExtent3dDict, - ); + ) -> Result<(), JsValue>; } diff --git a/crates/web-sys/src/features/gen_GpuRenderBundleEncoder.rs b/crates/web-sys/src/features/gen_GpuRenderBundleEncoder.rs index 9aaecf3d44d..355f86931f8 100644 --- a/crates/web-sys/src/features/gen_GpuRenderBundleEncoder.rs +++ b/crates/web-sys/src/features/gen_GpuRenderBundleEncoder.rs @@ -100,7 +100,7 @@ extern "C" { ); #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] @@ -116,10 +116,10 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: u32, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] @@ -135,7 +135,7 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: f64, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = insertDebugMarker)] #[doc = "The `insertDebugMarker()` method."] diff --git a/crates/web-sys/src/features/gen_GpuRenderPassEncoder.rs b/crates/web-sys/src/features/gen_GpuRenderPassEncoder.rs index a708d6978f9..131609d43e0 100644 --- a/crates/web-sys/src/features/gen_GpuRenderPassEncoder.rs +++ b/crates/web-sys/src/features/gen_GpuRenderPassEncoder.rs @@ -83,7 +83,7 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn execute_bundles(this: &GpuRenderPassEncoder, bundles: &::wasm_bindgen::JsValue); #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] #[doc = "The `setBlendConstant()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBlendConstant)"] @@ -95,10 +95,10 @@ extern "C" { pub fn set_blend_constant_with_f64_sequence( this: &GpuRenderPassEncoder, color: &::wasm_bindgen::JsValue, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuColorDict")] - # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] #[doc = "The `setBlendConstant()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBlendConstant)"] @@ -110,7 +110,7 @@ extern "C" { pub fn set_blend_constant_with_gpu_color_dict( this: &GpuRenderPassEncoder, color: &GpuColorDict, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setScissorRect)] #[doc = "The `setScissorRect()` method."] @@ -187,7 +187,7 @@ extern "C" { ); #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] @@ -203,10 +203,10 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: u32, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuBindGroup")] - # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + # [wasm_bindgen (catch , method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] #[doc = "The `setBindGroup()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] @@ -222,7 +222,7 @@ extern "C" { dynamic_offsets_data: &[u32], dynamic_offsets_data_start: f64, dynamic_offsets_data_length: u32, - ); + ) -> Result<(), JsValue>; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = insertDebugMarker)] #[doc = "The `insertDebugMarker()` method."] diff --git a/crates/web-sys/src/features/gen_GpuTexture.rs b/crates/web-sys/src/features/gen_GpuTexture.rs index 0e7fc68ed8b..d1d72cd0b65 100644 --- a/crates/web-sys/src/features/gen_GpuTexture.rs +++ b/crates/web-sys/src/features/gen_GpuTexture.rs @@ -130,7 +130,7 @@ extern "C" { pub fn set_label(this: &GpuTexture, value: &str); #[cfg(web_sys_unstable_apis)] #[cfg(feature = "GpuTextureView")] - # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = createView)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUTexture" , js_name = createView)] #[doc = "The `createView()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/createView)"] @@ -139,10 +139,10 @@ extern "C" { #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn create_view(this: &GpuTexture) -> GpuTextureView; + pub fn create_view(this: &GpuTexture) -> Result; #[cfg(web_sys_unstable_apis)] #[cfg(all(feature = "GpuTextureView", feature = "GpuTextureViewDescriptor",))] - # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = createView)] + # [wasm_bindgen (catch , method , structural , js_class = "GPUTexture" , js_name = createView)] #[doc = "The `createView()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/createView)"] @@ -154,7 +154,7 @@ extern "C" { pub fn create_view_with_descriptor( this: &GpuTexture, descriptor: &GpuTextureViewDescriptor, - ) -> GpuTextureView; + ) -> Result; #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = destroy)] #[doc = "The `destroy()` method."] diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index cf01e4d5763..d6091590a63 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -3211,6 +3211,20 @@ mod gen_GpuCanvasContext; #[allow(unused_imports)] pub use gen_GpuCanvasContext::*; +#[cfg(feature = "GpuCanvasToneMapping")] +#[allow(non_snake_case)] +mod gen_GpuCanvasToneMapping; +#[cfg(feature = "GpuCanvasToneMapping")] +#[allow(unused_imports)] +pub use gen_GpuCanvasToneMapping::*; + +#[cfg(feature = "GpuCanvasToneMappingMode")] +#[allow(non_snake_case)] +mod gen_GpuCanvasToneMappingMode; +#[cfg(feature = "GpuCanvasToneMappingMode")] +#[allow(unused_imports)] +pub use gen_GpuCanvasToneMappingMode::*; + #[cfg(feature = "GpuColorDict")] #[allow(non_snake_case)] mod gen_GpuColorDict; diff --git a/crates/web-sys/webidls/unstable/WebGPU.webidl b/crates/web-sys/webidls/unstable/WebGPU.webidl index 32397b6e27b..96fa115992e 100644 --- a/crates/web-sys/webidls/unstable/WebGPU.webidl +++ b/crates/web-sys/webidls/unstable/WebGPU.webidl @@ -6,7 +6,7 @@ dictionary GPUObjectDescriptorBase { USVString label = ""; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSupportedLimits { readonly attribute unsigned long maxTextureDimension1D; readonly attribute unsigned long maxTextureDimension2D; @@ -42,17 +42,17 @@ interface GPUSupportedLimits { readonly attribute unsigned long maxComputeWorkgroupsPerDimension; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSupportedFeatures { readonly setlike; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface WGSLLanguageFeatures { readonly setlike; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUAdapterInfo { readonly attribute DOMString vendor; readonly attribute DOMString architecture; @@ -66,7 +66,7 @@ interface mixin NavigatorGPU { Navigator includes NavigatorGPU; WorkerNavigator includes NavigatorGPU; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPU { Promise requestAdapter(optional GPURequestAdapterOptions options = {}); GPUTextureFormat getPreferredCanvasFormat(); @@ -83,13 +83,15 @@ enum GPUPowerPreference { "high-performance", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUAdapter { [SameObject] readonly attribute GPUSupportedFeatures features; [SameObject] readonly attribute GPUSupportedLimits limits; + [SameObject] readonly attribute GPUAdapterInfo info; readonly attribute boolean isFallbackAdapter; Promise requestDevice(optional GPUDeviceDescriptor descriptor = {}); + [RustDeprecated] Promise requestAdapterInfo(); }; @@ -104,6 +106,7 @@ enum GPUFeatureName { "depth-clip-control", "depth32float-stencil8", "texture-compression-bc", + "texture-compression-bc-sliced-3d", "texture-compression-etc2", "texture-compression-astc", "timestamp-query", @@ -112,9 +115,11 @@ enum GPUFeatureName { "rg11b10ufloat-renderable", "bgra8unorm-storage", "float32-filterable", + "clip-distances", + "dual-source-blending", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUDevice : EventTarget { [SameObject] readonly attribute GPUSupportedFeatures features; [SameObject] readonly attribute GPUSupportedLimits limits; @@ -123,29 +128,37 @@ interface GPUDevice : EventTarget { undefined destroy(); + [Throws] GPUBuffer createBuffer(GPUBufferDescriptor descriptor); + [Throws] GPUTexture createTexture(GPUTextureDescriptor descriptor); GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {}); + [Throws] GPUExternalTexture importExternalTexture(GPUExternalTextureDescriptor descriptor); + [Throws] GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor); GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor); + [Throws] GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); + [Throws] GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor); Promise createComputePipelineAsync(GPUComputePipelineDescriptor descriptor); Promise createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor); GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); + [Throws] GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); + [Throws] GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor); }; GPUDevice includes GPUObjectBase; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBuffer { readonly attribute GPUSize64Out size; readonly attribute GPUFlagsConstant usage; @@ -153,6 +166,7 @@ interface GPUBuffer { readonly attribute GPUBufferMapState mapState; Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); + [Throws] ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size); undefined unmap(); @@ -174,7 +188,7 @@ dictionary GPUBufferDescriptor }; typedef [EnforceRange] unsigned long GPUBufferUsageFlags; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUBufferUsage { const GPUFlagsConstant MAP_READ = 0x0001; const GPUFlagsConstant MAP_WRITE = 0x0002; @@ -189,14 +203,15 @@ namespace GPUBufferUsage { }; typedef [EnforceRange] unsigned long GPUMapModeFlags; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUMapMode { const GPUFlagsConstant READ = 0x0001; const GPUFlagsConstant WRITE = 0x0002; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUTexture { + [Throws] GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {}); undefined destroy(); @@ -230,7 +245,7 @@ enum GPUTextureDimension { }; typedef [EnforceRange] unsigned long GPUTextureUsageFlags; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUTextureUsage { const GPUFlagsConstant COPY_SRC = 0x01; const GPUFlagsConstant COPY_DST = 0x02; @@ -239,7 +254,7 @@ namespace GPUTextureUsage { const GPUFlagsConstant RENDER_ATTACHMENT = 0x10; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUTextureView { }; GPUTextureView includes GPUObjectBase; @@ -391,7 +406,7 @@ enum GPUTextureFormat { "astc-12x12-unorm-srgb", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUExternalTexture { }; GPUExternalTexture includes GPUObjectBase; @@ -402,7 +417,7 @@ dictionary GPUExternalTextureDescriptor PredefinedColorSpace colorSpace = "srgb"; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSampler { }; GPUSampler includes GPUObjectBase; @@ -448,7 +463,7 @@ enum GPUCompareFunction { "always", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBindGroupLayout { }; GPUBindGroupLayout includes GPUObjectBase; @@ -470,7 +485,7 @@ dictionary GPUBindGroupLayoutEntry { }; typedef [EnforceRange] unsigned long GPUShaderStageFlags; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUShaderStage { const GPUFlagsConstant VERTEX = 0x1; const GPUFlagsConstant FRAGMENT = 0x2; @@ -528,7 +543,7 @@ dictionary GPUStorageTextureBindingLayout { dictionary GPUExternalTextureBindingLayout { }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBindGroup { }; GPUBindGroup includes GPUObjectBase; @@ -552,7 +567,7 @@ dictionary GPUBufferBinding { GPUSize64 size; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUPipelineLayout { }; GPUPipelineLayout includes GPUObjectBase; @@ -562,7 +577,7 @@ dictionary GPUPipelineLayoutDescriptor required sequence bindGroupLayouts; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUShaderModule { Promise getCompilationInfo(); }; @@ -586,7 +601,7 @@ enum GPUCompilationMessageType { "info", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), Serializable, SecureContext] +[Exposed=(Window, Worker), Serializable, SecureContext] interface GPUCompilationMessage { readonly attribute DOMString message; readonly attribute GPUCompilationMessageType type; @@ -596,14 +611,14 @@ interface GPUCompilationMessage { readonly attribute unsigned long long length; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), Serializable, SecureContext] +[Exposed=(Window, Worker), Serializable, SecureContext] interface GPUCompilationInfo { readonly attribute FrozenArray messages; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext, Serializable] +[Exposed=(Window, Worker), SecureContext, Serializable] interface GPUPipelineError : DOMException { - constructor(DOMString message, GPUPipelineErrorInit options); + constructor(optional DOMString message = "", GPUPipelineErrorInit options); readonly attribute GPUPipelineErrorReason reason; }; @@ -637,7 +652,7 @@ dictionary GPUProgrammableStage { typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled. -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUComputePipeline { }; GPUComputePipeline includes GPUObjectBase; @@ -648,7 +663,7 @@ dictionary GPUComputePipelineDescriptor required GPUProgrammableStage compute; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderPipeline { }; GPURenderPipeline includes GPUObjectBase; @@ -716,7 +731,7 @@ dictionary GPUBlendState { }; typedef [EnforceRange] unsigned long GPUColorWriteFlags; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUColorWrite { const GPUFlagsConstant RED = 0x1; const GPUFlagsConstant GREEN = 0x2; @@ -745,6 +760,10 @@ enum GPUBlendFactor { "src-alpha-saturated", "constant", "one-minus-constant", + "src1", + "one-minus-src1", + "src1-alpha", + "one-minus-src1-alpha", }; enum GPUBlendOperation { @@ -890,7 +909,7 @@ dictionary GPUImageCopyExternalImage { boolean flipY = false; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCommandBuffer { }; GPUCommandBuffer includes GPUObjectBase; @@ -902,8 +921,9 @@ dictionary GPUCommandBufferDescriptor interface mixin GPUCommandsMixin { }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCommandEncoder { + [Throws] GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); @@ -914,16 +934,19 @@ interface GPUCommandEncoder { GPUSize64 destinationOffset, GPUSize64 size); + [Throws] undefined copyBufferToTexture( GPUImageCopyBuffer source, GPUImageCopyTexture destination, GPUExtent3D copySize); + [Throws] undefined copyTextureToBuffer( GPUImageCopyTexture source, GPUImageCopyBuffer destination, GPUExtent3D copySize); + [Throws] undefined copyTextureToTexture( GPUImageCopyTexture source, GPUImageCopyTexture destination, @@ -955,6 +978,7 @@ interface mixin GPUBindingCommandsMixin { undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup, optional sequence dynamicOffsets = []); + [Throws] undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup, Uint32Array dynamicOffsetsData, GPUSize64 dynamicOffsetsDataStart, @@ -967,7 +991,7 @@ interface mixin GPUDebugCommandsMixin { undefined insertDebugMarker(USVString markerLabel); }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUComputePassEncoder { undefined setPipeline(GPUComputePipeline pipeline); undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1); @@ -991,7 +1015,7 @@ dictionary GPUComputePassDescriptor GPUComputePassTimestampWrites timestampWrites; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderPassEncoder { undefined setViewport(float x, float y, float width, float height, @@ -1000,6 +1024,7 @@ interface GPURenderPassEncoder { undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, GPUIntegerCoordinate width, GPUIntegerCoordinate height); + [Throws] undefined setBlendConstant(GPUColor color); undefined setStencilReference(GPUStencilValue reference); @@ -1088,7 +1113,7 @@ interface mixin GPURenderCommandsMixin { undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderBundle { }; GPURenderBundle includes GPUObjectBase; @@ -1097,7 +1122,7 @@ dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase { }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderBundleEncoder { GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {}); }; @@ -1117,25 +1142,28 @@ dictionary GPUQueueDescriptor : GPUObjectDescriptorBase { }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUQueue { undefined submit(sequence commandBuffers); Promise onSubmittedWorkDone(); + [Throws] undefined writeBuffer( GPUBuffer buffer, GPUSize64 bufferOffset, - [AllowShared] BufferSource data, + AllowSharedBufferSource data, optional GPUSize64 dataOffset = 0, optional GPUSize64 size); + [Throws] undefined writeTexture( GPUImageCopyTexture destination, - [AllowShared] BufferSource data, + AllowSharedBufferSource data, GPUImageDataLayout dataLayout, GPUExtent3D size); + [Throws] undefined copyExternalImageToTexture( GPUImageCopyExternalImage source, GPUImageCopyTextureTagged destination, @@ -1143,7 +1171,7 @@ interface GPUQueue { }; GPUQueue includes GPUObjectBase; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUQuerySet { undefined destroy(); @@ -1163,13 +1191,15 @@ enum GPUQueryType { "timestamp", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCanvasContext { readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; + [Throws] undefined configure(GPUCanvasConfiguration configuration); undefined unconfigure(); + [Throws] GPUTexture getCurrentTexture(); }; @@ -1178,12 +1208,22 @@ enum GPUCanvasAlphaMode { "premultiplied", }; +enum GPUCanvasToneMappingMode { + "standard", + "extended", +}; + +dictionary GPUCanvasToneMapping { + GPUCanvasToneMappingMode mode = "standard"; +}; + dictionary GPUCanvasConfiguration { required GPUDevice device; required GPUTextureFormat format; GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT sequence viewFormats = []; PredefinedColorSpace colorSpace = "srgb"; + GPUCanvasToneMapping toneMapping = {}; GPUCanvasAlphaMode alphaMode = "opaque"; }; @@ -1192,7 +1232,7 @@ enum GPUDeviceLostReason { "destroyed", }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUDeviceLostInfo { readonly attribute GPUDeviceLostReason reason; readonly attribute DOMString message; @@ -1202,24 +1242,24 @@ partial interface GPUDevice { readonly attribute Promise lost; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUError { readonly attribute DOMString message; }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUValidationError : GPUError { constructor(DOMString message); }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUOutOfMemoryError : GPUError { constructor(DOMString message); }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUInternalError : GPUError { constructor(DOMString message); @@ -1236,7 +1276,7 @@ partial interface GPUDevice { Promise popErrorScope(); }; -[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUUncapturedErrorEvent : Event { constructor( DOMString type, @@ -1250,7 +1290,7 @@ dictionary GPUUncapturedErrorEventInit : EventInit { }; partial interface GPUDevice { - [Exposed=(Window, DedicatedWorker, ServiceWorker)] + [Exposed=(Window, Worker)] attribute EventHandler onuncapturederror; }; diff --git a/crates/webidl/src/idl_type.rs b/crates/webidl/src/idl_type.rs index 674fad0d447..750649f65c9 100644 --- a/crates/webidl/src/idl_type.rs +++ b/crates/webidl/src/idl_type.rs @@ -100,6 +100,10 @@ pub(crate) enum IdentifierType<'a> { }, // DOMTimeStamp UnsignedLongLong, + // AllowSharedBufferSource + BufferSource { + immutable: bool, + }, } pub(crate) trait ToIdlType<'a> { @@ -336,6 +340,8 @@ impl<'a> ToIdlType<'a> for Identifier<'a> { let ty = if self.0 == "DOMTimeStamp" { // https://heycam.github.io/webidl/#DOMTimeStamp IdentifierType::UnsignedLongLong + } else if self.0 == "AllowSharedBufferSource" { + IdentifierType::BufferSource { immutable: false } } else if let Some(idl_type) = record.typedefs.get(&self.0) { return idl_type.to_idl_type(record); } else if record.interfaces.contains_key(self.0) { @@ -525,6 +531,10 @@ impl<'a> IdlType<'a> { IdentifierType::UnsignedLongLong => { IdlType::UnsignedLongLong.push_snake_case_name(dst) } + IdentifierType::BufferSource { immutable } => IdlType::BufferSource { + immutable: *immutable, + } + .push_snake_case_name(dst), }, } } @@ -761,29 +771,38 @@ impl<'a> IdlType<'a> { ], IdlType::LongLong => vec![IdlType::Long, IdlType::Double], IdlType::UnsignedLongLong => vec![IdlType::UnsignedLong, IdlType::Double], - IdlType::Identifier { + idl_type @ IdlType::Identifier { name: identifier, - ty: + ty, + } => { + match ty { IdentifierType::CallbackInterface { name, single_function: true, - }, - } => { - // According to the webidl spec [1] single-function callback - // interfaces can also be replaced in arguments with simply a - // single callable function, which we map to a `Callback`. - // - // [1]: https://heycam.github.io/webidl/#es-user-objects - vec![ - IdlType::id(identifier, IdentifierType::Callback), - IdlType::id( - identifier, - IdentifierType::CallbackInterface { - name, - single_function: false, - }, - ), - ] + } => { + // According to the webidl spec [1] single-function callback + // interfaces can also be replaced in arguments with simply a + // single callable function, which we map to a `Callback`. + // + // [1]: https://heycam.github.io/webidl/#es-user-objects + vec![ + IdlType::id(identifier, IdentifierType::Callback), + IdlType::id( + identifier, + IdentifierType::CallbackInterface { + name, + single_function: false, + }, + ), + ] + } + IdentifierType::UnsignedLongLong => IdlType::UnsignedLongLong.flatten(attrs), + IdentifierType::BufferSource { immutable } => IdlType::BufferSource { + immutable: *immutable, + } + .flatten(attrs), + _ => vec![idl_type.clone()], + } } idl_type => vec![idl_type.clone()], } @@ -826,6 +845,10 @@ impl<'a> IdentifierType<'a> { Ok(Some(ident_ty(rust_ident(camel_case_ident(name).as_str())))) } IdentifierType::UnsignedLongLong => IdlType::UnsignedLongLong.to_syn_type(pos), + IdentifierType::BufferSource { immutable } => IdlType::BufferSource { + immutable: *immutable, + } + .to_syn_type(pos), } } } diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 6f40f64e6d1..c103def4165 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -237,24 +237,36 @@ impl<'src> FirstPassRecord<'src> { // undefined. let mut signatures = Vec::new(); for signature in data.signatures.iter() { - let mut idl_args = Vec::with_capacity(signature.args.len()); - for (i, arg) in signature.args.iter().enumerate() { - if arg.optional { - assert!( - signature.args[i..] + fn pass<'src>( + this: &FirstPassRecord<'src>, + id: &'src OperationId<'_>, + signatures: &mut Vec<(&Signature<'src>, Vec>>)>, + signature: &'src Signature<'_>, + mut idl_args: Vec>>, + ) { + for (i, arg) in signature.args.iter().enumerate().skip(idl_args.len()) { + if arg.optional { + if signature.args[i..] .iter() - .all(|arg| arg.optional || arg.variadic), - "Not optional or variadic argument after optional argument: {:?}", - signature.args, - ); - signatures.push((signature, idl_args.clone())); - } + .all(|arg| arg.optional || arg.variadic) + { + signatures.push((signature, idl_args.clone())); + } else if signature.args.get(i + 1).is_some() { + let mut idl_args = idl_args.clone(); + idl_args.push(None); + pass(this, id, signatures, signature, idl_args) + } + } - let idl_type = arg.ty.to_idl_type(self); - let idl_type = self.maybe_adjust(idl_type, id); - idl_args.push(idl_type); + let idl_type = arg.ty.to_idl_type(this); + let idl_type = this.maybe_adjust(idl_type, id); + idl_args.push(Some(idl_type)); + } + signatures.push((signature, idl_args)); } - signatures.push((signature, idl_args)); + + let idl_args = Vec::with_capacity(signature.args.len()); + pass(self, id, &mut signatures, signature, idl_args); } // Next expand all the signatures in `data` into all signatures that @@ -263,7 +275,7 @@ impl<'src> FirstPassRecord<'src> { #[derive(Clone)] struct ExpandedSig<'a> { orig: &'a Signature<'a>, - args: Vec>, + args: Vec>>, } let mut actual_signatures = Vec::new(); @@ -280,30 +292,34 @@ impl<'src> FirstPassRecord<'src> { for (i, idl_type) in idl_args.iter().enumerate() { // small sanity check assert!(start < actual_signatures.len()); - for sig in actual_signatures[start..].iter() { - assert_eq!(sig.args.len(), i); - } // The first element of the flattened type gets pushed directly // in-place, but all other flattened types will cause new // signatures to be created. let cur = actual_signatures.len(); - for (j, idl_type) in idl_type - .flatten(signature.attrs.as_ref()) - .into_iter() - .enumerate() - { - for k in start..cur { - if j == 0 { - actual_signatures[k].args.push(idl_type.clone()); - } else { - let mut sig = actual_signatures[k].clone(); - assert_eq!(sig.args.len(), i + 1); - sig.args.truncate(i); - sig.args.push(idl_type.clone()); - actual_signatures.push(sig); + + if let Some(idl_type) = idl_type { + for (j, idl_type) in idl_type + .flatten(signature.attrs.as_ref()) + .into_iter() + .enumerate() + { + for k in start..cur { + if j == 0 { + actual_signatures[k].args.push(Some(idl_type.clone())); + } else { + let mut sig = actual_signatures[k].clone(); + assert_eq!(sig.args.len(), i + 1); + sig.args.truncate(i); + sig.args.push(Some(idl_type.clone())); + actual_signatures.push(sig); + } } } + } else { + for signature in actual_signatures.iter_mut().take(cur).skip(start) { + signature.args.push(None); + } } } } @@ -357,7 +373,12 @@ impl<'src> FirstPassRecord<'src> { let mut rust_name = snake_case_ident(js_name); let mut first = true; - for (i, arg) in signature.args.iter().enumerate() { + for (i, arg) in signature + .args + .iter() + .enumerate() + .filter_map(|(i, ty)| ty.as_ref().map(|ty| (i, ty))) + { // Find out if any other known signature either has the same // name for this argument or a different type for this argument. let mut any_same_name = false; @@ -370,7 +391,7 @@ impl<'src> FirstPassRecord<'src> { { any_same_name = true; } - if let Some(other) = other.args.get(i) { + if let Some(Some(other)) = other.args.get(i) { if other != arg { any_different_type = true; any_different = true; @@ -458,21 +479,22 @@ impl<'src> FirstPassRecord<'src> { Some(output) } - let arguments = idl_arguments( - signature - .args - .iter() - .zip(&signature.orig.args) - .map(|(idl_type, orig_arg)| (orig_arg.name.to_string(), idl_type)), - ); + let arguments = + idl_arguments(signature.args.iter().zip(&signature.orig.args).filter_map( + |(idl_type, orig_arg)| { + idl_type + .as_ref() + .map(|idl_type| (orig_arg.name.to_string(), idl_type)) + }, + )); // Stable types can have methods that have unstable argument types. // If any of the arguments types are `unstable` then this method is downgraded // to be unstable. - let has_unstable_args = signature - .args - .iter() - .any(|arg| is_idl_type_unstable(arg, unstable_types)); + let has_unstable_args = signature.args.iter().any(|arg| { + arg.as_ref() + .is_some_and(|arg| is_idl_type_unstable(arg, unstable_types)) + }); let unstable = unstable || data.stability.is_unstable() || has_unstable_args; @@ -508,14 +530,18 @@ impl<'src> FirstPassRecord<'src> { if !variadic { continue; } - let last_idl_type = &signature.args[signature.args.len() - 1]; + let last_idl_type = signature.args[signature.args.len() - 1].as_ref().unwrap(); let last_name = signature.orig.args[signature.args.len() - 1].name; for i in 0..=MAX_VARIADIC_ARGUMENTS_COUNT { let arguments = idl_arguments( signature.args[..signature.args.len() - 1] .iter() .zip(&signature.orig.args) - .map(|(idl_type, orig_arg)| (orig_arg.name.to_string(), idl_type)) + .filter_map(|(idl_type, orig_arg)| { + idl_type + .as_ref() + .map(|idl_type| (orig_arg.name.to_string(), idl_type)) + }) .chain((1..=i).map(|j| (format!("{}_{}", last_name, j), last_idl_type))), ); @@ -715,7 +741,11 @@ fn flag_slices_immutable(ty: &mut IdlType) { | IdlType::Float32Array { immutable } | IdlType::Float64Array { immutable } | IdlType::ArrayBufferView { immutable } - | IdlType::BufferSource { immutable } => *immutable = true, + | IdlType::BufferSource { immutable } + | IdlType::Identifier { + ty: IdentifierType::BufferSource { immutable }, + .. + } => *immutable = true, IdlType::Nullable(item) => flag_slices_immutable(item), IdlType::FrozenArray(item) => flag_slices_immutable(item), IdlType::Sequence(item) => flag_slices_immutable(item),