Hello, I am working on wasm-bridge, a project to "make wasmtime work on the web". I am currently looking into a way to add component model support.
When I invoke the wasm_bridge::component::bindgen!
macro, the generated code uses the wasmtime
crate. I was wondering if it would be possible to write my own proc macro, call the original bindgen macro with the same TokenStream
input, and modify it's output.
Something like this:
#[proc_macro]
pub fn my_bindgen(stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
let stream = wasmtime_component_macro::bindgen(stream);
// Modify the stream
eprintln!("{stream:?}");
stream
}
But this gives a syntax error: expected function, found macro wasmtime_component_macro::bindgen
Is it even possible to call a proc macro like a normal function with TokenStream
, or do I need to do something else?
Last updated: Dec 23 2024 at 12:05 UTC