mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
75 lines
1.5 KiB
Swift
75 lines
1.5 KiB
Swift
@exported import ObjectiveC // Clang module
|
|
|
|
// The iOS/arm64 target uses _Bool for Objective C's BOOL. We include
|
|
// x86_64 here as well because the iOS simulator also uses _Bool.
|
|
#if os(iOS) && (arch(arm64) || arch(x86_64))
|
|
public struct ObjCBool : BooleanType {
|
|
private var value : Bool
|
|
|
|
public init(_ value: Bool) {
|
|
self.value = value
|
|
}
|
|
|
|
/// \brief Allow use in a Boolean context.
|
|
public func getLogicValue() -> Bool {
|
|
return value
|
|
}
|
|
}
|
|
|
|
#else
|
|
|
|
public struct ObjCBool : BooleanType {
|
|
private var value : UInt8
|
|
|
|
public init(_ value: Bool) {
|
|
self.value = value ? 1 : 0
|
|
}
|
|
|
|
public init(_ value: UInt8) {
|
|
self.value = value
|
|
}
|
|
|
|
/// \brief Allow use in a Boolean context.
|
|
public func getLogicValue() -> Bool {
|
|
if value == 0 { return false }
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
public struct Selector : StringLiteralConvertible {
|
|
private var ptr : COpaquePointer
|
|
|
|
public static func convertFromExtendedGraphemeClusterLiteral(
|
|
value: String) -> Selector {
|
|
|
|
return convertFromStringLiteral(value)
|
|
}
|
|
|
|
public static func convertFromStringLiteral(value: String) -> Selector {
|
|
return sel_registerName(value)
|
|
}
|
|
}
|
|
|
|
internal func _convertBoolToObjCBool(x: Bool) -> ObjCBool {
|
|
return ObjCBool(x)
|
|
}
|
|
|
|
internal func _convertObjCBoolToBool(x: ObjCBool) -> Bool {
|
|
return Bool(x)
|
|
}
|
|
|
|
public func ~=(x: NSObject, y: NSObject) -> Bool {
|
|
return true
|
|
}
|
|
|
|
extension NSObject : Equatable, Hashable {
|
|
public var hashValue: Int {
|
|
return hash
|
|
}
|
|
}
|
|
|
|
public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
|
return lhs.isEqual(rhs)
|
|
}
|