mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use config directives to carve out a 'portable' kernel stdlib.
Swift SVN r23202
This commit is contained in:
@@ -266,6 +266,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
/// Compare two strings using the Unicode collation algorithm in the
|
||||
/// deterministic comparison mode. (The strings which are equivalent according
|
||||
/// to their NFD form are considered equal. Strings which are equivalent
|
||||
@@ -284,23 +285,36 @@ extension String {
|
||||
public func _stdlib_compareNSStringDeterministicUnicodeCollation(
|
||||
lhs: AnyObject, rhs: AnyObject
|
||||
)-> Int32
|
||||
#endif
|
||||
|
||||
extension String: Equatable {
|
||||
}
|
||||
|
||||
public func ==(lhs: String, rhs: String) -> Bool {
|
||||
#if _runtime(_ObjC)
|
||||
// Note: this operation should be consistent with equality comparison of
|
||||
// Character.
|
||||
return _stdlib_compareNSStringDeterministicUnicodeCollation(
|
||||
lhs._bridgeToObjectiveCImpl(), rhs._bridgeToObjectiveCImpl()) == 0
|
||||
#else
|
||||
// FIXME: Actually implement. For now, all strings are unequal.
|
||||
// rdar://problem/18878343
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
|
||||
extension String : Comparable {
|
||||
}
|
||||
|
||||
public func <(lhs: String, rhs: String) -> Bool {
|
||||
#if _runtime(_ObjC)
|
||||
return _stdlib_compareNSStringDeterministicUnicodeCollation(
|
||||
lhs._bridgeToObjectiveCImpl(), rhs._bridgeToObjectiveCImpl()) < 0
|
||||
#else
|
||||
// FIXME: Actually implement. For now, all strings are unequal
|
||||
// rdar://problem/18878343
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
|
||||
// Support for copy-on-write
|
||||
@@ -327,8 +341,10 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
@asmname("swift_stdlib_NSStringNFDHashValue")
|
||||
func _stdlib_NSStringNFDHashValue(str: AnyObject) -> Int
|
||||
#endif
|
||||
|
||||
extension String : Hashable {
|
||||
/// The hash value.
|
||||
@@ -346,11 +362,17 @@ extension String : Hashable {
|
||||
#else
|
||||
let hashOffset = 0x429b126688ddcc21
|
||||
#endif
|
||||
#if _runtime(_ObjC)
|
||||
// FIXME(performance): constructing a temporary NSString is extremely
|
||||
// wasteful and inefficient.
|
||||
let cocoaString =
|
||||
unsafeBitCast(self._bridgeToObjectiveCImpl(), _NSStringCoreType.self)
|
||||
return hashOffset ^ _stdlib_NSStringNFDHashValue(cocoaString)
|
||||
#else
|
||||
// FIXME: Actually implement. For now, all strings have the same hash.
|
||||
// rdar://problem/18878343
|
||||
return hashOffset
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,10 +414,6 @@ public func += (inout lhs: String, rhs: String) {
|
||||
}
|
||||
}
|
||||
|
||||
// Comparison operators
|
||||
extension String : Comparable {
|
||||
}
|
||||
|
||||
extension String {
|
||||
/// Low-level construction interface used by introspection
|
||||
/// implementation in the runtime library. Constructs a String in
|
||||
|
||||
Reference in New Issue
Block a user