Skip to content

Commit ba14406

Browse files
authored
Merge pull request #1572 from millenomi/LinuxAsBridging-4.2
[4.2] Adopt ‘as’ bridging on Linux
2 parents caca409 + 7eb2e6f commit ba14406

33 files changed

+151
-137
lines changed

Foundation/AffineTransform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ open class NSAffineTransform : NSObject, NSCopying, NSSecureCoding {
476476
}
477477
}
478478

479-
extension AffineTransform : _ObjectTypeBridgeable {
479+
extension AffineTransform : _ObjectiveCBridgeable {
480480
public static func _isBridgedToObjectiveC() -> Bool {
481481
return true
482482
}

Foundation/Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
extension Array : _ObjectTypeBridgeable {
10+
extension Array : _ObjectiveCBridgeable {
1111

1212
public typealias _ObjectType = NSArray
1313
public func _bridgeToObjectiveC() -> _ObjectType {

Foundation/Bridging.swift

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,10 @@
1212

1313
import CoreFoundation
1414

15-
// Support protocols for casting
16-
public protocol _ObjectBridgeable {
17-
func _bridgeToAnyObject() -> AnyObject
18-
}
19-
2015
public protocol _StructBridgeable {
2116
func _bridgeToAny() -> Any
2217
}
2318

24-
/// - Note: This is a similar interface to the _ObjectiveCBridgeable protocol
25-
public protocol _ObjectTypeBridgeable : _ObjectBridgeable {
26-
associatedtype _ObjectType : AnyObject
27-
28-
func _bridgeToObjectiveC() -> _ObjectType
29-
30-
static func _forceBridgeFromObjectiveC(_ source: _ObjectType, result: inout Self?)
31-
32-
@discardableResult
33-
static func _conditionallyBridgeFromObjectiveC(_ source: _ObjectType, result: inout Self?) -> Bool
34-
35-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectType?) -> Self
36-
}
37-
3819
/// - Note: This does not exist currently on Darwin but it is the inverse correlation to the bridge types such that a
3920
/// reference type can be converted via a callout to a conversion method.
4021
public protocol _StructTypeBridgeable : _StructBridgeable {
@@ -44,7 +25,7 @@ public protocol _StructTypeBridgeable : _StructBridgeable {
4425
}
4526

4627
// Default adoption of the type specific variants to the Any variant
47-
extension _ObjectTypeBridgeable {
28+
extension _ObjectiveCBridgeable {
4829
public func _bridgeToAnyObject() -> AnyObject {
4930
return _bridgeToObjectiveC()
5031
}
@@ -74,8 +55,8 @@ internal protocol _NSBridgeable {
7455

7556

7657
/// - Note: This is an internal boxing value for containing abstract structures
77-
internal final class _SwiftValue : NSObject, NSCopying {
78-
internal private(set) var value: Any
58+
internal final class _SwiftValue : NSObject, NSCopying, _NSSwiftValue {
59+
public private(set) var value: Any
7960

8061
static func fetch(_ object: AnyObject?) -> Any? {
8162
if let obj = object {
@@ -108,10 +89,8 @@ internal final class _SwiftValue : NSObject, NSCopying {
10889
static func store(_ value: Any) -> NSObject {
10990
if let val = value as? NSObject {
11091
return val
111-
} else if let val = value as? _ObjectBridgeable {
112-
return val._bridgeToAnyObject() as! NSObject
11392
} else {
114-
return _SwiftValue(value)
93+
return (value as AnyObject) as! NSObject
11594
}
11695
}
11796

@@ -144,4 +123,6 @@ internal final class _SwiftValue : NSObject, NSCopying {
144123
public func copy(with zone: NSZone?) -> Any {
145124
return _SwiftValue(value)
146125
}
126+
127+
public static let null: AnyObject = NSNull()
147128
}

Foundation/Calendar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ extension Calendar : CustomDebugStringConvertible, CustomStringConvertible, Cust
11631163
}
11641164
}
11651165

1166-
extension Calendar: _ObjectTypeBridgeable {
1166+
extension Calendar: _ObjectiveCBridgeable {
11671167
public typealias _ObjectType = NSCalendar
11681168

11691169
@_semantics("convertToObjectiveC")

Foundation/CharacterSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
481481

482482

483483
// MARK: Objective-C Bridging
484-
extension CharacterSet : _ObjectTypeBridgeable {
484+
extension CharacterSet : _ObjectiveCBridgeable {
485485
public static func _isBridgedToObjectiveC() -> Bool {
486486
return true
487487
}

Foundation/Data.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,13 +1893,7 @@ extension Data {
18931893

18941894
/// Provides bridging functionality for struct Data to class NSData and vice-versa.
18951895

1896-
#if DEPLOYMENT_RUNTIME_SWIFT
1897-
internal typealias DataBridgeType = _ObjectTypeBridgeable
1898-
#else
1899-
internal typealias DataBridgeType = _ObjectiveCBridgeable
1900-
#endif
1901-
1902-
extension Data : DataBridgeType {
1896+
extension Data : _ObjectiveCBridgeable {
19031897
@_semantics("convertToObjectiveC")
19041898
public func _bridgeToObjectiveC() -> NSData {
19051899
return _backing.bridgedReference(_sliceRange)

Foundation/Date.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ extension Date : CustomDebugStringConvertible, CustomStringConvertible, CustomRe
230230
}
231231
}
232232

233-
extension Date : _ObjectTypeBridgeable {
233+
extension Date : _ObjectiveCBridgeable {
234234
@_semantics("convertToObjectiveC")
235235
public func _bridgeToObjectiveC() -> NSDate {
236236
return NSDate(timeIntervalSinceReferenceDate: _time)

Foundation/DateComponents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ extension DateComponents : CustomStringConvertible, CustomDebugStringConvertible
352352

353353
// MARK: - Bridging
354354

355-
extension DateComponents : _ObjectTypeBridgeable {
355+
extension DateComponents : _ObjectiveCBridgeable {
356356
public static func _isBridgedToObjectiveC() -> Bool {
357357
return true
358358
}

Foundation/DateInterval.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ extension DateInterval : CustomStringConvertible, CustomDebugStringConvertible,
187187
}
188188
}
189189

190-
extension DateInterval : _ObjectTypeBridgeable {
190+
extension DateInterval : _ObjectiveCBridgeable {
191191
public static func _isBridgedToObjectiveC() -> Bool {
192192
return true
193193
}

Foundation/Dictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import CoreFoundation
1111

12-
extension Dictionary : _ObjectTypeBridgeable {
12+
extension Dictionary : _ObjectiveCBridgeable {
1313

1414
public typealias _ObjectType = NSDictionary
1515
public func _bridgeToObjectiveC() -> _ObjectType {

0 commit comments

Comments
 (0)