wasmtime_internal_component_macro/
lib.rs

1//! > **⚠️ Warning ⚠️**: this crate is an internal-only crate for the Wasmtime
2//! > project and is not intended for general use. APIs are not strictly
3//! > reviewed for safety and usage outside of Wasmtime may have bugs. If
4//! > you're interested in using this feel free to file an issue on the
5//! > Wasmtime repository to start a discussion about doing so, but otherwise
6//! > be aware that your usage of this crate is not supported.
7
8use syn::{DeriveInput, Error, parse_macro_input};
9
10mod bindgen;
11mod component;
12
13#[proc_macro_derive(Lift, attributes(component))]
14pub fn lift(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
15    component::expand(
16        &component::LiftExpander,
17        &parse_macro_input!(input as DeriveInput),
18    )
19    .unwrap_or_else(Error::into_compile_error)
20    .into()
21}
22
23#[proc_macro_derive(Lower, attributes(component))]
24pub fn lower(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
25    component::expand(
26        &component::LowerExpander,
27        &parse_macro_input!(input as DeriveInput),
28    )
29    .unwrap_or_else(Error::into_compile_error)
30    .into()
31}
32
33#[proc_macro_derive(ComponentType, attributes(component))]
34pub fn component_type(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
35    component::expand(
36        &component::ComponentTypeExpander,
37        &parse_macro_input!(input as DeriveInput),
38    )
39    .unwrap_or_else(Error::into_compile_error)
40    .into()
41}
42
43#[proc_macro]
44pub fn flags(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
45    component::expand_flags(&parse_macro_input!(input as component::Flags))
46        .unwrap_or_else(Error::into_compile_error)
47        .into()
48}
49
50#[proc_macro]
51pub fn bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
52    bindgen::expand(&parse_macro_input!(input as bindgen::Config))
53        .unwrap_or_else(Error::into_compile_error)
54        .into()
55}