macro_rules! convert_args_list { ( { {$($first_args:tt)+} $({$($args:tt)+})* }, { {$first_value:expr} $({$value:expr})* }, { $({$converted:expr})* }) => { ... }; ({$($args:tt)+}, {}, {$({$converted:expr})*}) => { ... }; ({}, {$($value:tt)+}, {$({$converted:expr})*}) => { ... }; ({}, {}, {$({$converted:expr})*}) => { ... }; ({$($args:tt)*}, {$($value:expr),*}) => { ... }; ($($invalid:tt)*) => { ... }; }
Expand description
Convert the argument value list when invoking a method to a list of JValue
by the argument type list in the signature
use risingwave_jni_core::convert_args_list;
use jni::objects::{JObject, JValue};
use jni::sys::JNI_TRUE;
let list: [JValue<'static, 'static>; 3] = convert_args_list!(
{boolean first, int second, byte third},
{true, 10, 20}
);
match &list[0] {
JValue::Bool(b) => assert_eq!(*b, JNI_TRUE),
value => unreachable!("wrong value: {:?}", value),
}
match &list[1] {
JValue::Int(v) => assert_eq!(*v, 10),
value => unreachable!("wrong value: {:?}", value),
}
match &list[2] {
JValue::Byte(v) => assert_eq!(*v, 20),
value => unreachable!("wrong value: {:?}", value),
}