mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 06:51:24 +00:00
Update with masters and fix PR changes
This commit is contained in:
@ -128,6 +128,10 @@ impl WebidlParse<()> for webidl::ast::Interface {
|
||||
|
||||
impl WebidlParse<()> for webidl::ast::Typedef {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, _: ()) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let dest = rust_ident(&self.name);
|
||||
let src = match webidl_ty_to_syn_ty(&self.type_, TypePosition::Return) {
|
||||
Some(src) => src,
|
||||
@ -154,6 +158,10 @@ impl WebidlParse<()> for webidl::ast::Typedef {
|
||||
|
||||
impl WebidlParse<()> for webidl::ast::NonPartialInterface {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, _: ()) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
program.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
@ -293,6 +301,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::Operation {
|
||||
|
||||
impl<'a> WebidlParse<&'a str> for webidl::ast::RegularAttribute {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
create_getter(
|
||||
&self.name,
|
||||
&self.type_,
|
||||
@ -317,6 +329,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::RegularAttribute {
|
||||
|
||||
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
create_getter(
|
||||
&self.name,
|
||||
&self.type_,
|
||||
@ -341,6 +357,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
||||
|
||||
impl<'a> WebidlParse<&'a str> for webidl::ast::RegularOperation {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
create_basic_method(
|
||||
&self.arguments,
|
||||
self.name.as_ref(),
|
||||
@ -356,6 +376,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::RegularOperation {
|
||||
|
||||
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticOperation {
|
||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
||||
if util::is_chrome_only(&self.extended_attributes) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
create_basic_method(
|
||||
&self.arguments,
|
||||
self.name.as_ref(),
|
||||
|
@ -6,6 +6,7 @@ use heck::SnakeCase;
|
||||
use proc_macro2::Ident;
|
||||
use syn;
|
||||
use webidl;
|
||||
use webidl::ast::ExtendedAttribute;
|
||||
|
||||
fn shared_ref(ty: syn::Type) -> syn::Type {
|
||||
syn::TypeReference {
|
||||
@ -285,3 +286,32 @@ pub fn create_setter(
|
||||
vec![backend::ast::BindgenAttr::Setter(Some(raw_ident(name)))],
|
||||
)
|
||||
}
|
||||
|
||||
/// ChromeOnly is for things that are only exposed to priveleged code in Firefox.
|
||||
pub fn is_chrome_only(ext_attrs: &[Box<ExtendedAttribute>]) -> bool {
|
||||
ext_attrs.iter().any(|external_attribute| {
|
||||
return match &**external_attribute {
|
||||
ExtendedAttribute::ArgumentList(al) => {
|
||||
println!("ArgumentList");
|
||||
al.name == "ChromeOnly"
|
||||
},
|
||||
ExtendedAttribute::Identifier(i) => {
|
||||
println!("Identifier");
|
||||
i.lhs == "ChromeOnly"
|
||||
},
|
||||
ExtendedAttribute::IdentifierList(il) => {
|
||||
println!("IdentifierList");
|
||||
il.lhs == "ChromeOnly"
|
||||
},
|
||||
ExtendedAttribute::NamedArgumentList(nal) => {
|
||||
println!("NamedArgumentList");
|
||||
nal.lhs_name == "ChromeOnly"
|
||||
},
|
||||
ExtendedAttribute::NoArguments(webidl::ast::Other::Identifier(name)) => name == "ChromeOnly",
|
||||
ExtendedAttribute::NoArguments(_na) => {
|
||||
println!("NoArguments");
|
||||
false
|
||||
}
|
||||
};
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user