summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
authorlegendecas <legendecas@gmail.com>2022-08-02 00:01:02 +0800
committerlegendecas <legendecas@gmail.com>2022-08-02 00:01:02 +0800
commita7e5b413efd5f98d4b9acf39ff5e87ddbd8c63ff (patch)
treeb3ae111dcfe5ab8db74df9d355aa009a9ea024c7 /src/node_util.cc
parent7f7a899fa5f3b192d4f503f6602f24f7ff4ec57a (diff)
downloadnode-new-a7e5b413efd5f98d4b9acf39ff5e87ddbd8c63ff.tar.gz
src: split property helpers from node::Environment
PR-URL: https://github.com/nodejs/node/pull/44056 Refs: https://github.com/nodejs/node/issues/42528 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 5b5dab36f0..1613a276c5 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -347,6 +347,7 @@ void Initialize(Local<Object> target,
Local<Context> context,
void* priv) {
Environment* env = Environment::GetCurrent(context);
+ Isolate* isolate = env->isolate();
#define V(name, _) \
target->Set(context, \
@@ -368,18 +369,21 @@ void Initialize(Local<Object> target,
V(kRejected);
#undef V
- env->SetMethodNoSideEffect(target, "getHiddenValue", GetHiddenValue);
- env->SetMethod(target, "setHiddenValue", SetHiddenValue);
- env->SetMethodNoSideEffect(target, "getPromiseDetails", GetPromiseDetails);
- env->SetMethodNoSideEffect(target, "getProxyDetails", GetProxyDetails);
- env->SetMethodNoSideEffect(target, "previewEntries", PreviewEntries);
- env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties",
- GetOwnNonIndexProperties);
- env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName);
- env->SetMethodNoSideEffect(target, "getExternalValue", GetExternalValue);
- env->SetMethod(target, "sleep", Sleep);
-
- env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer);
+ SetMethodNoSideEffect(context, target, "getHiddenValue", GetHiddenValue);
+ SetMethod(context, target, "setHiddenValue", SetHiddenValue);
+ SetMethodNoSideEffect(
+ context, target, "getPromiseDetails", GetPromiseDetails);
+ SetMethodNoSideEffect(context, target, "getProxyDetails", GetProxyDetails);
+ SetMethodNoSideEffect(context, target, "previewEntries", PreviewEntries);
+ SetMethodNoSideEffect(
+ context, target, "getOwnNonIndexProperties", GetOwnNonIndexProperties);
+ SetMethodNoSideEffect(
+ context, target, "getConstructorName", GetConstructorName);
+ SetMethodNoSideEffect(context, target, "getExternalValue", GetExternalValue);
+ SetMethod(context, target, "sleep", Sleep);
+
+ SetMethod(
+ context, target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer);
Local<Object> constants = Object::New(env->isolate());
NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES);
NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE);
@@ -394,24 +398,24 @@ void Initialize(Local<Object> target,
Local<String> should_abort_on_uncaught_toggle =
FIXED_ONE_BYTE_STRING(env->isolate(), "shouldAbortOnUncaughtToggle");
CHECK(target
- ->Set(env->context(),
+ ->Set(context,
should_abort_on_uncaught_toggle,
env->should_abort_on_uncaught_toggle().GetJSArray())
.FromJust());
Local<FunctionTemplate> weak_ref =
- env->NewFunctionTemplate(WeakReference::New);
+ NewFunctionTemplate(isolate, WeakReference::New);
weak_ref->InstanceTemplate()->SetInternalFieldCount(
WeakReference::kInternalFieldCount);
weak_ref->Inherit(BaseObject::GetConstructorTemplate(env));
- env->SetProtoMethod(weak_ref, "get", WeakReference::Get);
- env->SetProtoMethod(weak_ref, "incRef", WeakReference::IncRef);
- env->SetProtoMethod(weak_ref, "decRef", WeakReference::DecRef);
- env->SetConstructorFunction(target, "WeakReference", weak_ref);
+ SetProtoMethod(isolate, weak_ref, "get", WeakReference::Get);
+ SetProtoMethod(isolate, weak_ref, "incRef", WeakReference::IncRef);
+ SetProtoMethod(isolate, weak_ref, "decRef", WeakReference::DecRef);
+ SetConstructorFunction(context, target, "WeakReference", weak_ref);
- env->SetMethod(target, "guessHandleType", GuessHandleType);
+ SetMethod(context, target, "guessHandleType", GuessHandleType);
- env->SetMethodNoSideEffect(target, "toUSVString", ToUSVString);
+ SetMethodNoSideEffect(context, target, "toUSVString", ToUSVString);
}
} // namespace util