Files
swift-mirror/test/Inputs/clang-importer-sdk/swift-modules-without-ns/ObjectiveC.swift
Doug Gregor e51e969b35 [Clang importer] Strip the "NS" prefix from entities in Foundation
As part of the improved import of Objective-C APIs into Swift, strip
the "NS" prefix from entities defined in the Foundation
framework. Addresses rdar://problem/24050011, which is part of
SE-0005. Naturally, this is hidden behind -enable-omit-needless-words.
2016-01-17 23:40:14 -08:00

92 lines
1.9 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) || os(tvOS)) && (arch(arm64) || arch(x86_64))) || os(watchOS)
public struct ObjCBool : BooleanType {
private var value : Bool
public init(_ value: Bool) {
self.value = value
}
/// \brief Allow use in a Boolean context.
public var boolValue: 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 var boolValue: Bool {
if value == 0 { return false }
return true
}
}
#endif
extension ObjCBool : BooleanLiteralConvertible {
public init(booleanLiteral: Bool) {
self.init(booleanLiteral)
}
}
public struct Selector : StringLiteralConvertible {
private var ptr : COpaquePointer
public init(unicodeScalarLiteral value: String) {
self.init(stringLiteral: value)
}
public init(extendedGraphemeClusterLiteral value: String) {
self.init(stringLiteral: value)
}
public init (stringLiteral value: String) {
self = sel_registerName(value)
}
}
public struct Zone: NilLiteralConvertible {
public var pointer : COpaquePointer
@_transparent public
init(nilLiteral: ()) {
pointer = COpaquePointer()
}
}
internal func _convertBoolToObjCBool(x: Bool) -> ObjCBool {
return ObjCBool(x)
}
internal func _convertObjCBoolToBool(x: ObjCBool) -> Bool {
return Bool(x)
}
public func ~=(x: Object, y: Object) -> Bool {
return true
}
extension Object : Equatable, Hashable {
public var hashValue: Int {
return hash
}
}
public func == (lhs: Object, rhs: Object) -> Bool {
return lhs.isEqual(rhs)
}