mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
webidl: Turn the [Throws]
extended attributes into Result<T, JsValue>
This sets the `catch` flag on the emitted AST when an operation/attribute has the `[Throws]` extended attribute on it. Additionally, constructors aren't annotated with `[Throws]` but can still throw exceptions, so we must conservatively assume *every* constructor can throw an error.
This commit is contained in:
@ -35,6 +35,23 @@ pub fn raw_ident(name: &str) -> Ident {
|
||||
/// Create a path type from the given segments. For example an iterator yielding
|
||||
/// the idents `[foo, bar, baz]` will result in the path type `foo::bar::baz`.
|
||||
pub fn simple_path_ty<I>(segments: I) -> syn::Type
|
||||
where
|
||||
I: IntoIterator<Item = Ident>,
|
||||
{
|
||||
path_ty(false, segments)
|
||||
}
|
||||
|
||||
/// Create a global path type from the given segments. For example an iterator
|
||||
/// yielding the idents `[foo, bar, baz]` will result in the path type
|
||||
/// `::foo::bar::baz`.
|
||||
pub fn leading_colon_path_ty<I>(segments: I) -> syn::Type
|
||||
where
|
||||
I: IntoIterator<Item = Ident>,
|
||||
{
|
||||
path_ty(true, segments)
|
||||
}
|
||||
|
||||
fn path_ty<I>(leading_colon: bool, segments: I) -> syn::Type
|
||||
where
|
||||
I: IntoIterator<Item = Ident>,
|
||||
{
|
||||
@ -49,7 +66,11 @@ where
|
||||
syn::TypePath {
|
||||
qself: None,
|
||||
path: syn::Path {
|
||||
leading_colon: None,
|
||||
leading_colon: if leading_colon {
|
||||
Some(Default::default())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
segments: syn::punctuated::Punctuated::from_iter(segments),
|
||||
},
|
||||
}.into()
|
||||
|
Reference in New Issue
Block a user