@@ -29,7 +29,10 @@ private func _utfRangeToCFRange(_ inRange : ClosedRange<Unicode.Scalar>) -> CFRa
29
29
30
30
// MARK: -
31
31
32
- fileprivate final class _CharacterSetStorage : Hashable {
32
+ // NOTE: older overlays called this class _CharacterSetStorage.
33
+ // The two must coexist without a conflicting ObjC class name, so it
34
+ // was renamed. The old name must not be used in the new runtime.
35
+ fileprivate final class __CharacterSetStorage : Hashable {
33
36
fileprivate enum Backing {
34
37
case immutable( CFCharacterSet )
35
38
case mutable( CFMutableCharacterSet )
@@ -58,7 +61,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
58
61
}
59
62
}
60
63
61
- fileprivate static func == ( lhs : _CharacterSetStorage , rhs : _CharacterSetStorage ) -> Bool {
64
+ fileprivate static func == ( lhs : __CharacterSetStorage , rhs : __CharacterSetStorage ) -> Bool {
62
65
switch ( lhs. _backing, rhs. _backing) {
63
66
case ( . immutable( let cs1) , . immutable( let cs2) ) :
64
67
return CFEqual ( cs1, cs2)
@@ -73,12 +76,12 @@ fileprivate final class _CharacterSetStorage : Hashable {
73
76
74
77
// MARK: -
75
78
76
- fileprivate func mutableCopy( ) -> _CharacterSetStorage {
79
+ fileprivate func mutableCopy( ) -> __CharacterSetStorage {
77
80
switch _backing {
78
81
case . immutable( let cs) :
79
- return _CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutableCopy ( nil , cs) )
82
+ return __CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutableCopy ( nil , cs) )
80
83
case . mutable( let cs) :
81
- return _CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutableCopy ( nil , cs) )
84
+ return __CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutableCopy ( nil , cs) )
82
85
}
83
86
}
84
87
@@ -223,7 +226,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
223
226
224
227
225
228
// When the underlying collection does not have a method to return new CharacterSets with changes applied, so we will copy and apply here
226
- private static func _apply( _ lhs : _CharacterSetStorage , _ rhs : _CharacterSetStorage , _ f : ( CFMutableCharacterSet , CFCharacterSet ) -> ( ) ) -> CharacterSet {
229
+ private static func _apply( _ lhs : __CharacterSetStorage , _ rhs : __CharacterSetStorage , _ f : ( CFMutableCharacterSet , CFCharacterSet ) -> ( ) ) -> CharacterSet {
227
230
let copyOfMe : CFMutableCharacterSet
228
231
switch lhs. _backing {
229
232
case . immutable( let cs) :
@@ -239,10 +242,10 @@ fileprivate final class _CharacterSetStorage : Hashable {
239
242
f ( copyOfMe, cs)
240
243
}
241
244
242
- return CharacterSet ( _uncopiedStorage: _CharacterSetStorage ( mutableReference: copyOfMe) )
245
+ return CharacterSet ( _uncopiedStorage: __CharacterSetStorage ( mutableReference: copyOfMe) )
243
246
}
244
247
245
- private func _applyMutation( _ other : _CharacterSetStorage , _ f : ( CFMutableCharacterSet , CFCharacterSet ) -> ( ) ) {
248
+ private func _applyMutation( _ other : __CharacterSetStorage , _ f : ( CFMutableCharacterSet , CFCharacterSet ) -> ( ) ) {
246
249
switch _backing {
247
250
case . immutable( let cs) :
248
251
let r = CFCharacterSetCreateMutableCopy ( nil , cs) !
@@ -267,47 +270,47 @@ fileprivate final class _CharacterSetStorage : Hashable {
267
270
fileprivate var inverted : CharacterSet {
268
271
switch _backing {
269
272
case . immutable( let cs) :
270
- return CharacterSet ( _uncopiedStorage: _CharacterSetStorage ( immutableReference: CFCharacterSetCreateInvertedSet ( nil , cs) ) )
273
+ return CharacterSet ( _uncopiedStorage: __CharacterSetStorage ( immutableReference: CFCharacterSetCreateInvertedSet ( nil , cs) ) )
271
274
case . mutable( let cs) :
272
275
// Even if input is mutable, the result is immutable
273
- return CharacterSet ( _uncopiedStorage: _CharacterSetStorage ( immutableReference: CFCharacterSetCreateInvertedSet ( nil , cs) ) )
276
+ return CharacterSet ( _uncopiedStorage: __CharacterSetStorage ( immutableReference: CFCharacterSetCreateInvertedSet ( nil , cs) ) )
274
277
}
275
278
}
276
279
277
- fileprivate func union( _ other: _CharacterSetStorage ) -> CharacterSet {
278
- return _CharacterSetStorage . _apply ( self , other, CFCharacterSetUnion)
280
+ fileprivate func union( _ other: __CharacterSetStorage ) -> CharacterSet {
281
+ return __CharacterSetStorage . _apply ( self , other, CFCharacterSetUnion)
279
282
}
280
283
281
- fileprivate func formUnion( _ other: _CharacterSetStorage ) {
284
+ fileprivate func formUnion( _ other: __CharacterSetStorage ) {
282
285
_applyMutation ( other, CFCharacterSetUnion)
283
286
}
284
287
285
- fileprivate func intersection( _ other: _CharacterSetStorage ) -> CharacterSet {
286
- return _CharacterSetStorage . _apply ( self , other, CFCharacterSetIntersect)
288
+ fileprivate func intersection( _ other: __CharacterSetStorage ) -> CharacterSet {
289
+ return __CharacterSetStorage . _apply ( self , other, CFCharacterSetIntersect)
287
290
}
288
291
289
- fileprivate func formIntersection( _ other: _CharacterSetStorage ) {
292
+ fileprivate func formIntersection( _ other: __CharacterSetStorage ) {
290
293
_applyMutation ( other, CFCharacterSetIntersect)
291
294
}
292
295
293
- fileprivate func subtracting( _ other: _CharacterSetStorage ) -> CharacterSet {
296
+ fileprivate func subtracting( _ other: __CharacterSetStorage ) -> CharacterSet {
294
297
return intersection ( other. inverted. _storage)
295
298
}
296
299
297
- fileprivate func subtract( _ other: _CharacterSetStorage ) {
300
+ fileprivate func subtract( _ other: __CharacterSetStorage ) {
298
301
_applyMutation ( other. inverted. _storage, CFCharacterSetIntersect)
299
302
}
300
303
301
- fileprivate func symmetricDifference( _ other: _CharacterSetStorage ) -> CharacterSet {
304
+ fileprivate func symmetricDifference( _ other: __CharacterSetStorage ) -> CharacterSet {
302
305
return union ( other) . subtracting ( intersection ( other) )
303
306
}
304
307
305
- fileprivate func formSymmetricDifference( _ other: _CharacterSetStorage ) {
308
+ fileprivate func formSymmetricDifference( _ other: __CharacterSetStorage ) {
306
309
// This feels like cheating
307
310
_backing = symmetricDifference ( other) . _storage. _backing
308
311
}
309
312
310
- fileprivate func isSuperset( of other: _CharacterSetStorage ) -> Bool {
313
+ fileprivate func isSuperset( of other: __CharacterSetStorage ) -> Bool {
311
314
switch _backing {
312
315
case . immutable( let cs) :
313
316
switch other. _backing {
@@ -363,43 +366,43 @@ fileprivate final class _CharacterSetStorage : Hashable {
363
366
public struct CharacterSet : ReferenceConvertible , Equatable , Hashable , SetAlgebra {
364
367
public typealias ReferenceType = NSCharacterSet
365
368
366
- fileprivate var _storage : _CharacterSetStorage
369
+ fileprivate var _storage : __CharacterSetStorage
367
370
368
371
// MARK: Init methods
369
372
370
373
/// Initialize an empty instance.
371
374
public init ( ) {
372
375
// It's unlikely that we are creating an empty character set with no intention to mutate it
373
- _storage = _CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutable ( nil ) )
376
+ _storage = __CharacterSetStorage ( mutableReference: CFCharacterSetCreateMutable ( nil ) )
374
377
}
375
378
376
379
/// Initialize with a range of integers.
377
380
///
378
381
/// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.
379
382
public init ( charactersIn range: Range < Unicode . Scalar > ) {
380
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
383
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
381
384
}
382
385
383
386
/// Initialize with a closed range of integers.
384
387
///
385
388
/// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.
386
389
public init ( charactersIn range: ClosedRange < Unicode . Scalar > ) {
387
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
390
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
388
391
}
389
392
390
393
/// Initialize with the characters in the given string.
391
394
///
392
395
/// - parameter string: The string content to inspect for characters.
393
396
public init ( charactersIn string: __shared String) {
394
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInString ( nil , string as CFString ) )
397
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInString ( nil , string as CFString ) )
395
398
}
396
399
397
400
/// Initialize with a bitmap representation.
398
401
///
399
402
/// This method is useful for creating a character set object with data from a file or other external data source.
400
403
/// - parameter data: The bitmap representation.
401
404
public init ( bitmapRepresentation data: __shared Data) {
402
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithBitmapRepresentation ( nil , data as CFData ) )
405
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithBitmapRepresentation ( nil , data as CFData ) )
403
406
}
404
407
405
408
/// Initialize with the contents of a file.
@@ -409,26 +412,26 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
409
412
public init ? ( contentsOfFile file: __shared String) {
410
413
do {
411
414
let data = try Data ( contentsOf: URL ( fileURLWithPath: file) , options: . mappedIfSafe)
412
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithBitmapRepresentation ( nil , data as CFData ) )
415
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithBitmapRepresentation ( nil , data as CFData ) )
413
416
} catch {
414
417
return nil
415
418
}
416
419
}
417
420
418
421
fileprivate init ( _bridged characterSet: __shared NSCharacterSet) {
419
- _storage = _CharacterSetStorage ( immutableReference: characterSet. copy ( ) as! CFCharacterSet )
422
+ _storage = __CharacterSetStorage ( immutableReference: characterSet. copy ( ) as! CFCharacterSet )
420
423
}
421
424
422
425
fileprivate init ( _uncopiedImmutableReference characterSet: CFCharacterSet ) {
423
- _storage = _CharacterSetStorage ( immutableReference: characterSet)
426
+ _storage = __CharacterSetStorage ( immutableReference: characterSet)
424
427
}
425
428
426
- fileprivate init ( _uncopiedStorage : _CharacterSetStorage ) {
429
+ fileprivate init ( _uncopiedStorage : __CharacterSetStorage ) {
427
430
_storage = _uncopiedStorage
428
431
}
429
432
430
433
fileprivate init ( _builtIn: __shared CFCharacterSetPredefinedSet) {
431
- _storage = _CharacterSetStorage ( immutableReference: CFCharacterSetGetPredefined ( _builtIn) )
434
+ _storage = __CharacterSetStorage ( immutableReference: CFCharacterSetGetPredefined ( _builtIn) )
432
435
}
433
436
434
437
// MARK: Static functions
0 commit comments