Skip to content

Commit eeb780b

Browse files
committed
wip: internalize more
1 parent 257d720 commit eeb780b

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
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() {
@@ -225,7 +225,7 @@ extension _ArrayBuffer {
225225

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

stdlib/public/core/Arrays.swift.gyb

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

874874
%if Self == 'Array':
875875
#if _runtime(_ObjC)
876-
public typealias _Buffer = _ArrayBuffer<Element>
876+
internal typealias _Buffer = _ArrayBuffer<Element>
877877
#else
878-
public typealias _Buffer = _ContiguousArrayBuffer<Element>
878+
internal typealias _Buffer = _ContiguousArrayBuffer<Element>
879879
#endif
880880
%elif Self == 'ArraySlice':
881-
public typealias _Buffer = _SliceBuffer<Element>
881+
internal typealias _Buffer = _SliceBuffer<Element>
882882
%else:
883-
public typealias _Buffer = _${Self.strip('_')}Buffer<Element>
883+
internal typealias _Buffer = _${Self.strip('_')}Buffer<Element>
884884
%end
885885

886886
/// Initialization from an existing buffer does not have "array.init"
887887
/// semantics because the caller may retain an alias to buffer.
888-
public // @testable
889-
init(_buffer: _Buffer) {
888+
internal init(_buffer: _Buffer) {
890889
self._buffer = _buffer
891890
}
892891

893892
%if Self == 'ArraySlice':
894893
/// Initialization from an existing buffer does not have "array.init"
895894
/// semantics because the caller may retain an alias to buffer.
896-
public // @testable
897-
init(_buffer buffer: _ContiguousArrayBuffer<Element>) {
895+
internal init(_buffer buffer: _ContiguousArrayBuffer<Element>) {
898896
self.init(_buffer: _Buffer(_buffer: buffer, shiftedToStartIndex: 0))
899897
}
900898
%end
901899

902-
public var _buffer: _Buffer
900+
internal var _buffer: _Buffer
903901
}
904902

905903
extension ${Self} : ArrayLiteralConvertible {

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
396396

397397
/// Returns a `_SliceBuffer` containing the given `bounds` of values
398398
/// from this buffer.
399-
public subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
399+
internal subscript(bounds: Range<Int>) -> _SliceBuffer<Element> {
400400
get {
401401
return _SliceBuffer(
402402
owner: __bufferPointer.buffer,
@@ -414,14 +414,14 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
414414
/// - Note: This does not mean the buffer is mutable. Other factors
415415
/// may need to be considered, such as whether the buffer could be
416416
/// some immutable Cocoa container.
417-
public mutating func isUniquelyReferenced() -> Bool {
417+
internal mutating func isUniquelyReferenced() -> Bool {
418418
return __bufferPointer.holdsUniqueReference()
419419
}
420420

421421
/// Returns `true` iff this buffer's storage is either
422422
/// uniquely-referenced or pinned. NOTE: this does not mean
423423
/// the buffer is mutable; see the comment on isUniquelyReferenced.
424-
public mutating func isUniquelyReferencedOrPinned() -> Bool {
424+
internal mutating func isUniquelyReferencedOrPinned() -> Bool {
425425
return __bufferPointer.holdsUniqueOrPinnedReference()
426426
}
427427

@@ -431,7 +431,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
431431
/// - Precondition: `Element` is bridged to Objective-C.
432432
///
433433
/// - Complexity: O(1).
434-
public func _asCocoaArray() -> _NSArrayCore {
434+
internal func _asCocoaArray() -> _NSArrayCore {
435435
_sanityCheck(
436436
_isBridgedToObjectiveC(Element.self),
437437
"Array element type is not bridged to Objective-C")
@@ -444,20 +444,20 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
444444
#endif
445445

446446
/// An object that keeps the elements stored in this buffer alive.
447-
public var owner: AnyObject {
447+
internal var owner: AnyObject {
448448
return _storage
449449
}
450450

451451
/// An object that keeps the elements stored in this buffer alive.
452-
public var nativeOwner: AnyObject {
452+
internal var nativeOwner: AnyObject {
453453
return _storage
454454
}
455455

456456
/// A value that identifies the storage used by the buffer.
457457
///
458458
/// Two buffers address the same elements when they have the same
459459
/// identity and count.
460-
public var identity: UnsafePointer<Void> {
460+
internal var identity: UnsafePointer<Void> {
461461
return UnsafePointer(firstElementAddress)
462462
}
463463

@@ -499,7 +499,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
499499
}
500500

501501
/// Append the elements of `rhs` to `lhs`.
502-
public func += <Element, C : Collection>(
502+
internal func += <Element, C : Collection>(
503503
lhs: inout _ContiguousArrayBuffer<Element>, rhs: C
504504
) where C.Iterator.Element == Element {
505505

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: UnsafePointer<Void> {
116+
internal var identity: UnsafePointer<Void> {
115117
return UnsafePointer(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)