Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade weedle to v0.11 #2024

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/webidl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ proc-macro2 = "1.0"
quote = '1.0'
syn = { version = '1.0', features = ['full'] }
wasm-bindgen-backend = { version = "=0.2.58", path = "../backend" }
weedle = "0.10"
weedle = "0.11"
7 changes: 7 additions & 0 deletions crates/webidl/src/first_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,13 @@ impl<'src> FirstPass<'src, (&'src str, ApiStability)> for weedle::interface::Int
.push(const_);
Ok(())
}
InterfaceMember::Constructor(_) => {
log::warn!(
"Unsupported WebIDL Constructor interface member: {:?}",
self
);
Ok(())
}
InterfaceMember::Iterable(_iterable) => {
log::warn!("Unsupported WebIDL iterable interface member: {:?}", self);
Ok(())
Expand Down
32 changes: 13 additions & 19 deletions crates/webidl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use wasm_bindgen_backend::TryToTokens;
use weedle::attribute::ExtendedAttributeList;
use weedle::dictionary::DictionaryMember;
use weedle::interface::InterfaceMember;
use weedle::Parse;

struct Program {
main: ast::Program,
Expand Down Expand Up @@ -74,26 +75,19 @@ impl Default for ApiStability {
}

fn parse_source(source: &str) -> Result<Vec<weedle::Definition>> {
weedle::parse(source).map_err(|e| {
match &e {
weedle::Err::Incomplete(needed) => anyhow::anyhow!("needed {:?} more bytes", needed),
weedle::Err::Error(cx) | weedle::Err::Failure(cx) => {
// Note that #[allow] here is a workaround for Geal/nom#843
// because the `Context` type here comes from `nom` and if
// something else in our crate graph enables the
// `verbose-errors` feature then we need to still compiled
// against the changed enum definition.
#[allow(unreachable_patterns)]
let remaining = match cx {
weedle::Context::Code(remaining, _) => remaining.len(),
_ => 0,
};
let pos = source.len() - remaining;

WebIDLParseError(pos).into()
}
match weedle::Definitions::parse(source) {
Ok(("", parsed)) => Ok(parsed),

Ok((remaining, _))
| Err(weedle::Err::Error((remaining, _)))
| Err(weedle::Err::Failure((remaining, _))) => {
Err(WebIDLParseError(source.len() - remaining.len()).into())
}
})

Err(weedle::Err::Incomplete(needed)) => {
Err(anyhow::anyhow!("needed {:?} more bytes", needed))
}
}
}

/// Parse a string of WebIDL source text into a wasm-bindgen AST.
Expand Down