mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The SDK directory is now confusing as the Windows target also has a SDK overlay. In order to make this more uniform, move the SDK directory to Darwin which covers the fact that this covers the XNU family of OSes. The Windows directory contains the SDK overlay for the Windows target.
39 lines
1.4 KiB
Swift
39 lines
1.4 KiB
Swift
@_exported import CoreLocation
|
|
import Foundation
|
|
|
|
%{
|
|
from gyb_foundation_support import \
|
|
ObjectiveCBridgeableImplementationForNSValueWithCategoryMethods
|
|
}%
|
|
|
|
// Get the ObjC type used by -[NSValue valueWithMKCoordinate:]
|
|
// to instantiate the resulting NSValue objects, in case these get changed
|
|
// in the future. This is extra tricky because MapKit *might not be loaded*,
|
|
// in which case we need to fall back to the static @encode string.
|
|
private let CLLocationCoordinate2DInNSValueObjCType: UnsafePointer<CChar> = {
|
|
let factorySel = Selector(("valueWithMKCoordinate:"))
|
|
guard let opaqueFactoryMethod = NSValue.method(for: factorySel) else {
|
|
return _getObjCTypeEncoding(CLLocationCoordinate2D.self)
|
|
}
|
|
typealias FactoryMethodType =
|
|
@convention(c) (AnyClass, Selector, CLLocationCoordinate2D) -> NSValue
|
|
let factoryMethod =
|
|
unsafeBitCast(opaqueFactoryMethod, to: FactoryMethodType.self)
|
|
return factoryMethod(NSValue.self, factorySel, .init()).objCType
|
|
}()
|
|
|
|
${ ObjectiveCBridgeableImplementationForNSValueWithCategoryMethods(
|
|
Type="CLLocationCoordinate2D",
|
|
initializer="""{
|
|
var addressableValue = $0
|
|
return NSValue(bytes: &addressableValue,
|
|
objCType: CLLocationCoordinate2DInNSValueObjCType)
|
|
}""",
|
|
getter="""{
|
|
var result = CLLocationCoordinate2D()
|
|
$0.getValue(&result)
|
|
return result
|
|
}""",
|
|
objCType="{ _ in CLLocationCoordinate2DInNSValueObjCType }",
|
|
) }
|