Skip to content

Commit 90f3479

Browse files
committed
wip: internalize more
1 parent 164a7c3 commit 90f3479

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ public struct ${Self}<Element>
897897
}
898898
%end
899899

900+
@_versioned
900901
internal var _buffer: _Buffer
901902
}
902903

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
264264

265265
/// Call `body(p)`, where `p` is an `UnsafeBufferPointer` over the
266266
/// underlying contiguous storage.
267-
public func withUnsafeBufferPointer<R>(
267+
internal func withUnsafeBufferPointer<R>(
268268
_ body: @noescape (UnsafeBufferPointer<Element>) throws -> R
269269
) rethrows -> R {
270270
defer { _fixLifetime(self) }
@@ -274,7 +274,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
274274

275275
/// Call `body(p)`, where `p` is an `UnsafeMutableBufferPointer`
276276
/// over the underlying contiguous storage.
277-
public mutating func withUnsafeMutableBufferPointer<R>(
277+
internal mutating func withUnsafeMutableBufferPointer<R>(
278278
_ body: @noescape (UnsafeMutableBufferPointer<Element>) throws -> R
279279
) rethrows -> R {
280280
defer { _fixLifetime(self) }
@@ -284,7 +284,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
284284

285285
//===--- _ArrayBufferProtocol conformance -----------------------------------===//
286286
/// Create an empty buffer.
287-
public init() {
287+
internal init() {
288288
__bufferPointer = ManagedBufferPointer(
289289
_uncheckedUnsafeBufferObject: _emptyArrayStorage)
290290
}
@@ -294,7 +294,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
294294
self = buffer
295295
}
296296

297-
public mutating func requestUniqueMutableBackingBuffer(
297+
internal mutating func requestUniqueMutableBackingBuffer(
298298
minimumCapacity: Int
299299
) -> _ContiguousArrayBuffer<Element>? {
300300
if _fastPath(isUniquelyReferenced() && capacity >= minimumCapacity) {
@@ -303,29 +303,29 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
303303
return nil
304304
}
305305

306-
public mutating func isMutableAndUniquelyReferenced() -> Bool {
306+
internal mutating func isMutableAndUniquelyReferenced() -> Bool {
307307
return isUniquelyReferenced()
308308
}
309309

310-
public mutating func isMutableAndUniquelyReferencedOrPinned() -> Bool {
310+
internal mutating func isMutableAndUniquelyReferencedOrPinned() -> Bool {
311311
return isUniquelyReferencedOrPinned()
312312
}
313313

314314
/// If this buffer is backed by a `_ContiguousArrayBuffer`
315315
/// containing the same number of elements as `self`, return it.
316316
/// Otherwise, return `nil`.
317-
public func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
317+
internal func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
318318
return self
319319
}
320320

321321
@_versioned
322-
func getElement(_ i: Int) -> Element {
322+
internal func getElement(_ i: Int) -> Element {
323323
_sanityCheck(i >= 0 && i < count, "Array index out of range")
324324
return firstElementAddress[i]
325325
}
326326

327327
/// Get or set the value of the ith element.
328-
public subscript(i: Int) -> Element {
328+
internal subscript(i: Int) -> Element {
329329
get {
330330
return getElement(i)
331331
}
@@ -343,7 +343,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
343343
}
344344

345345
/// The number of elements the buffer stores.
346-
public var count: Int {
346+
internal var count: Int {
347347
get {
348348
return __bufferPointer.header.count
349349
}
@@ -369,15 +369,15 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
369369
}
370370

371371
/// The number of elements the buffer can store without reallocation.
372-
public var capacity: Int {
372+
internal var capacity: Int {
373373
return __bufferPointer.header.capacity
374374
}
375375

376376
/// Copy the elements in `bounds` from this buffer into uninitialized
377377
/// memory starting at `target`. Return a pointer "past the end" of the
378378
/// just-initialized memory.
379379
@discardableResult
380-
public func _copyContents(
380+
internal func _copyContents(
381381
subRange bounds: Range<Int>,
382382
initializing target: UnsafeMutablePointer<Element>
383383
) -> UnsafeMutablePointer<Element> {
@@ -526,19 +526,19 @@ extension _ContiguousArrayBuffer : RandomAccessCollection {
526526
/// The position of the first element in a non-empty collection.
527527
///
528528
/// In an empty collection, `startIndex == endIndex`.
529-
public var startIndex: Int {
529+
internal var startIndex: Int {
530530
return 0
531531
}
532532
/// The collection's "past the end" position.
533533
///
534534
/// `endIndex` is not a valid argument to `subscript`, and is always
535535
/// reachable from `startIndex` by zero or more applications of
536536
/// `index(after:)`.
537-
public var endIndex: Int {
537+
internal var endIndex: Int {
538538
return count
539539
}
540540

541-
public typealias Indices = CountableRange<Int>
541+
internal typealias Indices = CountableRange<Int>
542542
}
543543

544544
extension Sequence {
@@ -573,13 +573,13 @@ internal func _copySequenceToContiguousArray<
573573
}
574574

575575
extension Collection {
576-
public func _copyToContiguousArray() -> ContiguousArray<Iterator.Element> {
576+
internal func _copyToContiguousArray() -> ContiguousArray<Iterator.Element> {
577577
return _copyCollectionToContiguousArray(self)
578578
}
579579
}
580580

581581
extension _ContiguousArrayBuffer {
582-
public func _copyToContiguousArray() -> ContiguousArray<Element> {
582+
internal func _copyToContiguousArray() -> ContiguousArray<Element> {
583583
return ContiguousArray(_buffer: self)
584584
}
585585
}

0 commit comments

Comments
 (0)