macro_rules! split_extract_plain_native_methods {
(
{$($input:tt)*},
$macro:path
$(,$extra_args:tt)*
) => { ... };
(
{
$(public)? static native $($first:tt)*
},
{
$($second:tt)*
},
$macro:path
$(,$extra_args:tt)*
) => { ... };
(
{
$($ret:tt).+ $func_name:ident($($args:tt)*); $($rest:tt)*
},
{
$({$prev_func_name:ident, {$($prev_ret:tt)*}, {$($prev_args:tt)*}})*
},
$macro:path
$(,$extra_args:tt)*
) => { ... };
(
{
$($ret:tt).+ [] $func_name:ident($($args:tt)*); $($rest:tt)*
},
{
$({$prev_func_name:ident, {$($prev_ret:tt)*}, {$($prev_args:tt)*}})*
},
$macro:path
$(,$extra_args:tt)*
) => { ... };
(
{},
{
$({$func_name:ident, {$($ret:tt)*}, {$($args:tt)*}})*
},
$macro:path
$(,$extra_args:tt)*
) => { ... };
($($invalid:tt)*) => { ... };
}
Expand description
Given the plain text of a list native methods, split the methods by semicolon (;), extract
the return type, argument list and name of the methods and pass the result to the callback
$macro
with the extracted result as the first parameter. The result can be matched with
pattern {$({$func_name:ident, {$($ret:tt)*}, {$($args:tt)*}})*}
macro_rules! call_split_extract_plain_native_methods {
({$({$func_name:ident, {$($ret:tt)*}, {$($args:tt)*}})*}) => {
[$(
(stringify! {$func_name}, stringify!{$($ret)*}, stringify!{($($args)*)})
),*]
};
($($input:tt)*) => {{
risingwave_jni_core::split_extract_plain_native_methods! {
{$($input)*},
call_split_extract_plain_native_methods
}
}}
}
assert_eq!([
("f", "int", "(int param1, boolean param2)"),
("f2", "boolean[]", "()"),
("f3", "java.lang.String", "(byte[] param)")
], call_split_extract_plain_native_methods!(
int f(int param1, boolean param2);
boolean[] f2();
java.lang.String f3(byte[] param);
))