wasmtime_component_macro/
lib.rs1use syn::{parse_macro_input, DeriveInput, Error};
2
3mod bindgen;
4mod component;
5
6#[proc_macro_derive(Lift, attributes(component))]
7pub fn lift(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
8 component::expand(
9 &component::LiftExpander,
10 &parse_macro_input!(input as DeriveInput),
11 )
12 .unwrap_or_else(Error::into_compile_error)
13 .into()
14}
15
16#[proc_macro_derive(Lower, attributes(component))]
17pub fn lower(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
18 component::expand(
19 &component::LowerExpander,
20 &parse_macro_input!(input as DeriveInput),
21 )
22 .unwrap_or_else(Error::into_compile_error)
23 .into()
24}
25
26#[proc_macro_derive(ComponentType, attributes(component))]
27pub fn component_type(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
28 component::expand(
29 &component::ComponentTypeExpander,
30 &parse_macro_input!(input as DeriveInput),
31 )
32 .unwrap_or_else(Error::into_compile_error)
33 .into()
34}
35
36#[proc_macro]
37pub fn flags(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
38 component::expand_flags(&parse_macro_input!(input as component::Flags))
39 .unwrap_or_else(Error::into_compile_error)
40 .into()
41}
42
43#[proc_macro]
44pub fn bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
45 bindgen::expand(&parse_macro_input!(input as bindgen::Config))
46 .unwrap_or_else(Error::into_compile_error)
47 .into()
48}