Skip to content

Commit 7bdec18

Browse files
authored
Generate getters for all WebIDL dictionary types and deprecate builder-pattern style setters (#3993)
1 parent 869562c commit 7bdec18

File tree

555 files changed

+33132
-14275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

555 files changed

+33132
-14275
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
* Add bindings for `RTCRtpReceiver.jitterBufferTarget`.
4343
[#3968](https://github.com/rustwasm/wasm-bindgen/pull/3968)
4444

45+
* Generate getters for all WebIDL dictionary types.
46+
[#3993](https://github.com/rustwasm/wasm-bindgen/pull/3993)
47+
4548
### Changed
4649

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

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

6773
* Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`.

crates/web-sys/src/features/gen_AddEventListenerOptions.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,36 @@ extern "C" {
1010
#[doc = ""]
1111
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
1212
pub type AddEventListenerOptions;
13+
#[doc = "Get the `capture` field of this object."]
14+
#[doc = ""]
15+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
16+
#[wasm_bindgen(method, getter = "capture")]
17+
pub fn get_capture(this: &AddEventListenerOptions) -> Option<bool>;
18+
#[doc = "Change the `capture` field of this object."]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
1321
#[wasm_bindgen(method, setter = "capture")]
14-
fn capture_shim(this: &AddEventListenerOptions, val: bool);
22+
pub fn set_capture(this: &AddEventListenerOptions, val: bool);
23+
#[doc = "Get the `once` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
26+
#[wasm_bindgen(method, getter = "once")]
27+
pub fn get_once(this: &AddEventListenerOptions) -> Option<bool>;
28+
#[doc = "Change the `once` field of this object."]
29+
#[doc = ""]
30+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
1531
#[wasm_bindgen(method, setter = "once")]
16-
fn once_shim(this: &AddEventListenerOptions, val: bool);
32+
pub fn set_once(this: &AddEventListenerOptions, val: bool);
33+
#[doc = "Get the `passive` field of this object."]
34+
#[doc = ""]
35+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
36+
#[wasm_bindgen(method, getter = "passive")]
37+
pub fn get_passive(this: &AddEventListenerOptions) -> Option<bool>;
38+
#[doc = "Change the `passive` field of this object."]
39+
#[doc = ""]
40+
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
1741
#[wasm_bindgen(method, setter = "passive")]
18-
fn passive_shim(this: &AddEventListenerOptions, val: bool);
42+
pub fn set_passive(this: &AddEventListenerOptions, val: bool);
1943
}
2044
impl AddEventListenerOptions {
2145
#[doc = "Construct a new `AddEventListenerOptions`."]
@@ -26,25 +50,19 @@ impl AddEventListenerOptions {
2650
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
2751
ret
2852
}
29-
#[doc = "Change the `capture` field of this object."]
30-
#[doc = ""]
31-
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
53+
#[deprecated = "Use `set_capture()` instead."]
3254
pub fn capture(&mut self, val: bool) -> &mut Self {
33-
self.capture_shim(val);
55+
self.set_capture(val);
3456
self
3557
}
36-
#[doc = "Change the `once` field of this object."]
37-
#[doc = ""]
38-
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
58+
#[deprecated = "Use `set_once()` instead."]
3959
pub fn once(&mut self, val: bool) -> &mut Self {
40-
self.once_shim(val);
60+
self.set_once(val);
4161
self
4262
}
43-
#[doc = "Change the `passive` field of this object."]
44-
#[doc = ""]
45-
#[doc = "*This API requires the following crate features to be activated: `AddEventListenerOptions`*"]
63+
#[deprecated = "Use `set_passive()` instead."]
4664
pub fn passive(&mut self, val: bool) -> &mut Self {
47-
self.passive_shim(val);
65+
self.set_passive(val);
4866
self
4967
}
5068
}

crates/web-sys/src/features/gen_AesCbcParams.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,26 @@ extern "C" {
1010
#[doc = ""]
1111
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
1212
pub type AesCbcParams;
13+
#[doc = "Get the `name` field of this object."]
14+
#[doc = ""]
15+
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
16+
#[wasm_bindgen(method, getter = "name")]
17+
pub fn get_name(this: &AesCbcParams) -> String;
18+
#[doc = "Change the `name` field of this object."]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
1321
#[wasm_bindgen(method, setter = "name")]
14-
fn name_shim(this: &AesCbcParams, val: &str);
22+
pub fn set_name(this: &AesCbcParams, val: &str);
23+
#[doc = "Get the `iv` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
26+
#[wasm_bindgen(method, getter = "iv")]
27+
pub fn get_iv(this: &AesCbcParams) -> ::js_sys::Object;
28+
#[doc = "Change the `iv` field of this object."]
29+
#[doc = ""]
30+
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
1531
#[wasm_bindgen(method, setter = "iv")]
16-
fn iv_shim(this: &AesCbcParams, val: &::js_sys::Object);
32+
pub fn set_iv(this: &AesCbcParams, val: &::js_sys::Object);
1733
}
1834
impl AesCbcParams {
1935
#[doc = "Construct a new `AesCbcParams`."]
@@ -26,18 +42,14 @@ impl AesCbcParams {
2642
ret.iv(iv);
2743
ret
2844
}
29-
#[doc = "Change the `name` field of this object."]
30-
#[doc = ""]
31-
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
45+
#[deprecated = "Use `set_name()` instead."]
3246
pub fn name(&mut self, val: &str) -> &mut Self {
33-
self.name_shim(val);
47+
self.set_name(val);
3448
self
3549
}
36-
#[doc = "Change the `iv` field of this object."]
37-
#[doc = ""]
38-
#[doc = "*This API requires the following crate features to be activated: `AesCbcParams`*"]
50+
#[deprecated = "Use `set_iv()` instead."]
3951
pub fn iv(&mut self, val: &::js_sys::Object) -> &mut Self {
40-
self.iv_shim(val);
52+
self.set_iv(val);
4153
self
4254
}
4355
}

crates/web-sys/src/features/gen_AesCtrParams.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,36 @@ extern "C" {
1010
#[doc = ""]
1111
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
1212
pub type AesCtrParams;
13+
#[doc = "Get the `name` field of this object."]
14+
#[doc = ""]
15+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
16+
#[wasm_bindgen(method, getter = "name")]
17+
pub fn get_name(this: &AesCtrParams) -> String;
18+
#[doc = "Change the `name` field of this object."]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
1321
#[wasm_bindgen(method, setter = "name")]
14-
fn name_shim(this: &AesCtrParams, val: &str);
22+
pub fn set_name(this: &AesCtrParams, val: &str);
23+
#[doc = "Get the `counter` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
26+
#[wasm_bindgen(method, getter = "counter")]
27+
pub fn get_counter(this: &AesCtrParams) -> ::js_sys::Object;
28+
#[doc = "Change the `counter` field of this object."]
29+
#[doc = ""]
30+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
1531
#[wasm_bindgen(method, setter = "counter")]
16-
fn counter_shim(this: &AesCtrParams, val: &::js_sys::Object);
32+
pub fn set_counter(this: &AesCtrParams, val: &::js_sys::Object);
33+
#[doc = "Get the `length` field of this object."]
34+
#[doc = ""]
35+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
36+
#[wasm_bindgen(method, getter = "length")]
37+
pub fn get_length(this: &AesCtrParams) -> u8;
38+
#[doc = "Change the `length` field of this object."]
39+
#[doc = ""]
40+
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
1741
#[wasm_bindgen(method, setter = "length")]
18-
fn length_shim(this: &AesCtrParams, val: u8);
42+
pub fn set_length(this: &AesCtrParams, val: u8);
1943
}
2044
impl AesCtrParams {
2145
#[doc = "Construct a new `AesCtrParams`."]
@@ -29,25 +53,19 @@ impl AesCtrParams {
2953
ret.length(length);
3054
ret
3155
}
32-
#[doc = "Change the `name` field of this object."]
33-
#[doc = ""]
34-
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
56+
#[deprecated = "Use `set_name()` instead."]
3557
pub fn name(&mut self, val: &str) -> &mut Self {
36-
self.name_shim(val);
58+
self.set_name(val);
3759
self
3860
}
39-
#[doc = "Change the `counter` field of this object."]
40-
#[doc = ""]
41-
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
61+
#[deprecated = "Use `set_counter()` instead."]
4262
pub fn counter(&mut self, val: &::js_sys::Object) -> &mut Self {
43-
self.counter_shim(val);
63+
self.set_counter(val);
4464
self
4565
}
46-
#[doc = "Change the `length` field of this object."]
47-
#[doc = ""]
48-
#[doc = "*This API requires the following crate features to be activated: `AesCtrParams`*"]
66+
#[deprecated = "Use `set_length()` instead."]
4967
pub fn length(&mut self, val: u8) -> &mut Self {
50-
self.length_shim(val);
68+
self.set_length(val);
5169
self
5270
}
5371
}

crates/web-sys/src/features/gen_AesDerivedKeyParams.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,26 @@ extern "C" {
1010
#[doc = ""]
1111
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
1212
pub type AesDerivedKeyParams;
13+
#[doc = "Get the `name` field of this object."]
14+
#[doc = ""]
15+
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
16+
#[wasm_bindgen(method, getter = "name")]
17+
pub fn get_name(this: &AesDerivedKeyParams) -> String;
18+
#[doc = "Change the `name` field of this object."]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
1321
#[wasm_bindgen(method, setter = "name")]
14-
fn name_shim(this: &AesDerivedKeyParams, val: &str);
22+
pub fn set_name(this: &AesDerivedKeyParams, val: &str);
23+
#[doc = "Get the `length` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
26+
#[wasm_bindgen(method, getter = "length")]
27+
pub fn get_length(this: &AesDerivedKeyParams) -> u32;
28+
#[doc = "Change the `length` field of this object."]
29+
#[doc = ""]
30+
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
1531
#[wasm_bindgen(method, setter = "length")]
16-
fn length_shim(this: &AesDerivedKeyParams, val: u32);
32+
pub fn set_length(this: &AesDerivedKeyParams, val: u32);
1733
}
1834
impl AesDerivedKeyParams {
1935
#[doc = "Construct a new `AesDerivedKeyParams`."]
@@ -26,18 +42,14 @@ impl AesDerivedKeyParams {
2642
ret.length(length);
2743
ret
2844
}
29-
#[doc = "Change the `name` field of this object."]
30-
#[doc = ""]
31-
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
45+
#[deprecated = "Use `set_name()` instead."]
3246
pub fn name(&mut self, val: &str) -> &mut Self {
33-
self.name_shim(val);
47+
self.set_name(val);
3448
self
3549
}
36-
#[doc = "Change the `length` field of this object."]
37-
#[doc = ""]
38-
#[doc = "*This API requires the following crate features to be activated: `AesDerivedKeyParams`*"]
50+
#[deprecated = "Use `set_length()` instead."]
3951
pub fn length(&mut self, val: u32) -> &mut Self {
40-
self.length_shim(val);
52+
self.set_length(val);
4153
self
4254
}
4355
}

crates/web-sys/src/features/gen_AesGcmParams.rs

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,46 @@ extern "C" {
1010
#[doc = ""]
1111
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
1212
pub type AesGcmParams;
13+
#[doc = "Get the `name` field of this object."]
14+
#[doc = ""]
15+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
16+
#[wasm_bindgen(method, getter = "name")]
17+
pub fn get_name(this: &AesGcmParams) -> String;
18+
#[doc = "Change the `name` field of this object."]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
1321
#[wasm_bindgen(method, setter = "name")]
14-
fn name_shim(this: &AesGcmParams, val: &str);
22+
pub fn set_name(this: &AesGcmParams, val: &str);
23+
#[doc = "Get the `additionalData` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
26+
#[wasm_bindgen(method, getter = "additionalData")]
27+
pub fn get_additional_data(this: &AesGcmParams) -> Option<::js_sys::Object>;
28+
#[doc = "Change the `additionalData` field of this object."]
29+
#[doc = ""]
30+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
1531
#[wasm_bindgen(method, setter = "additionalData")]
16-
fn additional_data_shim(this: &AesGcmParams, val: &::js_sys::Object);
32+
pub fn set_additional_data(this: &AesGcmParams, val: &::js_sys::Object);
33+
#[doc = "Get the `iv` field of this object."]
34+
#[doc = ""]
35+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
36+
#[wasm_bindgen(method, getter = "iv")]
37+
pub fn get_iv(this: &AesGcmParams) -> ::js_sys::Object;
38+
#[doc = "Change the `iv` field of this object."]
39+
#[doc = ""]
40+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
1741
#[wasm_bindgen(method, setter = "iv")]
18-
fn iv_shim(this: &AesGcmParams, val: &::js_sys::Object);
42+
pub fn set_iv(this: &AesGcmParams, val: &::js_sys::Object);
43+
#[doc = "Get the `tagLength` field of this object."]
44+
#[doc = ""]
45+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
46+
#[wasm_bindgen(method, getter = "tagLength")]
47+
pub fn get_tag_length(this: &AesGcmParams) -> Option<u8>;
48+
#[doc = "Change the `tagLength` field of this object."]
49+
#[doc = ""]
50+
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
1951
#[wasm_bindgen(method, setter = "tagLength")]
20-
fn tag_length_shim(this: &AesGcmParams, val: u8);
52+
pub fn set_tag_length(this: &AesGcmParams, val: u8);
2153
}
2254
impl AesGcmParams {
2355
#[doc = "Construct a new `AesGcmParams`."]
@@ -30,32 +62,24 @@ impl AesGcmParams {
3062
ret.iv(iv);
3163
ret
3264
}
33-
#[doc = "Change the `name` field of this object."]
34-
#[doc = ""]
35-
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
65+
#[deprecated = "Use `set_name()` instead."]
3666
pub fn name(&mut self, val: &str) -> &mut Self {
37-
self.name_shim(val);
67+
self.set_name(val);
3868
self
3969
}
40-
#[doc = "Change the `additionalData` field of this object."]
41-
#[doc = ""]
42-
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
70+
#[deprecated = "Use `set_additional_data()` instead."]
4371
pub fn additional_data(&mut self, val: &::js_sys::Object) -> &mut Self {
44-
self.additional_data_shim(val);
72+
self.set_additional_data(val);
4573
self
4674
}
47-
#[doc = "Change the `iv` field of this object."]
48-
#[doc = ""]
49-
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
75+
#[deprecated = "Use `set_iv()` instead."]
5076
pub fn iv(&mut self, val: &::js_sys::Object) -> &mut Self {
51-
self.iv_shim(val);
77+
self.set_iv(val);
5278
self
5379
}
54-
#[doc = "Change the `tagLength` field of this object."]
55-
#[doc = ""]
56-
#[doc = "*This API requires the following crate features to be activated: `AesGcmParams`*"]
80+
#[deprecated = "Use `set_tag_length()` instead."]
5781
pub fn tag_length(&mut self, val: u8) -> &mut Self {
58-
self.tag_length_shim(val);
82+
self.set_tag_length(val);
5983
self
6084
}
6185
}

0 commit comments

Comments
 (0)