14
14
import CoreFoundation
15
15
import _SwiftCoreFoundationOverlayShims
16
16
17
- private func _utfRangeToCFRange( _ inRange : Range < UnicodeScalar > ) -> CFRange {
17
+ private func _utfRangeToCFRange( _ inRange : Range < Unicode . Scalar > ) -> CFRange {
18
18
return CFRange (
19
19
location: Int ( inRange. lowerBound. value) ,
20
20
length: Int ( inRange. upperBound. value - inRange. lowerBound. value) )
21
21
}
22
22
23
- private func _utfRangeToCFRange( _ inRange : ClosedRange < UnicodeScalar > ) -> CFRange {
23
+ private func _utfRangeToCFRange( _ inRange : ClosedRange < Unicode . Scalar > ) -> CFRange {
24
24
return CFRange (
25
25
location: Int ( inRange. lowerBound. value) ,
26
26
length: Int ( inRange. upperBound. value - inRange. lowerBound. value + 1 ) )
@@ -104,7 +104,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
104
104
105
105
// MARK: Mutable functions
106
106
107
- fileprivate func insert( charactersIn range: Range < UnicodeScalar > ) {
107
+ fileprivate func insert( charactersIn range: Range < Unicode . Scalar > ) {
108
108
switch _backing {
109
109
case . immutable( let cs) :
110
110
let r = CFCharacterSetCreateMutableCopy ( nil , cs) !
@@ -115,7 +115,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
115
115
}
116
116
}
117
117
118
- fileprivate func insert( charactersIn range: ClosedRange < UnicodeScalar > ) {
118
+ fileprivate func insert( charactersIn range: ClosedRange < Unicode . Scalar > ) {
119
119
switch _backing {
120
120
case . immutable( let cs) :
121
121
let r = CFCharacterSetCreateMutableCopy ( nil , cs) !
@@ -126,7 +126,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
126
126
}
127
127
}
128
128
129
- fileprivate func remove( charactersIn range: Range < UnicodeScalar > ) {
129
+ fileprivate func remove( charactersIn range: Range < Unicode . Scalar > ) {
130
130
switch _backing {
131
131
case . immutable( let cs) :
132
132
let r = CFCharacterSetCreateMutableCopy ( nil , cs) !
@@ -137,7 +137,7 @@ fileprivate final class _CharacterSetStorage : Hashable {
137
137
}
138
138
}
139
139
140
- fileprivate func remove( charactersIn range: ClosedRange < UnicodeScalar > ) {
140
+ fileprivate func remove( charactersIn range: ClosedRange < Unicode . Scalar > ) {
141
141
switch _backing {
142
142
case . immutable( let cs) :
143
143
let r = CFCharacterSetCreateMutableCopy ( nil , cs) !
@@ -186,28 +186,28 @@ fileprivate final class _CharacterSetStorage : Hashable {
186
186
// MARK: SetAlgebraType
187
187
188
188
@discardableResult
189
- fileprivate func insert( _ character: UnicodeScalar ) -> ( inserted: Bool , memberAfterInsert: UnicodeScalar ) {
190
- insert ( charactersIn: character..< UnicodeScalar ( character. value + 1 ) !)
189
+ fileprivate func insert( _ character: Unicode . Scalar ) -> ( inserted: Bool , memberAfterInsert: Unicode . Scalar ) {
190
+ insert ( charactersIn: character..< Unicode . Scalar ( character. value + 1 ) !)
191
191
// TODO: This should probably return the truth, but figuring it out requires two calls into NSCharacterSet
192
192
return ( true , character)
193
193
}
194
194
195
195
@discardableResult
196
- fileprivate func update( with character: UnicodeScalar ) -> UnicodeScalar ? {
196
+ fileprivate func update( with character: Unicode . Scalar ) -> Unicode . Scalar ? {
197
197
insert ( character)
198
198
// TODO: This should probably return the truth, but figuring it out requires two calls into NSCharacterSet
199
199
return character
200
200
}
201
201
202
202
@discardableResult
203
- fileprivate func remove( _ character: UnicodeScalar ) -> UnicodeScalar ? {
203
+ fileprivate func remove( _ character: Unicode . Scalar ) -> Unicode . Scalar ? {
204
204
// TODO: Add method to CFCharacterSet to do this in one call
205
- let result : UnicodeScalar ? = contains ( character) ? character : nil
206
- remove ( charactersIn: character..< UnicodeScalar ( character. value + 1 ) !)
205
+ let result : Unicode . Scalar ? = contains ( character) ? character : nil
206
+ remove ( charactersIn: character..< Unicode . Scalar ( character. value + 1 ) !)
207
207
return result
208
208
}
209
209
210
- fileprivate func contains( _ member: UnicodeScalar ) -> Bool {
210
+ fileprivate func contains( _ member: Unicode . Scalar ) -> Bool {
211
211
switch _backing {
212
212
case . immutable( let cs) :
213
213
return CFCharacterSetIsLongCharacterMember ( cs, member. value)
@@ -374,15 +374,15 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
374
374
375
375
/// Initialize with a range of integers.
376
376
///
377
- /// It is the caller's responsibility to ensure that the values represent valid `UnicodeScalar ` values, if that is what is desired.
378
- public init ( charactersIn range: Range < UnicodeScalar > ) {
377
+ /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar ` values, if that is what is desired.
378
+ public init ( charactersIn range: Range < Unicode . Scalar > ) {
379
379
_storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
380
380
}
381
381
382
382
/// Initialize with a closed range of integers.
383
383
///
384
- /// It is the caller's responsibility to ensure that the values represent valid `UnicodeScalar ` values, if that is what is desired.
385
- public init ( charactersIn range: ClosedRange < UnicodeScalar > ) {
384
+ /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar ` values, if that is what is desired.
385
+ public init ( charactersIn range: ClosedRange < Unicode . Scalar > ) {
386
386
_storage = _CharacterSetStorage ( immutableReference: CFCharacterSetCreateWithCharactersInRange ( nil , _utfRangeToCFRange ( range) ) )
387
387
}
388
388
@@ -569,8 +569,8 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
569
569
570
570
/// Insert a range of integer values in the `CharacterSet`.
571
571
///
572
- /// It is the caller's responsibility to ensure that the values represent valid `UnicodeScalar ` values, if that is what is desired.
573
- public mutating func insert( charactersIn range: Range < UnicodeScalar > ) {
572
+ /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar ` values, if that is what is desired.
573
+ public mutating func insert( charactersIn range: Range < Unicode . Scalar > ) {
574
574
if !isKnownUniquelyReferenced( & _storage) {
575
575
_storage = _storage. mutableCopy ( )
576
576
}
@@ -579,24 +579,24 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
579
579
580
580
/// Insert a closed range of integer values in the `CharacterSet`.
581
581
///
582
- /// It is the caller's responsibility to ensure that the values represent valid `UnicodeScalar ` values, if that is what is desired.
583
- public mutating func insert( charactersIn range: ClosedRange < UnicodeScalar > ) {
582
+ /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar ` values, if that is what is desired.
583
+ public mutating func insert( charactersIn range: ClosedRange < Unicode . Scalar > ) {
584
584
if !isKnownUniquelyReferenced( & _storage) {
585
585
_storage = _storage. mutableCopy ( )
586
586
}
587
587
_storage. insert ( charactersIn: range)
588
588
}
589
589
590
590
/// Remove a range of integer values from the `CharacterSet`.
591
- public mutating func remove( charactersIn range: Range < UnicodeScalar > ) {
591
+ public mutating func remove( charactersIn range: Range < Unicode . Scalar > ) {
592
592
if !isKnownUniquelyReferenced( & _storage) {
593
593
_storage = _storage. mutableCopy ( )
594
594
}
595
595
_storage. remove ( charactersIn: range)
596
596
}
597
597
598
598
/// Remove a closed range of integer values from the `CharacterSet`.
599
- public mutating func remove( charactersIn range: ClosedRange < UnicodeScalar > ) {
599
+ public mutating func remove( charactersIn range: ClosedRange < Unicode . Scalar > ) {
600
600
if !isKnownUniquelyReferenced( & _storage) {
601
601
_storage = _storage. mutableCopy ( )
602
602
}
@@ -631,42 +631,42 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
631
631
// MARK: -
632
632
// MARK: SetAlgebraType
633
633
634
- /// Insert a `UnicodeScalar ` representation of a character into the `CharacterSet`.
634
+ /// Insert a `Unicode.Scalar ` representation of a character into the `CharacterSet`.
635
635
///
636
- /// `UnicodeScalar ` values are available on `Swift.String.UnicodeScalarView`.
636
+ /// `Unicode.Scalar ` values are available on `Swift.String.UnicodeScalarView`.
637
637
@discardableResult
638
- public mutating func insert( _ character: UnicodeScalar ) -> ( inserted: Bool , memberAfterInsert: UnicodeScalar ) {
638
+ public mutating func insert( _ character: Unicode . Scalar ) -> ( inserted: Bool , memberAfterInsert: Unicode . Scalar ) {
639
639
if !isKnownUniquelyReferenced( & _storage) {
640
640
_storage = _storage. mutableCopy ( )
641
641
}
642
642
return _storage. insert ( character)
643
643
}
644
644
645
- /// Insert a `UnicodeScalar ` representation of a character into the `CharacterSet`.
645
+ /// Insert a `Unicode.Scalar ` representation of a character into the `CharacterSet`.
646
646
///
647
- /// `UnicodeScalar ` values are available on `Swift.String.UnicodeScalarView`.
647
+ /// `Unicode.Scalar ` values are available on `Swift.String.UnicodeScalarView`.
648
648
@discardableResult
649
- public mutating func update( with character: UnicodeScalar ) -> UnicodeScalar ? {
649
+ public mutating func update( with character: Unicode . Scalar ) -> Unicode . Scalar ? {
650
650
if !isKnownUniquelyReferenced( & _storage) {
651
651
_storage = _storage. mutableCopy ( )
652
652
}
653
653
return _storage. update ( with: character)
654
654
}
655
655
656
656
657
- /// Remove a `UnicodeScalar ` representation of a character from the `CharacterSet`.
657
+ /// Remove a `Unicode.Scalar ` representation of a character from the `CharacterSet`.
658
658
///
659
- /// `UnicodeScalar ` values are available on `Swift.String.UnicodeScalarView`.
659
+ /// `Unicode.Scalar ` values are available on `Swift.String.UnicodeScalarView`.
660
660
@discardableResult
661
- public mutating func remove( _ character: UnicodeScalar ) -> UnicodeScalar ? {
661
+ public mutating func remove( _ character: Unicode . Scalar ) -> Unicode . Scalar ? {
662
662
if !isKnownUniquelyReferenced( & _storage) {
663
663
_storage = _storage. mutableCopy ( )
664
664
}
665
665
return _storage. remove ( character)
666
666
}
667
667
668
- /// Test for membership of a particular `UnicodeScalar ` in the `CharacterSet`.
669
- public func contains( _ member: UnicodeScalar ) -> Bool {
668
+ /// Test for membership of a particular `Unicode.Scalar ` in the `CharacterSet`.
669
+ public func contains( _ member: Unicode . Scalar ) -> Bool {
670
670
return _storage. contains ( member)
671
671
}
672
672
0 commit comments