macro_rules! to_jvalue { ({ boolean $($param_name:ident)? }, $value:expr) => { ... }; ({ byte $($param_name:ident)? }, $value:expr) => { ... }; ({ char $($param_name:ident)? }, $value:expr) => { ... }; ({ double $($param_name:ident)? }, $value:expr) => { ... }; ({ float $($param_name:ident)? }, $value:expr) => { ... }; ({ int $($param_name:ident)? }, $value:expr) => { ... }; ({ long $($param_name:ident)? }, $value:expr) => { ... }; ({ short $($param_name:ident)? }, $value:expr) => { ... }; ({ void }, $value:expr) => { ... }; ({ $($class:ident)+ $([])? $($param_name:ident)? }, $value:expr) => { ... }; }
Expand description
Cast a JValueGen
to a concrete type by the given type
use jni::sys::JNI_TRUE;
use risingwave_jni_core::{cast_jvalue, to_jvalue};
assert_eq!(
cast_jvalue!({ boolean }, to_jvalue!({ boolean }, JNI_TRUE)),
true
);
assert_eq!(cast_jvalue!({ byte }, to_jvalue!({ byte }, 10)), 10);
assert_eq!(
cast_jvalue!({ char }, to_jvalue!({ char }, 'c')),
'c' as u16
);
assert_eq!(cast_jvalue!({ double }, to_jvalue!({ double }, 3.14)), 3.14);
assert_eq!(cast_jvalue!({ float }, to_jvalue!({ float }, 3.14)), 3.14);
assert_eq!(cast_jvalue!({ int }, to_jvalue!({ int }, 10)), 10);
assert_eq!(cast_jvalue!({ long }, to_jvalue!({ long }, 10)), 10);
assert_eq!(cast_jvalue!({ short }, to_jvalue!({ short }, 10)), 10);
cast_jvalue!(
{ String },
to_jvalue!({ String }, &jni::objects::JObject::null())
);