Remove ReadableStreamByobReader::read_with_u8_array() (#3582)

This commit is contained in:
daxpedda 2023-08-30 00:13:19 +02:00 committed by GitHub
parent 77cfb61a6c
commit 865923bdef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 27 deletions

View File

@ -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.

View File

@ -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 = ""]

View File

@ -91,6 +91,7 @@ dictionary ReadableStreamReadResult {
interface ReadableStreamBYOBReader {
[Throws] constructor(ReadableStream stream);
[RustNotWasmMemory]
Promise<ReadableStreamReadResult> read(ArrayBufferView view);
undefined releaseLock();
};

View File

@ -140,5 +140,9 @@ pub(crate) static FIXED_INTERFACES: Lazy<
"OffscreenCanvasRenderingContext2d",
canvas_rendering_context,
),
(
"ReadableStreamByobReader",
BTreeMap::from_iter([("read", "read_with_array_buffer_view")]),
),
])
});

View File

@ -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::*;
@ -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()),
@ -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,
@ -758,7 +773,7 @@ fn idl_type_flatten_test() {
Interface("NodeList"),
])),),
])
.flatten(),
.flatten(None),
vec![
Interface("Node"),
Sequence(Box::new(Long)),

View File

@ -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());