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:
Alex Crichton 2018-09-06 10:09:03 -07:00
parent 3c41d39b16
commit cda71757d3

View File

@ -448,7 +448,11 @@ impl<'a> IdlType<'a> {
}, },
IdlType::Object => { IdlType::Object => {
let path = vec![rust_ident("js_sys"), rust_ident("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::Symbol => None,
IdlType::Error => None, IdlType::Error => None,
@ -471,7 +475,11 @@ impl<'a> IdlType<'a> {
IdlType::ArrayBufferView | IdlType::BufferSource => { IdlType::ArrayBufferView | IdlType::BufferSource => {
let path = vec![rust_ident("js_sys"), rust_ident("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::Interface(name) IdlType::Interface(name)
| IdlType::Dictionary(name) => { | IdlType::Dictionary(name) => {
@ -577,9 +585,12 @@ impl<'a> IdlType<'a> {
.iter() .iter()
.flat_map(|idl_type| idl_type.flatten()) .flat_map(|idl_type| idl_type.flatten())
.collect(), .collect(),
IdlType::ArrayBufferView | IdlType::BufferSource => IdlType::ArrayBufferView => {
vec![IdlType::Object, IdlType::Uint8ArrayMut], vec![IdlType::ArrayBufferView, IdlType::Uint8ArrayMut]
}
IdlType::BufferSource => {
vec![IdlType::BufferSource, IdlType::Uint8ArrayMut]
}
idl_type @ _ => vec![idl_type.clone()], idl_type @ _ => vec![idl_type.clone()],
} }
} }