From 4a5910b4a31a7980e68717e1e514dad232072ecc Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 14 May 2019 11:37:23 +0200 Subject: [PATCH] Capture correct return type --- wasi-common-cbindgen/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wasi-common-cbindgen/src/lib.rs b/wasi-common-cbindgen/src/lib.rs index 52cdd7999b..310c2cf441 100644 --- a/wasi-common-cbindgen/src/lib.rs +++ b/wasi-common-cbindgen/src/lib.rs @@ -2,21 +2,21 @@ 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 { assert!(attr.is_empty()); let function = syn::parse_macro_input!(function as syn::ItemFn); - + // generate C fn name prefixed with __wasi_ let ident = &function.ident; 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 { + } };