@@ -46,7 +46,7 @@ internal 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 @@ internal 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
}
@@ -89,12 +89,12 @@ extension _ArrayBuffer {
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
}
@@ -114,7 +114,7 @@ extension _ArrayBuffer {
114
114
///
115
115
/// - Precondition: `_isBridgedToObjectiveC(Element.self)`.
116
116
/// O(1) if the element type is bridged verbatim, O(N) otherwise.
117
- public func _asCocoaArray( ) -> _NSArrayCore {
117
+ internal func _asCocoaArray( ) -> _NSArrayCore {
118
118
_sanityCheck (
119
119
_isBridgedToObjectiveC ( Element . self) ,
120
120
" Array element type is not bridged to Objective-C " )
@@ -175,7 +175,7 @@ extension _ArrayBuffer {
175
175
}
176
176
}
177
177
178
- func _typeCheck( _ subRange: Range < Int > ) {
178
+ internal func _typeCheck( _ subRange: Range < Int > ) {
179
179
if !_isClassOrObjCExistential( Element . self) {
180
180
return
181
181
}
@@ -194,7 +194,7 @@ extension _ArrayBuffer {
194
194
/// memory starting at `target`. Return a pointer "past the end" of the
195
195
/// just-initialized memory.
196
196
@discardableResult
197
- public func _copyContents(
197
+ internal func _copyContents(
198
198
subRange bounds: Range < Int > ,
199
199
initializing target: UnsafeMutablePointer < Element >
200
200
) -> UnsafeMutablePointer < Element > {
@@ -274,17 +274,17 @@ extension _ArrayBuffer {
274
274
/// A pointer to the first element.
275
275
///
276
276
/// - Precondition: The elements are known to be stored contiguously.
277
- public var firstElementAddress : UnsafeMutablePointer < Element > {
277
+ internal var firstElementAddress : UnsafeMutablePointer < Element > {
278
278
_sanityCheck ( _isNative, " must be a native buffer " )
279
279
return _native. firstElementAddress
280
280
}
281
281
282
- public var firstElementAddressIfContiguous : UnsafeMutablePointer < Element > ? {
282
+ internal var firstElementAddressIfContiguous : UnsafeMutablePointer < Element > ? {
283
283
return _fastPath ( _isNative) ? firstElementAddress : nil
284
284
}
285
285
286
286
/// The number of elements the buffer stores.
287
- public var count : Int {
287
+ internal var count : Int {
288
288
@inline ( __always)
289
289
get {
290
290
return _fastPath ( _isNative) ? _native. count : _nonNative. count
@@ -332,13 +332,13 @@ extension _ArrayBuffer {
332
332
}
333
333
334
334
/// The number of elements the buffer can store without reallocation.
335
- public var capacity : Int {
335
+ internal var capacity : Int {
336
336
return _fastPath ( _isNative) ? _native. capacity : _nonNative. count
337
337
}
338
338
339
339
@_versioned
340
340
@inline ( __always)
341
- func getElement( _ i: Int , wasNativeTypeChecked: Bool ) -> Element {
341
+ internal func getElement( _ i: Int , wasNativeTypeChecked: Bool ) -> Element {
342
342
if _fastPath ( wasNativeTypeChecked) {
343
343
return _nativeTypeChecked [ i]
344
344
}
@@ -347,7 +347,7 @@ extension _ArrayBuffer {
347
347
348
348
@_versioned
349
349
@inline ( never)
350
- func _getElementSlowPath( _ i: Int ) -> AnyObject {
350
+ internal func _getElementSlowPath( _ i: Int ) -> AnyObject {
351
351
_sanityCheck (
352
352
_isClassOrObjCExistential ( Element . self) ,
353
353
" Only single reference elements can be indexed here. " )
@@ -373,7 +373,7 @@ extension _ArrayBuffer {
373
373
}
374
374
375
375
/// Get or set the value of the ith element.
376
- public subscript( i: Int ) -> Element {
376
+ internal subscript( i: Int ) -> Element {
377
377
get {
378
378
return getElement ( i, wasNativeTypeChecked: _isNativeTypeChecked)
379
379
}
@@ -395,7 +395,7 @@ extension _ArrayBuffer {
395
395
/// Call `body(p)`, where `p` is an `UnsafeBufferPointer` over the
396
396
/// underlying contiguous storage. If no such storage exists, it is
397
397
/// created on-demand.
398
- public func withUnsafeBufferPointer< R> (
398
+ internal func withUnsafeBufferPointer< R> (
399
399
_ body: @noescape ( UnsafeBufferPointer < Element > ) throws -> R
400
400
) rethrows -> R {
401
401
if _fastPath ( _isNative) {
@@ -410,7 +410,7 @@ extension _ArrayBuffer {
410
410
/// over the underlying contiguous storage.
411
411
///
412
412
/// - Precondition: Such contiguous storage exists or the buffer is empty.
413
- public mutating func withUnsafeMutableBufferPointer< R> (
413
+ internal mutating func withUnsafeMutableBufferPointer< R> (
414
414
_ body: @noescape ( UnsafeMutableBufferPointer < Element > ) throws -> R
415
415
) rethrows -> R {
416
416
_sanityCheck (
@@ -423,22 +423,22 @@ extension _ArrayBuffer {
423
423
}
424
424
425
425
/// An object that keeps the elements stored in this buffer alive.
426
- public var owner : AnyObject {
426
+ internal var owner : AnyObject {
427
427
return _fastPath ( _isNative) ? _native. _storage : _nonNative
428
428
}
429
429
430
430
/// An object that keeps the elements stored in this buffer alive.
431
431
///
432
432
/// - Precondition: This buffer is backed by a `_ContiguousArrayBuffer`.
433
- public var nativeOwner : AnyObject {
433
+ internal var nativeOwner : AnyObject {
434
434
_sanityCheck ( _isNative, " Expect a native array " )
435
435
return _native. _storage
436
436
}
437
437
438
438
/// A value that identifies the storage used by the buffer. Two
439
439
/// buffers address the same elements when they have the same
440
440
/// identity and count.
441
- public var identity : UnsafePointer < Void > {
441
+ internal var identity : UnsafePointer < Void > {
442
442
if _isNative {
443
443
return _native. identity
444
444
}
@@ -451,7 +451,7 @@ extension _ArrayBuffer {
451
451
/// The position of the first element in a non-empty collection.
452
452
///
453
453
/// In an empty collection, `startIndex == endIndex`.
454
- public var startIndex : Int {
454
+ internal var startIndex : Int {
455
455
return 0
456
456
}
457
457
@@ -460,18 +460,18 @@ extension _ArrayBuffer {
460
460
/// `endIndex` is not a valid argument to `subscript`, and is always
461
461
/// reachable from `startIndex` by zero or more applications of
462
462
/// `index(after:)`.
463
- public var endIndex : Int {
463
+ internal var endIndex : Int {
464
464
return count
465
465
}
466
466
467
- public typealias Indices = CountableRange < Int >
467
+ internal typealias Indices = CountableRange < Int >
468
468
469
469
//===--- private --------------------------------------------------------===//
470
470
internal typealias Storage = _ContiguousArrayStorage < Element >
471
471
internal typealias NativeBuffer = _ContiguousArrayBuffer < Element >
472
472
473
473
@_versioned
474
- var _isNative : Bool {
474
+ internal var _isNative : Bool {
475
475
if !_isClassOrObjCExistential( Element . self) {
476
476
return true
477
477
} else {
@@ -480,7 +480,7 @@ extension _ArrayBuffer {
480
480
}
481
481
482
482
/// `true`, if the array is native and does not need a deferred type check.
483
- var _isNativeTypeChecked : Bool {
483
+ internal var _isNativeTypeChecked : Bool {
484
484
if !_isClassOrObjCExistential( Element . self) {
485
485
return true
486
486
} else {
@@ -492,7 +492,7 @@ extension _ArrayBuffer {
492
492
///
493
493
/// - Precondition: `_isNative`.
494
494
@_versioned
495
- var _native : NativeBuffer {
495
+ internal var _native : NativeBuffer {
496
496
return NativeBuffer (
497
497
_isClassOrObjCExistential ( Element . self)
498
498
? _storage. nativeInstance : _storage. nativeInstance_noSpareBits)
@@ -502,12 +502,12 @@ extension _ArrayBuffer {
502
502
///
503
503
/// - Precondition: `_isNativeTypeChecked`.
504
504
@_versioned
505
- var _nativeTypeChecked : NativeBuffer {
505
+ internal var _nativeTypeChecked : NativeBuffer {
506
506
return NativeBuffer ( _storage. nativeInstance_noSpareBits)
507
507
}
508
508
509
509
@_versioned
510
- var _nonNative : _NSArrayCore {
510
+ internal var _nonNative : _NSArrayCore {
511
511
@inline ( __always)
512
512
get {
513
513
_sanityCheck ( _isClassOrObjCExistential ( Element . self) )
0 commit comments