Update dependencies

This commit is contained in:
Alex Crichton 2018-04-03 07:07:14 -07:00
parent e6a483f906
commit 782378e7c0
7 changed files with 54 additions and 56 deletions

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Nick Fitzgerald <fitzgen@gmail.com>"] authors = ["Nick Fitzgerald <fitzgen@gmail.com>"]
[dependencies] [dependencies]
quote = '0.4' quote = '0.5'
proc-macro2 = { version = "0.2", features = ["nightly"] } proc-macro2 = { version = "0.3", features = ["nightly"] }
wasm-bindgen-shared = { path = "../shared", version = "0.1.0" } wasm-bindgen-shared = { path = "../shared", version = "0.1.0" }
syn = { version = '0.12', features = ['full'] } syn = { version = '0.13', features = ['full'] }

View File

@ -518,7 +518,7 @@ impl Export {
} }
None => shared::free_function_export_name(self.function.name.as_ref()), None => shared::free_function_export_name(self.function.name.as_ref()),
}; };
syn::LitStr::new(&name, Span::def_site()) syn::LitStr::new(&name, Span::call_site())
} }
} }
@ -751,7 +751,7 @@ fn extract_first_ty_param(ty: Option<&Type>) -> Option<Option<Type>> {
} }
fn term<'a>(cursor: syn::buffer::Cursor<'a>, name: &str) -> syn::synom::PResult<'a, ()> { fn term<'a>(cursor: syn::buffer::Cursor<'a>, name: &str) -> syn::synom::PResult<'a, ()> {
if let Some((_span, term, next)) = cursor.term() { if let Some((term, next)) = cursor.term() {
if term.as_str() == name { if term.as_str() == name {
return Ok(((), next)); return Ok(((), next));
} }

View File

@ -5,7 +5,7 @@ use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
use ast; use ast;
use quote::{ToTokens, Tokens}; use quote::{ToTokens, Tokens};
use proc_macro2::{Span, Literal}; use proc_macro2::Literal;
use shared; use shared;
use syn; use syn;
@ -76,7 +76,7 @@ impl ToTokens for ast::Program {
let mut generated_static_value = Tokens::new(); let mut generated_static_value = Tokens::new();
let generated_static_length = self.literal(&mut generated_static_value); let generated_static_length = self.literal(&mut generated_static_value);
(my_quote! { (quote! {
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
#[wasm_custom_section = "__wasm_bindgen_unstable"] #[wasm_custom_section = "__wasm_bindgen_unstable"]
const #generated_static_name: [u8; #generated_static_length] = const #generated_static_name: [u8; #generated_static_length] =
@ -92,7 +92,7 @@ impl ToTokens for ast::Struct {
let c = shared::name_to_descriptor(name.as_ref()); let c = shared::name_to_descriptor(name.as_ref());
let descriptor = Literal::byte_string(format!("{:4}", c).as_bytes()); let descriptor = Literal::byte_string(format!("{:4}", c).as_bytes());
let borrowed_descriptor = Literal::byte_string(format!("{:4}", c + 1).as_bytes()); let borrowed_descriptor = Literal::byte_string(format!("{:4}", c + 1).as_bytes());
(my_quote! { (quote! {
impl ::wasm_bindgen::convert::WasmBoundary for #name { impl ::wasm_bindgen::convert::WasmBoundary for #name {
type Abi = u32; type Abi = u32;
const DESCRIPTOR: ::wasm_bindgen::convert::Descriptor = const DESCRIPTOR: ::wasm_bindgen::convert::Descriptor =
@ -176,8 +176,8 @@ impl ToTokens for ast::Export {
let mut offset = 0; let mut offset = 0;
if self.method { if self.method {
let class = self.class.unwrap(); let class = self.class.unwrap();
args.push(my_quote! { me: *mut ::wasm_bindgen::__rt::WasmRefCell<#class> }); args.push(quote! { me: *mut ::wasm_bindgen::__rt::WasmRefCell<#class> });
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
::wasm_bindgen::__rt::assert_not_null(me); ::wasm_bindgen::__rt::assert_not_null(me);
let me = unsafe { &*me }; let me = unsafe { &*me };
}); });
@ -189,10 +189,10 @@ impl ToTokens for ast::Export {
let ident = syn::Ident::from(format!("arg{}", i)); let ident = syn::Ident::from(format!("arg{}", i));
match *ty { match *ty {
ast::Type::ByValue(ref t) => { ast::Type::ByValue(ref t) => {
args.push(my_quote! { args.push(quote! {
#ident: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi #ident: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
}); });
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
let #ident = unsafe { let #ident = unsafe {
<#t as ::wasm_bindgen::convert::WasmBoundary> <#t as ::wasm_bindgen::convert::WasmBoundary>
::from_abi(#ident, &mut __stack) ::from_abi(#ident, &mut __stack)
@ -200,10 +200,10 @@ impl ToTokens for ast::Export {
}); });
} }
ast::Type::ByRef(ref ty) => { ast::Type::ByRef(ref ty) => {
args.push(my_quote! { args.push(quote! {
#ident: <#ty as ::wasm_bindgen::convert::FromRefWasmBoundary>::Abi #ident: <#ty as ::wasm_bindgen::convert::FromRefWasmBoundary>::Abi
}); });
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
let #ident = unsafe { let #ident = unsafe {
<#ty as ::wasm_bindgen::convert::FromRefWasmBoundary> <#ty as ::wasm_bindgen::convert::FromRefWasmBoundary>
::from_abi_ref(#ident, &mut __stack) ::from_abi_ref(#ident, &mut __stack)
@ -212,10 +212,10 @@ impl ToTokens for ast::Export {
}); });
} }
ast::Type::ByMutRef(ref ty) => { ast::Type::ByMutRef(ref ty) => {
args.push(my_quote! { args.push(quote! {
#ident: <#ty as ::wasm_bindgen::convert::FromRefMutWasmBoundary>::Abi #ident: <#ty as ::wasm_bindgen::convert::FromRefMutWasmBoundary>::Abi
}); });
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
let mut #ident = unsafe { let mut #ident = unsafe {
<#ty as ::wasm_bindgen::convert::FromRefMutWasmBoundary> <#ty as ::wasm_bindgen::convert::FromRefMutWasmBoundary>
::from_abi_ref_mut(#ident, &mut __stack) ::from_abi_ref_mut(#ident, &mut __stack)
@ -224,16 +224,16 @@ impl ToTokens for ast::Export {
}); });
} }
} }
converted_arguments.push(my_quote! { #ident }); converted_arguments.push(quote! { #ident });
} }
let ret_ty; let ret_ty;
let convert_ret; let convert_ret;
match self.function.ret { match self.function.ret {
Some(ast::Type::ByValue(ref t)) => { Some(ast::Type::ByValue(ref t)) => {
ret_ty = my_quote! { ret_ty = quote! {
-> <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi -> <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
}; };
convert_ret = my_quote! { convert_ret = quote! {
<#t as ::wasm_bindgen::convert::WasmBoundary> <#t as ::wasm_bindgen::convert::WasmBoundary>
::into_abi(#ret, &mut unsafe { ::into_abi(#ret, &mut unsafe {
::wasm_bindgen::convert::GlobalStack::new() ::wasm_bindgen::convert::GlobalStack::new()
@ -245,8 +245,8 @@ impl ToTokens for ast::Export {
panic!("can't return a borrowed ref"); panic!("can't return a borrowed ref");
} }
None => { None => {
ret_ty = my_quote!{}; ret_ty = quote!{};
convert_ret = my_quote!{}; convert_ret = quote!{};
} }
} }
@ -254,16 +254,16 @@ impl ToTokens for ast::Export {
let receiver = match self.class { let receiver = match self.class {
Some(_) if self.method => { Some(_) if self.method => {
if self.mutable { if self.mutable {
my_quote! { me.borrow_mut().#name } quote! { me.borrow_mut().#name }
} else { } else {
my_quote! { me.borrow().#name } quote! { me.borrow().#name }
} }
} }
Some(class) => my_quote! { #class::#name }, Some(class) => quote! { #class::#name },
None => my_quote!{ #name }, None => quote!{ #name },
}; };
let tokens = my_quote! { let tokens = quote! {
#[export_name = #export_name] #[export_name = #export_name]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub extern fn #generated_name(#(#args),*) #ret_ty { pub extern fn #generated_name(#(#args),*) #ret_ty {
@ -286,7 +286,7 @@ impl ToTokens for ast::ImportType {
fn to_tokens(&self, tokens: &mut Tokens) { fn to_tokens(&self, tokens: &mut Tokens) {
let vis = &self.vis; let vis = &self.vis;
let name = &self.name; let name = &self.name;
(my_quote! { (quote! {
#[allow(bad_style)] #[allow(bad_style)]
#vis struct #name { #vis struct #name {
obj: ::wasm_bindgen::JsValue, obj: ::wasm_bindgen::JsValue,
@ -412,15 +412,15 @@ impl ToTokens for ast::ImportFunction {
match *ty { match *ty {
ast::Type::ByValue(ref t) => { ast::Type::ByValue(ref t) => {
abi_argument_names.push(name); abi_argument_names.push(name);
abi_arguments.push(my_quote! { abi_arguments.push(quote! {
#name: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi #name: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
}); });
let var = if i == 0 && is_method { let var = if i == 0 && is_method {
my_quote! { self } quote! { self }
} else { } else {
quote! { #name } quote! { #name }
}; };
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
let #name = <#t as ::wasm_bindgen::convert::WasmBoundary> let #name = <#t as ::wasm_bindgen::convert::WasmBoundary>
::into_abi(#var, &mut __stack); ::into_abi(#var, &mut __stack);
}); });
@ -428,13 +428,13 @@ impl ToTokens for ast::ImportFunction {
ast::Type::ByMutRef(_) => panic!("urgh mut"), ast::Type::ByMutRef(_) => panic!("urgh mut"),
ast::Type::ByRef(ref t) => { ast::Type::ByRef(ref t) => {
abi_argument_names.push(name); abi_argument_names.push(name);
abi_arguments.push(my_quote! { #name: u32 }); abi_arguments.push(quote! { #name: u32 });
let var = if i == 0 && is_method { let var = if i == 0 && is_method {
my_quote! { self } quote! { self }
} else { } else {
quote! { #name } quote! { #name }
}; };
arg_conversions.push(my_quote! { arg_conversions.push(quote! {
let #name = <#t as ::wasm_bindgen::convert::ToRefWasmBoundary> let #name = <#t as ::wasm_bindgen::convert::ToRefWasmBoundary>
::to_abi_ref(#var, &mut __stack); ::to_abi_ref(#var, &mut __stack);
}); });
@ -445,10 +445,10 @@ impl ToTokens for ast::ImportFunction {
let mut convert_ret; let mut convert_ret;
match self.function.ret { match self.function.ret {
Some(ast::Type::ByValue(ref t)) => { Some(ast::Type::ByValue(ref t)) => {
abi_ret = my_quote! { abi_ret = quote! {
<#t as ::wasm_bindgen::convert::WasmBoundary>::Abi <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
}; };
convert_ret = my_quote! { convert_ret = quote! {
<#t as ::wasm_bindgen::convert::WasmBoundary> <#t as ::wasm_bindgen::convert::WasmBoundary>
::from_abi( ::from_abi(
#ret_ident, #ret_ident,
@ -459,19 +459,19 @@ impl ToTokens for ast::ImportFunction {
Some(ast::Type::ByRef(_)) Some(ast::Type::ByRef(_))
| Some(ast::Type::ByMutRef(_)) => panic!("can't return a borrowed ref"), | Some(ast::Type::ByMutRef(_)) => panic!("can't return a borrowed ref"),
None => { None => {
abi_ret = my_quote! { () }; abi_ret = quote! { () };
convert_ret = my_quote! { () }; convert_ret = quote! { () };
} }
} }
let mut exceptional_ret = my_quote!{}; let mut exceptional_ret = quote!{};
let exn_data = if self.function.opts.catch() { let exn_data = if self.function.opts.catch() {
let exn_data = syn::Ident::from("exn_data"); let exn_data = syn::Ident::from("exn_data");
let exn_data_ptr = syn::Ident::from("exn_data_ptr"); let exn_data_ptr = syn::Ident::from("exn_data_ptr");
abi_argument_names.push(exn_data_ptr); abi_argument_names.push(exn_data_ptr);
abi_arguments.push(my_quote! { #exn_data_ptr: *mut u32 }); abi_arguments.push(quote! { #exn_data_ptr: *mut u32 });
convert_ret = my_quote! { Ok(#convert_ret) }; convert_ret = quote! { Ok(#convert_ret) };
exceptional_ret = my_quote! { exceptional_ret = quote! {
if #exn_data[0] == 1 { if #exn_data[0] == 1 {
return Err( return Err(
< <
@ -480,7 +480,7 @@ impl ToTokens for ast::ImportFunction {
) )
} }
}; };
my_quote! { quote! {
let mut #exn_data = [0; 2]; let mut #exn_data = [0; 2];
let #exn_data_ptr = #exn_data.as_mut_ptr(); let #exn_data_ptr = #exn_data.as_mut_ptr();
} }
@ -500,12 +500,12 @@ impl ToTokens for ast::ImportFunction {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let me = if is_method { let me = if is_method {
my_quote! { &self, } quote! { &self, }
} else { } else {
quote!() quote!()
}; };
let invocation = my_quote! { let invocation = quote! {
#(#attrs)* #(#attrs)*
#[allow(bad_style)] #[allow(bad_style)]
#vis extern #fn_token #rust_name(#me #(#arguments),*) #ret { #vis extern #fn_token #rust_name(#me #(#arguments),*) #ret {
@ -554,7 +554,7 @@ impl ToTokens for ast::Enum {
} }
} }
}); });
(my_quote! { (quote! {
impl #enum_name { impl #enum_name {
fn from_u32(#incoming_u32: u32) -> #enum_name { fn from_u32(#incoming_u32: u32) -> #enum_name {
#(#cast_clauses else)* { #(#cast_clauses else)* {
@ -591,7 +591,7 @@ impl ToTokens for ast::ImportStatic {
let ty = &self.ty; let ty = &self.ty;
let shim_name = self.shim; let shim_name = self.shim;
let vis = &self.vis; let vis = &self.vis;
(my_quote! { (quote! {
#[allow(bad_style)] #[allow(bad_style)]
#vis static #name: ::wasm_bindgen::JsStatic<#ty> = { #vis static #name: ::wasm_bindgen::JsStatic<#ty> = {
fn init() -> #ty { fn init() -> #ty {

View File

@ -8,10 +8,6 @@ extern crate syn;
extern crate wasm_bindgen_shared as shared; extern crate wasm_bindgen_shared as shared;
macro_rules! my_quote {
($($t:tt)*) => (quote_spanned!(Span::call_site() => $($t)*))
}
pub mod ast; pub mod ast;
mod codegen; mod codegen;
mod literal; mod literal;

View File

@ -1,5 +1,4 @@
use ast; use ast;
use proc_macro2::Span;
use quote::{ToTokens, Tokens}; use quote::{ToTokens, Tokens};
use shared; use shared;
use std::collections::BTreeSet; use std::collections::BTreeSet;
@ -142,14 +141,14 @@ impl Literal for ast::Type {
fn literal(&self, a: &mut LiteralBuilder) { fn literal(&self, a: &mut LiteralBuilder) {
match *self { match *self {
ast::Type::ByValue(ref t) => { ast::Type::ByValue(ref t) => {
a.as_char(my_quote! { a.as_char(quote! {
<#t as ::wasm_bindgen::convert::WasmBoundary>::DESCRIPTOR <#t as ::wasm_bindgen::convert::WasmBoundary>::DESCRIPTOR
}); });
} }
ast::Type::ByRef(ref ty) | ast::Type::ByMutRef(ref ty) => { ast::Type::ByRef(ref ty) | ast::Type::ByMutRef(ref ty) => {
// TODO: this assumes `ToRef*` and `FromRef*` use the same // TODO: this assumes `ToRef*` and `FromRef*` use the same
// descriptor. // descriptor.
a.as_char(my_quote! { a.as_char(quote! {
<#ty as ::wasm_bindgen::convert::FromRefWasmBoundary>::DESCRIPTOR <#ty as ::wasm_bindgen::convert::FromRefWasmBoundary>::DESCRIPTOR
}); });
} }

View File

@ -14,9 +14,9 @@ Definition of the `#[wasm_bindgen]` attribute, an internal dependency
proc-macro = true proc-macro = true
[dependencies] [dependencies]
syn = { version = '0.12', features = ['full'] } syn = { version = '0.13', features = ['full'] }
quote = '0.4' quote = '0.5'
proc-macro2 = { version = "0.2", features = ["nightly"] } proc-macro2 = { version = "0.3", features = ["nightly"] }
serde_json = "1" serde_json = "1"
wasm-bindgen-shared = { path = "../shared", version = "0.1.0" } wasm-bindgen-shared = { path = "../shared", version = "0.1.0" }
wasm-bindgen-backend = { path = "../backend", version = "0.1.0" } wasm-bindgen-backend = { path = "../backend", version = "0.1.0" }

View File

@ -210,6 +210,9 @@ impl Project {
// move files from the root into each test, it looks like this may be // move files from the root into each test, it looks like this may be
// needed for webpack to work well when invoked concurrently. // needed for webpack to work well when invoked concurrently.
fs::hard_link("package.json", root.join("package.json")).unwrap(); fs::hard_link("package.json", root.join("package.json")).unwrap();
if !Path::new("yarn.lock").exists() {
panic!("\n\nfailed to find `yarn.lock`, have you run `yarn` yet?\n\n");
}
fs::hard_link("yarn.lock", root.join("yarn.lock")).unwrap(); fs::hard_link("yarn.lock", root.join("yarn.lock")).unwrap();
let cwd = env::current_dir().unwrap(); let cwd = env::current_dir().unwrap();
symlink_dir(&cwd.join("node_modules"), &root.join("node_modules")).unwrap(); symlink_dir(&cwd.join("node_modules"), &root.join("node_modules")).unwrap();