mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Update to released syn/quote verisons
This commit is contained in:
parent
5c0f9613f6
commit
28a25ef8b9
@ -7,8 +7,8 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { git = 'https://github.com/dtolnay/syn', features = ['full'] }
|
||||
quote = { git = 'https://github.com/dtolnay/quote' }
|
||||
proc-macro2 = { version = "0.1", features = ["unstable"] }
|
||||
syn = { version = '0.12', features = ['full'] }
|
||||
quote = '0.4'
|
||||
proc-macro2 = { version = "0.2", features = ["nightly"] }
|
||||
serde_json = "1"
|
||||
wasm-bindgen-shared = { path = "../wasm-bindgen-shared" }
|
||||
|
@ -1,4 +1,4 @@
|
||||
use proc_macro2::Literal;
|
||||
use proc_macro2::Span;
|
||||
use syn;
|
||||
use wasm_bindgen_shared as shared;
|
||||
|
||||
@ -76,7 +76,7 @@ impl Program {
|
||||
|
||||
pub fn push_foreign_mod(&mut self, f: &syn::ItemForeignMod) {
|
||||
match f.abi.name {
|
||||
Some(ref l) if l.to_string() == "\"JS\"" => {}
|
||||
Some(ref l) if l.value() == "JS" => {}
|
||||
_ => panic!("only foreign mods with the `JS` ABI are allowed"),
|
||||
}
|
||||
for item in f.items.iter() {
|
||||
@ -156,20 +156,14 @@ impl Function {
|
||||
Function { name, arguments, ret }
|
||||
}
|
||||
|
||||
pub fn free_function_export_name(&self) -> syn::Lit {
|
||||
pub fn free_function_export_name(&self) -> syn::LitStr {
|
||||
let name = self.shared().free_function_export_name();
|
||||
syn::Lit {
|
||||
value: syn::LitKind::Other(Literal::string(&name)),
|
||||
span: Default::default(),
|
||||
}
|
||||
syn::LitStr::new(&name, Span::def_site())
|
||||
}
|
||||
|
||||
pub fn struct_function_export_name(&self, s: syn::Ident) -> syn::Lit {
|
||||
pub fn struct_function_export_name(&self, s: syn::Ident) -> syn::LitStr {
|
||||
let name = self.shared().struct_function_export_name(s.as_ref());
|
||||
syn::Lit {
|
||||
value: syn::LitKind::Other(Literal::string(&name)),
|
||||
span: Default::default(),
|
||||
}
|
||||
syn::LitStr::new(&name, Span::def_site())
|
||||
}
|
||||
|
||||
pub fn rust_symbol(&self, namespace: Option<syn::Ident>) -> syn::Ident {
|
||||
@ -199,11 +193,11 @@ pub fn extract_path_ident(path: &syn::Path) -> syn::Ident {
|
||||
if path.segments.len() != 1 {
|
||||
panic!("unsupported path that needs name resolution")
|
||||
}
|
||||
match path.segments.first().unwrap().item().arguments {
|
||||
match path.segments.first().unwrap().value().arguments {
|
||||
syn::PathArguments::None => {}
|
||||
_ => panic!("unsupported path that has path arguments")
|
||||
}
|
||||
path.segments.first().unwrap().item().ident
|
||||
path.segments.first().unwrap().value().ident
|
||||
}
|
||||
|
||||
impl Type {
|
||||
|
@ -11,7 +11,7 @@ extern crate wasm_bindgen_shared;
|
||||
use std::sync::atomic::*;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::{Literal, Span, TokenNode, Delimiter, TokenTree};
|
||||
use proc_macro2::{Span, TokenNode, Delimiter, TokenTree};
|
||||
use quote::{Tokens, ToTokens};
|
||||
|
||||
mod ast;
|
||||
@ -20,7 +20,7 @@ static MALLOC_GENERATED: AtomicBool = ATOMIC_BOOL_INIT;
|
||||
static BOXED_STR_GENERATED: AtomicBool = ATOMIC_BOOL_INIT;
|
||||
|
||||
macro_rules! my_quote {
|
||||
($($t:tt)*) => (quote_spanned!(Span::call_site(), $($t)*))
|
||||
($($t:tt)*) => (quote_spanned!(Span::call_site() => $($t)*))
|
||||
}
|
||||
|
||||
#[proc_macro]
|
||||
@ -87,10 +87,10 @@ pub fn wasm_bindgen(input: TokenStream) -> TokenStream {
|
||||
let generated_static_name = syn::Ident::from(generated_static_name);
|
||||
let mut generated_static = String::from("wbg:");
|
||||
generated_static.push_str(&serde_json::to_string(&program.shared()).unwrap());
|
||||
let generated_static_value = syn::Lit {
|
||||
value: syn::LitKind::Other(Literal::byte_string(generated_static.as_bytes())),
|
||||
span: Default::default(),
|
||||
};
|
||||
let generated_static_value = syn::LitByteStr::new(
|
||||
generated_static.as_bytes(),
|
||||
Span::def_site(),
|
||||
);
|
||||
let generated_static_length = generated_static.len();
|
||||
|
||||
(my_quote! {
|
||||
@ -157,7 +157,7 @@ enum Receiver {
|
||||
StructMethod(syn::Ident, bool, syn::Ident),
|
||||
}
|
||||
|
||||
fn bindgen(export_name: &syn::Lit,
|
||||
fn bindgen(export_name: &syn::LitStr,
|
||||
generated_name: syn::Ident,
|
||||
receiver: Receiver,
|
||||
arguments: &[ast::Type],
|
||||
@ -404,7 +404,7 @@ impl ToTokens for Receiver {
|
||||
syn::Ident::from("borrow").to_tokens(tokens);
|
||||
}
|
||||
tokens.append(TokenTree {
|
||||
span: Default::default(),
|
||||
span: Span::def_site(),
|
||||
kind: TokenNode::Group(Delimiter::Parenthesis,
|
||||
proc_macro2::TokenStream::empty()),
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user