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