mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
One minor revision: this lifts the proposed restriction against overriding a non-open method with an open one. On reflection, that was inconsistent with the existing rule permitting non-public methods to be overridden with public ones. The restriction on subclassing a non-open class with an open class remains, and is in fact consistent with the existing access rule.
54 lines
1.2 KiB
Swift
54 lines
1.2 KiB
Swift
// This is an overlay Swift module.
|
|
@_exported import ObjectiveC
|
|
|
|
public struct ObjCBool : CustomStringConvertible {
|
|
#if os(OSX) || (os(iOS) && (arch(i386) || arch(arm)))
|
|
// On OS X and 32-bit iOS, Objective-C's BOOL type is a "signed char".
|
|
private var value: Int8
|
|
|
|
public init(_ value: Bool) {
|
|
self.value = value ? 1 : 0
|
|
}
|
|
|
|
/// \brief Allow use in a Boolean context.
|
|
public var boolValue: Bool {
|
|
return value != 0
|
|
}
|
|
#else
|
|
// Everywhere else it is C/C++'s "Bool"
|
|
private var value: Bool
|
|
|
|
public init(_ value: Bool) {
|
|
self.value = value
|
|
}
|
|
|
|
public var boolValue: Bool {
|
|
return value
|
|
}
|
|
#endif
|
|
|
|
public var description: String {
|
|
// Dispatch to Bool.
|
|
return self.boolValue.description
|
|
}
|
|
}
|
|
|
|
public struct Selector {
|
|
private var ptr : OpaquePointer
|
|
}
|
|
|
|
// Functions used to implicitly bridge ObjCBool types to Swift's Bool type.
|
|
|
|
public func _convertBoolToObjCBool(_ x: Bool) -> ObjCBool {
|
|
return ObjCBool(x)
|
|
}
|
|
public func _convertObjCBoolToBool(_ x: ObjCBool) -> Bool {
|
|
return x.boolValue
|
|
}
|
|
|
|
extension NSObject : Hashable {
|
|
open var hashValue: Int { return 0 }
|
|
}
|
|
public func ==(x: NSObject, y: NSObject) -> Bool { return x === y }
|
|
|