mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 21:11:22 +00:00
Backend refactor (#411)
* remove BindgenAttrs from other backend::ast structs This is primarily a tool for use with the macro crate. Most of these attributes were ignored in the actual codegen, but a few were still being used. This is confusing when trying to add other sources for codegen (such as webidl and typescript). * move parsing logic to macro crate This makes the backend crate solely concerned with having an ast for which we can generate code.
This commit is contained in:
committed by
Alex Crichton
parent
056b45aeed
commit
2d50d5209b
File diff suppressed because it is too large
Load Diff
@ -273,7 +273,7 @@ impl ToTokens for ast::StructField {
|
||||
}
|
||||
}).to_tokens(tokens);
|
||||
|
||||
if self.opts.readonly() {
|
||||
if self.readonly {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -356,12 +356,10 @@ impl ToTokens for ast::Export {
|
||||
});
|
||||
quote! { me.#name }
|
||||
}
|
||||
None => {
|
||||
match &self.class {
|
||||
Some(class) => quote! { #class::#name },
|
||||
None => quote! { #name }
|
||||
}
|
||||
}
|
||||
None => match &self.class {
|
||||
Some(class) => quote! { #class::#name },
|
||||
None => quote! { #name },
|
||||
},
|
||||
};
|
||||
|
||||
for (i, syn::ArgCaptured { ty, .. }) in self.function.arguments.iter().enumerate() {
|
||||
@ -591,7 +589,10 @@ impl ToTokens for ast::ImportFunction {
|
||||
ast::ImportFunctionKind::Method {
|
||||
ref ty, ref kind, ..
|
||||
} => {
|
||||
if let ast::MethodKind::Normal = kind {
|
||||
if let ast::MethodKind::Operation(ast::Operation {
|
||||
is_static: false, ..
|
||||
}) = kind
|
||||
{
|
||||
is_method = true;
|
||||
}
|
||||
class_ty = Some(ty);
|
||||
@ -618,9 +619,7 @@ impl ToTokens for ast::ImportFunction {
|
||||
subpat: None,
|
||||
..
|
||||
}) => ident.clone(),
|
||||
syn::Pat::Wild(_) => {
|
||||
syn::Ident::new(&format!("__genarg_{}", i), Span::call_site())
|
||||
}
|
||||
syn::Pat::Wild(_) => syn::Ident::new(&format!("__genarg_{}", i), Span::call_site()),
|
||||
_ => panic!("unsupported pattern in foreign function"),
|
||||
};
|
||||
|
||||
@ -664,7 +663,7 @@ impl ToTokens for ast::ImportFunction {
|
||||
}
|
||||
|
||||
let mut exceptional_ret = quote!();
|
||||
let exn_data = if self.function.opts.catch() {
|
||||
let exn_data = if self.catch {
|
||||
let exn_data = Ident::new("exn_data", Span::call_site());
|
||||
let exn_data_ptr = Ident::new("exn_data_ptr", Span::call_site());
|
||||
abi_argument_names.push(exn_data_ptr.clone());
|
||||
|
@ -4,9 +4,8 @@
|
||||
extern crate proc_macro2;
|
||||
#[macro_use]
|
||||
extern crate quote;
|
||||
#[macro_use]
|
||||
extern crate syn;
|
||||
extern crate serde_json;
|
||||
extern crate syn;
|
||||
|
||||
extern crate wasm_bindgen_shared as shared;
|
||||
|
||||
|
Reference in New Issue
Block a user