summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-12-19 02:44:42 +0530
committerGitHub <noreply@github.com>2021-12-18 16:14:42 -0500
commit6de53b631fcdb96d72639b6d2db3592d5fa8498d (patch)
tree9a93d868f5f434a4898f212cb6bd53e65ca49ce0 /core/bindings.rs
parent3db18bf9e6466c74efd9052df4d372ea0b581154 (diff)
refactor: use `once_cell` instead of `lazy_static` (#13135)
Diffstat (limited to 'core/bindings.rs')
-rw-r--r--core/bindings.rs55
1 files changed, 28 insertions, 27 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 5f1806e4b..8aed39ea9 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -17,6 +17,7 @@ use crate::PromiseId;
use crate::ZeroCopyBuf;
use anyhow::Error;
use log::debug;
+use once_cell::sync::Lazy;
use serde::Deserialize;
use serde::Serialize;
use serde_v8::to_v8;
@@ -35,71 +36,71 @@ const UNDEFINED_OP_ID_MSG: &str =
This error is often caused by a typo in an op name, or not calling
JsRuntime::sync_ops_cache() after JsRuntime initialization.";
-lazy_static::lazy_static! {
- pub static ref EXTERNAL_REFERENCES: v8::ExternalReferences =
+pub static EXTERNAL_REFERENCES: Lazy<v8::ExternalReferences> =
+ Lazy::new(|| {
v8::ExternalReferences::new(&[
v8::ExternalReference {
- function: opcall_async.map_fn_to()
+ function: opcall_async.map_fn_to(),
},
v8::ExternalReference {
- function: opcall_sync.map_fn_to()
+ function: opcall_sync.map_fn_to(),
},
v8::ExternalReference {
- function: ref_op.map_fn_to()
+ function: ref_op.map_fn_to(),
},
v8::ExternalReference {
- function: unref_op.map_fn_to()
+ function: unref_op.map_fn_to(),
},
v8::ExternalReference {
- function: set_macrotask_callback.map_fn_to()
+ function: set_macrotask_callback.map_fn_to(),
},
v8::ExternalReference {
- function: set_nexttick_callback.map_fn_to()
+ function: set_nexttick_callback.map_fn_to(),
},
v8::ExternalReference {
- function: set_promise_reject_callback.map_fn_to()
+ function: set_promise_reject_callback.map_fn_to(),
},
v8::ExternalReference {
- function: set_uncaught_exception_callback.map_fn_to()
+ function: set_uncaught_exception_callback.map_fn_to(),
},
v8::ExternalReference {
- function: run_microtasks.map_fn_to()
+ function: run_microtasks.map_fn_to(),
},
v8::ExternalReference {
- function: has_tick_scheduled.map_fn_to()
+ function: has_tick_scheduled.map_fn_to(),
},
v8::ExternalReference {
- function: set_has_tick_scheduled.map_fn_to()
+ function: set_has_tick_scheduled.map_fn_to(),
},
v8::ExternalReference {
- function: eval_context.map_fn_to()
+ function: eval_context.map_fn_to(),
},
v8::ExternalReference {
- function: queue_microtask.map_fn_to()
+ function: queue_microtask.map_fn_to(),
},
v8::ExternalReference {
- function: create_host_object.map_fn_to()
+ function: create_host_object.map_fn_to(),
},
v8::ExternalReference {
- function: encode.map_fn_to()
+ function: encode.map_fn_to(),
},
v8::ExternalReference {
- function: decode.map_fn_to()
+ function: decode.map_fn_to(),
},
v8::ExternalReference {
- function: serialize.map_fn_to()
+ function: serialize.map_fn_to(),
},
v8::ExternalReference {
- function: deserialize.map_fn_to()
+ function: deserialize.map_fn_to(),
},
v8::ExternalReference {
- function: get_promise_details.map_fn_to()
+ function: get_promise_details.map_fn_to(),
},
v8::ExternalReference {
- function: get_proxy_details.map_fn_to()
+ function: get_proxy_details.map_fn_to(),
},
v8::ExternalReference {
- function: is_proxy.map_fn_to()
+ function: is_proxy.map_fn_to(),
},
v8::ExternalReference {
function: memory_usage.map_fn_to(),
@@ -108,10 +109,10 @@ lazy_static::lazy_static! {
function: call_console.map_fn_to(),
},
v8::ExternalReference {
- function: set_wasm_streaming_callback.map_fn_to()
- }
- ]);
-}
+ function: set_wasm_streaming_callback.map_fn_to(),
+ },
+ ])
+ });
pub fn script_origin<'a>(
s: &mut v8::HandleScope<'a>,