1
- //===--- UnicodeStorage .swift ---------------------------------------------===//
1
+ //===--- UnicodeViews .swift -- ---------------------------------------------===//
2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
@@ -32,12 +32,12 @@ internal func __swift_stdlib_U_FAILURE(_ x: __swift_stdlib_UErrorCode) -> Bool {
32
32
33
33
/// A collection of `CodeUnit`s to be interpreted by some `Encoding`.
34
34
///
35
- /// View types nested in UnicodeStorage may be suitable *generic* implementation
35
+ /// View types nested in _UnicodeViews may be suitable *generic* implementation
36
36
/// guts for views for models of Unicode, but specific models may want to
37
37
/// provide their own implementations. For example, the UTF16 view of a
38
38
/// Latin1String would might be a simple lazy zero-extended mapping, rather than
39
39
/// something that goes through the transcoding machinery.
40
- public struct UnicodeStorage <
40
+ public struct _UnicodeViews <
41
41
CodeUnits : RandomAccessCollection ,
42
42
Encoding : UnicodeEncoding
43
43
>
@@ -54,15 +54,15 @@ where Encoding.EncodedScalar.Iterator.Element == CodeUnits.Iterator.Element,
54
54
public var codeUnits : CodeUnits
55
55
}
56
56
57
- /// A straightforward typealias for _UnicodeStorage
57
+ /// A straightforward typealias for _UnicodeViews
58
58
///
59
59
/// Use this to escape the automatic deduction of the generic arguments given
60
- /// the name `UnicodeStorage ` from within nested contexts
60
+ /// the name `_UnicodeViews ` from within nested contexts
61
61
/// (https://bugs.swift.org/browse/SR-4155).
62
- internal typealias _UnicodeStorage <
62
+ internal typealias _UnicodeViews_ <
63
63
CodeUnits : RandomAccessCollection ,
64
64
Encoding : UnicodeEncoding
65
- > = UnicodeStorage < CodeUnits , Encoding >
65
+ > = _UnicodeViews < CodeUnits , Encoding >
66
66
where Encoding. EncodedScalar . Iterator . Element == CodeUnits . Iterator. Element,
67
67
CodeUnits . SubSequence : Rando mAccessCollection,
68
68
CodeUnits . SubSequence. Index == CodeUnits . Index,
@@ -71,7 +71,7 @@ CodeUnits.SubSequence.Iterator.Element == CodeUnits.Iterator.Element
71
71
72
72
/// A lazy collection of `Encoding.EncodedScalar` that results
73
73
/// from parsing an instance of codeUnits using that `Encoding`.
74
- extension UnicodeStorage {
74
+ extension _UnicodeViews {
75
75
public struct EncodedScalars {
76
76
let codeUnits : CodeUnits
77
77
@@ -81,7 +81,7 @@ extension UnicodeStorage {
81
81
}
82
82
}
83
83
84
- extension UnicodeStorage . EncodedScalars {
84
+ extension _UnicodeViews . EncodedScalars {
85
85
// Because parsing produces a buffer and a new index, to avoid
86
86
// repeatedly decoding the same data, this index stores that buffer
87
87
// and the next index. This would obviously be more complicated if
@@ -108,7 +108,7 @@ extension UnicodeStorage.EncodedScalars {
108
108
}
109
109
110
110
/// Collection Conformance
111
- extension UnicodeStorage . EncodedScalars : BidirectionalCollection {
111
+ extension _UnicodeViews . EncodedScalars : BidirectionalCollection {
112
112
public var startIndex : Index {
113
113
if _slowPath ( codeUnits. isEmpty) { return endIndex }
114
114
let s = codeUnits. startIndex
@@ -177,15 +177,15 @@ extension UnicodeStorage.EncodedScalars : BidirectionalCollection {
177
177
}
178
178
}
179
179
180
- extension UnicodeStorage {
180
+ extension _UnicodeViews {
181
181
public typealias ScalarsTranscoded < ToEncoding : UnicodeEncoding >
182
182
= LazyMapBidirectionalCollection < EncodedScalars , ToEncoding . EncodedScalar >
183
183
184
184
public func scalarsTranscoded< ToEncoding : UnicodeEncoding > (
185
185
to dst: ToEncoding . Type
186
186
)
187
187
-> ScalarsTranscoded < ToEncoding > {
188
- return UnicodeStorage . EncodedScalars ( codeUnits, Encoding . self) . lazy. map {
188
+ return _UnicodeViews . EncodedScalars ( codeUnits, Encoding . self) . lazy. map {
189
189
dst. encode ( $0) !
190
190
}
191
191
}
@@ -201,7 +201,7 @@ extension UnicodeStorage {
201
201
// Instead, we wrap an instance of Base.
202
202
public typealias Base = FlattenBidirectionalCollection <
203
203
LazyMapBidirectionalCollection <
204
- UnicodeStorage < CodeUnits , FromEncoding > . EncodedScalars ,
204
+ _UnicodeViews < CodeUnits , FromEncoding > . EncodedScalars ,
205
205
ToEncoding . EncodedScalar
206
206
>
207
207
>
@@ -211,7 +211,7 @@ extension UnicodeStorage {
211
211
from src: FromEncoding . Type = FromEncoding . self,
212
212
to dst: ToEncoding . Type = ToEncoding . self
213
213
) {
214
- base = Base ( UnicodeStorage ( codeUnits) . scalarsTranscoded ( to: dst) )
214
+ base = Base ( _UnicodeViews ( codeUnits) . scalarsTranscoded ( to: dst) )
215
215
}
216
216
217
217
// FIXME: this should go in the extension below but for <rdar://30320012>
@@ -241,7 +241,7 @@ extension UnicodeStorage {
241
241
}
242
242
}
243
243
244
- extension UnicodeStorage : _UTextable {
244
+ extension _UnicodeViews : _UTextable {
245
245
internal func _nativeLength( _ uText: inout _UText ) -> Int64 {
246
246
uText. validate ( )
247
247
return codeUnits. count^
@@ -250,15 +250,15 @@ extension UnicodeStorage : _UTextable {
250
250
internal func _parsedSlice(
251
251
_ offset: Int64 ,
252
252
_ slice: ( CodeUnits . Index ) -> CodeUnits . SubSequence
253
- ) -> UnicodeStorage < CodeUnits . SubSequence , Encoding > . EncodedScalars . SubSequence {
254
- return _UnicodeStorage (
253
+ ) -> _UnicodeViews < CodeUnits . SubSequence , Encoding > . EncodedScalars . SubSequence {
254
+ return _UnicodeViews_ (
255
255
slice ( codeUnits. index ( atOffset: offset) ) , Encoding . self
256
256
) . scalars. dropFirst ( 0 )
257
257
}
258
258
259
259
internal func _parsedSuffix(
260
260
fromOffset offset: Int64
261
- ) -> UnicodeStorage < CodeUnits . SubSequence , Encoding > . EncodedScalars . SubSequence {
261
+ ) -> _UnicodeViews < CodeUnits . SubSequence , Encoding > . EncodedScalars . SubSequence {
262
262
return _parsedSlice ( offset, codeUnits. suffix ( from: ) )
263
263
}
264
264
@@ -381,7 +381,7 @@ extension UnicodeStorage : _UTextable {
381
381
// the generic TranscodedView, which is likely to be less efficient in
382
382
// some common cases.
383
383
let source
384
- = _UnicodeStorage ( base, Encoding . self) . transcoded ( to: UTF16 . self)
384
+ = _UnicodeViews_ ( base, Encoding . self) . transcoded ( to: UTF16 . self)
385
385
var d = destination // copy due to https://bugs.swift.org/browse/SR-3782
386
386
let ( limit, remainder) = d. copy ( from: source)
387
387
@@ -426,26 +426,26 @@ extension UnicodeStorage : _UTextable {
426
426
..<
427
427
codeUnits. index ( atOffset: nativeIndex) ]
428
428
429
- return _UnicodeStorage (
429
+ return _UnicodeViews_ (
430
430
nativeChunk, Encoding . self) . transcoded ( to: UTF16 . self) . count^
431
431
}
432
432
}
433
433
434
- extension UnicodeStorage {
434
+ extension _UnicodeViews {
435
435
public var scalars : EncodedScalars {
436
436
return EncodedScalars ( codeUnits, Encoding . self)
437
437
}
438
438
}
439
439
440
- extension UnicodeStorage {
440
+ extension _UnicodeViews {
441
441
442
442
public struct CharacterView : BidirectionalCollection {
443
443
444
444
public init ( _ codeUnits: CodeUnits , _: Encoding . Type = Encoding . self) {
445
- self . storage = UnicodeStorage ( codeUnits)
445
+ self . storage = _UnicodeViews ( codeUnits)
446
446
}
447
447
448
- internal let storage : UnicodeStorage
448
+ internal let storage : _UnicodeViews
449
449
450
450
public typealias SubSequence = BidirectionalSlice < CharacterView >
451
451
@@ -455,7 +455,7 @@ extension UnicodeStorage {
455
455
456
456
public subscript( i: Index ) -> Character {
457
457
let j = index ( after: i)
458
- let contents = UnicodeStorage <
458
+ let contents = _UnicodeViews <
459
459
// explicit generic parameters shouldn't be needed
460
460
// <rdar://problem/30882312>
461
461
CodeUnits . SubSequence, Encoding
@@ -532,7 +532,7 @@ internal func _makeFCCNormalizer() -> OpaquePointer {
532
532
533
533
internal var _fccNormalizer = _makeFCCNormalizer ( )
534
534
535
- extension UnicodeStorage {
535
+ extension _UnicodeViews {
536
536
537
537
public typealias FCCNormalizedUTF16View = [ UInt16 ]
538
538
0 commit comments