Skip to content

Commit 55cfcee

Browse files
juanarbolrefack
authored andcommitted
src: elevate v8 namespaces referenced
PR-URL: nodejs#24657 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 8324a71 commit 55cfcee

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/async_wrap.cc

+22-16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "v8-profiler.h"
3131

3232
using v8::Context;
33+
using v8::DontDelete;
34+
using v8::EscapableHandleScope;
3335
using v8::Function;
3436
using v8::FunctionCallbackInfo;
3537
using v8::FunctionTemplate;
@@ -38,16 +40,22 @@ using v8::Integer;
3840
using v8::Isolate;
3941
using v8::Local;
4042
using v8::MaybeLocal;
43+
using v8::NewStringType;
4144
using v8::Number;
4245
using v8::Object;
4346
using v8::ObjectTemplate;
4447
using v8::Promise;
4548
using v8::PromiseHookType;
49+
using v8::PropertyAttribute;
4650
using v8::PropertyCallbackInfo;
51+
using v8::ReadOnly;
4752
using v8::String;
53+
using v8::TryCatch;
4854
using v8::Uint32;
4955
using v8::Undefined;
5056
using v8::Value;
57+
using v8::WeakCallbackInfo;
58+
using v8::WeakCallbackType;
5159

5260
using AsyncHooks = node::Environment::AsyncHooks;
5361

@@ -117,7 +125,7 @@ void Emit(Environment* env, double async_id, AsyncHooks::Fields type,
117125
if (async_hooks->fields()[type] == 0 || !env->can_call_into_js())
118126
return;
119127

120-
v8::HandleScope handle_scope(env->isolate());
128+
HandleScope handle_scope(env->isolate());
121129
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
122130
FatalTryCatch try_catch(env);
123131
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
@@ -341,8 +349,7 @@ class DestroyParam {
341349
Persistent<Object> propBag;
342350
};
343351

344-
345-
void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo<DestroyParam>& info) {
352+
void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) {
346353
HandleScope scope(info.GetIsolate());
347354

348355
std::unique_ptr<DestroyParam> p{info.GetParameter()};
@@ -373,8 +380,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
373380
p->env = Environment::GetCurrent(args);
374381
p->target.Reset(isolate, args[0].As<Object>());
375382
p->propBag.Reset(isolate, args[2].As<Object>());
376-
p->target.SetWeak(
377-
p, AsyncWrap::WeakCallback, v8::WeakCallbackType::kParameter);
383+
p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter);
378384
}
379385

380386

@@ -448,8 +454,8 @@ void AsyncWrap::Initialize(Local<Object> target,
448454
env->SetMethod(target, "disablePromiseHook", DisablePromiseHook);
449455
env->SetMethod(target, "registerDestroyHook", RegisterDestroyHook);
450456

451-
v8::PropertyAttribute ReadOnlyDontDelete =
452-
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
457+
PropertyAttribute ReadOnlyDontDelete =
458+
static_cast<PropertyAttribute>(ReadOnly | DontDelete);
453459

454460
#define FORCE_SET_TARGET_FIELD(obj, str, field) \
455461
(obj)->DefineOwnProperty(context, \
@@ -695,7 +701,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
695701

696702
async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
697703
// Environment::GetCurrent() allocates a Local<> handle.
698-
v8::HandleScope handle_scope(isolate);
704+
HandleScope handle_scope(isolate);
699705
Environment* env = Environment::GetCurrent(isolate);
700706
if (env == nullptr) return -1;
701707
return env->execution_async_id();
@@ -704,7 +710,7 @@ async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
704710

705711
async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) {
706712
// Environment::GetCurrent() allocates a Local<> handle.
707-
v8::HandleScope handle_scope(isolate);
713+
HandleScope handle_scope(isolate);
708714
Environment* env = Environment::GetCurrent(isolate);
709715
if (env == nullptr) return -1;
710716
return env->trigger_async_id();
@@ -715,18 +721,18 @@ async_context EmitAsyncInit(Isolate* isolate,
715721
Local<Object> resource,
716722
const char* name,
717723
async_id trigger_async_id) {
718-
v8::HandleScope handle_scope(isolate);
724+
HandleScope handle_scope(isolate);
719725
Local<String> type =
720-
String::NewFromUtf8(isolate, name, v8::NewStringType::kInternalized)
726+
String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
721727
.ToLocalChecked();
722728
return EmitAsyncInit(isolate, resource, type, trigger_async_id);
723729
}
724730

725731
async_context EmitAsyncInit(Isolate* isolate,
726732
Local<Object> resource,
727-
v8::Local<v8::String> name,
733+
Local<String> name,
728734
async_id trigger_async_id) {
729-
v8::HandleScope handle_scope(isolate);
735+
HandleScope handle_scope(isolate);
730736
Environment* env = Environment::GetCurrent(isolate);
731737
CHECK_NOT_NULL(env);
732738

@@ -748,7 +754,7 @@ async_context EmitAsyncInit(Isolate* isolate,
748754

749755
void EmitAsyncDestroy(Isolate* isolate, async_context asyncContext) {
750756
// Environment::GetCurrent() allocates a Local<> handle.
751-
v8::HandleScope handle_scope(isolate);
757+
HandleScope handle_scope(isolate);
752758
AsyncWrap::EmitDestroy(
753759
Environment::GetCurrent(isolate), asyncContext.async_id);
754760
}
@@ -767,10 +773,10 @@ Local<Object> AsyncWrap::GetOwner() {
767773
}
768774

769775
Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) {
770-
v8::EscapableHandleScope handle_scope(env->isolate());
776+
EscapableHandleScope handle_scope(env->isolate());
771777
CHECK(!obj.IsEmpty());
772778

773-
v8::TryCatch ignore_exceptions(env->isolate());
779+
TryCatch ignore_exceptions(env->isolate());
774780
while (true) {
775781
Local<Value> owner;
776782
if (!obj->Get(env->context(),

0 commit comments

Comments
 (0)