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));
@@ -341,8 +349,7 @@ class DestroyParam {
341
349
Persistent<Object> propBag;
342
350
};
343
351
344
-
345
- void AsyncWrap::WeakCallback (const v8::WeakCallbackInfo<DestroyParam>& info) {
352
+ void AsyncWrap::WeakCallback (const WeakCallbackInfo<DestroyParam>& info) {
346
353
HandleScope scope (info.GetIsolate ());
347
354
348
355
std::unique_ptr<DestroyParam> p{info.GetParameter ()};
@@ -373,8 +380,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
373
380
p->env = Environment::GetCurrent (args);
374
381
p->target .Reset (isolate, args[0 ].As <Object>());
375
382
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 );
378
384
}
379
385
380
386
@@ -448,8 +454,8 @@ void AsyncWrap::Initialize(Local<Object> target,
448
454
env->SetMethod (target, " disablePromiseHook" , DisablePromiseHook);
449
455
env->SetMethod (target, " registerDestroyHook" , RegisterDestroyHook);
450
456
451
- v8:: PropertyAttribute ReadOnlyDontDelete =
452
- static_cast <v8:: PropertyAttribute>(v8:: ReadOnly | v8:: DontDelete);
457
+ PropertyAttribute ReadOnlyDontDelete =
458
+ static_cast <PropertyAttribute>(ReadOnly | DontDelete);
453
459
454
460
#define FORCE_SET_TARGET_FIELD (obj, str, field ) \
455
461
(obj)->DefineOwnProperty (context, \
@@ -695,7 +701,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
695
701
696
702
async_id AsyncHooksGetExecutionAsyncId (Isolate* isolate) {
697
703
// Environment::GetCurrent() allocates a Local<> handle.
698
- v8:: HandleScope handle_scope (isolate);
704
+ HandleScope handle_scope (isolate);
699
705
Environment* env = Environment::GetCurrent (isolate);
700
706
if (env == nullptr ) return -1 ;
701
707
return env->execution_async_id ();
@@ -704,7 +710,7 @@ async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
704
710
705
711
async_id AsyncHooksGetTriggerAsyncId (Isolate* isolate) {
706
712
// Environment::GetCurrent() allocates a Local<> handle.
707
- v8:: HandleScope handle_scope (isolate);
713
+ HandleScope handle_scope (isolate);
708
714
Environment* env = Environment::GetCurrent (isolate);
709
715
if (env == nullptr ) return -1 ;
710
716
return env->trigger_async_id ();
@@ -715,18 +721,18 @@ async_context EmitAsyncInit(Isolate* isolate,
715
721
Local<Object> resource,
716
722
const char * name,
717
723
async_id trigger_async_id) {
718
- v8:: HandleScope handle_scope (isolate);
724
+ HandleScope handle_scope (isolate);
719
725
Local<String> type =
720
- String::NewFromUtf8 (isolate, name, v8:: NewStringType::kInternalized )
726
+ String::NewFromUtf8 (isolate, name, NewStringType::kInternalized )
721
727
.ToLocalChecked ();
722
728
return EmitAsyncInit (isolate, resource, type, trigger_async_id);
723
729
}
724
730
725
731
async_context EmitAsyncInit (Isolate* isolate,
726
732
Local<Object> resource,
727
- v8:: Local<v8:: String> name,
733
+ Local<String> name,
728
734
async_id trigger_async_id) {
729
- v8:: HandleScope handle_scope (isolate);
735
+ HandleScope handle_scope (isolate);
730
736
Environment* env = Environment::GetCurrent (isolate);
731
737
CHECK_NOT_NULL (env);
732
738
@@ -748,7 +754,7 @@ async_context EmitAsyncInit(Isolate* isolate,
748
754
749
755
void EmitAsyncDestroy (Isolate* isolate, async_context asyncContext) {
750
756
// Environment::GetCurrent() allocates a Local<> handle.
751
- v8:: HandleScope handle_scope (isolate);
757
+ HandleScope handle_scope (isolate);
752
758
AsyncWrap::EmitDestroy (
753
759
Environment::GetCurrent (isolate), asyncContext.async_id );
754
760
}
@@ -767,10 +773,10 @@ Local<Object> AsyncWrap::GetOwner() {
767
773
}
768
774
769
775
Local<Object> AsyncWrap::GetOwner (Environment* env, Local<Object> obj) {
770
- v8:: EscapableHandleScope handle_scope (env->isolate ());
776
+ EscapableHandleScope handle_scope (env->isolate ());
771
777
CHECK (!obj.IsEmpty ());
772
778
773
- v8:: TryCatch ignore_exceptions (env->isolate ());
779
+ TryCatch ignore_exceptions (env->isolate ());
774
780
while (true ) {
775
781
Local<Value> owner;
776
782
if (!obj->Get (env->context (),
0 commit comments