Capture correct return type
@@ -2,8 +2,8 @@ extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
-use syn::{FnArg, ArgCaptured, Pat, PatIdent, TypeReference, Type, Token};
use std::collections::HashMap;
+use syn::{ArgCaptured, FnArg, Pat, PatIdent, Token, Type, TypeReference};
#[proc_macro_attribute]
pub fn wasi_common_cbindgen(attr: TokenStream, function: TokenStream) -> TokenStream {
@@ -16,7 +16,7 @@ pub fn wasi_common_cbindgen(attr: TokenStream, function: TokenStream) -> TokenSt
let concatenated = format!("__wasi_{}", ident);
let c_fn_ident = syn::Ident::new(&concatenated, ident.span());
- // capture signature
+ // capture input args
let mut arg_ident = Vec::new();
let mut arg_type = Vec::new();
for input in &function.decl.inputs {
@@ -43,8 +43,8 @@ pub fn wasi_common_cbindgen(attr: TokenStream, function: TokenStream) -> TokenSt
}
}
- println!("{:#?}", arg_ident);
- println!("{:#?}", arg_type);
+ // capture output arg
+ let output = &function.decl.output;
let result = quote! {
#function
@@ -53,7 +53,8 @@ pub fn wasi_common_cbindgen(attr: TokenStream, function: TokenStream) -> TokenSt
#(
#arg_ident: #arg_type,
)*
- ) {
+ ) #output {
+
}
};
