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:
Doug Gregor
2014-08-02 01:03:41 +00:00
parent 811d0021ab
commit c593d49b08
20 changed files with 484 additions and 236 deletions

View File

@@ -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
}
}