1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
extern crate proc_macro;

mod hostcalls;
mod raw_types;
mod utils;
mod wasi;

use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;

#[proc_macro]
pub fn witx_host_types(args: TokenStream) -> TokenStream {
    TokenStream::from(raw_types::gen(
        TokenStream2::from(args),
        raw_types::Mode::Host,
    ))
}

#[proc_macro]
pub fn witx_wasi_types(args: TokenStream) -> TokenStream {
    TokenStream::from(raw_types::gen(
        TokenStream2::from(args),
        raw_types::Mode::Wasi,
    ))
}

#[proc_macro]
pub fn witx_wasi32_types(args: TokenStream) -> TokenStream {
    TokenStream::from(raw_types::gen(
        TokenStream2::from(args),
        raw_types::Mode::Wasi32,
    ))
}

/// A single-use macro in the `wasmtime-wasi` crate.
#[proc_macro]
pub fn define_wasi_struct(args: TokenStream) -> TokenStream {
    wasi::define_struct(args.into()).into()
}

#[proc_macro]
pub fn define_wasi_struct_for_wiggle(args: TokenStream) -> TokenStream {
    wasi::define_struct_for_wiggle(args.into()).into()
}

#[proc_macro]
pub fn define_hostcalls(args: TokenStream) -> TokenStream {
    hostcalls::define(args.into()).into()
}