mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rework the _ObjectiveCBridgeable to use inout parameters rather than returns.
The _forceBridgeFromObjectiveC and _conditionallyBridgeFromObjectiveC requirements of the _ObjectiveCBridgeable protocol previously returned Self and Self?, respectively, where 'Self' is the value type that is bridged. This use of returns is fairly hostile to the idea of calling the witnesses for these requirements from the C++ part of the runtime, leading to "interesting" tricks with OpaqueExistentialContainer that made it hard to use these witnesses within the dynamic casting infrastructure. Replace the returns with inout Self? parameters, which are far easier to deal with in the C++ part of the runtime. Despite the churn because we're changing the _ObjectiveCBridgeable protocol, this is NFC. Swift SVN r20934
This commit is contained in:
@@ -23,13 +23,18 @@ extension NSRange : _ObjectiveCBridgeable {
|
||||
return NSValue(range: self)
|
||||
}
|
||||
|
||||
public static func _forceBridgeFromObjectiveC(x: NSValue) -> NSRange {
|
||||
return x.rangeValue
|
||||
public static func _forceBridgeFromObjectiveC(
|
||||
x: NSValue,
|
||||
inout result: NSRange?
|
||||
) {
|
||||
result = x.rangeValue
|
||||
}
|
||||
|
||||
public static func _conditionallyBridgeFromObjectiveC(
|
||||
x: NSValue
|
||||
) -> NSRange? {
|
||||
return self._forceBridgeFromObjectiveC(x)
|
||||
x: NSValue,
|
||||
inout result: NSRange?
|
||||
) -> Bool {
|
||||
self._forceBridgeFromObjectiveC(x, result: &result)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user