mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-02 02:11:06 +00:00
Merge pull request #303 from teovoinea/master
Added is_chrome_only (#244)
This commit is contained in:
commit
9339a55f3e
@ -128,6 +128,10 @@ impl WebidlParse<()> for webidl::ast::Interface {
|
|||||||
|
|
||||||
impl WebidlParse<()> for webidl::ast::Typedef {
|
impl WebidlParse<()> for webidl::ast::Typedef {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, _: ()) -> Result<()> {
|
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 dest = rust_ident(&self.name);
|
||||||
let src = match webidl_ty_to_syn_ty(&self.type_, TypePosition::Return) {
|
let src = match webidl_ty_to_syn_ty(&self.type_, TypePosition::Return) {
|
||||||
Some(src) => src,
|
Some(src) => src,
|
||||||
@ -154,6 +158,10 @@ impl WebidlParse<()> for webidl::ast::Typedef {
|
|||||||
|
|
||||||
impl WebidlParse<()> for webidl::ast::NonPartialInterface {
|
impl WebidlParse<()> for webidl::ast::NonPartialInterface {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, _: ()) -> Result<()> {
|
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 {
|
program.imports.push(backend::ast::Import {
|
||||||
module: None,
|
module: None,
|
||||||
version: 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 {
|
impl<'a> WebidlParse<&'a str> for webidl::ast::RegularAttribute {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
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(
|
create_getter(
|
||||||
&self.name,
|
&self.name,
|
||||||
&self.type_,
|
&self.type_,
|
||||||
@ -317,6 +329,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::RegularAttribute {
|
|||||||
|
|
||||||
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
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(
|
create_getter(
|
||||||
&self.name,
|
&self.name,
|
||||||
&self.type_,
|
&self.type_,
|
||||||
@ -341,6 +357,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
|||||||
|
|
||||||
impl<'a> WebidlParse<&'a str> for webidl::ast::RegularOperation {
|
impl<'a> WebidlParse<&'a str> for webidl::ast::RegularOperation {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
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(
|
create_basic_method(
|
||||||
&self.arguments,
|
&self.arguments,
|
||||||
self.name.as_ref(),
|
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 {
|
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticOperation {
|
||||||
fn webidl_parse(&self, program: &mut backend::ast::Program, self_name: &'a str) -> Result<()> {
|
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(
|
create_basic_method(
|
||||||
&self.arguments,
|
&self.arguments,
|
||||||
self.name.as_ref(),
|
self.name.as_ref(),
|
||||||
|
@ -6,6 +6,7 @@ use heck::SnakeCase;
|
|||||||
use proc_macro2::Ident;
|
use proc_macro2::Ident;
|
||||||
use syn;
|
use syn;
|
||||||
use webidl;
|
use webidl;
|
||||||
|
use webidl::ast::ExtendedAttribute;
|
||||||
|
|
||||||
fn shared_ref(ty: syn::Type) -> syn::Type {
|
fn shared_ref(ty: syn::Type) -> syn::Type {
|
||||||
syn::TypeReference {
|
syn::TypeReference {
|
||||||
@ -285,3 +286,32 @@ pub fn create_setter(
|
|||||||
vec![backend::ast::BindgenAttr::Setter(Some(raw_ident(name)))],
|
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
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
}
|
@ -402,94 +402,6 @@ impl Event {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern "C" fn __wbindgen_describe___widl_f_default_prevented_by_chrome_Event() {
|
|
||||||
use wasm_bindgen::describe::*;
|
|
||||||
inform(FUNCTION);
|
|
||||||
inform(1u32);
|
|
||||||
<&Event as WasmDescribe>::describe();
|
|
||||||
inform(1);
|
|
||||||
<bool as WasmDescribe>::describe();
|
|
||||||
}
|
|
||||||
impl Event {
|
|
||||||
#[allow(bad_style)]
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
|
||||||
pub extern "C" fn default_prevented_by_chrome(&self) -> bool {
|
|
||||||
::wasm_bindgen::__rt::link_this_library();
|
|
||||||
#[wasm_import_module = "__wbindgen_placeholder__"]
|
|
||||||
extern "C" {
|
|
||||||
fn __widl_f_default_prevented_by_chrome_Event(
|
|
||||||
self_: <&Event as ::wasm_bindgen::convert::IntoWasmAbi>::Abi,
|
|
||||||
) -> <bool as ::wasm_bindgen::convert::FromWasmAbi>::Abi;
|
|
||||||
}
|
|
||||||
unsafe {
|
|
||||||
let _ret = {
|
|
||||||
let mut __stack = ::wasm_bindgen::convert::GlobalStack::new();
|
|
||||||
let self_ =
|
|
||||||
<&Event as ::wasm_bindgen::convert::IntoWasmAbi>::into_abi(self, &mut __stack);
|
|
||||||
__widl_f_default_prevented_by_chrome_Event(self_)
|
|
||||||
};
|
|
||||||
<bool as ::wasm_bindgen::convert::FromWasmAbi>::from_abi(
|
|
||||||
_ret,
|
|
||||||
&mut ::wasm_bindgen::convert::GlobalStack::new(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[allow(bad_style, unused_variables)]
|
|
||||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
|
||||||
pub extern "C" fn default_prevented_by_chrome(&self) -> bool {
|
|
||||||
panic!(
|
|
||||||
"cannot call wasm-bindgen imported functions on \
|
|
||||||
non-wasm targets"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[no_mangle]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub extern "C" fn __wbindgen_describe___widl_f_default_prevented_by_content_Event() {
|
|
||||||
use wasm_bindgen::describe::*;
|
|
||||||
inform(FUNCTION);
|
|
||||||
inform(1u32);
|
|
||||||
<&Event as WasmDescribe>::describe();
|
|
||||||
inform(1);
|
|
||||||
<bool as WasmDescribe>::describe();
|
|
||||||
}
|
|
||||||
impl Event {
|
|
||||||
#[allow(bad_style)]
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
|
||||||
pub extern "C" fn default_prevented_by_content(&self) -> bool {
|
|
||||||
::wasm_bindgen::__rt::link_this_library();
|
|
||||||
#[wasm_import_module = "__wbindgen_placeholder__"]
|
|
||||||
extern "C" {
|
|
||||||
fn __widl_f_default_prevented_by_content_Event(
|
|
||||||
self_: <&Event as ::wasm_bindgen::convert::IntoWasmAbi>::Abi,
|
|
||||||
) -> <bool as ::wasm_bindgen::convert::FromWasmAbi>::Abi;
|
|
||||||
}
|
|
||||||
unsafe {
|
|
||||||
let _ret = {
|
|
||||||
let mut __stack = ::wasm_bindgen::convert::GlobalStack::new();
|
|
||||||
let self_ =
|
|
||||||
<&Event as ::wasm_bindgen::convert::IntoWasmAbi>::into_abi(self, &mut __stack);
|
|
||||||
__widl_f_default_prevented_by_content_Event(self_)
|
|
||||||
};
|
|
||||||
<bool as ::wasm_bindgen::convert::FromWasmAbi>::from_abi(
|
|
||||||
_ret,
|
|
||||||
&mut ::wasm_bindgen::convert::GlobalStack::new(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[allow(bad_style, unused_variables)]
|
|
||||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
|
||||||
pub extern "C" fn default_prevented_by_content(&self) -> bool {
|
|
||||||
panic!(
|
|
||||||
"cannot call wasm-bindgen imported functions on \
|
|
||||||
non-wasm targets"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[no_mangle]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub extern "C" fn __wbindgen_describe___widl_f_composed_Event() {
|
pub extern "C" fn __wbindgen_describe___widl_f_composed_Event() {
|
||||||
use wasm_bindgen::describe::*;
|
use wasm_bindgen::describe::*;
|
||||||
inform(FUNCTION);
|
inform(FUNCTION);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user