Skip to content

Commit bc49d22

Browse files
authored
Revert "Swift 3: Value Types and Naming" (#526)
Reverts #508. It broke on Linux.
1 parent f2a3cb1 commit bc49d22

File tree

8 files changed

+325
-448
lines changed

8 files changed

+325
-448
lines changed

Foundation/CharacterSet.swift

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ 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
5762

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-
7063
override var bitmapRepresentation: Data {
7164
return _mapUnmanaged { $0.bitmapRepresentation }
7265
}
@@ -75,8 +68,8 @@ internal final class _SwiftNSCharacterSet : NSCharacterSet, _SwiftNativeFoundati
7568
return _mapUnmanaged { $0.inverted }
7669
}
7770

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

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

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

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

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

196189
/// Returns a character set containing the characters in the category of Decimal Numbers.
197190
public static var decimalDigits : CharacterSet {
198-
return NSCharacterSet.decimalDigits
191+
return NSCharacterSet.decimalDigits()
199192
}
200193

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

206199
/// Returns a character set containing the characters in Unicode General Category Ll.
207200
public static var lowercaseLetters : CharacterSet {
208-
return NSCharacterSet.lowercaseLetters
201+
return NSCharacterSet.lowercaseLetters()
209202
}
210203

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

216209
/// Returns a character set containing the characters in Unicode General Category M*.
217210
public static var nonBaseCharacters : CharacterSet {
218-
return NSCharacterSet.nonBaseCharacters
211+
return NSCharacterSet.nonBaseCharacters()
219212
}
220213

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

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.
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.
227220
public static var decomposables : CharacterSet {
228-
return NSCharacterSet.decomposables
221+
return NSCharacterSet.decomposables()
229222
}
230223

231224
/// 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.
232225
public static var illegalCharacters : CharacterSet {
233-
return NSCharacterSet.illegalCharacters
226+
return NSCharacterSet.illegalCharacters()
234227
}
235228

236229
/// Returns a character set containing the characters in Unicode General Category P*.
237230
public static var punctuation : CharacterSet {
238-
return NSCharacterSet.punctuation
231+
return NSCharacterSet.punctuation()
239232
}
240233

241234
/// Returns a character set containing the characters in Unicode General Category Lt.
242235
public static var capitalizedLetters : CharacterSet {
243-
return NSCharacterSet.capitalizedLetters
236+
return NSCharacterSet.capitalizedLetters()
244237
}
245238

246239
/// Returns a character set containing the characters in Unicode General Category S*.
247240
public static var symbols : CharacterSet {
248-
return NSCharacterSet.symbols
241+
return NSCharacterSet.symbols()
249242
}
250243

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

256249
// MARK: Static functions, from NSURL
@@ -301,7 +294,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
301294
///
302295
/// 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.
303296
public func hasMember(inPlane plane: UInt8) -> Bool {
304-
return _mapUnmanaged { $0.hasMemberInPlane(plane) }
297+
return _mapUnmanaged { $0.hasMember(inPlane: plane) }
305298
}
306299

307300
// MARK: Mutable functions
@@ -366,7 +359,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
366359
// -----
367360
// MARK: -
368361
// MARK: SetAlgebraType
369-
362+
370363
/// Insert a `UnicodeScalar` representation of a character into the `CharacterSet`.
371364
///
372365
/// `UnicodeScalar` values are available on `Swift.String.UnicodeScalarView`.
@@ -455,11 +448,11 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
455448
public func isSuperset(of other: CharacterSet) -> Bool {
456449
return _mapUnmanaged { $0.isSuperset(of: other) }
457450
}
451+
}
458452

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-
}
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())
463456
}
464457

465458

@@ -492,3 +485,9 @@ extension CharacterSet {
492485
}
493486

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

0 commit comments

Comments
 (0)