44// This program and the accompanying materials are made available under the
55// terms of the Eclipse Public License 2.0 which is available at
66// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7- // which is available at https://www.apache.org/licenses/LICENSE -2.0.
7+ // which is available at https://www.apache.org/legal/epl -2.0.
88//
99// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
1010//
@@ -19,19 +19,13 @@ import io.zenoh.exceptions.ZError
1919/* *
2020 * Helpers for the key-expression JNI surface.
2121 *
22- * The native side accepts `Any` for every key-expr parameter and
23- * dispatches at runtime: a [Long] is treated as the
24- * `Arc<KeyExpr<'static>>` registration handle, anything else
25- * (a [String] in practice) is validated and converted to an owned
26- * `KeyExpr<'static>`. Pass `handle ?: keyExprString` to native fns —
27- * the `?:` operator picks the boxed [Long] when present, otherwise the
28- * raw string.
29- *
30- * Functions that *return* a key-expression hand back a [Long] (the
31- * Arc pointer); the canonical string is computed locally on the
32- * Kotlin side. For [join] / [concat] the result string matches
33- * Rust's `format!("{a}/{other}")` / `format!("{a}{other}")` since
34- * the native validation is non-rewriting.
22+ * Operations that have a `#[prebindgen]` counterpart in `zenoh-flat`
23+ * (`try_from`, `autocanonize`, `intersects`, `includes`, `relation_to`,
24+ * `join`, `concat`) delegate to the generator-emitted wrappers in
25+ * [JNIWrappers]. The hand-written `dropKeyExprViaJNI` is retained as a
26+ * dedicated free entry point — it doesn't appear as a `#[prebindgen]`
27+ * fn because the consume semantic for a session-undeclare goes through
28+ * `undeclare_key_expr` instead.
3529 */
3630
3731/* *
@@ -42,36 +36,36 @@ import io.zenoh.exceptions.ZError
4236fun keyExprArg (handle : Long? , str : String ): Any = handle ? : str
4337
4438@Throws(ZError ::class )
45- fun keyExprTryFrom (keyExpr : String ): String = JNINative .tryFromViaJNI (keyExpr)
39+ fun keyExprTryFrom (keyExpr : String ): String = JNIWrappers .tryFrom (keyExpr)
4640
4741@Throws(ZError ::class )
48- fun keyExprAutocanonize (keyExpr : String ): String = JNINative .autocanonizeViaJNI (keyExpr)
42+ fun keyExprAutocanonize (keyExpr : String ): String = JNIWrappers .autocanonize (keyExpr)
4943
5044@Throws(ZError ::class )
5145fun keyExprIntersects (a : Long? , aStr : String , b : Long? , bStr : String ): Boolean =
52- JNINative .intersectsViaJNI (keyExprArg(a, aStr), keyExprArg(b, bStr))
46+ JNIWrappers .intersects (keyExprArg(a, aStr), keyExprArg(b, bStr))
5347
5448@Throws(ZError ::class )
5549fun keyExprIncludes (a : Long? , aStr : String , b : Long? , bStr : String ): Boolean =
56- JNINative .includesViaJNI (keyExprArg(a, aStr), keyExprArg(b, bStr))
50+ JNIWrappers .includes (keyExprArg(a, aStr), keyExprArg(b, bStr))
5751
5852@Throws(ZError ::class )
5953fun keyExprRelationTo (a : Long? , aStr : String , b : Long? , bStr : String ): Int =
60- JNINative .relationToViaJNI (keyExprArg(a, aStr), keyExprArg(b, bStr))
54+ JNIWrappers .relationTo (keyExprArg(a, aStr), keyExprArg(b, bStr))
6155
6256/* * Result of a join/concat: `(handle, canonicalString)`. */
6357data class KeyExprResult (val handle : Long , val string : String )
6458
6559@Throws(ZError ::class )
6660fun keyExprJoin (a : Long? , aStr : String , other : String ): KeyExprResult {
67- val handle = JNINative .joinViaJNI (keyExprArg(a, aStr), other)
61+ val handle = JNIWrappers .join (keyExprArg(a, aStr), other).peek( )
6862 // Match Rust's `KeyExpr::join` formatting: "{self}/{other}".
6963 return KeyExprResult (handle, " $aStr /$other " )
7064}
7165
7266@Throws(ZError ::class )
7367fun keyExprConcat (a : Long? , aStr : String , other : String ): KeyExprResult {
74- val handle = JNINative .concatViaJNI (keyExprArg(a, aStr), other)
68+ val handle = JNIWrappers .concat (keyExprArg(a, aStr), other).peek( )
7569 // Match Rust's `KeyExpr::concat` formatting: "{self}{other}".
7670 return KeyExprResult (handle, " $aStr$other " )
7771}
0 commit comments