mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words
This commit is contained in:
@@ -19,16 +19,16 @@
|
||||
import SwiftShims
|
||||
|
||||
internal typealias _ArrayBridgeStorage
|
||||
= _BridgeStorage<_ContiguousArrayStorageBase, _NSArrayCoreType>
|
||||
= _BridgeStorage<_ContiguousArrayStorageBase, _NSArrayCore>
|
||||
|
||||
public struct _ArrayBuffer<Element> : _ArrayBufferType {
|
||||
public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
|
||||
|
||||
/// Create an empty buffer.
|
||||
public init() {
|
||||
_storage = _ArrayBridgeStorage(native: _emptyArrayStorage)
|
||||
}
|
||||
|
||||
public init(nsArray: _NSArrayCoreType) {
|
||||
public init(nsArray: _NSArrayCore) {
|
||||
_sanityCheck(_isClassOrObjCExistential(Element.self))
|
||||
_storage = _ArrayBridgeStorage(objC: nsArray)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ extension _ArrayBuffer {
|
||||
/// - Precondition: `_isBridgedToObjectiveC(Element.self)`.
|
||||
/// O(1) if the element type is bridged verbatim, O(N) otherwise.
|
||||
@warn_unused_result
|
||||
public func _asCocoaArray() -> _NSArrayCoreType {
|
||||
public func _asCocoaArray() -> _NSArrayCore {
|
||||
_sanityCheck(
|
||||
_isBridgedToObjectiveC(Element.self),
|
||||
"Array element type is not bridged to Objective-C")
|
||||
@@ -171,13 +171,13 @@ extension _ArrayBuffer {
|
||||
internal func _typeCheckSlowPath(index: Int) {
|
||||
if _fastPath(_isNative) {
|
||||
let element: AnyObject = castToBufferOf(AnyObject.self)._native[index]
|
||||
_precondition(
|
||||
_require(
|
||||
element is Element,
|
||||
"Down-casted Array element failed to match the target type")
|
||||
}
|
||||
else {
|
||||
let ns = _nonNative
|
||||
_precondition(
|
||||
_require(
|
||||
ns.objectAt(index) is Element,
|
||||
"NSArray element failed to match the Swift Array Element type")
|
||||
}
|
||||
@@ -224,8 +224,8 @@ extension _ArrayBuffer {
|
||||
// Make another pass to retain the copied objects
|
||||
var result = target
|
||||
for _ in bounds {
|
||||
result.initialize(result.memory)
|
||||
++result
|
||||
result.initializeMemory(result.pointee)
|
||||
result += 1
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -305,7 +305,7 @@ extension _ArrayBuffer {
|
||||
/// Because the optimizer can hoist the original check it might have
|
||||
/// been invalidated by illegal user code.
|
||||
internal func _checkInoutAndNativeBounds(index: Int, wasNative: Bool) {
|
||||
_precondition(
|
||||
_require(
|
||||
_isNative == wasNative,
|
||||
"inout rules were violated: the array was overwritten")
|
||||
|
||||
@@ -325,7 +325,7 @@ extension _ArrayBuffer {
|
||||
internal func _checkInoutAndNativeTypeCheckedBounds(
|
||||
index: Int, wasNativeTypeChecked: Bool
|
||||
) {
|
||||
_precondition(
|
||||
_require(
|
||||
_isNativeTypeChecked == wasNativeTypeChecked,
|
||||
"inout rules were violated: the array was overwritten")
|
||||
|
||||
@@ -362,13 +362,13 @@ extension _ArrayBuffer {
|
||||
_native._checkValidSubscript(i)
|
||||
|
||||
element = castToBufferOf(AnyObject.self)._native[i]
|
||||
_precondition(
|
||||
_require(
|
||||
element is Element,
|
||||
"Down-casted Array element failed to match the target type")
|
||||
} else {
|
||||
// ObjC arrays do their own subscript checking.
|
||||
element = _nonNative.objectAt(i)
|
||||
_precondition(
|
||||
_require(
|
||||
element is Element,
|
||||
"NSArray element failed to match the Swift Array Element type")
|
||||
}
|
||||
@@ -504,7 +504,7 @@ extension _ArrayBuffer {
|
||||
return NativeBuffer(_storage.nativeInstance_noSpareBits)
|
||||
}
|
||||
|
||||
var _nonNative: _NSArrayCoreType {
|
||||
var _nonNative: _NSArrayCore {
|
||||
@inline(__always)
|
||||
get {
|
||||
_sanityCheck(_isClassOrObjCExistential(Element.self))
|
||||
|
||||
Reference in New Issue
Block a user