Runtime: Handle bridging from ObjC objects to Any or boxed types.

This commit is contained in:
Joe Groff
2016-07-24 09:01:14 -07:00
parent 32b50c624d
commit b1fb1fa3ea
2 changed files with 101 additions and 23 deletions

View File

@@ -246,6 +246,27 @@ func _bridgeNonVerbatimFromObjectiveC<T>(
_ result: inout T?
)
/// Helper stub to upcast to Any and store the result to an inout Any?
/// on the C++ runtime's behalf.
// COMPILER_INTRINSIC
@_silgen_name("_swift_bridgeNonVerbatimFromObjectiveCToAny")
public func _bridgeNonVerbatimFromObjectiveCToAny(
_ x: AnyObject,
_ result: inout Any?
) {
result = x as Any
}
/// Helper stub to upcast to Optional on the C++ runtime's behalf.
// COMPILER_INTRINSIC
@_silgen_name("_swift_bridgeNonVerbatimBoxedValue")
public func _bridgeNonVerbatimBoxedValue<NativeType>(
_ x: UnsafePointer<NativeType>,
_ result: inout NativeType?
) {
result = x.pointee
}
/// Runtime optional to conditionally perform a bridge from an object to a value
/// type.
///