Skip to content

Commit

Permalink
pass args types and return type in for_all_native_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wenym1 committed Sep 22, 2023
1 parent eafc379 commit 605f3bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/jni_core/src/jvm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ pub fn register_native_method_for_jvm(jvm: &JavaVM) -> Result<(), jni::errors::E
() => {{
$crate::for_all_native_methods! {gen_native_method_array}
}};
({$({ $func_name:ident, $sig:expr }),*}) => {
({$({ $func_name:ident, {$($ret:tt).+}, {$($args:tt)*} }),*}) => {
[
$(
{
let fn_ptr = paste::paste! {[<Java_com_risingwave_java_binding_Binding_ $func_name> ]} as *mut c_void;
let sig = $crate::gen_jni_sig! { $($ret).+ ($($args)*)};
NativeMethod {
name: JNIString::from(stringify! {$func_name}),
sig: JNIString::from($sig),
sig: JNIString::from(sig),
fn_ptr,
}
},
)*

]
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/jni_core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ macro_rules! gen_jni_sig_inner {
($(public)? static native $($rest:tt)*) => {
gen_jni_sig_inner! { $($rest)* }
};
($($ret:tt).+ $func_name:ident($($args:tt)*)) => {
($($ret:tt).+ $($func_name:ident)? ($($args:tt)*)) => {
concat! {"(", gen_jni_sig_inner!{$($args)*}, ")", gen_jni_sig_inner! {$($ret).+} }
};
(boolean) => {
Expand Down Expand Up @@ -142,7 +142,7 @@ macro_rules! for_all_native_methods {
$macro! {
{
$(
{ $func_name, {gen_jni_sig! {$($ret).+ $func_name($($args)*)}}}
{ $func_name, {$($ret).+}, {$($args)*}}
),*
}
$(,$extra_args)*
Expand Down Expand Up @@ -214,10 +214,10 @@ mod tests {
gen_array
}
}};
({$({ $func_name:ident, $sig:expr }),*}) => {{
({$({ $func_name:ident, {$($ret:tt).+}, {$($args:tt)*} }),*}) => {{
[
$(
(stringify! {$func_name}, $sig),
(stringify! {$func_name}, gen_jni_sig! { $($ret).+ ($($args)*)}),
)*
]
}};
Expand Down

0 comments on commit 605f3bf

Please sign in to comment.