From 478e3fcedf3463cbbf9e996a5f06b9001329f602 Mon Sep 17 00:00:00 2001 From: Ben Merritt Date: Tue, 17 Jul 2018 22:23:17 -0700 Subject: [PATCH] Add basic support for [NoInterfaceObject] attribute (#497) --- crates/webidl/src/lib.rs | 4 ++++ crates/webidl/src/util.rs | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/webidl/src/lib.rs b/crates/webidl/src/lib.rs index d4b81986..17612b45 100644 --- a/crates/webidl/src/lib.rs +++ b/crates/webidl/src/lib.rs @@ -244,6 +244,10 @@ impl WebidlParse<()> for webidl::ast::NonPartialInterface { return Ok(()); } + if util::is_no_interface_object(&self.extended_attributes) { + return Ok(()); + } + program.imports.push(backend::ast::Import { module: None, version: None, diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 58c1d8da..e8de5e7c 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -385,16 +385,24 @@ impl<'a> FirstPassRecord<'a> { } } -/// ChromeOnly is for things that are only exposed to priveleged code in Firefox. -pub fn is_chrome_only(ext_attrs: &[Box]) -> bool { +fn has_named_attribute(ext_attrs: &[Box], attribute: &str) -> bool { ext_attrs.iter().any(|attr| match &**attr { ExtendedAttribute::NoArguments(webidl::ast::Other::Identifier(name)) => { - name == "ChromeOnly" + name == attribute } _ => false, }) } +/// ChromeOnly is for things that are only exposed to privileged code in Firefox. +pub fn is_chrome_only(ext_attrs: &[Box]) -> bool { + has_named_attribute(ext_attrs, "ChromeOnly") +} + +pub fn is_no_interface_object(ext_attrs: &[Box]) -> bool { + has_named_attribute(ext_attrs, "NoInterfaceObject") +} + pub fn is_structural(attrs: &[Box]) -> bool { attrs.iter().any(|attr| match &**attr { ExtendedAttribute::NoArguments(webidl::ast::Other::Identifier(name)) => {