Path: blob/main/crates/component-macro/src/lib.rs
1692 views
//! > **⚠️ Warning ⚠️**: this crate is an internal-only crate for the Wasmtime1//! > project and is not intended for general use. APIs are not strictly2//! > reviewed for safety and usage outside of Wasmtime may have bugs. If3//! > you're interested in using this feel free to file an issue on the4//! > Wasmtime repository to start a discussion about doing so, but otherwise5//! > be aware that your usage of this crate is not supported.67use syn::{DeriveInput, Error, parse_macro_input};89mod bindgen;10mod component;1112#[proc_macro_derive(Lift, attributes(component))]13pub fn lift(input: proc_macro::TokenStream) -> proc_macro::TokenStream {14component::expand(15&component::LiftExpander,16&parse_macro_input!(input as DeriveInput),17)18.unwrap_or_else(Error::into_compile_error)19.into()20}2122#[proc_macro_derive(Lower, attributes(component))]23pub fn lower(input: proc_macro::TokenStream) -> proc_macro::TokenStream {24component::expand(25&component::LowerExpander,26&parse_macro_input!(input as DeriveInput),27)28.unwrap_or_else(Error::into_compile_error)29.into()30}3132#[proc_macro_derive(ComponentType, attributes(component))]33pub fn component_type(input: proc_macro::TokenStream) -> proc_macro::TokenStream {34component::expand(35&component::ComponentTypeExpander,36&parse_macro_input!(input as DeriveInput),37)38.unwrap_or_else(Error::into_compile_error)39.into()40}4142#[proc_macro]43pub fn flags(input: proc_macro::TokenStream) -> proc_macro::TokenStream {44component::expand_flags(&parse_macro_input!(input as component::Flags))45.unwrap_or_else(Error::into_compile_error)46.into()47}4849#[proc_macro]50pub fn bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {51bindgen::expand(&parse_macro_input!(input as bindgen::Config))52.unwrap_or_else(Error::into_compile_error)53.into()54}555657