Skip to content

Commit f2a3cb1

Browse files
Merge pull request swiftlang#508 from michael-lehew/master
Swift 3: Value Types and Naming
2 parents 0a2b78d + f3143d7 commit f2a3cb1

8 files changed

+448
-325
lines changed

Diff for: Foundation/CharacterSet.swift

+36-35
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,19 @@ internal final class _SwiftNSCharacterSet : NSCharacterSet, _SwiftNativeFoundati
5454
releaseWrappedObject()
5555
}
5656

57-
// These for some reason cause a crash in the compiler
58-
// Stubs
59-
// -----
60-
61-
// Immutable
6257

58+
override func copy(with zone: NSZone? = nil) -> AnyObject {
59+
return _mapUnmanaged { $0.copy(with: zone) }
60+
}
61+
62+
override func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
63+
return _mapUnmanaged { $0.mutableCopy(with: zone) }
64+
}
65+
66+
public override var classForCoder: AnyClass {
67+
return NSCharacterSet.self
68+
}
69+
6370
override var bitmapRepresentation: Data {
6471
return _mapUnmanaged { $0.bitmapRepresentation }
6572
}
@@ -68,8 +75,8 @@ internal final class _SwiftNSCharacterSet : NSCharacterSet, _SwiftNativeFoundati
6875
return _mapUnmanaged { $0.inverted }
6976
}
7077

71-
override func hasMember(inPlane plane: UInt8) -> Bool {
72-
return _mapUnmanaged {$0.hasMember(inPlane: plane) }
78+
override func hasMemberInPlane(_ thePlane: UInt8) -> Bool {
79+
return _mapUnmanaged {$0.hasMemberInPlane(thePlane) }
7380
}
7481

7582
override func characterIsMember(_ member: unichar) -> Bool {
@@ -173,77 +180,77 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
173180

174181
/// Returns a character set containing the characters in Unicode General Category Cc and Cf.
175182
public static var controlCharacters : CharacterSet {
176-
return NSCharacterSet.controlCharacters()
183+
return NSCharacterSet.controlCharacters
177184
}
178185

179186
/// Returns a character set containing the characters in Unicode General Category Zs and `CHARACTER TABULATION (U+0009)`.
180187
public static var whitespaces : CharacterSet {
181-
return NSCharacterSet.whitespaces()
188+
return NSCharacterSet.whitespaces
182189
}
183190

184191
/// Returns a character set containing characters in Unicode General Category Z*, `U+000A ~ U+000D`, and `U+0085`.
185192
public static var whitespacesAndNewlines : CharacterSet {
186-
return NSCharacterSet.whitespacesAndNewlines()
193+
return NSCharacterSet.whitespacesAndNewlines
187194
}
188195

189196
/// Returns a character set containing the characters in the category of Decimal Numbers.
190197
public static var decimalDigits : CharacterSet {
191-
return NSCharacterSet.decimalDigits()
198+
return NSCharacterSet.decimalDigits
192199
}
193200

194201
/// Returns a character set containing the characters in Unicode General Category L* & M*.
195202
public static var letters : CharacterSet {
196-
return NSCharacterSet.letters()
203+
return NSCharacterSet.letters
197204
}
198205

199206
/// Returns a character set containing the characters in Unicode General Category Ll.
200207
public static var lowercaseLetters : CharacterSet {
201-
return NSCharacterSet.lowercaseLetters()
208+
return NSCharacterSet.lowercaseLetters
202209
}
203210

204211
/// Returns a character set containing the characters in Unicode General Category Lu and Lt.
205212
public static var uppercaseLetters : CharacterSet {
206-
return NSCharacterSet.uppercaseLetters()
213+
return NSCharacterSet.uppercaseLetters
207214
}
208215

209216
/// Returns a character set containing the characters in Unicode General Category M*.
210217
public static var nonBaseCharacters : CharacterSet {
211-
return NSCharacterSet.nonBaseCharacters()
218+
return NSCharacterSet.nonBaseCharacters
212219
}
213220

214221
/// Returns a character set containing the characters in Unicode General Categories L*, M*, and N*.
215222
public static var alphanumerics : CharacterSet {
216-
return NSCharacterSet.alphanumerics()
223+
return NSCharacterSet.alphanumerics
217224
}
218225

219-
/// Returns a character set containing individual Unicode characters that can also be represented as composed character sequences (such as for letters with accents), by the definition of standard decomposition in version 3.2 of the Unicode character encoding standard.
226+
/// Returns a character set containing individual Unicode characters that can also be represented as composed character sequences (such as for letters with accents), by the definition of "standard decomposition" in version 3.2 of the Unicode character encoding standard.
220227
public static var decomposables : CharacterSet {
221-
return NSCharacterSet.decomposables()
228+
return NSCharacterSet.decomposables
222229
}
223230

224231
/// Returns a character set containing values in the category of Non-Characters or that have not yet been defined in version 3.2 of the Unicode standard.
225232
public static var illegalCharacters : CharacterSet {
226-
return NSCharacterSet.illegalCharacters()
233+
return NSCharacterSet.illegalCharacters
227234
}
228235

229236
/// Returns a character set containing the characters in Unicode General Category P*.
230237
public static var punctuation : CharacterSet {
231-
return NSCharacterSet.punctuation()
238+
return NSCharacterSet.punctuation
232239
}
233240

234241
/// Returns a character set containing the characters in Unicode General Category Lt.
235242
public static var capitalizedLetters : CharacterSet {
236-
return NSCharacterSet.capitalizedLetters()
243+
return NSCharacterSet.capitalizedLetters
237244
}
238245

239246
/// Returns a character set containing the characters in Unicode General Category S*.
240247
public static var symbols : CharacterSet {
241-
return NSCharacterSet.symbols()
248+
return NSCharacterSet.symbols
242249
}
243250

244251
/// Returns a character set containing the newline characters (`U+000A ~ U+000D`, `U+0085`, `U+2028`, and `U+2029`).
245252
public static var newlines : CharacterSet {
246-
return NSCharacterSet.newlines()
253+
return NSCharacterSet.newlines
247254
}
248255

249256
// MARK: Static functions, from NSURL
@@ -294,7 +301,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
294301
///
295302
/// This method makes it easier to find the plane containing the members of the current character set. The Basic Multilingual Plane (BMP) is plane 0.
296303
public func hasMember(inPlane plane: UInt8) -> Bool {
297-
return _mapUnmanaged { $0.hasMember(inPlane: plane) }
304+
return _mapUnmanaged { $0.hasMemberInPlane(plane) }
298305
}
299306

300307
// MARK: Mutable functions
@@ -359,7 +366,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
359366
// -----
360367
// MARK: -
361368
// MARK: SetAlgebraType
362-
369+
363370
/// Insert a `UnicodeScalar` representation of a character into the `CharacterSet`.
364371
///
365372
/// `UnicodeScalar` values are available on `Swift.String.UnicodeScalarView`.
@@ -448,11 +455,11 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
448455
public func isSuperset(of other: CharacterSet) -> Bool {
449456
return _mapUnmanaged { $0.isSuperset(of: other) }
450457
}
451-
}
452458

453-
/// Returns true if the two `CharacterSet`s are equal.
454-
public func ==(lhs : CharacterSet, rhs: CharacterSet) -> Bool {
455-
return lhs._wrapped.isEqual(rhs._bridgeToObjectiveC())
459+
/// Returns true if the two `CharacterSet`s are equal.
460+
public static func ==(lhs : CharacterSet, rhs: CharacterSet) -> Bool {
461+
return lhs._wrapped.isEqual(rhs._bridgeToObjectiveC()) // TODO: mlehew - as NSCharacterSet
462+
}
456463
}
457464

458465

@@ -485,9 +492,3 @@ extension CharacterSet {
485492
}
486493

487494
}
488-
489-
extension CharacterSet {
490-
public func contains(_ member: unichar) -> Bool {
491-
return contains(UnicodeScalar(member)!)
492-
}
493-
}

0 commit comments

Comments
 (0)