mirror of
https://github.com/tribufu/tribufu-java
synced 2026-06-01 09:42:37 +00:00
Update lib.rs
This commit is contained in:
parent
81ddefbe61
commit
9e6d76b679
1 changed files with 5 additions and 7 deletions
|
|
@ -3,8 +3,6 @@
|
||||||
//! Jvm bindings to TribuFu SDK.
|
//! Jvm bindings to TribuFu SDK.
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(unused_variables)]
|
|
||||||
#![allow(unused_imports)]
|
|
||||||
|
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "windows",
|
target_os = "windows",
|
||||||
|
|
@ -25,17 +23,17 @@ use std::ffi::{CStr, CString};
|
||||||
// native method.
|
// native method.
|
||||||
pub extern "system" fn Java_com_tribufu_sdk_TribuFu_getVersion(
|
pub extern "system" fn Java_com_tribufu_sdk_TribuFu_getVersion(
|
||||||
env: JNIEnv,
|
env: JNIEnv,
|
||||||
_: JClass,
|
_class: JClass,
|
||||||
j_input: JString,
|
input: JString,
|
||||||
) -> jstring {
|
) -> jstring {
|
||||||
// First, we have to get the string out of Java. Check out the `strings`
|
// First, we have to get the string out of Java. Check out the `strings`
|
||||||
// module for more info on how this works.
|
// module for more info on how this works.
|
||||||
let input = CString::from(unsafe { CStr::from_ptr(env.get_string(j_input).unwrap().as_ptr()) });
|
let input = CString::from(unsafe { CStr::from_ptr(env.get_string(input).unwrap().as_ptr()) });
|
||||||
|
|
||||||
// Then we have to create a new Java string to return. Again, more info
|
// Then we have to create a new Java string to return. Again, more info
|
||||||
// in the `strings` module.
|
// in the `strings` module.
|
||||||
let res = env.new_string(input.to_str().unwrap()).unwrap();
|
let output = env.new_string(input.to_str().unwrap()).unwrap();
|
||||||
|
|
||||||
// Finally, extract the raw pointer to return.
|
// Finally, extract the raw pointer to return.
|
||||||
return res.into_inner();
|
return output.into_inner();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue