From 21063fd42f902344d991a263d54591cc872ad011 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 15 Aug 2018 14:24:09 -0700 Subject: [PATCH] webidl: Make logging a little more consistently formatted This commit makes these changes: * Unsupported constructs always log "unsupported" for easy `grep`ing * There is always a " :
" format now, so we can easily use `cut` to grab the generic message and count which kinds of things are our biggest missing features. * Make sure that we have different `warn!` logs for each kind of unsupported thing, instead of grouping them together. Put all that together and this is the current state of `wasm-bindgen-webidl` and `web-sys`: ``` $ grep WARN stderr.txt | grep wasm_bindgen_webidl | grep -i unsupported | cut -d ' ' -f5- | cut -d ':' -f 1 | sort | uniq -c | sort -rn 387 Unsupported WebIDL Dictionary definition 139 Unsupported argument type 70 Unsupported return type 47 Unsupported WebIDL Callback definition 22 Unsupported WebIDL extended attribute 18 Unsupported unnamed operation 9 Unsupported WebIDL CallbackInterface definition 7 Unsupported WebIDL Stringifier interface member 7 Unsupported WebIDL Maplike interface member 2 Unsupported webidl stringifier 2 Unsupported WebIDL Setlike interface member 2 Unsupported stringifier on type ``` --- crates/webidl/src/first_pass.rs | 13 ++++----- crates/webidl/src/idl_type.rs | 2 +- crates/webidl/src/lib.rs | 47 +++++++++++++++++++++------------ crates/webidl/src/util.rs | 8 +++--- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/crates/webidl/src/first_pass.rs b/crates/webidl/src/first_pass.rs index 5011d6f6..41884ff5 100644 --- a/crates/webidl/src/first_pass.rs +++ b/crates/webidl/src/first_pass.rs @@ -123,7 +123,7 @@ impl<'src> FirstPass<'src, ()> for weedle::DictionaryDefinition<'src> { } if !record.dictionaries.insert(self.identifier.0) { - warn!("encountered multiple dictionary declarations of {}", self.identifier.0); + info!("Encountered multiple dictionary declarations: {}", self.identifier.0); } Ok(()) @@ -137,7 +137,7 @@ impl<'src> FirstPass<'src, ()> for weedle::EnumDefinition<'src> { } if !record.enums.insert(self.identifier.0) { - warn!("Encountered multiple enum declarations of {}", self.identifier.0); + info!("Encountered multiple enum declarations: {}", self.identifier.0); } Ok(()) @@ -336,11 +336,11 @@ impl<'src> FirstPass<'src, &'src str> for weedle::interface::OperationInterfaceM } if self.specials.len() > 1 { - warn!("Unsupported webidl operation {:?}", self); + warn!("Unsupported webidl operation: {:?}", self); return Ok(()) } if let Some(StringifierOrStatic::Stringifier(_)) = self.modifier { - warn!("Unsupported webidl operation {:?}", self); + warn!("Unsupported webidl stringifier: {:?}", self); return Ok(()) } let mut ids = vec![OperationId::Operation(self.identifier.map(|s| s.0))]; @@ -430,9 +430,10 @@ impl<'src> FirstPass<'src, &'src str> for weedle::mixin::OperationMixinMember<'s } if self.stringifier.is_some() { - warn!("Unsupported webidl operation {:?}", self); + warn!("Unsupported webidl stringifier: {:?}", self); return Ok(()) } + first_pass_operation( record, FirstPassOperationType::Mixin, @@ -450,7 +451,7 @@ impl<'src> FirstPass<'src, ()> for weedle::TypedefDefinition<'src> { } if record.typedefs.insert(self.identifier.0, &self.type_.type_).is_some() { - warn!("Encountered multiple declarations of {}", self.identifier.0); + info!("Encountered multiple typedef declarations: {}", self.identifier.0); } Ok(()) diff --git a/crates/webidl/src/idl_type.rs b/crates/webidl/src/idl_type.rs index be96d596..ecfe4f54 100644 --- a/crates/webidl/src/idl_type.rs +++ b/crates/webidl/src/idl_type.rs @@ -290,7 +290,7 @@ impl<'a> ToIdlType<'a> for Identifier<'a> { } else if record.enums.contains(self.0) { Some(IdlType::Enum(self.0)) } else { - warn!("unrecognized type {}", self.0); + warn!("Unrecognized type: {}", self.0); None } } diff --git a/crates/webidl/src/lib.rs b/crates/webidl/src/lib.rs index d077a1f7..30746f2f 100644 --- a/crates/webidl/src/lib.rs +++ b/crates/webidl/src/lib.rs @@ -188,12 +188,19 @@ impl<'src> WebidlParse<'src, ()> for weedle::Definition<'src> { weedle::Definition::Namespace(namespace) => { namespace.webidl_parse(program, first_pass, ())? } + // TODO - | weedle::Definition::Callback(..) - | weedle::Definition::CallbackInterface(..) - | weedle::Definition::Dictionary(..) - | weedle::Definition::PartialDictionary(..) => { - warn!("Unsupported WebIDL definition: {:?}", self) + weedle::Definition::Callback(..) => { + warn!("Unsupported WebIDL Callback definition: {:?}", self) + } + weedle::Definition::CallbackInterface(..) => { + warn!("Unsupported WebIDL CallbackInterface definition: {:?}", self) + } + weedle::Definition::Dictionary(..) => { + warn!("Unsupported WebIDL Dictionary definition: {:?}", self) + } + weedle::Definition::PartialDictionary(..) => { + warn!("Unsupported WebIDL PartialDictionary definition: {:?}", self) } } Ok(()) @@ -288,7 +295,7 @@ impl<'src> WebidlParse<'src, ()> for weedle::PartialInterfaceDefinition<'src> { .get(self.identifier.0) .map(|interface_data| !interface_data.partial) .unwrap_or(true) { - warn!( + info!( "Partial interface {} missing non-partial interface", self.identifier.0 ); @@ -453,10 +460,16 @@ impl<'src> WebidlParse<'src, &'src str> for weedle::interface::InterfaceMember<' iterable.webidl_parse(program, first_pass, self_name) } // TODO - | Maplike(_) - | Stringifier(_) - | Setlike(_) => { - warn!("Unsupported WebIDL interface member: {:?}", self); + Maplike(_) => { + warn!("Unsupported WebIDL Maplike interface member: {:?}", self); + Ok(()) + } + Stringifier(_) => { + warn!("Unsupported WebIDL Stringifier interface member: {:?}", self); + Ok(()) + } + Setlike(_) => { + warn!("Unsupported WebIDL Setlike interface member: {:?}", self); Ok(()) } } @@ -482,7 +495,7 @@ impl<'a, 'src> WebidlParse<'src, &'a str> for weedle::mixin::MixinMember<'src> { } // TODO weedle::mixin::MixinMember::Stringifier(_) => { - warn!("Unsupported WebIDL mixin member: {:?}", self); + warn!("Unsupported WebIDL stringifier mixin member: {:?}", self); Ok(()) } } @@ -551,7 +564,7 @@ fn member_attribute<'src>( let is_static = match modifier { Some(Stringifier(_)) => { - warn!("Unsupported stringifier on type {:?}", (self_name, identifier)); + warn!("Unsupported stringifier on type: {:?}", (self_name, identifier)); return Ok(()) } Some(Inherit(_)) => false, @@ -560,7 +573,7 @@ fn member_attribute<'src>( }; if type_.attributes.is_some() { - warn!("Unsupported attributes on type {:?}", (self_name, identifier)); + warn!("Unsupported attributes on type: {:?}", (self_name, identifier)); return Ok(()) } @@ -656,7 +669,7 @@ fn member_operation<'src>( let is_static = match modifier { Some(Stringifier(_)) => { - warn!("Unsupported stringifier on type {:?}", (self_name, identifier)); + warn!("Unsupported stringifier on type: {:?}", (self_name, identifier)); return Ok(()) } Some(Static(_)) => true, @@ -668,7 +681,7 @@ fn member_operation<'src>( ]; if specials.len() > 1 { warn!( - "Unsupported specials ({:?}) on type {:?}", + "Unsupported specials: ({:?}) on type {:?}", specials, (self_name, identifier), ); @@ -893,8 +906,8 @@ impl<'src> WebidlParse<'src, (&'src str, &'src mut backend::ast::Module)> for we weedle::namespace::NamespaceMember::Operation(op) => { op.webidl_parse(program, first_pass, (self_name, module))?; } - weedle::namespace::NamespaceMember::Attribute(_) => { - warn!("Attribute namespace members are not supported") + weedle::namespace::NamespaceMember::Attribute(attr) => { + warn!("Unsupported attribute namespace member: {:?}", attr) } } Ok(()) diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 011d3555..aa80f93c 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -236,7 +236,7 @@ impl<'src> FirstPassRecord<'src> { match ret.to_syn_type(TypePosition::Return) { None => { warn!( - "Cannot convert return type to syn type: {:?} on {:?}", + "Unsupported return type: {:?} on {:?}", ret, rust_name ); @@ -320,7 +320,7 @@ impl<'src> FirstPassRecord<'src> { syn_type } else { warn!( - "Cannot convert argument type to syn type: {:?} on {:?}", + "Unsupported argument type: {:?} on {:?}", idl_type, rust_name ); @@ -397,7 +397,7 @@ impl<'src> FirstPassRecord<'src> { first_pass::OperationId::Constructor => panic!("constructors are unsupported"), first_pass::OperationId::Operation(name) => match name { None => { - warn!("Operations without a name are unsupported"); + warn!("Unsupported unnamed operation: {:?}", operation_id); return Vec::new(); } Some(name) => name, @@ -541,7 +541,7 @@ impl<'src> FirstPassRecord<'src> { let name = match operation_name { Some(name) => name.to_string(), None => { - warn!("Operations without a name are unsupported"); + warn!("Unsupported unnamed operation: on {:?}", self_name); return Vec::new(); } };