mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
Tweak ArrayBuffer IDL type expansion slightly
A few small changes here: * `ArrayBufferView` and `BufferSource` are expanded to themselves plus `Uint8ArrayMut` instead of `Object` to ensure we keep the original type. * Generating an argument type for `ArrayBufferView`, `BufferSource`, and `Object` all now generate shared references instead of owned objects, which is a little more consistent with the other interface types.
This commit is contained in:
parent
3c41d39b16
commit
cda71757d3
@ -448,7 +448,11 @@ impl<'a> IdlType<'a> {
|
||||
},
|
||||
IdlType::Object => {
|
||||
let path = vec![rust_ident("js_sys"), rust_ident("Object")];
|
||||
Some(leading_colon_path_ty(path))
|
||||
let ty = leading_colon_path_ty(path);
|
||||
Some(match pos {
|
||||
TypePosition::Argument => shared_ref(ty, false),
|
||||
TypePosition::Return => ty,
|
||||
})
|
||||
},
|
||||
IdlType::Symbol => None,
|
||||
IdlType::Error => None,
|
||||
@ -471,7 +475,11 @@ impl<'a> IdlType<'a> {
|
||||
|
||||
IdlType::ArrayBufferView | IdlType::BufferSource => {
|
||||
let path = vec![rust_ident("js_sys"), rust_ident("Object")];
|
||||
Some(leading_colon_path_ty(path))
|
||||
let ty = leading_colon_path_ty(path);
|
||||
Some(match pos {
|
||||
TypePosition::Argument => shared_ref(ty, false),
|
||||
TypePosition::Return => ty,
|
||||
})
|
||||
},
|
||||
IdlType::Interface(name)
|
||||
| IdlType::Dictionary(name) => {
|
||||
@ -577,9 +585,12 @@ impl<'a> IdlType<'a> {
|
||||
.iter()
|
||||
.flat_map(|idl_type| idl_type.flatten())
|
||||
.collect(),
|
||||
IdlType::ArrayBufferView | IdlType::BufferSource =>
|
||||
vec![IdlType::Object, IdlType::Uint8ArrayMut],
|
||||
|
||||
IdlType::ArrayBufferView => {
|
||||
vec![IdlType::ArrayBufferView, IdlType::Uint8ArrayMut]
|
||||
}
|
||||
IdlType::BufferSource => {
|
||||
vec![IdlType::BufferSource, IdlType::Uint8ArrayMut]
|
||||
}
|
||||
idl_type @ _ => vec![idl_type.clone()],
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user