@@ -34,6 +34,10 @@ - (instancetype)initWithMap:(std::shared_ptr<Persistent<Value>>)map isolate:(Iso
34
34
35
35
- (id )nextObject {
36
36
Isolate* isolate = self->isolate_ ;
37
+ v8::Locker locker (isolate);
38
+ Isolate::Scope isolate_scope (isolate);
39
+ HandleScope handle_scope (isolate);
40
+
37
41
Local<Context> context = self->cache_ ->GetContext ();
38
42
Local<v8::Array> array = self->map_ ->Get (isolate).As <Map>()->AsArray ();
39
43
@@ -82,15 +86,23 @@ - (instancetype)initWithProperties:(std::shared_ptr<Persistent<Value>>)dictionar
82
86
}
83
87
84
88
- (Local<v8::Array>)getProperties {
89
+ v8::Locker locker (self->isolate_ );
90
+ Isolate::Scope isolate_scope (self->isolate_ );
91
+ EscapableHandleScope handle_scope (self->isolate_ );
92
+
85
93
Local<Context> context = self->cache_ ->GetContext ();
86
94
Local<v8::Array> properties;
87
95
Local<Object> dictionary = self->dictionary_ ->Get (self->isolate_ ).As <Object>();
88
96
tns::Assert (dictionary->GetOwnPropertyNames (context).ToLocal (&properties), self->isolate_ );
89
- return properties;
97
+ return handle_scope. Escape ( properties) ;
90
98
}
91
99
92
100
- (id )nextObject {
93
101
Isolate* isolate = self->isolate_ ;
102
+ v8::Locker locker (isolate);
103
+ Isolate::Scope isolate_scope (isolate);
104
+ HandleScope handle_scope (isolate);
105
+
94
106
Local<Context> context = self->cache_ ->GetContext ();
95
107
Local<v8::Array> properties = [self getProperties ];
96
108
if (self->index_ < properties->Length ()) {
@@ -107,6 +119,10 @@ - (id)nextObject {
107
119
108
120
- (NSArray *)allObjects {
109
121
Isolate* isolate = self->isolate_ ;
122
+ v8::Locker locker (isolate);
123
+ Isolate::Scope isolate_scope (isolate);
124
+ HandleScope handle_scope (isolate);
125
+
110
126
Local<Context> context = self->cache_ ->GetContext ();
111
127
NSMutableArray * array = [NSMutableArray array ];
112
128
Local<v8::Array> properties = [self getProperties ];
@@ -146,6 +162,10 @@ - (instancetype)initWithJSObject:(Local<Object>)jsObject isolate:(Isolate*)isola
146
162
}
147
163
148
164
- (NSUInteger )count {
165
+ v8::Locker locker (self->isolate_ );
166
+ Isolate::Scope isolate_scope (self->isolate_ );
167
+ HandleScope handle_scope (self->isolate_ );
168
+
149
169
Local<Object> obj = self->object_ ->Get (self->isolate_ ).As <Object>();
150
170
151
171
if (obj->IsMap ()) {
@@ -163,6 +183,10 @@ - (NSUInteger)count {
163
183
164
184
- (id )objectForKey : (id )aKey {
165
185
Isolate* isolate = self->isolate_ ;
186
+ v8::Locker locker (isolate);
187
+ Isolate::Scope isolate_scope (isolate);
188
+ HandleScope handle_scope (isolate);
189
+
166
190
Local<Context> context = self->cache_ ->GetContext ();
167
191
Local<Object> obj = self->object_ ->Get (self->isolate_ ).As <Object>();
168
192
@@ -194,6 +218,10 @@ - (id)objectForKey:(id)aKey {
194
218
}
195
219
196
220
- (NSEnumerator *)keyEnumerator {
221
+ v8::Locker locker (self->isolate_ );
222
+ Isolate::Scope isolate_scope (self->isolate_ );
223
+ HandleScope handle_scope (self->isolate_ );
224
+
197
225
Local<Value> obj = self->object_ ->Get (self->isolate_ );
198
226
199
227
if (obj->IsMap ()) {
0 commit comments