mirror of
https://github.com/hexedtech/jni-toolbox.git
synced 2024-11-22 07:24:53 +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"));
|
return Err(syn::Error::new(Span::call_site(), "#[jni] macro doesn't work on methods"));
|
||||||
};
|
};
|
||||||
incoming.append_all(quote::quote!( #ty , ));
|
incoming.append_all(quote::quote!( #ty , ));
|
||||||
let pat = ty.pat;
|
let pat = unpack_pat(*ty.pat)?;
|
||||||
forwarding.append_all(quote::quote!( #pat , ));
|
forwarding.append_all(quote::quote!( #pat , ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,3 +195,16 @@ enum WhatNext {
|
||||||
Class,
|
Class,
|
||||||
Exception,
|
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