@@ -13,6 +13,16 @@ Value createScope(const CallbackInfo& info) {
13
13
return String::New (info.Env (), " scope" );
14
14
}
15
15
16
+ Value createScopeFromExisting (const CallbackInfo& info) {
17
+ {
18
+ napi_handle_scope scope;
19
+ napi_open_handle_scope (info.Env (), &scope);
20
+ HandleScope scope_existing (info.Env (), scope);
21
+ String::New (scope_existing.Env (), " inner-existing-scope" );
22
+ }
23
+ return String::New (info.Env (), " existing_scope" );
24
+ }
25
+
16
26
Value escapeFromScope (const CallbackInfo& info) {
17
27
Value result;
18
28
{
@@ -22,6 +32,18 @@ Value escapeFromScope(const CallbackInfo& info) {
22
32
return result;
23
33
}
24
34
35
+ Value escapeFromExistingScope (const CallbackInfo& info) {
36
+ Value result;
37
+ {
38
+ napi_escapable_handle_scope scope;
39
+ napi_open_escapable_handle_scope (info.Env (), &scope);
40
+ EscapableHandleScope scope_existing (info.Env (), scope);
41
+ result = scope_existing.Escape (
42
+ String::New (scope_existing.Env (), " inner-existing-scope" ));
43
+ }
44
+ return result;
45
+ }
46
+
25
47
#define LOOP_MAX 1000000
26
48
Value stressEscapeFromScope (const CallbackInfo& info) {
27
49
Value result;
@@ -52,7 +74,11 @@ Object InitHandleScope(Env env) {
52
74
Object exports = Object::New (env);
53
75
54
76
exports[" createScope" ] = Function::New (env, createScope);
77
+ exports[" createScopeFromExisting" ] =
78
+ Function::New (env, createScopeFromExisting);
55
79
exports[" escapeFromScope" ] = Function::New (env, escapeFromScope);
80
+ exports[" escapeFromExistingScope" ] =
81
+ Function::New (env, escapeFromExistingScope);
56
82
exports[" stressEscapeFromScope" ] = Function::New (env, stressEscapeFromScope);
57
83
exports[" doubleEscapeFromScope" ] = Function::New (env, doubleEscapeFromScope);
58
84
0 commit comments