Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/src/lib.rs
1692 views
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
8
use syn::{DeriveInput, Error, parse_macro_input};
9
10
mod bindgen;
11
mod component;
12
13
#[proc_macro_derive(Lift, attributes(component))]
14
pub 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))]
24
pub 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))]
34
pub 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]
44
pub 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]
51
pub 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
}
56
57