@@ -30,57 +30,58 @@ class FuncRefObject : public Napi::ObjectWrap<FuncRefObject> {
30
30
namespace {
31
31
32
32
Value ConstructRefFromExisitingRef (const CallbackInfo& info) {
33
- HandleScope scope (info.Env ());
33
+ EscapableHandleScope scope (info.Env ());
34
34
FunctionReference ref;
35
35
FunctionReference movedRef;
36
36
ref.Reset (info[0 ].As <Function>());
37
37
movedRef = std::move (ref);
38
38
39
- return MaybeUnwrap (movedRef ({}));
39
+ return scope. Escape ( MaybeUnwrap (movedRef ({}) ));
40
40
}
41
41
42
42
Value CallWithVectorArgs (const CallbackInfo& info) {
43
- HandleScope scope (info.Env ());
43
+ EscapableHandleScope scope (info.Env ());
44
44
std::vector<napi_value> newVec;
45
45
FunctionReference ref;
46
46
ref.Reset (info[0 ].As <Function>());
47
47
48
48
for (int i = 1 ; i < (int )info.Length (); i++) {
49
49
newVec.push_back (info[i]);
50
50
}
51
- return MaybeUnwrap (ref.Call (newVec));
51
+ return scope. Escape ( MaybeUnwrap (ref.Call (newVec) ));
52
52
}
53
53
54
54
Value CallWithInitList (const CallbackInfo& info) {
55
- HandleScope scope (info.Env ());
55
+ EscapableHandleScope scope (info.Env ());
56
56
FunctionReference ref;
57
57
ref.Reset (info[0 ].As <Function>());
58
58
59
- return MaybeUnwrap (ref.Call ({info[1 ], info[2 ], info[3 ]}));
59
+ return scope. Escape ( MaybeUnwrap (ref.Call ({info[1 ], info[2 ], info[3 ]}) ));
60
60
}
61
61
62
62
Value CallWithRecvInitList (const CallbackInfo& info) {
63
- HandleScope scope (info.Env ());
63
+ EscapableHandleScope scope (info.Env ());
64
64
FunctionReference ref;
65
65
ref.Reset (info[0 ].As <Function>());
66
66
67
- return MaybeUnwrap (ref.Call (info[1 ], {info[2 ], info[3 ], info[4 ]}));
67
+ return scope.Escape (
68
+ MaybeUnwrap (ref.Call (info[1 ], {info[2 ], info[3 ], info[4 ]})));
68
69
}
69
70
70
71
Value CallWithRecvVector (const CallbackInfo& info) {
71
- HandleScope scope (info.Env ());
72
+ EscapableHandleScope scope (info.Env ());
72
73
FunctionReference ref;
73
74
std::vector<napi_value> newVec;
74
75
ref.Reset (info[0 ].As <Function>());
75
76
76
77
for (int i = 2 ; i < (int )info.Length (); i++) {
77
78
newVec.push_back (info[i]);
78
79
}
79
- return MaybeUnwrap (ref.Call (info[1 ], newVec));
80
+ return scope. Escape ( MaybeUnwrap (ref.Call (info[1 ], newVec) ));
80
81
}
81
82
82
83
Value CallWithRecvArgc (const CallbackInfo& info) {
83
- HandleScope scope (info.Env ());
84
+ EscapableHandleScope scope (info.Env ());
84
85
FunctionReference ref;
85
86
ref.Reset (info[0 ].As <Function>());
86
87
@@ -91,7 +92,7 @@ Value CallWithRecvArgc(const CallbackInfo& info) {
91
92
args[i] = info[i + 2 ];
92
93
}
93
94
94
- return MaybeUnwrap (ref.Call (info[1 ], argLength, args.get ()));
95
+ return scope. Escape ( MaybeUnwrap (ref.Call (info[1 ], argLength, args.get () )));
95
96
}
96
97
97
98
Value MakeAsyncCallbackWithInitList (const Napi::CallbackInfo& info) {
@@ -163,19 +164,19 @@ Value CreateFunctionReferenceUsingNewVec(const Napi::CallbackInfo& info) {
163
164
}
164
165
165
166
Value Call (const CallbackInfo& info) {
166
- HandleScope scope (info.Env ());
167
+ EscapableHandleScope scope (info.Env ());
167
168
FunctionReference ref;
168
169
ref.Reset (info[0 ].As <Function>());
169
170
170
- return MaybeUnwrapOr (ref.Call ({}), Value ());
171
+ return scope. Escape ( MaybeUnwrapOr (ref.Call ({}), Value () ));
171
172
}
172
173
173
174
Value Construct (const CallbackInfo& info) {
174
- HandleScope scope (info.Env ());
175
+ EscapableHandleScope scope (info.Env ());
175
176
FunctionReference ref;
176
177
ref.Reset (info[0 ].As <Function>());
177
178
178
- return MaybeUnwrapOr (ref.New ({}), Object ());
179
+ return scope. Escape ( MaybeUnwrapOr (ref.New ({}), Object () ));
179
180
}
180
181
} // namespace
181
182
0 commit comments