summaryrefslogtreecommitdiff
path: root/cli/napi/threadsafe_functions.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-10-06 20:51:08 -0700
committerGitHub <noreply@github.com>2022-10-07 09:21:08 +0530
commit5a1ea586b4d99a8e3028d51899b921acca484648 (patch)
tree95588101291c66767e74a86e344c5a3e9a2e6876 /cli/napi/threadsafe_functions.rs
parentafeacb8328ffb588dccd9e51cb048cf04c85fb3f (diff)
refactor(napi): simplify `napi_value` interface (#16170)
Diffstat (limited to 'cli/napi/threadsafe_functions.rs')
-rw-r--r--cli/napi/threadsafe_functions.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/cli/napi/threadsafe_functions.rs b/cli/napi/threadsafe_functions.rs
index 5374b6159..1a9704dbe 100644
--- a/cli/napi/threadsafe_functions.rs
+++ b/cli/napi/threadsafe_functions.rs
@@ -49,22 +49,12 @@ impl TsFn {
let func: v8::Local<v8::Value> =
func.open(scope).to_object(scope).unwrap().into();
unsafe {
- call_js_cb(
- env as *mut c_void,
- transmute::<v8::Local<v8::Value>, napi_value>(func),
- context,
- data,
- )
+ call_js_cb(env as *mut c_void, func.into(), context, data)
};
}
None => {
unsafe {
- call_js_cb(
- env as *mut c_void,
- std::ptr::null_mut(),
- context,
- data,
- )
+ call_js_cb(env as *mut c_void, std::mem::zeroed(), context, data)
};
}
}
@@ -110,9 +100,7 @@ fn napi_create_threadsafe_function(
return Err(Error::InvalidArg);
}
let maybe_func = func
- .as_mut()
- .map(|func| {
- let value = transmute::<napi_value, v8::Local<v8::Value>>(func);
+ .map(|value| {
let func = v8::Local::<v8::Function>::try_from(value)
.map_err(|_| Error::FunctionExpected)?;
Ok(v8::Global::new(&mut env_ref.scope(), func))