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