Merge branch 'master' into add-wasm-bindgen-skip-attr

This commit is contained in:
alexlapa
2019-04-14 23:43:21 +03:00
67 changed files with 1030 additions and 214 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "wasm-bindgen-macro-support"
version = "0.2.40"
version = "0.2.42"
authors = ["The wasm-bindgen Developers"]
license = "MIT/Apache-2.0"
repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro-support"
@ -20,5 +20,5 @@ strict-macro = []
syn = { version = '0.15.0', features = ['visit'] }
quote = '0.6'
proc-macro2 = "0.4.9"
wasm-bindgen-backend = { path = "../backend", version = "=0.2.40" }
wasm-bindgen-shared = { path = "../shared", version = "=0.2.40" }
wasm-bindgen-backend = { path = "../backend", version = "=0.2.42" }
wasm-bindgen-shared = { path = "../shared", version = "=0.2.42" }

View File

@ -45,6 +45,7 @@ macro_rules! attrgen {
(readonly, Readonly(Span)),
(js_name, JsName(Span, String, Span)),
(js_class, JsClass(Span, String, Span)),
(is_type_of, IsTypeOf(Span, syn::Expr)),
(extends, Extends(Span, syn::Path)),
(vendor_prefix, VendorPrefix(Span, Ident)),
(variadic, Variadic(Span)),
@ -241,6 +242,11 @@ impl Parse for BindgenAttr {
return Ok(BindgenAttr::$variant(attr_span, input.parse()?));
});
(@parser $variant:ident(Span, syn::Expr)) => ({
input.parse::<Token![=]>()?;
return Ok(BindgenAttr::$variant(attr_span, input.parse()?));
});
(@parser $variant:ident(Span, String, Span)) => ({
input.parse::<Token![=]>()?;
let (val, span) = match input.parse::<syn::LitStr>() {
@ -523,6 +529,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ForeignItemType {
.js_name()
.map(|s| s.0)
.map_or_else(|| self.ident.to_string(), |s| s.to_string());
let is_type_of = attrs.is_type_of().cloned();
let shim = format!("__wbg_instanceof_{}_{}", self.ident, ShortHash(&self.ident));
let mut extends = Vec::new();
let mut vendor_prefixes = Vec::new();
@ -545,6 +552,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ForeignItemType {
attrs: self.attrs,
doc_comment: None,
instanceof_shim: shim,
is_type_of,
rust_name: self.ident,
js_name,
extends,
@ -904,7 +912,7 @@ fn prepare_for_impl_recursion(
pound_token: Default::default(),
style: syn::AttrStyle::Outer,
bracket_token: Default::default(),
path: syn::Ident::new("__wasm_bindgen_class_marker", Span::call_site()).into(),
path: syn::parse_quote! { wasm_bindgen::prelude::__wasm_bindgen_class_marker },
tts: quote::quote! { (#class = #js_class) }.into(),
},
);