Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit d06e4ac

Browse files
committed
Updated for Swift 3.0
Swift 3.0 Development 2016-07-16
1 parent 6e145f4 commit d06e4ac

File tree

10 files changed

+53
-51
lines changed

10 files changed

+53
-51
lines changed

Sources/SwiftFoundation/Base64.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
let appendByteToResult : (UInt8) -> () = {
233233
result.append($0)
234234
currentLineCount += 1
235-
if let options = lineOptions where currentLineCount == options.lineLength {
235+
if let options = lineOptions, currentLineCount == options.lineLength {
236236
result.append(contentsOf: options.separator)
237237
currentLineCount = 0
238238
}

Sources/SwiftFoundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
guard let pointer = buffer.baseAddress
8686
else { self.init(); return }
8787

88-
self.init(bytes: pointer, count: sizeof(SourceType) * buffer.count)
88+
self.init(bytes: pointer, count: sizeof(SourceType.self) * buffer.count)
8989
}
9090

9191
// MARK: - Accessors

Sources/SwiftFoundation/JSONExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public extension Collection where Iterator.Element: JSONEncodable {
100100
}
101101
}
102102

103-
public extension Dictionary where Value: JSONEncodable, Key: StringLiteralConvertible {
103+
public extension Dictionary where Value: JSONEncodable, Key: ExpressibleByStringLiteral {
104104

105105
/// Encodes the reciever into JSON.
106106
func toJSON() -> JSON.Value {

Sources/SwiftFoundation/JSONSerialization.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,22 @@ public extension JSON {
103103
public enum WritingOption: BitMaskOption {
104104

105105
/// Causes the output to have minimal whitespace inserted to make things slightly more readable.
106-
case Spaced
106+
case spaced
107107

108108
/// Causes the output to be formatted. See the [Two Space Tab](http://jsonformatter.curiousconcept.com/) option
109109
/// for an example of the format.
110-
case Pretty
110+
case pretty
111111

112112
/// Drop trailing zero for float values
113-
case NoZero
113+
case noZero
114114

115115
public init?(rawValue: Int32) {
116116

117117
switch rawValue {
118118

119-
case JSON_C_TO_STRING_SPACED: self = .Spaced
120-
case JSON_C_TO_STRING_PRETTY: self = .Pretty
121-
case JSON_C_TO_STRING_NOZERO: self = .NoZero
119+
case JSON_C_TO_STRING_SPACED: self = .spaced
120+
case JSON_C_TO_STRING_PRETTY: self = .pretty
121+
case JSON_C_TO_STRING_NOZERO: self = .noZero
122122

123123
default: return nil
124124
}
@@ -128,9 +128,9 @@ public extension JSON {
128128

129129
switch self {
130130

131-
case Spaced: return JSON_C_TO_STRING_SPACED
132-
case Pretty: return JSON_C_TO_STRING_PRETTY
133-
case NoZero: return JSON_C_TO_STRING_NOZERO
131+
case .spaced: return JSON_C_TO_STRING_SPACED
132+
case .pretty: return JSON_C_TO_STRING_PRETTY
133+
case .noZero: return JSON_C_TO_STRING_NOZERO
134134
}
135135
}
136136
}

Sources/SwiftFoundation/POSIXError.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
import Glibc
1414
#endif
1515

16-
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
17-
18-
#endif
19-
2016
public extension POSIXError {
2117

2218
/// Creates error from C ```errno```.
@@ -28,14 +24,18 @@ public extension POSIXError {
2824
return self.init(code: code)
2925
}
3026

27+
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
28+
3129
/// Creates `POSIXError` from error code.
32-
@inline(__always)
3330
init(code: POSIXErrorCode) {
3431

3532
let nsError = NSError(domain: NSPOSIXErrorDomain, code: Int(code.rawValue), userInfo: nil)
3633

3734
self.init(_nsError: nsError)
3835
}
36+
37+
#endif
38+
3939
}
4040

4141
#if os(Linux)

Sources/SwiftFoundation/RegularExpressionCompileError.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public extension RegularExpression {
1616

1717
// POSIX Regular Expression compilation error
18-
public enum CompileError: RawRepresentable, ErrorProtocol {
18+
public enum CompileError: Error, RawRepresentable {
1919

2020
/// Invalid use of repetition operators such as using '*' as the first character.
2121
///
@@ -71,18 +71,18 @@ public extension RegularExpression {
7171

7272
switch rawValue {
7373

74-
case REG_BADRPT: self = InvalidRepetition
75-
case REG_BADBR: self = InvalidBackReference
76-
case REG_ESPACE: self = OutOfMemory
77-
case REG_BADPAT: self = InvalidPatternOperator
78-
case REG_EBRACE: self = UnMatchedBraceInterval
79-
case REG_EBRACK: self = UnMatchedBracketList
80-
case REG_ECOLLATE: self = InvalidCollating
81-
case REG_ECTYPE: self = UnknownCharacterClassName
82-
case REG_EESCAPE: self = TrailingBackslash
83-
case REG_EPAREN: self = UnMatchedParenthesis
84-
case REG_ERANGE: self = InvalidRange
85-
case REG_ESUBREG: self = InvalidBackReferenceToSubExpression
74+
case REG_BADRPT: self = .InvalidRepetition
75+
case REG_BADBR: self = .InvalidBackReference
76+
case REG_ESPACE: self = .OutOfMemory
77+
case REG_BADPAT: self = .InvalidPatternOperator
78+
case REG_EBRACE: self = .UnMatchedBraceInterval
79+
case REG_EBRACK: self = .UnMatchedBracketList
80+
case REG_ECOLLATE: self = .InvalidCollating
81+
case REG_ECTYPE: self = .UnknownCharacterClassName
82+
case REG_EESCAPE: self = .TrailingBackslash
83+
case REG_EPAREN: self = .UnMatchedParenthesis
84+
case REG_ERANGE: self = .InvalidRange
85+
case REG_ESUBREG: self = .InvalidBackReferenceToSubExpression
8686

8787
/*
8888
#if os(linux)
@@ -101,18 +101,18 @@ public extension RegularExpression {
101101

102102
switch self {
103103

104-
case InvalidRepetition: return REG_BADRPT
105-
case InvalidBackReference: return REG_BADBR
106-
case OutOfMemory: return REG_ESPACE
107-
case InvalidPatternOperator: return REG_BADPAT
108-
case UnMatchedBraceInterval: return REG_EBRACE
109-
case UnMatchedBracketList: return REG_EBRACK
110-
case InvalidCollating: return REG_ECOLLATE
111-
case UnknownCharacterClassName: return REG_ECTYPE
112-
case TrailingBackslash: return REG_EESCAPE
113-
case UnMatchedParenthesis: return REG_EPAREN
114-
case InvalidRange: return REG_ERANGE
115-
case InvalidBackReferenceToSubExpression: return REG_ESUBREG
104+
case .InvalidRepetition: return REG_BADRPT
105+
case .InvalidBackReference: return REG_BADBR
106+
case .OutOfMemory: return REG_ESPACE
107+
case .InvalidPatternOperator: return REG_BADPAT
108+
case .UnMatchedBraceInterval: return REG_EBRACE
109+
case .UnMatchedBracketList: return REG_EBRACK
110+
case .InvalidCollating: return REG_ECOLLATE
111+
case .UnknownCharacterClassName: return REG_ECTYPE
112+
case .TrailingBackslash: return REG_EESCAPE
113+
case .UnMatchedParenthesis: return REG_EPAREN
114+
case .InvalidRange: return REG_ERANGE
115+
case .InvalidBackReferenceToSubExpression: return REG_ESUBREG
116116
}
117117
}
118118
}

Sources/SwiftFoundation/RegularExpressionCompileOption.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public extension RegularExpression {
3636

3737
switch rawValue {
3838

39-
case REG_ICASE: self = CaseInsensitive
40-
case REG_EXTENDED: self = ExtendedSyntax
41-
case REG_NOSUB: self = NoSub
42-
case REG_NEWLINE: self = NewLine
39+
case REG_ICASE: self = .CaseInsensitive
40+
case REG_EXTENDED: self = .ExtendedSyntax
41+
case REG_NOSUB: self = .NoSub
42+
case REG_NEWLINE: self = .NewLine
4343

4444
default: return nil
4545
}

Sources/SwiftFoundation/RegularExpressionMatchOption.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public extension RegularExpression {
2929

3030
switch rawValue {
3131

32-
case REG_NOTBOL: self = NotBeginningOfLine
33-
case REG_NOTEOL: self = NotEndOfLine
32+
case REG_NOTBOL: self = .NotBeginningOfLine
33+
case REG_NOTEOL: self = .NotEndOfLine
3434

3535
default: return nil
3636
}
@@ -45,4 +45,4 @@ public extension RegularExpression {
4545
}
4646
}
4747
}
48-
}
48+
}

Sources/SwiftFoundation/Thread.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ public final class Thread {
6666
let errorCode = pthread_join(internalThread, nil)
6767

6868
guard errorCode == 0
69-
else { throw POSIXError(rawValue: errorCode)! }
69+
else { throw POSIXError(code: POSIXErrorCode(rawValue: errorCode)!) }
7070
}
7171

7272
public func cancel() throws {
7373

7474
let errorCode = pthread_cancel(internalThread)
7575

7676
guard errorCode == 0
77-
else { throw POSIXError(rawValue: errorCode)! }
77+
else { throw POSIXError(code: POSIXErrorCode(rawValue: errorCode)!) }
7878
}
7979
}
8080

Xcode/SwiftFoundation.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@
10111011
PRODUCT_NAME = SwiftFoundation;
10121012
SDKROOT = macosx;
10131013
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1014+
SWIFT_VERSION = 3.0;
10141015
VERSIONING_SYSTEM = "apple-generic";
10151016
VERSION_INFO_PREFIX = "";
10161017
WATCHOS_DEPLOYMENT_TARGET = 2.0;
@@ -1056,6 +1057,7 @@
10561057
PRODUCT_NAME = SwiftFoundation;
10571058
SDKROOT = macosx;
10581059
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1060+
SWIFT_VERSION = 3.0;
10591061
VERSIONING_SYSTEM = "apple-generic";
10601062
VERSION_INFO_PREFIX = "";
10611063
WATCHOS_DEPLOYMENT_TARGET = 2.0;

0 commit comments

Comments
 (0)