Skip to content

Commit 9616f32

Browse files
committed
decode arc macro added
1 parent 67d28c4 commit 9616f32

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

zenoh-jni/build.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ macro_rules! decode_owned_raw {
6969
};
7070
}
7171

72+
macro_rules! decode_arc_from_raw {
73+
() => {
74+
InputFn::new(|input: &syn::Ident| -> TokenStream {
75+
quote! { (*std::sync::Arc::from_raw(#input)).clone() }
76+
})
77+
};
78+
}
79+
7280
macro_rules! encode_wrapper {
7381
($path:path) => {
7482
OutputFn::new(|output: Option<&syn::Ident>| -> TokenStream {
@@ -147,9 +155,7 @@ fn shared_bindings() -> TypeRegistry {
147155
// (releasing its strong reference at end of scope) and hands a cloned
148156
// `Session` to the wrapped fn. Used by `drop_session`.
149157
.type_pair("Session", "*const Session")
150-
.input(InputFn::new(|input: &syn::Ident| -> TokenStream {
151-
quote! { (*std::sync::Arc::from_raw(#input)).clone() }
152-
}))
158+
.input(decode_arc_from_raw!())
153159
// Returns: ZenohId / Vec<ZenohId> via custom encoders.
154160
.type_pair("ZResult<ZenohId>", "jni::sys::jbyteArray")
155161
.output(encode_wrapper!(crate::zenoh_id::zenoh_id_to_byte_array))

0 commit comments

Comments
 (0)