mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: Use config directives to work without objective-c.
Swift SVN r23211
This commit is contained in:
@@ -286,7 +286,15 @@ public struct ${Self}<T> : MutableCollectionType, Sliceable {
|
||||
}
|
||||
|
||||
public
|
||||
%if Self == 'Array':
|
||||
#if _runtime(_ObjC)
|
||||
typealias _Buffer = _ArrayBuffer<T>
|
||||
#else
|
||||
typealias _Buffer = _ContiguousArrayBuffer<T>
|
||||
#endif
|
||||
%else:
|
||||
typealias _Buffer = _${Self.strip('_')}Buffer<T>
|
||||
%end
|
||||
|
||||
/// Initialization from an existing buffer does not have "array.init"
|
||||
/// semantics because the caller may retain an alias to buffer.
|
||||
@@ -1139,13 +1147,18 @@ public func !=<T: Equatable>(lhs: ${Self}<T>, rhs: ${Self}<T>) -> Bool {
|
||||
}
|
||||
%end
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
/// Returns an Array<Base> containing the same elements as a in
|
||||
/// O(1). Requires: Base is a base class or base @objc protocol (such
|
||||
/// as AnyObject) of Derived.
|
||||
/// FIXME: Dynamic casting is currently not possible without the objc runtime:
|
||||
/// rdar://problem/18801510
|
||||
public func _arrayUpCast<Derived, Base>(a: Array<Derived>) -> Array<Base> {
|
||||
return Array(a._buffer.castToBufferOf(Base.self))
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
extension Array {
|
||||
/// Try to downcast the source `NSArray` as our native buffer type.
|
||||
/// If it succeeds, create a new `Array` around it and return that.
|
||||
@@ -1181,7 +1194,7 @@ extension Array {
|
||||
self = Array(_ArrayBuffer(selectedSource))
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ${'Local Variables'}:
|
||||
// eval: (read-only-mode 1)
|
||||
|
||||
Reference in New Issue
Block a user