library/avatar: keep nativeGetPosesJson hand-written
- Commit
7b3f39ea365fa8a48205fe964d307f9d67498893- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 20:17 UTC (4 days ago)
- Parents
b93846f
Correction to the previous commit: nativeGetPosesJson computes let json = poses_json(); before its with_env call, so it is a prologue method like nativeSetConfig, not a pure scaffold user. The jni_fn! conversion dropped that statement and did not compile (the symbol check in the previous commit ran against a stale .so). Restored hand-written, verbatim. Final avatar surface: 7 jni_direct!, 4 hand-written (nativeInit, nativeSetConfig, nativeSurfaceCreated, nativeGetPosesJson). Lines: lib.rs 307 -> 256 (-51, -16.6%), still clearing the 10% bar. Verified now on a fresh build: nm -D on libyuu_avatar.so (aarch64-linux-android) before/after - exported symbol set identical (11/11 Java_ YuuAvatarNative symbols); cargo test -p yuu_avatar 90 passed, identical to baseline; cargo fmt --check -p yuu_avatar clean; bodies token-for-token by script.
Diff
library/avatar/src/main/rust/src/lib.rs
diff --git a/library/avatar/src/main/rust/src/lib.rs b/library/avatar/src/main/rust/src/lib.rsindex 13a5735cb9..a7fad21736 100644--- a/library/avatar/src/main/rust/src/lib.rs+++ b/library/avatar/src/main/rust/src/lib.rs@@ -18,7 +18,7 @@ pub mod vulkan; use jni::objects::{JClass, JObject, JString}; use jni::sys::{jboolean, jfloat, jint, jlong, jstring}; use jni::{Env, EnvUnowned};-use jni_bridge::{jni_direct, jni_fn};+use jni_bridge::jni_direct; #[cfg(target_os = "android")] use std::os::raw::c_void as CVoid;@@ -193,14 +193,24 @@ fn poses_json() -> String { #[cfg(test)] mod lib_tests; -jni_fn! { /// Pose preset ids as JSON (`["idle","wave",...]`) for the gallery.-Java_com_vayunmathur_library_avatar_YuuAvatarNative_nativeGetPosesJson -> jstring; (_class: JClass<'l>) |env| {+/// Pose preset ids as JSON (`["idle","wave",...]`) for the gallery.+#[no_mangle]+pub extern "system" fn Java_com_vayunmathur_library_avatar_YuuAvatarNative_nativeGetPosesJson<+ 'l,+>(+ mut env: EnvUnowned<'l>,+ _class: JClass<'l>,+) -> jstring {+ let json = poses_json();+ env.with_env(|env| -> jni::errors::Result<jstring> { let null = std::ptr::null_mut(); match env.new_string(json) { Ok(s) => Ok(s.into_raw()), Err(_) => Ok(null), }- } }+ })+ .resolve::<jni::errors::LogErrorAndDefault>()+} jni_direct! { /// User drag-rotate delta for a surface (radians). Accumulates into the /// surface's yaw/pitch; pitch clamps native-side.