summaryrefslogtreecommitdiff
path: root/ext/napi/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-23 21:33:31 +0200
committerGitHub <noreply@github.com>2023-09-23 19:33:31 +0000
commit68851d6f371ce353d4313a17a4d0461f03061814 (patch)
tree237a4a24a7dc85fc30d504876d9beaace7a08a93 /ext/napi/lib.rs
parent65dccc389a355ec83f7cf0cee59be57b0bc8985c (diff)
refactor: rewrite ops to op2 macro (#20628)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'ext/napi/lib.rs')
-rw-r--r--ext/napi/lib.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs
index ada9aa13f..e897e149d 100644
--- a/ext/napi/lib.rs
+++ b/ext/napi/lib.rs
@@ -10,9 +10,8 @@ use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::futures::channel::mpsc;
use deno_core::futures::StreamExt;
-use deno_core::op;
+use deno_core::op2;
use deno_core::parking_lot::Mutex;
-use deno_core::serde_v8;
use deno_core::OpState;
use std::cell::RefCell;
use std::ffi::CString;
@@ -536,13 +535,13 @@ pub unsafe fn weak_local(
value
}
-#[op(v8)]
+#[op2]
fn op_napi_open<NP, 'scope>(
scope: &mut v8::HandleScope<'scope>,
op_state: &mut OpState,
- path: String,
- global: serde_v8::Value,
-) -> std::result::Result<serde_v8::Value<'scope>, AnyError>
+ #[string] path: String,
+ global: v8::Local<'scope, v8::Value>,
+) -> std::result::Result<v8::Local<'scope, v8::Value>, AnyError>
where
NP: NapiPermissions + 'static,
{
@@ -582,7 +581,7 @@ where
let mut env = Env::new(
isolate_ptr,
v8::Global::new(scope, ctx),
- v8::Global::new(scope, global.v8_value),
+ v8::Global::new(scope, global),
async_work_sender,
tsfn_sender,
cleanup_hooks,
@@ -640,7 +639,7 @@ where
// NAPI addons can't be unloaded, so we're going to "forget" the library
// object so it lives till the program exit.
std::mem::forget(library);
- return Ok(serde_v8::Value { v8_value: exports });
+ return Ok(exports);
}
// Initializer callback.
@@ -673,5 +672,5 @@ where
// NAPI addons can't be unloaded, so we're going to "forget" the library
// object so it lives till the program exit.
std::mem::forget(library);
- Ok(serde_v8::Value { v8_value: exports })
+ Ok(exports)
}