fix: move unsafe from fn decl to body
This commit is contained in:
parent
c41ace15f0
commit
6837291715
@ -27,14 +27,9 @@ pub mod retry_strategy;
|
||||
pub mod runtime_config;
|
||||
pub mod uint;
|
||||
|
||||
// Class: dev_toad_Runtime
|
||||
// Method: init
|
||||
// Signature: (Ldev/toad/RuntimeOptions;)V
|
||||
// JNIEXPORT void JNICALL Java_dev_toad_Runtime_init
|
||||
// (JNIEnv *, jclass, jobject);
|
||||
pub unsafe extern "system" fn Java_dev_toad_Runtime_init<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
cfg: JObject<'local>) {
|
||||
pub extern "system" fn Java_dev_toad_Runtime_init<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
cfg: JObject<'local>) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -40,19 +40,19 @@ impl<'local> MessageOptRef<'local> {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageOptionRef_number<'local>(mut env: JNIEnv<'local>,
|
||||
o: JObject<'local>,
|
||||
p: i64)
|
||||
-> i64 {
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageOptionRef_number<'local>(mut env: JNIEnv<'local>,
|
||||
o: JObject<'local>,
|
||||
p: i64)
|
||||
-> i64 {
|
||||
MessageOptRef(o).number(&mut env).0 as i64
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageOptionRef_values<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
p: i64)
|
||||
-> jobject {
|
||||
let o = &MessageOptRef::values_ptr(p);
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageOptionRef_values<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
p: i64)
|
||||
-> jobject {
|
||||
let o = &unsafe { MessageOptRef::values_ptr(p) };
|
||||
|
||||
let value_ref_class = MessageOptValueRef::class(&mut env);
|
||||
let mut arr = env.new_object_array(o.len() as i32, value_ref_class, JObject::null())
|
||||
|
@ -28,11 +28,10 @@ impl<'local> MessageOptValueRef<'local> {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageOptionValueRef_bytes<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
p: i64)
|
||||
-> jobject {
|
||||
env.byte_array_from_slice(MessageOptValueRef::ptr(p).as_bytes())
|
||||
.unwrap()
|
||||
.as_raw()
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageOptionValueRef_bytes<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
p: i64)
|
||||
-> jobject {
|
||||
let val = unsafe { MessageOptValueRef::ptr(p) };
|
||||
env.byte_array_from_slice(val.as_bytes()).unwrap().as_raw()
|
||||
}
|
||||
|
@ -26,57 +26,57 @@ impl<'local> MessageRef<'local> {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_id<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> i32 {
|
||||
MessageRef::ptr(addr).id.0 as i32
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_id<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> i32 {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
msg.id.0 as i32
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_token<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
env.byte_array_from_slice(&MessageRef::ptr(addr).token.0)
|
||||
.unwrap()
|
||||
.as_raw()
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_token<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
env.byte_array_from_slice(&msg.token.0).unwrap().as_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_payload<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
env.byte_array_from_slice(&MessageRef::ptr(addr).payload.0)
|
||||
.unwrap()
|
||||
.as_raw()
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_payload<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
env.byte_array_from_slice(&msg.payload.0).unwrap().as_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_type<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
MessageType::new(&mut env, MessageRef::ptr(addr).ty).0
|
||||
.into_raw()
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_type<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
MessageType::new(&mut env, msg.ty).0.into_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_code<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
MessageCode::new(&mut env, MessageRef::ptr(addr).code).0
|
||||
.into_raw()
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_code<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
MessageCode::new(&mut env, msg.code).0.into_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_dev_toad_msg_MessageRef_opts<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let opts = &MessageRef::ptr(addr).opts;
|
||||
pub extern "system" fn Java_dev_toad_msg_MessageRef_opts<'local>(mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
addr: i64)
|
||||
-> jobject {
|
||||
let msg = unsafe { MessageRef::ptr(addr) };
|
||||
let opts = &msg.opts;
|
||||
|
||||
let opt_ref_class = MessageOptRef::class(&mut env);
|
||||
let mut arr = env.new_object_array((*opts).len() as i32, opt_ref_class, JObject::null())
|
||||
|
Loading…
Reference in New Issue
Block a user