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

Remove ReadableStreamByobReader::read_with_u8_array() #3582

Merged
merged 1 commit into from
Aug 29, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
* Fixed optional parameters in JSDoc.
[#3577](https://github.com/rustwasm/wasm-bindgen/pull/3577)

### Removed

* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.
[#3582](https://github.com/rustwasm/wasm-bindgen/pull/3582)

## [0.2.87](https://github.com/rustwasm/wasm-bindgen/compare/0.2.86...0.2.87)

Released 2023-06-12.
Expand Down
10 changes: 0 additions & 10 deletions crates/web-sys/src/features/gen_ReadableStreamByobReader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ extern "C" {
this: &ReadableStreamByobReader,
view: &::js_sys::Object,
) -> ::js_sys::Promise;
# [wasm_bindgen (method , structural , js_class = "ReadableStreamBYOBReader" , js_name = read)]
#[doc = "The `read()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader/read)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableStreamByobReader`*"]
pub fn read_with_u8_array(
this: &ReadableStreamByobReader,
view: &mut [u8],
) -> ::js_sys::Promise;
# [wasm_bindgen (method , structural , js_class = "ReadableStreamBYOBReader" , js_name = releaseLock)]
#[doc = "The `releaseLock()` method."]
#[doc = ""]
Expand Down
1 change: 1 addition & 0 deletions crates/web-sys/webidls/enabled/Streams.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ dictionary ReadableStreamReadResult {
interface ReadableStreamBYOBReader {
[Throws] constructor(ReadableStream stream);

[RustNotWasmMemory]
Promise<ReadableStreamReadResult> read(ArrayBufferView view);
undefined releaseLock();
};
Expand Down
4 changes: 4 additions & 0 deletions crates/webidl/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,9 @@ pub(crate) static FIXED_INTERFACES: Lazy<
"OffscreenCanvasRenderingContext2d",
canvas_rendering_context,
),
(
"ReadableStreamByobReader",
BTreeMap::from_iter([("read", "read_with_array_buffer_view")]),
),
])
});
47 changes: 31 additions & 16 deletions crates/webidl/src/idl_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use proc_macro2::{Ident, Span};
use wasm_bindgen_backend::util::{ident_ty, leading_colon_path_ty, raw_ident, rust_ident};
use weedle::attribute::{ExtendedAttribute, ExtendedAttributeList};
use weedle::common::Identifier;
use weedle::term;
use weedle::types::*;
Expand Down Expand Up @@ -659,36 +660,36 @@ impl<'a> IdlType<'a> {
/// but also flattens unions inside generics of other types.
///
/// [flattened union member types]: https://heycam.github.io/webidl/#dfn-flattened-union-member-types
pub(crate) fn flatten(&self) -> Vec<Self> {
pub(crate) fn flatten(&self, attrs: Option<&ExtendedAttributeList<'_>>) -> Vec<Self> {
match self {
IdlType::Nullable(idl_type) => idl_type
.flatten()
.flatten(attrs)
.into_iter()
.map(Box::new)
.map(IdlType::Nullable)
.collect(),
IdlType::FrozenArray(idl_type) => idl_type
.flatten()
.flatten(attrs)
.into_iter()
.map(Box::new)
.map(IdlType::FrozenArray)
.collect(),
IdlType::Sequence(idl_type) => idl_type
.flatten()
.flatten(attrs)
.into_iter()
.map(Box::new)
.map(IdlType::Sequence)
.collect(),
IdlType::Promise(idl_type) => idl_type
.flatten()
.flatten(attrs)
.into_iter()
.map(Box::new)
.map(IdlType::Promise)
.collect(),
IdlType::Record(idl_type_from, idl_type_to) => {
let mut idl_types = Vec::new();
for idl_type_from in idl_type_from.flatten() {
for idl_type_to in idl_type_to.flatten() {
for idl_type_from in idl_type_from.flatten(attrs) {
for idl_type_to in idl_type_to.flatten(attrs) {
idl_types.push(IdlType::Record(
Box::new(idl_type_from.clone()),
Box::new(idl_type_to.clone()),
Expand All @@ -699,16 +700,30 @@ impl<'a> IdlType<'a> {
}
IdlType::Union(idl_types) => idl_types
.iter()
.flat_map(|idl_type| idl_type.flatten())
.flat_map(|idl_type| idl_type.flatten(attrs))
.collect(),
IdlType::ArrayBufferView { immutable } => vec![
IdlType::ArrayBufferView {
IdlType::ArrayBufferView { immutable } => {
let view = IdlType::ArrayBufferView {
immutable: *immutable,
},
IdlType::Uint8Array {
immutable: *immutable,
},
],
};

if let Some(attrs) = attrs {
for attr in &attrs.body.list {
if let ExtendedAttribute::NoArgs(attr) = attr {
if attr.0 .0 == "RustNotWasmMemory" {
return vec![view];
}
}
}
}

vec![
view,
IdlType::Uint8Array {
immutable: *immutable,
},
]
}
IdlType::BufferSource { immutable } => vec![
IdlType::BufferSource {
immutable: *immutable,
Expand Down Expand Up @@ -758,7 +773,7 @@ fn idl_type_flatten_test() {
Interface("NodeList"),
])),),
])
.flatten(),
.flatten(None),
vec![
Interface("Node"),
Sequence(Box::new(Long)),
Expand Down
6 changes: 5 additions & 1 deletion crates/webidl/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ impl<'src> FirstPassRecord<'src> {
// 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().into_iter().enumerate() {
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());
Expand Down