mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
Handle more slice types in flag_slices_immutable
Should address the latest comment on #1539
This commit is contained in:
parent
f1cd643992
commit
3b06e58c9e
@ -33,27 +33,37 @@ pub(crate) enum IdlType<'a> {
|
|||||||
|
|
||||||
ArrayBuffer,
|
ArrayBuffer,
|
||||||
DataView,
|
DataView,
|
||||||
Int8Array,
|
Int8Array {
|
||||||
|
immutable: bool,
|
||||||
|
},
|
||||||
Uint8Array {
|
Uint8Array {
|
||||||
/// Whether or not the generated web-sys function should use an immutable slice
|
|
||||||
immutable: bool,
|
immutable: bool,
|
||||||
},
|
},
|
||||||
Uint8ClampedArray,
|
Uint8ClampedArray {
|
||||||
Int16Array,
|
immutable: bool,
|
||||||
Uint16Array,
|
},
|
||||||
Int32Array,
|
Int16Array {
|
||||||
Uint32Array,
|
immutable: bool,
|
||||||
|
},
|
||||||
|
Uint16Array {
|
||||||
|
immutable: bool,
|
||||||
|
},
|
||||||
|
Int32Array {
|
||||||
|
immutable: bool,
|
||||||
|
},
|
||||||
|
Uint32Array {
|
||||||
|
immutable: bool,
|
||||||
|
},
|
||||||
Float32Array {
|
Float32Array {
|
||||||
/// Whether or not the generated web-sys function should use an immutable slice
|
|
||||||
immutable: bool,
|
immutable: bool,
|
||||||
},
|
},
|
||||||
Float64Array,
|
Float64Array {
|
||||||
|
immutable: bool,
|
||||||
|
},
|
||||||
ArrayBufferView {
|
ArrayBufferView {
|
||||||
/// Whether or not the generated web-sys function should use an immutable slice
|
|
||||||
immutable: bool,
|
immutable: bool,
|
||||||
},
|
},
|
||||||
BufferSource {
|
BufferSource {
|
||||||
/// Whether or not the generated web-sys function should use an immutable slice
|
|
||||||
immutable: bool,
|
immutable: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -381,21 +391,21 @@ terms_to_idl_type! {
|
|||||||
Void => Void
|
Void => Void
|
||||||
ArrayBuffer => ArrayBuffer
|
ArrayBuffer => ArrayBuffer
|
||||||
DataView => DataView
|
DataView => DataView
|
||||||
Int8Array => Int8Array
|
|
||||||
Int16Array => Int16Array
|
|
||||||
Int32Array => Int32Array
|
|
||||||
Uint16Array => Uint16Array
|
|
||||||
Uint32Array => Uint32Array
|
|
||||||
Uint8ClampedArray => Uint8ClampedArray
|
|
||||||
Float64Array => Float64Array
|
|
||||||
Error => Error
|
Error => Error
|
||||||
}
|
}
|
||||||
|
|
||||||
terms_to_idl_type_maybe_immutable! {
|
terms_to_idl_type_maybe_immutable! {
|
||||||
Uint8Array => Uint8Array
|
|
||||||
Float32Array => Float32Array
|
|
||||||
ArrayBufferView => ArrayBufferView
|
ArrayBufferView => ArrayBufferView
|
||||||
BufferSource => BufferSource
|
BufferSource => BufferSource
|
||||||
|
Float32Array => Float32Array
|
||||||
|
Float64Array => Float64Array
|
||||||
|
Int16Array => Int16Array
|
||||||
|
Int32Array => Int32Array
|
||||||
|
Int8Array => Int8Array
|
||||||
|
Uint16Array => Uint16Array
|
||||||
|
Uint32Array => Uint32Array
|
||||||
|
Uint8Array => Uint8Array
|
||||||
|
Uint8ClampedArray => Uint8ClampedArray
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IdlType<'a> {
|
impl<'a> IdlType<'a> {
|
||||||
@ -421,15 +431,15 @@ impl<'a> IdlType<'a> {
|
|||||||
|
|
||||||
IdlType::ArrayBuffer => dst.push_str("array_buffer"),
|
IdlType::ArrayBuffer => dst.push_str("array_buffer"),
|
||||||
IdlType::DataView => dst.push_str("data_view"),
|
IdlType::DataView => dst.push_str("data_view"),
|
||||||
IdlType::Int8Array => dst.push_str("i8_array"),
|
IdlType::Int8Array { .. } => dst.push_str("i8_array"),
|
||||||
IdlType::Uint8Array { .. } => dst.push_str("u8_array"),
|
IdlType::Uint8Array { .. } => dst.push_str("u8_array"),
|
||||||
IdlType::Uint8ClampedArray => dst.push_str("u8_clamped_array"),
|
IdlType::Uint8ClampedArray { .. } => dst.push_str("u8_clamped_array"),
|
||||||
IdlType::Int16Array => dst.push_str("i16_array"),
|
IdlType::Int16Array { .. } => dst.push_str("i16_array"),
|
||||||
IdlType::Uint16Array => dst.push_str("u16_array"),
|
IdlType::Uint16Array { .. } => dst.push_str("u16_array"),
|
||||||
IdlType::Int32Array => dst.push_str("i32_array"),
|
IdlType::Int32Array { .. } => dst.push_str("i32_array"),
|
||||||
IdlType::Uint32Array => dst.push_str("u32_array"),
|
IdlType::Uint32Array { .. } => dst.push_str("u32_array"),
|
||||||
IdlType::Float32Array { .. } => dst.push_str("f32_array"),
|
IdlType::Float32Array { .. } => dst.push_str("f32_array"),
|
||||||
IdlType::Float64Array => dst.push_str("f64_array"),
|
IdlType::Float64Array { .. } => dst.push_str("f64_array"),
|
||||||
IdlType::ArrayBufferView { .. } => dst.push_str("array_buffer_view"),
|
IdlType::ArrayBufferView { .. } => dst.push_str("array_buffer_view"),
|
||||||
IdlType::BufferSource { .. } => dst.push_str("buffer_source"),
|
IdlType::BufferSource { .. } => dst.push_str("buffer_source"),
|
||||||
|
|
||||||
@ -533,15 +543,15 @@ impl<'a> IdlType<'a> {
|
|||||||
|
|
||||||
IdlType::ArrayBuffer => js_sys("ArrayBuffer"),
|
IdlType::ArrayBuffer => js_sys("ArrayBuffer"),
|
||||||
IdlType::DataView => None,
|
IdlType::DataView => None,
|
||||||
IdlType::Int8Array => Some(array("i8", pos, false)),
|
IdlType::Int8Array { immutable } => Some(array("i8", pos, *immutable)),
|
||||||
IdlType::Uint8Array { immutable } => Some(array("u8", pos, *immutable)),
|
IdlType::Uint8Array { immutable } => Some(array("u8", pos, *immutable)),
|
||||||
IdlType::Uint8ClampedArray => Some(clamped(array("u8", pos, false))),
|
IdlType::Uint8ClampedArray { immutable } => Some(clamped(array("u8", pos, *immutable))),
|
||||||
IdlType::Int16Array => Some(array("i16", pos, false)),
|
IdlType::Int16Array { immutable } => Some(array("i16", pos, *immutable)),
|
||||||
IdlType::Uint16Array => Some(array("u16", pos, false)),
|
IdlType::Uint16Array { immutable } => Some(array("u16", pos, *immutable)),
|
||||||
IdlType::Int32Array => Some(array("i32", pos, false)),
|
IdlType::Int32Array { immutable } => Some(array("i32", pos, *immutable)),
|
||||||
IdlType::Uint32Array => Some(array("u32", pos, false)),
|
IdlType::Uint32Array { immutable } => Some(array("u32", pos, *immutable)),
|
||||||
IdlType::Float32Array { immutable } => Some(array("f32", pos, *immutable)),
|
IdlType::Float32Array { immutable } => Some(array("f32", pos, *immutable)),
|
||||||
IdlType::Float64Array => Some(array("f64", pos, false)),
|
IdlType::Float64Array { immutable } => Some(array("f64", pos, *immutable)),
|
||||||
|
|
||||||
IdlType::ArrayBufferView { .. } | IdlType::BufferSource { .. } => js_sys("Object"),
|
IdlType::ArrayBufferView { .. } | IdlType::BufferSource { .. } => js_sys("Object"),
|
||||||
IdlType::Interface(name)
|
IdlType::Interface(name)
|
||||||
|
@ -735,10 +735,17 @@ pub fn public() -> syn::Visibility {
|
|||||||
|
|
||||||
fn flag_slices_immutable(ty: &mut IdlType) {
|
fn flag_slices_immutable(ty: &mut IdlType) {
|
||||||
match ty {
|
match ty {
|
||||||
IdlType::Uint8Array { immutable } => *immutable = true,
|
IdlType::Int8Array { immutable }
|
||||||
IdlType::Float32Array { immutable } => *immutable = true,
|
| IdlType::Uint8Array { immutable }
|
||||||
IdlType::ArrayBufferView { immutable } => *immutable = true,
|
| IdlType::Uint8ClampedArray { immutable }
|
||||||
IdlType::BufferSource { immutable } => *immutable = true,
|
| IdlType::Int16Array { immutable }
|
||||||
|
| IdlType::Uint16Array { immutable }
|
||||||
|
| IdlType::Int32Array { immutable }
|
||||||
|
| IdlType::Uint32Array { immutable }
|
||||||
|
| IdlType::Float32Array { immutable }
|
||||||
|
| IdlType::Float64Array { immutable }
|
||||||
|
| IdlType::ArrayBufferView { immutable }
|
||||||
|
| IdlType::BufferSource { immutable } => *immutable = true,
|
||||||
IdlType::Nullable(item) => flag_slices_immutable(item),
|
IdlType::Nullable(item) => flag_slices_immutable(item),
|
||||||
IdlType::FrozenArray(item) => flag_slices_immutable(item),
|
IdlType::FrozenArray(item) => flag_slices_immutable(item),
|
||||||
IdlType::Sequence(item) => flag_slices_immutable(item),
|
IdlType::Sequence(item) => flag_slices_immutable(item),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user