mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 15:31:25 +00:00
Move the macro support code into its own crate (#529)
This commit is contained in:
26
crates/macro-support/src/lib.rs
Executable file
26
crates/macro-support/src/lib.rs
Executable file
@ -0,0 +1,26 @@
|
||||
//! This crate contains the part of the implementation of the `#[wasm_bindgen]` optsibute that is
|
||||
//! not in the shared backend crate.
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/wasm-bindgen-macro-support/0.2")]
|
||||
|
||||
extern crate proc_macro2;
|
||||
extern crate quote;
|
||||
#[macro_use]
|
||||
extern crate syn;
|
||||
extern crate wasm_bindgen_backend as backend;
|
||||
extern crate wasm_bindgen_shared as shared;
|
||||
|
||||
pub use parser::BindgenAttrs;
|
||||
use parser::MacroParse;
|
||||
use quote::ToTokens;
|
||||
|
||||
mod parser;
|
||||
|
||||
/// Takes the parsed input from a `#[wasm_bindgen]` macro and returns the generated bindings
|
||||
pub fn expand(item: syn::Item, opts: parser::BindgenAttrs) -> proc_macro2::TokenStream {
|
||||
let mut tokens = proc_macro2::TokenStream::new();
|
||||
let mut program = backend::ast::Program::default();
|
||||
item.macro_parse(&mut program, (Some(opts), &mut tokens));
|
||||
program.to_tokens(&mut tokens);
|
||||
tokens
|
||||
}
|
Reference in New Issue
Block a user