Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Generate getters for all WebIDL dictionary types and deprecate builder-pattern style setters #3993

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
* Add bindings for `RTCRtpReceiver.jitterBufferTarget`.
[#3968](https://github.com/rustwasm/wasm-bindgen/pull/3968)

* Generate getters for all WebIDL dictionary types.
[#3993](https://github.com/rustwasm/wasm-bindgen/pull/3993)

### Changed

* Stabilize Web Share API.
Expand All @@ -62,6 +65,9 @@
* Update and stabilize the Clipboard API.
[#3992](https://github.com/rustwasm/wasm-bindgen/pull/3992)

* Deprecate builder-pattern type setters for WebIDL dictionary types and introduce non-mutable setters instead.
[#3993](https://github.com/rustwasm/wasm-bindgen/pull/3993)

### Fixed

* Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`.
Expand Down
48 changes: 33 additions & 15 deletions crates/web-sys/src/features/gen_AddEventListenerOptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,36 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
pub type AddEventListenerOptions;
#[doc = "Get the `capture` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, getter = "capture")]
pub fn get_capture(this: &AddEventListenerOptions) -> Option<bool>;
#[doc = "Change the `capture` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, setter = "capture")]
fn capture_shim(this: &AddEventListenerOptions, val: bool);
pub fn set_capture(this: &AddEventListenerOptions, val: bool);
#[doc = "Get the `once` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, getter = "once")]
pub fn get_once(this: &AddEventListenerOptions) -> Option<bool>;
#[doc = "Change the `once` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, setter = "once")]
fn once_shim(this: &AddEventListenerOptions, val: bool);
pub fn set_once(this: &AddEventListenerOptions, val: bool);
#[doc = "Get the `passive` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, getter = "passive")]
pub fn get_passive(this: &AddEventListenerOptions) -> Option<bool>;
#[doc = "Change the `passive` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[wasm_bindgen(method, setter = "passive")]
fn passive_shim(this: &AddEventListenerOptions, val: bool);
pub fn set_passive(this: &AddEventListenerOptions, val: bool);
}
impl AddEventListenerOptions {
#[doc = "Construct a new `AddEventListenerOptions`."]
Expand All @@ -26,25 +50,19 @@ impl AddEventListenerOptions {
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `capture` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[deprecated = "Use `set_capture()` instead."]
pub fn capture(&mut self, val: bool) -> &mut Self {
self.capture_shim(val);
self.set_capture(val);
self
}
#[doc = "Change the `once` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[deprecated = "Use `set_once()` instead."]
pub fn once(&mut self, val: bool) -> &mut Self {
self.once_shim(val);
self.set_once(val);
self
}
#[doc = "Change the `passive` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
#[deprecated = "Use `set_passive()` instead."]
pub fn passive(&mut self, val: bool) -> &mut Self {
self.passive_shim(val);
self.set_passive(val);
self
}
}
Expand Down
32 changes: 22 additions & 10 deletions crates/web-sys/src/features/gen_AesCbcParams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
pub type AesCbcParams;
#[doc = "Get the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[wasm_bindgen(method, getter = "name")]
pub fn get_name(this: &AesCbcParams) -> String;
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[wasm_bindgen(method, setter = "name")]
fn name_shim(this: &AesCbcParams, val: &str);
pub fn set_name(this: &AesCbcParams, val: &str);
#[doc = "Get the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[wasm_bindgen(method, getter = "iv")]
pub fn get_iv(this: &AesCbcParams) -> ::js_sys::Object;
#[doc = "Change the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[wasm_bindgen(method, setter = "iv")]
fn iv_shim(this: &AesCbcParams, val: &::js_sys::Object);
pub fn set_iv(this: &AesCbcParams, val: &::js_sys::Object);
}
impl AesCbcParams {
#[doc = "Construct a new `AesCbcParams`."]
Expand All @@ -26,18 +42,14 @@ impl AesCbcParams {
ret.iv(iv);
ret
}
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[deprecated = "Use `set_name()` instead."]
pub fn name(&mut self, val: &str) -> &mut Self {
self.name_shim(val);
self.set_name(val);
self
}
#[doc = "Change the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
#[deprecated = "Use `set_iv()` instead."]
pub fn iv(&mut self, val: &::js_sys::Object) -> &mut Self {
self.iv_shim(val);
self.set_iv(val);
self
}
}
48 changes: 33 additions & 15 deletions crates/web-sys/src/features/gen_AesCtrParams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,36 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
pub type AesCtrParams;
#[doc = "Get the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, getter = "name")]
pub fn get_name(this: &AesCtrParams) -> String;
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, setter = "name")]
fn name_shim(this: &AesCtrParams, val: &str);
pub fn set_name(this: &AesCtrParams, val: &str);
#[doc = "Get the `counter` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, getter = "counter")]
pub fn get_counter(this: &AesCtrParams) -> ::js_sys::Object;
#[doc = "Change the `counter` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, setter = "counter")]
fn counter_shim(this: &AesCtrParams, val: &::js_sys::Object);
pub fn set_counter(this: &AesCtrParams, val: &::js_sys::Object);
#[doc = "Get the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, getter = "length")]
pub fn get_length(this: &AesCtrParams) -> u8;
#[doc = "Change the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[wasm_bindgen(method, setter = "length")]
fn length_shim(this: &AesCtrParams, val: u8);
pub fn set_length(this: &AesCtrParams, val: u8);
}
impl AesCtrParams {
#[doc = "Construct a new `AesCtrParams`."]
Expand All @@ -29,25 +53,19 @@ impl AesCtrParams {
ret.length(length);
ret
}
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[deprecated = "Use `set_name()` instead."]
pub fn name(&mut self, val: &str) -> &mut Self {
self.name_shim(val);
self.set_name(val);
self
}
#[doc = "Change the `counter` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[deprecated = "Use `set_counter()` instead."]
pub fn counter(&mut self, val: &::js_sys::Object) -> &mut Self {
self.counter_shim(val);
self.set_counter(val);
self
}
#[doc = "Change the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
#[deprecated = "Use `set_length()` instead."]
pub fn length(&mut self, val: u8) -> &mut Self {
self.length_shim(val);
self.set_length(val);
self
}
}
32 changes: 22 additions & 10 deletions crates/web-sys/src/features/gen_AesDerivedKeyParams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
pub type AesDerivedKeyParams;
#[doc = "Get the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[wasm_bindgen(method, getter = "name")]
pub fn get_name(this: &AesDerivedKeyParams) -> String;
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[wasm_bindgen(method, setter = "name")]
fn name_shim(this: &AesDerivedKeyParams, val: &str);
pub fn set_name(this: &AesDerivedKeyParams, val: &str);
#[doc = "Get the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[wasm_bindgen(method, getter = "length")]
pub fn get_length(this: &AesDerivedKeyParams) -> u32;
#[doc = "Change the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[wasm_bindgen(method, setter = "length")]
fn length_shim(this: &AesDerivedKeyParams, val: u32);
pub fn set_length(this: &AesDerivedKeyParams, val: u32);
}
impl AesDerivedKeyParams {
#[doc = "Construct a new `AesDerivedKeyParams`."]
Expand All @@ -26,18 +42,14 @@ impl AesDerivedKeyParams {
ret.length(length);
ret
}
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[deprecated = "Use `set_name()` instead."]
pub fn name(&mut self, val: &str) -> &mut Self {
self.name_shim(val);
self.set_name(val);
self
}
#[doc = "Change the `length` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
#[deprecated = "Use `set_length()` instead."]
pub fn length(&mut self, val: u32) -> &mut Self {
self.length_shim(val);
self.set_length(val);
self
}
}
64 changes: 44 additions & 20 deletions crates/web-sys/src/features/gen_AesGcmParams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,46 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
pub type AesGcmParams;
#[doc = "Get the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, getter = "name")]
pub fn get_name(this: &AesGcmParams) -> String;
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, setter = "name")]
fn name_shim(this: &AesGcmParams, val: &str);
pub fn set_name(this: &AesGcmParams, val: &str);
#[doc = "Get the `additionalData` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, getter = "additionalData")]
pub fn get_additional_data(this: &AesGcmParams) -> Option<::js_sys::Object>;
#[doc = "Change the `additionalData` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, setter = "additionalData")]
fn additional_data_shim(this: &AesGcmParams, val: &::js_sys::Object);
pub fn set_additional_data(this: &AesGcmParams, val: &::js_sys::Object);
#[doc = "Get the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, getter = "iv")]
pub fn get_iv(this: &AesGcmParams) -> ::js_sys::Object;
#[doc = "Change the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, setter = "iv")]
fn iv_shim(this: &AesGcmParams, val: &::js_sys::Object);
pub fn set_iv(this: &AesGcmParams, val: &::js_sys::Object);
#[doc = "Get the `tagLength` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, getter = "tagLength")]
pub fn get_tag_length(this: &AesGcmParams) -> Option<u8>;
#[doc = "Change the `tagLength` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[wasm_bindgen(method, setter = "tagLength")]
fn tag_length_shim(this: &AesGcmParams, val: u8);
pub fn set_tag_length(this: &AesGcmParams, val: u8);
}
impl AesGcmParams {
#[doc = "Construct a new `AesGcmParams`."]
Expand All @@ -30,32 +62,24 @@ impl AesGcmParams {
ret.iv(iv);
ret
}
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[deprecated = "Use `set_name()` instead."]
pub fn name(&mut self, val: &str) -> &mut Self {
self.name_shim(val);
self.set_name(val);
self
}
#[doc = "Change the `additionalData` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[deprecated = "Use `set_additional_data()` instead."]
pub fn additional_data(&mut self, val: &::js_sys::Object) -> &mut Self {
self.additional_data_shim(val);
self.set_additional_data(val);
self
}
#[doc = "Change the `iv` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[deprecated = "Use `set_iv()` instead."]
pub fn iv(&mut self, val: &::js_sys::Object) -> &mut Self {
self.iv_shim(val);
self.set_iv(val);
self
}
#[doc = "Change the `tagLength` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
#[deprecated = "Use `set_tag_length()` instead."]
pub fn tag_length(&mut self, val: u8) -> &mut Self {
self.tag_length_shim(val);
self.set_tag_length(val);
self
}
}
Loading