Skip to content

Commit 3c741ba

Browse files
committed
stdlib: mark _ArrayBuffer, _ContiguousArrayBuffer, and _SliceBuffer internal
1 parent 2708afe commit 3c741ba

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

stdlib/public/core/ArrayBuffer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal typealias _ArrayBridgeStorage
2222
= _BridgeStorage<_ContiguousArrayStorageBase, _NSArrayCore>
2323

2424
@_fixed_layout
25-
public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
25+
internal struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
2626

2727
/// Create an empty buffer.
2828
public init() {
@@ -221,7 +221,7 @@ extension _ArrayBuffer {
221221

222222
/// Returns a `_SliceBuffer` containing the given sub-range of elements in
223223
/// `bounds` from this buffer.
224-
public subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
224+
internal subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
225225
get {
226226
_typeCheck(bounds)
227227

stdlib/public/core/Arrays.swift.gyb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,33 +865,31 @@ public struct ${Self}<Element>
865865

866866
%if Self == 'Array':
867867
#if _runtime(_ObjC)
868-
public typealias _Buffer = _ArrayBuffer<Element>
868+
internal typealias _Buffer = _ArrayBuffer<Element>
869869
#else
870-
public typealias _Buffer = _ContiguousArrayBuffer<Element>
870+
internal typealias _Buffer = _ContiguousArrayBuffer<Element>
871871
#endif
872872
%elif Self == 'ArraySlice':
873-
public typealias _Buffer = _SliceBuffer<Element>
873+
internal typealias _Buffer = _SliceBuffer<Element>
874874
%else:
875-
public typealias _Buffer = _${Self.strip('_')}Buffer<Element>
875+
internal typealias _Buffer = _${Self.strip('_')}Buffer<Element>
876876
%end
877877

878878
/// Initialization from an existing buffer does not have "array.init"
879879
/// semantics because the caller may retain an alias to buffer.
880-
public // @testable
881-
init(_buffer: _Buffer) {
880+
internal init(_buffer: _Buffer) {
882881
self._buffer = _buffer
883882
}
884883

885884
%if Self == 'ArraySlice':
886885
/// Initialization from an existing buffer does not have "array.init"
887886
/// semantics because the caller may retain an alias to buffer.
888-
public // @testable
889-
init(_buffer buffer: _ContiguousArrayBuffer<Element>) {
887+
internal init(_buffer buffer: _ContiguousArrayBuffer<Element>) {
890888
self.init(_buffer: _Buffer(_buffer: buffer, shiftedToStartIndex: 0))
891889
}
892890
%end
893891

894-
public var _buffer: _Buffer
892+
internal var _buffer: _Buffer
895893
}
896894

897895
extension ${Self} : ExpressibleByArrayLiteral {

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
184184
}
185185

186186
@_fixed_layout
187-
public // @testable
188-
struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
187+
internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
189188

190189
/// Make a buffer with uninitialized elements. After using this
191190
/// method, you must either initialize the `count` elements at the
@@ -396,7 +395,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
396395

397396
/// Returns a `_SliceBuffer` containing the given `bounds` of values
398397
/// from this buffer.
399-
public subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
398+
internal subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
400399
get {
401400
return _SliceBuffer(
402401
owner: __bufferPointer.buffer,
@@ -414,14 +413,14 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
414413
/// - Note: This does not mean the buffer is mutable. Other factors
415414
/// may need to be considered, such as whether the buffer could be
416415
/// some immutable Cocoa container.
417-
public mutating func isUniquelyReferenced() -> Bool {
416+
internal mutating func isUniquelyReferenced() -> Bool {
418417
return __bufferPointer.isUniqueReference()
419418
}
420419

421420
/// Returns `true` iff this buffer's storage is either
422421
/// uniquely-referenced or pinned. NOTE: this does not mean
423422
/// the buffer is mutable; see the comment on isUniquelyReferenced.
424-
public mutating func isUniquelyReferencedOrPinned() -> Bool {
423+
internal mutating func isUniquelyReferencedOrPinned() -> Bool {
425424
return __bufferPointer._isUniqueOrPinnedReference()
426425
}
427426

@@ -431,7 +430,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
431430
/// - Precondition: `Element` is bridged to Objective-C.
432431
///
433432
/// - Complexity: O(1).
434-
public func _asCocoaArray() -> _NSArrayCore {
433+
internal func _asCocoaArray() -> _NSArrayCore {
435434
if count == 0 {
436435
return _emptyArrayStorage
437436
}
@@ -443,20 +442,20 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
443442
#endif
444443

445444
/// An object that keeps the elements stored in this buffer alive.
446-
public var owner: AnyObject {
445+
internal var owner: AnyObject {
447446
return _storage
448447
}
449448

450449
/// An object that keeps the elements stored in this buffer alive.
451-
public var nativeOwner: AnyObject {
450+
internal var nativeOwner: AnyObject {
452451
return _storage
453452
}
454453

455454
/// A value that identifies the storage used by the buffer.
456455
///
457456
/// Two buffers address the same elements when they have the same
458457
/// identity and count.
459-
public var identity: UnsafeRawPointer {
458+
internal var identity: UnsafeRawPointer {
460459
return UnsafeRawPointer(firstElementAddress)
461460
}
462461

@@ -498,7 +497,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
498497
}
499498

500499
/// Append the elements of `rhs` to `lhs`.
501-
public func += <Element, C : Collection>(
500+
internal func += <Element, C : Collection>(
502501
lhs: inout _ContiguousArrayBuffer<Element>, rhs: C
503502
) where C.Iterator.Element == Element {
504503

stdlib/public/core/SliceBuffer.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// Buffer type for `ArraySlice<Element>`.
14-
public // @testable
15-
struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
14+
internal struct _SliceBuffer<Element>
15+
: _ArrayBufferProtocol,
16+
RandomAccessCollection
17+
{
1618
internal typealias NativeStorage = _ContiguousArrayStorage<Element>
1719
internal typealias NativeBuffer = _ContiguousArrayBuffer<Element>
1820

@@ -111,7 +113,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
111113
/// A value that identifies the storage used by the buffer. Two
112114
/// buffers address the same elements when they have the same
113115
/// identity and count.
114-
public var identity: UnsafeRawPointer {
116+
internal var identity: UnsafeRawPointer {
115117
return UnsafeRawPointer(firstElementAddress)
116118
}
117119

@@ -199,7 +201,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
199201
return _hasNativeBuffer
200202
}
201203

202-
public var count: Int {
204+
internal var count: Int {
203205
get {
204206
return endIndex - startIndex
205207
}
@@ -252,7 +254,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
252254
///
253255
/// - Precondition: `position` is a valid position in `self` and
254256
/// `position != endIndex`.
255-
public subscript(position: Int) -> Element {
257+
internal subscript(position: Int) -> Element {
256258
get {
257259
return getElement(position)
258260
}
@@ -263,7 +265,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
263265
}
264266
}
265267

266-
public subscript(bounds: Range<Int>) -> _SliceBuffer {
268+
internal subscript(bounds: Range<Int>) -> _SliceBuffer {
267269
get {
268270
_sanityCheck(bounds.lowerBound >= startIndex)
269271
_sanityCheck(bounds.upperBound >= bounds.lowerBound)
@@ -283,14 +285,14 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
283285
/// The position of the first element in a non-empty collection.
284286
///
285287
/// In an empty collection, `startIndex == endIndex`.
286-
public var startIndex: Int
288+
internal var startIndex: Int
287289

288290
/// The collection's "past the end" position---that is, the position one
289291
/// greater than the last valid subscript argument.
290292
///
291293
/// `endIndex` is always reachable from `startIndex` by zero or more
292294
/// applications of `index(after:)`.
293-
public var endIndex: Int {
295+
internal var endIndex: Int {
294296
get {
295297
return Int(endIndexAndFlags >> 1)
296298
}
@@ -299,7 +301,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
299301
}
300302
}
301303

302-
public typealias Indices = CountableRange<Int>
304+
internal typealias Indices = CountableRange<Int>
303305

304306
//===--- misc -----------------------------------------------------------===//
305307
/// Call `body(p)`, where `p` is an `UnsafeBufferPointer` over the
@@ -324,7 +326,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
324326
}
325327

326328
extension _SliceBuffer {
327-
public func _copyToContiguousArray() -> ContiguousArray<Element> {
329+
internal func _copyToContiguousArray() -> ContiguousArray<Element> {
328330
if _hasNativeBuffer {
329331
let n = nativeBuffer
330332
if count == n.count {

0 commit comments

Comments
 (0)