@@ -22,14 +22,14 @@ internal typealias _ArrayBridgeStorage
22
22
= _BridgeStorage < _ContiguousArrayStorageBase , _NSArrayCore >
23
23
24
24
@_fixed_layout
25
- public struct _ArrayBuffer < Element> : _ArrayBufferProtocol {
25
+ internal struct _ArrayBuffer < Element> : _ArrayBufferProtocol {
26
26
27
27
/// Create an empty buffer.
28
- public init ( ) {
28
+ internal init ( ) {
29
29
_storage = _ArrayBridgeStorage ( native: _emptyArrayStorage)
30
30
}
31
31
32
- public init ( nsArray: _NSArrayCore ) {
32
+ internal init ( nsArray: _NSArrayCore ) {
33
33
_sanityCheck ( _isClassOrObjCExistential ( Element . self) )
34
34
_storage = _ArrayBridgeStorage ( objC: nsArray)
35
35
}
@@ -46,7 +46,7 @@ public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
46
46
47
47
/// The spare bits that are set when a native array needs deferred
48
48
/// element type checking.
49
- var deferredTypeCheckMask : Int { return 1 }
49
+ internal var deferredTypeCheckMask : Int { return 1 }
50
50
51
51
/// Returns an `_ArrayBuffer<U>` containing the same elements,
52
52
/// deferring checking each element's `U`-ness until it is accessed.
@@ -68,7 +68,7 @@ public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
68
68
native: _native. _storage, bits: deferredTypeCheckMask) )
69
69
}
70
70
71
- var needsElementTypeCheck : Bool {
71
+ internal var needsElementTypeCheck : Bool {
72
72
// NSArray's need an element typecheck when the element type isn't AnyObject
73
73
return !_isNativeTypeChecked && !( AnyObject . self is Element . Type )
74
74
}
@@ -83,18 +83,18 @@ public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
83
83
84
84
extension _ArrayBuffer {
85
85
/// Adopt the storage of `source`.
86
- public init ( _buffer source: NativeBuffer , shiftedToStartIndex: Int ) {
86
+ internal init ( _buffer source: NativeBuffer , shiftedToStartIndex: Int ) {
87
87
_sanityCheck ( shiftedToStartIndex == 0 , " shiftedToStartIndex must be 0 " )
88
88
_storage = _ArrayBridgeStorage ( native: source. _storage)
89
89
}
90
90
91
91
/// `true`, if the array is native and does not need a deferred type check.
92
- var arrayPropertyIsNativeTypeChecked : Bool {
92
+ internal var arrayPropertyIsNativeTypeChecked : Bool {
93
93
return _isNativeTypeChecked
94
94
}
95
95
96
96
/// Returns `true` iff this buffer's storage is uniquely-referenced.
97
- mutating func isUniquelyReferenced( ) -> Bool {
97
+ internal mutating func isUniquelyReferenced( ) -> Bool {
98
98
if !_isClassOrObjCExistential( Element . self) {
99
99
return _storage. isUniquelyReferenced_native_noSpareBits ( )
100
100
}
@@ -103,7 +103,7 @@ extension _ArrayBuffer {
103
103
104
104
/// Returns `true` iff this buffer's storage is either
105
105
/// uniquely-referenced or pinned.
106
- mutating func isUniquelyReferencedOrPinned( ) -> Bool {
106
+ internal mutating func isUniquelyReferencedOrPinned( ) -> Bool {
107
107
if !_isClassOrObjCExistential( Element . self) {
108
108
return _storage. isUniquelyReferencedOrPinned_native_noSpareBits ( )
109
109
}
@@ -113,15 +113,15 @@ extension _ArrayBuffer {
113
113
/// Convert to an NSArray.
114
114
///
115
115
/// O(1) if the element type is bridged verbatim, O(N) otherwise.
116
- public func _asCocoaArray( ) -> _NSArrayCore {
116
+ internal func _asCocoaArray( ) -> _NSArrayCore {
117
117
return _fastPath ( _isNative) ? _native. _asCocoaArray ( ) : _nonNative
118
118
}
119
119
120
120
/// If this buffer is backed by a uniquely-referenced mutable
121
121
/// `_ContiguousArrayBuffer` that can be grown in-place to allow the self
122
122
/// buffer store minimumCapacity elements, returns that buffer.
123
123
/// Otherwise, returns `nil`.
124
- public mutating func requestUniqueMutableBackingBuffer( minimumCapacity: Int )
124
+ internal mutating func requestUniqueMutableBackingBuffer( minimumCapacity: Int )
125
125
-> NativeBuffer ? {
126
126
if _fastPath ( isUniquelyReferenced ( ) ) {
127
127
let b = _native
@@ -132,18 +132,18 @@ extension _ArrayBuffer {
132
132
return nil
133
133
}
134
134
135
- public mutating func isMutableAndUniquelyReferenced( ) -> Bool {
135
+ internal mutating func isMutableAndUniquelyReferenced( ) -> Bool {
136
136
return isUniquelyReferenced ( )
137
137
}
138
138
139
- public mutating func isMutableAndUniquelyReferencedOrPinned( ) -> Bool {
139
+ internal mutating func isMutableAndUniquelyReferencedOrPinned( ) -> Bool {
140
140
return isUniquelyReferencedOrPinned ( )
141
141
}
142
142
143
143
/// If this buffer is backed by a `_ContiguousArrayBuffer`
144
144
/// containing the same number of elements as `self`, return it.
145
145
/// Otherwise, return `nil`.
146
- public func requestNativeBuffer( ) -> NativeBuffer ? {
146
+ internal func requestNativeBuffer( ) -> NativeBuffer ? {
147
147
if !_isClassOrObjCExistential( Element . self) {
148
148
return _native
149
149
}
@@ -170,7 +170,7 @@ extension _ArrayBuffer {
170
170
}
171
171
}
172
172
173
- func _typeCheck( _ subRange: Range < Int > ) {
173
+ internal func _typeCheck( _ subRange: Range < Int > ) {
174
174
if !_isClassOrObjCExistential( Element . self) {
175
175
return
176
176
}
@@ -189,7 +189,7 @@ extension _ArrayBuffer {
189
189
/// memory starting at `target`. Return a pointer "past the end" of the
190
190
/// just-initialized memory.
191
191
@discardableResult
192
- public func _copyContents(
192
+ internal func _copyContents(
193
193
subRange bounds: Range < Int > ,
194
194
initializing target: UnsafeMutablePointer < Element >
195
195
) -> UnsafeMutablePointer < Element > {
@@ -221,7 +221,7 @@ extension _ArrayBuffer {
221
221
222
222
/// Returns a `_SliceBuffer` containing the given sub-range of elements in
223
223
/// `bounds` from this buffer.
224
- public subscript( bounds: Range < Int > ) -> _SliceBuffer < Element > {
224
+ internal subscript( bounds: Range < Int > ) -> _SliceBuffer < Element > {
225
225
get {
226
226
_typeCheck ( bounds)
227
227
@@ -254,7 +254,7 @@ extension _ArrayBuffer {
254
254
255
255
// No contiguous storage found; we must allocate
256
256
let result = _ContiguousArrayBuffer < Element > (
257
- uninitializedCount : boundsCount, minimumCapacity: 0 )
257
+ _uninitializedCount : boundsCount, minimumCapacity: 0 )
258
258
259
259
// Tell Cocoa to copy the objects into our storage
260
260
cocoa. buffer. getObjects (
@@ -273,17 +273,17 @@ extension _ArrayBuffer {
273
273
/// A pointer to the first element.
274
274
///
275
275
/// - Precondition: The elements are known to be stored contiguously.
276
- public var firstElementAddress : UnsafeMutablePointer < Element > {
276
+ internal var firstElementAddress : UnsafeMutablePointer < Element > {
277
277
_sanityCheck ( _isNative, " must be a native buffer " )
278
278
return _native. firstElementAddress
279
279
}
280
280
281
- public var firstElementAddressIfContiguous : UnsafeMutablePointer < Element > ? {
281
+ internal var firstElementAddressIfContiguous : UnsafeMutablePointer < Element > ? {
282
282
return _fastPath ( _isNative) ? firstElementAddress : nil
283
283
}
284
284
285
285
/// The number of elements the buffer stores.
286
- public var count : Int {
286
+ internal var count : Int {
287
287
@inline ( __always)
288
288
get {
289
289
return _fastPath ( _isNative) ? _native. count : _nonNative. count
@@ -331,13 +331,13 @@ extension _ArrayBuffer {
331
331
}
332
332
333
333
/// The number of elements the buffer can store without reallocation.
334
- public var capacity : Int {
334
+ internal var capacity : Int {
335
335
return _fastPath ( _isNative) ? _native. capacity : _nonNative. count
336
336
}
337
337
338
338
@_versioned
339
339
@inline ( __always)
340
- func getElement( _ i: Int , wasNativeTypeChecked: Bool ) -> Element {
340
+ internal func getElement( _ i: Int , wasNativeTypeChecked: Bool ) -> Element {
341
341
if _fastPath ( wasNativeTypeChecked) {
342
342
return _nativeTypeChecked [ i]
343
343
}
@@ -346,7 +346,7 @@ extension _ArrayBuffer {
346
346
347
347
@_versioned
348
348
@inline ( never)
349
- func _getElementSlowPath( _ i: Int ) -> AnyObject {
349
+ internal func _getElementSlowPath( _ i: Int ) -> AnyObject {
350
350
_sanityCheck (
351
351
_isClassOrObjCExistential ( Element . self) ,
352
352
" Only single reference elements can be indexed here. " )
@@ -372,7 +372,7 @@ extension _ArrayBuffer {
372
372
}
373
373
374
374
/// Get or set the value of the ith element.
375
- public subscript( i: Int ) -> Element {
375
+ internal subscript( i: Int ) -> Element {
376
376
get {
377
377
return getElement ( i, wasNativeTypeChecked: _isNativeTypeChecked)
378
378
}
@@ -394,7 +394,7 @@ extension _ArrayBuffer {
394
394
/// Call `body(p)`, where `p` is an `UnsafeBufferPointer` over the
395
395
/// underlying contiguous storage. If no such storage exists, it is
396
396
/// created on-demand.
397
- public func withUnsafeBufferPointer< R> (
397
+ internal func withUnsafeBufferPointer< R> (
398
398
_ body: ( UnsafeBufferPointer < Element > ) throws -> R
399
399
) rethrows -> R {
400
400
if _fastPath ( _isNative) {
@@ -409,7 +409,7 @@ extension _ArrayBuffer {
409
409
/// over the underlying contiguous storage.
410
410
///
411
411
/// - Precondition: Such contiguous storage exists or the buffer is empty.
412
- public mutating func withUnsafeMutableBufferPointer< R> (
412
+ internal mutating func withUnsafeMutableBufferPointer< R> (
413
413
_ body: ( UnsafeMutableBufferPointer < Element > ) throws -> R
414
414
) rethrows -> R {
415
415
_sanityCheck (
@@ -422,22 +422,22 @@ extension _ArrayBuffer {
422
422
}
423
423
424
424
/// An object that keeps the elements stored in this buffer alive.
425
- public var owner : AnyObject {
425
+ internal var owner : AnyObject {
426
426
return _fastPath ( _isNative) ? _native. _storage : _nonNative
427
427
}
428
428
429
429
/// An object that keeps the elements stored in this buffer alive.
430
430
///
431
431
/// - Precondition: This buffer is backed by a `_ContiguousArrayBuffer`.
432
- public var nativeOwner : AnyObject {
432
+ internal var nativeOwner : AnyObject {
433
433
_sanityCheck ( _isNative, " Expect a native array " )
434
434
return _native. _storage
435
435
}
436
436
437
437
/// A value that identifies the storage used by the buffer. Two
438
438
/// buffers address the same elements when they have the same
439
439
/// identity and count.
440
- public var identity : UnsafeRawPointer {
440
+ internal var identity : UnsafeRawPointer {
441
441
if _isNative {
442
442
return _native. identity
443
443
}
@@ -450,7 +450,7 @@ extension _ArrayBuffer {
450
450
/// The position of the first element in a non-empty collection.
451
451
///
452
452
/// In an empty collection, `startIndex == endIndex`.
453
- public var startIndex : Int {
453
+ internal var startIndex : Int {
454
454
return 0
455
455
}
456
456
@@ -459,18 +459,18 @@ extension _ArrayBuffer {
459
459
/// `endIndex` is not a valid argument to `subscript`, and is always
460
460
/// reachable from `startIndex` by zero or more applications of
461
461
/// `index(after:)`.
462
- public var endIndex : Int {
462
+ internal var endIndex : Int {
463
463
return count
464
464
}
465
465
466
- public typealias Indices = CountableRange < Int >
466
+ internal typealias Indices = CountableRange < Int >
467
467
468
468
//===--- private --------------------------------------------------------===//
469
- typealias Storage = _ContiguousArrayStorage < Element >
470
- public typealias NativeBuffer = _ContiguousArrayBuffer < Element >
469
+ internal typealias Storage = _ContiguousArrayStorage < Element >
470
+ internal typealias NativeBuffer = _ContiguousArrayBuffer < Element >
471
471
472
472
@_versioned
473
- var _isNative : Bool {
473
+ internal var _isNative : Bool {
474
474
if !_isClassOrObjCExistential( Element . self) {
475
475
return true
476
476
} else {
@@ -479,7 +479,7 @@ extension _ArrayBuffer {
479
479
}
480
480
481
481
/// `true`, if the array is native and does not need a deferred type check.
482
- var _isNativeTypeChecked : Bool {
482
+ internal var _isNativeTypeChecked : Bool {
483
483
if !_isClassOrObjCExistential( Element . self) {
484
484
return true
485
485
} else {
@@ -491,7 +491,7 @@ extension _ArrayBuffer {
491
491
///
492
492
/// - Precondition: `_isNative`.
493
493
@_versioned
494
- var _native : NativeBuffer {
494
+ internal var _native : NativeBuffer {
495
495
return NativeBuffer (
496
496
_isClassOrObjCExistential ( Element . self)
497
497
? _storage. nativeInstance : _storage. nativeInstance_noSpareBits)
@@ -501,12 +501,12 @@ extension _ArrayBuffer {
501
501
///
502
502
/// - Precondition: `_isNativeTypeChecked`.
503
503
@_versioned
504
- var _nativeTypeChecked : NativeBuffer {
504
+ internal var _nativeTypeChecked : NativeBuffer {
505
505
return NativeBuffer ( _storage. nativeInstance_noSpareBits)
506
506
}
507
507
508
508
@_versioned
509
- var _nonNative : _NSArrayCore {
509
+ internal var _nonNative : _NSArrayCore {
510
510
@inline ( __always)
511
511
get {
512
512
_sanityCheck ( _isClassOrObjCExistential ( Element . self) )
0 commit comments