chore: clean up

This commit is contained in:
Osei Fortune
2022-03-07 13:07:50 -04:00
parent 2fa6b4bd79
commit 11801790ae
4 changed files with 6 additions and 9 deletions

View File

@@ -25,10 +25,6 @@ pub(crate) struct AsyncCallbackInner {
}
impl AsyncCallbackInner {
pub(crate) fn inner_raw(&self) -> *mut jni::objects::GlobalRef {
self.inner as *mut jni::objects::GlobalRef
}
pub(crate) fn inner(&self) -> jni::objects::GlobalRef {
unsafe { (&*(self.inner as *mut jni::objects::GlobalRef)).clone() }
}

View File

@@ -22,6 +22,6 @@ pub extern "system" fn Java_org_nativescript_widgets_filesystem_AsyncCallback_di
_: JClass,
callback: jlong,
) {
let callback = unsafe { callback as *const AsyncCallback };
let callback = callback as *const AsyncCallback;
let _ = unsafe { Arc::from_raw(callback) };
}

View File

@@ -40,7 +40,7 @@ pub extern "system" fn Java_org_nativescript_widgets_filesystem_FileDir_nativeCl
file_dir: jlong,
callback: jlong,
) {
let callback = unsafe { callback as *const AsyncCallback };
let callback = callback as *const AsyncCallback;
let on_success = AsyncCallback::clone_from_ptr(callback);
let dir: *mut FileDir = file_dir as _;
if !dir.is_null() {
@@ -111,7 +111,7 @@ pub extern "system" fn Java_org_nativescript_widgets_filesystem_FileDir_nativeRe
file_dir: jlong,
callback: jlong,
) {
let callback = unsafe { callback as *const AsyncCallback };
let callback = callback as *const AsyncCallback;
let on_success = AsyncCallback::clone_from_ptr(callback);
let dir: *mut FileDir = file_dir as _;
if !dir.is_null() {

View File

@@ -1,5 +1,5 @@
use std::collections::HashMap;
use std::ffi::{CStr};
use std::ffi::CStr;
use std::os::raw::c_char;
use std::ptr::NonNull;
use std::sync::Arc;
@@ -18,6 +18,7 @@ use crate::common::fs::a_sync::{AsyncClosure, WatchEvent};
type WatcherCallbackMap = Arc<Mutex<HashMap<Arc<AsyncCallback>, FsWatchCallback>>>;
#[allow(dead_code)]
pub struct FsWatchCallback {
callback: Arc<AsyncCallback>,
inner: Arc<AsyncClosure<WatchEvent, std::io::Error>>,
@@ -194,7 +195,7 @@ pub extern "system" fn Java_org_nativescript_widgets_filesystem_WatcherEvent_nat
on_close: jlong,
) {
let callback = callback as *const AsyncCallback;
let on_close = unsafe { on_close as *const AsyncCallback };
let on_close = on_close as *const AsyncCallback;
let callback = AsyncCallback::clone_from_ptr(callback);
let on_close = AsyncCallback::clone_from_ptr(on_close);