mirror of
https://github.com/hexedtech/jni-toolbox.git
synced 2024-12-23 05:44:52 +01:00
fix: handle mut modifier in arguments
This commit is contained in:
parent
f00b8dc398
commit
d3da081886
1 changed files with 14 additions and 1 deletions
|
@ -117,7 +117,7 @@ fn generate_jni_wrapper(attrs: TokenStream, input: TokenStream) -> Result<TokenS
|
|||
return Err(syn::Error::new(Span::call_site(), "#[jni] macro doesn't work on methods"));
|
||||
};
|
||||
incoming.append_all(quote::quote!( #ty , ));
|
||||
let pat = ty.pat;
|
||||
let pat = unpack_pat(*ty.pat)?;
|
||||
forwarding.append_all(quote::quote!( #pat , ));
|
||||
}
|
||||
|
||||
|
@ -195,3 +195,16 @@ enum WhatNext {
|
|||
Class,
|
||||
Exception,
|
||||
}
|
||||
|
||||
fn unpack_pat(pat: syn::Pat) -> Result<TokenStream, syn::Error> {
|
||||
match pat {
|
||||
syn::Pat::Ident(i) => {
|
||||
let ident = i.ident;
|
||||
Ok(quote::quote!( #ident ,))
|
||||
},
|
||||
syn::Pat::Reference(r) => {
|
||||
unpack_pat(*r.pat)
|
||||
},
|
||||
_ => Err(syn::Error::new(Span::call_site(), "unsupported argument type")),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue