@@ -119,16 +119,21 @@ static inline KInt objCSizeToKotlinOrThrow(NSUInteger size) {
119
119
return objCSizeToKotlinOrThrow (set.count );
120
120
}
121
121
122
- NO_EXTERNAL_CALLS_CHECK
123
122
extern " C" KBoolean Kotlin_NSSetAsKSet_contains (KRef thiz, KRef element) {
124
123
NSSet * set = (NSSet *) GetAssociatedObject (thiz);
125
- return [set containsObject: refToObjCOrNSNull (element)];
124
+ id objCElement = refToObjCOrNSNull (element);
125
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
126
+ return [set containsObject: objCElement];
126
127
}
127
128
128
- NO_EXTERNAL_CALLS_CHECK
129
129
extern " C" OBJ_GETTER(Kotlin_NSSetAsKSet_getElement, KRef thiz, KRef element) {
130
130
NSSet * set = (NSSet *) GetAssociatedObject (thiz);
131
- id res = [set member: refToObjCOrNSNull (element)];
131
+ id objCElement = refToObjCOrNSNull (element);
132
+ id res;
133
+ {
134
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
135
+ res = [set member: objCElement];
136
+ }
132
137
RETURN_RESULT_OF (refFromObjCOrNSNull, res);
133
138
}
134
139
@@ -148,16 +153,17 @@ static inline OBJ_GETTER(CreateKIteratorFromNSEnumerator, NSEnumerator* enumerat
148
153
return objCSizeToKotlinOrThrow (dict.count );
149
154
}
150
155
151
- NO_EXTERNAL_CALLS_CHECK
152
156
extern " C" KBoolean Kotlin_NSDictionaryAsKMap_containsKey (KRef thiz, KRef key) {
153
157
NSDictionary * dict = (NSDictionary *) GetAssociatedObject (thiz);
154
- return [dict objectForKey: refToObjCOrNSNull (key)] != nullptr ;
158
+ id objCKey = refToObjCOrNSNull (key);
159
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
160
+ return [dict objectForKey: objCKey] != nullptr ;
155
161
}
156
162
157
- NO_EXTERNAL_CALLS_CHECK
158
163
extern " C" KBoolean Kotlin_NSDictionaryAsKMap_containsValue (KRef thiz, KRef value) {
159
164
NSDictionary * dict = (NSDictionary *) GetAssociatedObject (thiz);
160
165
id objCValue = refToObjCOrNSNull (value);
166
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
161
167
for (id key in dict) {
162
168
if ([[dict objectForKey: key] isEqual: objCValue]) {
163
169
return true ;
@@ -167,28 +173,38 @@ static inline OBJ_GETTER(CreateKIteratorFromNSEnumerator, NSEnumerator* enumerat
167
173
return false ;
168
174
}
169
175
170
- NO_EXTERNAL_CALLS_CHECK
171
176
extern " C" OBJ_GETTER(Kotlin_NSDictionaryAsKMap_get, KRef thiz, KRef key) {
172
177
NSDictionary * dict = (NSDictionary *) GetAssociatedObject (thiz);
173
- id value = [dict objectForKey: refToObjCOrNSNull (key)];
178
+ id objCKey = refToObjCOrNSNull (key);
179
+ id value;
180
+ {
181
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
182
+ value = [dict objectForKey: objCKey];
183
+ }
174
184
RETURN_RESULT_OF (refFromObjCOrNSNull, value);
175
185
}
176
186
177
- NO_EXTERNAL_CALLS_CHECK
178
187
extern " C" OBJ_GETTER(Kotlin_NSDictionaryAsKMap_getOrThrowConcurrentModification, KRef thiz, KRef key) {
179
188
NSDictionary * dict = (NSDictionary *) GetAssociatedObject (thiz);
180
- id value = [dict objectForKey: refToObjCOrNSNull (key)];
189
+ id objCKey = refToObjCOrNSNull (key);
190
+ id value;
191
+ {
192
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
193
+ value = [dict objectForKey: objCKey];
194
+ }
181
195
if (value == nullptr ) {
182
196
Kotlin_ObjCExport_ThrowCollectionConcurrentModification ();
183
197
}
184
198
185
199
RETURN_RESULT_OF (refFromObjCOrNSNull, value);
186
200
}
187
201
188
- NO_EXTERNAL_CALLS_CHECK
189
202
extern " C" KBoolean Kotlin_NSDictionaryAsKMap_containsEntry (KRef thiz, KRef key, KRef value) {
190
203
NSDictionary * dict = (NSDictionary *) GetAssociatedObject (thiz);
191
- return [refToObjCOrNSNull (value) isEqual: [dict objectForKey: refToObjCOrNSNull (key)]];
204
+ id objCValue = refToObjCOrNSNull (value);
205
+ id objCKey = refToObjCOrNSNull (key);
206
+ kotlin::ThreadStateGuard guard (kotlin::ThreadState::kNative );
207
+ return [objCValue isEqual: [dict objectForKey: objCKey]];
192
208
}
193
209
194
210
NO_EXTERNAL_CALLS_CHECK
0 commit comments