risingwave_jni_core

Macro gen_jni_sig

source
macro_rules! gen_jni_sig {
    ({$({$($args:tt)+})*}, {return {$($ret:tt)*}}) => { ... };
    ({$($ret:tt)*}, {$($args:tt)*}) => { ... };
    ({{$func_name:ident, {$($ret:tt)*}, {$($args:tt)*}}}) => { ... };
    ($($input:tt)*) => { ... };
}
Expand description

Generate the jni signature of a given function

use risingwave_jni_core::gen_jni_sig;
assert_eq!(gen_jni_sig!(boolean f(int, short, byte[])), "(IS[B)Z");
assert_eq!(
    gen_jni_sig!(boolean f(int, short, byte[], java.lang.String)),
    "(IS[BLjava/lang/String;)Z"
);
assert_eq!(
    gen_jni_sig!(boolean f(int, java.lang.String)),
    "(ILjava/lang/String;)Z"
);
assert_eq!(gen_jni_sig!(public static native int defaultVnodeCount()), "()I");
assert_eq!(
    gen_jni_sig!(long hummockIteratorNew(byte[] readPlan)),
    "([B)J"
);
assert_eq!(gen_jni_sig!(long hummockIteratorNext(long pointer)), "(J)J");
assert_eq!(
    gen_jni_sig!(void hummockIteratorClose(long pointer)),
    "(J)V"
);
assert_eq!(gen_jni_sig!(byte[] rowGetKey(long pointer)), "(J)[B");
assert_eq!(
    gen_jni_sig!(java.sql.Timestamp rowGetTimestampValue(long pointer, int index)),
    "(JI)Ljava/sql/Timestamp;"
);
assert_eq!(
    gen_jni_sig!(String rowGetStringValue(long pointer, int index)),
    "(JI)Ljava/lang/String;"
);
assert_eq!(
    gen_jni_sig!(static native Object rowGetArrayValue(long pointer, int index, Class clazz)),
    "(JILjava/lang/Class;)Ljava/lang/Object;"
);