30
30
#include " v8-profiler.h"
31
31
32
32
using v8::Context;
33
+ using v8::DontDelete;
34
+ using v8::EscapableHandleScope;
33
35
using v8::Function;
34
36
using v8::FunctionCallbackInfo;
35
37
using v8::FunctionTemplate;
@@ -38,16 +40,22 @@ using v8::Integer;
38
40
using v8::Isolate;
39
41
using v8::Local;
40
42
using v8::MaybeLocal;
43
+ using v8::NewStringType;
41
44
using v8::Number;
42
45
using v8::Object;
43
46
using v8::ObjectTemplate;
44
47
using v8::Promise;
45
48
using v8::PromiseHookType;
49
+ using v8::PropertyAttribute;
46
50
using v8::PropertyCallbackInfo;
51
+ using v8::ReadOnly;
47
52
using v8::String;
53
+ using v8::TryCatch;
48
54
using v8::Uint32;
49
55
using v8::Undefined;
50
56
using v8::Value;
57
+ using v8::WeakCallbackInfo;
58
+ using v8::WeakCallbackType;
51
59
52
60
using AsyncHooks = node::Environment::AsyncHooks;
53
61
@@ -117,7 +125,7 @@ void Emit(Environment* env, double async_id, AsyncHooks::Fields type,
117
125
if (async_hooks->fields ()[type] == 0 || !env->can_call_into_js ())
118
126
return ;
119
127
120
- v8:: HandleScope handle_scope (env->isolate ());
128
+ HandleScope handle_scope (env->isolate ());
121
129
Local<Value> async_id_value = Number::New (env->isolate (), async_id);
122
130
FatalTryCatch try_catch (env);
123
131
USE (fn->Call (env->context (), Undefined (env->isolate ()), 1 , &async_id_value));
@@ -353,8 +361,7 @@ class DestroyParam {
353
361
Persistent<Object> propBag;
354
362
};
355
363
356
-
357
- void AsyncWrap::WeakCallback (const v8::WeakCallbackInfo<DestroyParam>& info) {
364
+ void AsyncWrap::WeakCallback (const WeakCallbackInfo<DestroyParam>& info) {
358
365
HandleScope scope (info.GetIsolate ());
359
366
360
367
std::unique_ptr<DestroyParam> p{info.GetParameter ()};
@@ -385,8 +392,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
385
392
p->env = Environment::GetCurrent (args);
386
393
p->target .Reset (isolate, args[0 ].As <Object>());
387
394
p->propBag .Reset (isolate, args[2 ].As <Object>());
388
- p->target .SetWeak (
389
- p, AsyncWrap::WeakCallback, v8::WeakCallbackType::kParameter );
395
+ p->target .SetWeak (p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter );
390
396
}
391
397
392
398
@@ -460,8 +466,8 @@ void AsyncWrap::Initialize(Local<Object> target,
460
466
env->SetMethod (target, " disablePromiseHook" , DisablePromiseHook);
461
467
env->SetMethod (target, " registerDestroyHook" , RegisterDestroyHook);
462
468
463
- v8:: PropertyAttribute ReadOnlyDontDelete =
464
- static_cast <v8:: PropertyAttribute>(v8:: ReadOnly | v8:: DontDelete);
469
+ PropertyAttribute ReadOnlyDontDelete =
470
+ static_cast <PropertyAttribute>(ReadOnly | DontDelete);
465
471
466
472
#define FORCE_SET_TARGET_FIELD (obj, str, field ) \
467
473
(obj)->DefineOwnProperty (context, \
@@ -707,7 +713,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
707
713
708
714
async_id AsyncHooksGetExecutionAsyncId (Isolate* isolate) {
709
715
// Environment::GetCurrent() allocates a Local<> handle.
710
- v8:: HandleScope handle_scope (isolate);
716
+ HandleScope handle_scope (isolate);
711
717
Environment* env = Environment::GetCurrent (isolate);
712
718
if (env == nullptr ) return -1 ;
713
719
return env->execution_async_id ();
@@ -716,7 +722,7 @@ async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
716
722
717
723
async_id AsyncHooksGetTriggerAsyncId (Isolate* isolate) {
718
724
// Environment::GetCurrent() allocates a Local<> handle.
719
- v8:: HandleScope handle_scope (isolate);
725
+ HandleScope handle_scope (isolate);
720
726
Environment* env = Environment::GetCurrent (isolate);
721
727
if (env == nullptr ) return -1 ;
722
728
return env->trigger_async_id ();
@@ -727,18 +733,18 @@ async_context EmitAsyncInit(Isolate* isolate,
727
733
Local<Object> resource,
728
734
const char * name,
729
735
async_id trigger_async_id) {
730
- v8:: HandleScope handle_scope (isolate);
736
+ HandleScope handle_scope (isolate);
731
737
Local<String> type =
732
- String::NewFromUtf8 (isolate, name, v8:: NewStringType::kInternalized )
738
+ String::NewFromUtf8 (isolate, name, NewStringType::kInternalized )
733
739
.ToLocalChecked ();
734
740
return EmitAsyncInit (isolate, resource, type, trigger_async_id);
735
741
}
736
742
737
743
async_context EmitAsyncInit (Isolate* isolate,
738
744
Local<Object> resource,
739
- v8:: Local<v8:: String> name,
745
+ Local<String> name,
740
746
async_id trigger_async_id) {
741
- v8:: HandleScope handle_scope (isolate);
747
+ HandleScope handle_scope (isolate);
742
748
Environment* env = Environment::GetCurrent (isolate);
743
749
CHECK_NOT_NULL (env);
744
750
@@ -760,7 +766,7 @@ async_context EmitAsyncInit(Isolate* isolate,
760
766
761
767
void EmitAsyncDestroy (Isolate* isolate, async_context asyncContext) {
762
768
// Environment::GetCurrent() allocates a Local<> handle.
763
- v8:: HandleScope handle_scope (isolate);
769
+ HandleScope handle_scope (isolate);
764
770
AsyncWrap::EmitDestroy (
765
771
Environment::GetCurrent (isolate), asyncContext.async_id );
766
772
}
@@ -779,10 +785,10 @@ Local<Object> AsyncWrap::GetOwner() {
779
785
}
780
786
781
787
Local<Object> AsyncWrap::GetOwner (Environment* env, Local<Object> obj) {
782
- v8:: EscapableHandleScope handle_scope (env->isolate ());
788
+ EscapableHandleScope handle_scope (env->isolate ());
783
789
CHECK (!obj.IsEmpty ());
784
790
785
- v8:: TryCatch ignore_exceptions (env->isolate ());
791
+ TryCatch ignore_exceptions (env->isolate ());
786
792
while (true ) {
787
793
Local<Value> owner;
788
794
if (!obj->Get (env->context (),
0 commit comments