Skip to content

Commit

Permalink
Account for [AllowShared] and improve setters generated from interf…
Browse files Browse the repository at this point in the history
…ace attributes (#4156)
  • Loading branch information
daxpedda authored Oct 9, 2024
1 parent e575aba commit 95bf437
Show file tree
Hide file tree
Showing 68 changed files with 8,167 additions and 364 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
* Added `unsupported` crate to `wasm_bindgen_test(unsupported = test)` as a way of running tests on non-Wasm targets as well.
[#4150](https://github.com/rustwasm/wasm-bindgen/pull/4150)

* Added additional bindings for methods taking buffer view types (e.g. `&[u8]`) with corresponding JS types (e.g. `Uint8Array`).
[#4156](https://github.com/rustwasm/wasm-bindgen/pull/4156)

* Added additional bindings for setters from WebIDL interface attributes with applicaple parameter types of just `JsValue`.
[#4156](https://github.com/rustwasm/wasm-bindgen/pull/4156)

### Changed

* Implicitly enable reference type and multivalue transformations if the module already makes use of the corresponding target features.
Expand All @@ -49,6 +55,9 @@
* Updated the WebGPU API to the current draft as of 2024-10-07.
[#4145](https://github.com/rustwasm/wasm-bindgen/pull/4145)

* Deprecated generated setters from WebIDL interface attribute taking `JsValue` in favor of newer bindings with specific parameter types.
[#4156](https://github.com/rustwasm/wasm-bindgen/pull/4156)

### Fixed

* Fixed linked modules emitting snippet files when not using `--split-linked-modules`.
Expand Down Expand Up @@ -88,6 +97,9 @@
* Fixed string enums not generating TypeScript types.
[#4147](https://github.com/rustwasm/wasm-bindgen/pull/4147)

* Bindings that take buffer view types (e.g. `&[u8]`) as parameters will now correctly return a `Result` when they might not support a backing `SharedArrayBuffer`. This only applies to new and unstable APIs, which won't cause a breaking in the API.
[#4156](https://github.com/rustwasm/wasm-bindgen/pull/4156)

--------------------------------------------------------------------------------

## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)
Expand Down
37 changes: 37 additions & 0 deletions crates/web-sys/src/features/gen_AnalyserNode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,62 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_byte_frequency_data(this: &AnalyserNode, array: &mut [u8]);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getByteFrequencyData)]
#[doc = "The `getByteFrequencyData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_byte_frequency_data_with_u8_array(this: &AnalyserNode, array: &::js_sys::Uint8Array);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getByteTimeDomainData)]
#[doc = "The `getByteTimeDomainData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_byte_time_domain_data(this: &AnalyserNode, array: &mut [u8]);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getByteTimeDomainData)]
#[doc = "The `getByteTimeDomainData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_byte_time_domain_data_with_u8_array(
this: &AnalyserNode,
array: &::js_sys::Uint8Array,
);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getFloatFrequencyData)]
#[doc = "The `getFloatFrequencyData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatFrequencyData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_float_frequency_data(this: &AnalyserNode, array: &mut [f32]);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getFloatFrequencyData)]
#[doc = "The `getFloatFrequencyData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatFrequencyData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_float_frequency_data_with_f32_array(
this: &AnalyserNode,
array: &::js_sys::Float32Array,
);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getFloatTimeDomainData)]
#[doc = "The `getFloatTimeDomainData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatTimeDomainData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_float_time_domain_data(this: &AnalyserNode, array: &mut [f32]);
# [wasm_bindgen (method , structural , js_class = "AnalyserNode" , js_name = getFloatTimeDomainData)]
#[doc = "The `getFloatTimeDomainData()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatTimeDomainData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AnalyserNode`*"]
pub fn get_float_time_domain_data_with_f32_array(
this: &AnalyserNode,
array: &::js_sys::Float32Array,
);
}
46 changes: 46 additions & 0 deletions crates/web-sys/src/features/gen_AudioBuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,35 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyFromChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_from_channel_with_f32_array(
this: &AudioBuffer,
destination: &::js_sys::Float32Array,
channel_number: i32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = copyFromChannel)]
#[doc = "The `copyFromChannel()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyFromChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_from_channel_with_start_in_channel(
this: &AudioBuffer,
destination: &mut [f32],
channel_number: i32,
start_in_channel: u32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = copyFromChannel)]
#[doc = "The `copyFromChannel()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyFromChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_from_channel_with_f32_array_and_start_in_channel(
this: &AudioBuffer,
destination: &::js_sys::Float32Array,
channel_number: i32,
start_in_channel: u32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = copyToChannel)]
#[doc = "The `copyToChannel()` method."]
#[doc = ""]
Expand All @@ -88,12 +111,35 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyToChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_to_channel_with_f32_array(
this: &AudioBuffer,
source: &::js_sys::Float32Array,
channel_number: i32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = copyToChannel)]
#[doc = "The `copyToChannel()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyToChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_to_channel_with_start_in_channel(
this: &AudioBuffer,
source: &[f32],
channel_number: i32,
start_in_channel: u32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = copyToChannel)]
#[doc = "The `copyToChannel()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/copyToChannel)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
pub fn copy_to_channel_with_f32_array_and_start_in_channel(
this: &AudioBuffer,
source: &::js_sys::Float32Array,
channel_number: i32,
start_in_channel: u32,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioBuffer" , js_name = getChannelData)]
#[doc = "The `getChannelData()` method."]
#[doc = ""]
Expand Down
75 changes: 75 additions & 0 deletions crates/web-sys/src/features/gen_AudioContext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,42 @@ extern "C" {
real: &mut [f32],
imag: &mut [f32],
) -> Result<PeriodicWave, JsValue>;
#[cfg(feature = "PeriodicWave")]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`*"]
pub fn create_periodic_wave_with_f32_array_and_f32_slice(
this: &AudioContext,
real: &::js_sys::Float32Array,
imag: &mut [f32],
) -> Result<PeriodicWave, JsValue>;
#[cfg(feature = "PeriodicWave")]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`*"]
pub fn create_periodic_wave_with_f32_slice_and_f32_array(
this: &AudioContext,
real: &mut [f32],
imag: &::js_sys::Float32Array,
) -> Result<PeriodicWave, JsValue>;
#[cfg(feature = "PeriodicWave")]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`*"]
pub fn create_periodic_wave_with_f32_array_and_f32_array(
this: &AudioContext,
real: &::js_sys::Float32Array,
imag: &::js_sys::Float32Array,
) -> Result<PeriodicWave, JsValue>;
#[cfg(all(feature = "PeriodicWave", feature = "PeriodicWaveConstraints",))]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
Expand All @@ -375,6 +411,45 @@ extern "C" {
imag: &mut [f32],
constraints: &PeriodicWaveConstraints,
) -> Result<PeriodicWave, JsValue>;
#[cfg(all(feature = "PeriodicWave", feature = "PeriodicWaveConstraints",))]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`, `PeriodicWaveConstraints`*"]
pub fn create_periodic_wave_with_f32_array_and_f32_slice_and_constraints(
this: &AudioContext,
real: &::js_sys::Float32Array,
imag: &mut [f32],
constraints: &PeriodicWaveConstraints,
) -> Result<PeriodicWave, JsValue>;
#[cfg(all(feature = "PeriodicWave", feature = "PeriodicWaveConstraints",))]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`, `PeriodicWaveConstraints`*"]
pub fn create_periodic_wave_with_f32_slice_and_f32_array_and_constraints(
this: &AudioContext,
real: &mut [f32],
imag: &::js_sys::Float32Array,
constraints: &PeriodicWaveConstraints,
) -> Result<PeriodicWave, JsValue>;
#[cfg(all(feature = "PeriodicWave", feature = "PeriodicWaveConstraints",))]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createPeriodicWave)]
#[doc = "The `createPeriodicWave()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioContext`, `PeriodicWave`, `PeriodicWaveConstraints`*"]
pub fn create_periodic_wave_with_f32_array_and_f32_array_and_constraints(
this: &AudioContext,
real: &::js_sys::Float32Array,
imag: &::js_sys::Float32Array,
constraints: &PeriodicWaveConstraints,
) -> Result<PeriodicWave, JsValue>;
#[cfg(feature = "ScriptProcessorNode")]
# [wasm_bindgen (catch , method , structural , js_class = "AudioContext" , js_name = createScriptProcessor)]
#[doc = "The `createScriptProcessor()` method."]
Expand Down
18 changes: 17 additions & 1 deletion crates/web-sys/src/features/gen_AudioData.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,25 @@ 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 copy_to_with_u8_array(
pub fn copy_to_with_u8_slice(
this: &AudioData,
destination: &mut [u8],
options: &AudioDataCopyToOptions,
) -> Result<(), JsValue>;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "AudioDataCopyToOptions")]
# [wasm_bindgen (catch , method , structural , js_class = "AudioData" , js_name = copyTo)]
#[doc = "The `copyTo()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/copyTo)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioData`, `AudioDataCopyToOptions`*"]
#[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 copy_to_with_u8_array(
this: &AudioData,
destination: &::js_sys::Uint8Array,
options: &AudioDataCopyToOptions,
) -> Result<(), JsValue>;
}
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_AudioParam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,16 @@ extern "C" {
start_time: f64,
duration: f64,
) -> Result<AudioParam, JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "AudioParam" , js_name = setValueCurveAtTime)]
#[doc = "The `setValueCurveAtTime()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/setValueCurveAtTime)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AudioParam`*"]
pub fn set_value_curve_at_time_with_f32_array(
this: &AudioParam,
values: &::js_sys::Float32Array,
start_time: f64,
duration: f64,
) -> Result<AudioParam, JsValue>;
}
Loading

0 comments on commit 95bf437

Please sign in to comment.