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

Commit 371ec55

Browse files
committed
Merge branch 'release/2.2.2'
2 parents ec60a28 + 2a5af94 commit 371ec55

35 files changed

+455
-258
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ SwiftFoundation/build
1313
Xcode/SwiftFoundation.xcodeproj/xcuserdata
1414

1515
Xcode/SwiftFoundation.xcodeproj/project.xcworkspace/xcuserdata
16+
17+
.DS_Store

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: generic
22
osx_image: xcode8
33
os:
44
- linux
5-
- osx
65
sudo: required
76
dist: trusty
87
before_install:
@@ -13,9 +12,9 @@ install:
1312
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update ; fi
1413
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install clang uuid-dev libjson-c-dev ; fi
1514
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir $SWIFT_DIR ; fi
16-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://swift.org/builds/swift-3.0-preview-1/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz -s | tar xz -C $SWIFT_DIR &> /dev/null ; fi
15+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://swift.org/builds/development/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz -s | tar xz -C $SWIFT_DIR &> /dev/null ; fi
1716
env:
18-
- SWIFT_VERSION=swift-3.0-PREVIEW-1
17+
- SWIFT_VERSION=swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a
1918
script:
2019
- uname
2120
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then xctool test -project Xcode/SwiftFoundation.xcodeproj -scheme "SwiftFoundation OS X" -sdk macosx ONLY_ACTIVE_ARCH=NO ; fi

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "PureSwift/JSON-C" "098c5ad91d262de5ad695a6162b6d0d4b384741d"
1+
github "PureSwift/JSON-C" "0b49467d3f881523c9a74994f6e460a757bdb84f"

Package.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ import PackageDescription
22

33
let package = Package(
44
name: "SwiftFoundation",
5-
targets: [
6-
Target(
7-
name: "UnitTests",
8-
dependencies: [.Target(name: "SwiftFoundation")]),
9-
Target(
10-
name: "SwiftFoundation")
11-
],
125
dependencies: [
136
.Package(url: "https://github.com/PureSwift/CStatfs.git", majorVersion: 1),
147
.Package(url: "https://github.com/PureSwift/CJSONC.git", majorVersion: 1)

Sources/SwiftFoundation/Base64.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/* Create an NSData from a Base-64 encoded NSString using the given options. By default, returns nil when the input is not recognized as valid Base-64.
3131
*/
32-
public init?(base64Encoded base64String: String, options: Base64DecodingOptions) {
32+
public init?(base64Encoded base64String: String, options: Base64DecodingOptions = []) {
3333
let encodedBytes = Array(base64String.utf8)
3434
guard let decodedBytes = Data.base64DecodeBytes(encodedBytes, options: options) else {
3535
return nil
@@ -47,7 +47,7 @@
4747

4848
/* Create an NSData from a Base-64, UTF-8 encoded NSData. By default, returns nil when the input is not recognized as valid Base-64.
4949
*/
50-
public init?(base64Encoded base64Data: Data, options: Base64DecodingOptions) {
50+
public init?(base64Encoded base64Data: Data, options: Base64DecodingOptions = []) {
5151
guard let decodedBytes = Data.base64DecodeBytes(base64Data.bytes, options: options) else {
5252
return nil
5353
}
@@ -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/BitMaskOption.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public protocol BitMaskOption: RawRepresentable {
1414

1515
public extension BitMaskOption where Self.RawValue: Integer {
1616

17-
static func bitmask<S: Sequence where S.Iterator.Element == Self>(options: S) -> Self.RawValue {
17+
static func bitmask<S: Sequence>(options: S) -> Self.RawValue where S.Iterator.Element == Self {
1818
return options.reduce(0) { mask, option in
1919
mask | option.rawValue
2020
}

Sources/SwiftFoundation/ByteValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public protocol ByteValue: Equatable {
2222

2323
// MARK: - Equatable
2424

25-
public func == <T: ByteValue where T.ByteValue: Equatable> (lhs: T, rhs: T) -> Bool {
25+
public func == <T: ByteValue> (lhs: T, rhs: T) -> Bool where T.ByteValue: Equatable {
2626

2727
return lhs.bytes == rhs.bytes
2828
}

Sources/SwiftFoundation/Data.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
// MARK: - Properties
2626

27-
private var _bytes: ContiguousArray<Byte>
27+
fileprivate var _bytes: ContiguousArray<Byte>
2828

2929
public var bytes: [Byte] {
3030

@@ -70,7 +70,7 @@
7070
/// - parameter bytes: A pointer to the memory. It will be copied.
7171
/// - parameter count: The number of bytes to copy.
7272
@inline(__always)
73-
public init(bytes pointer: UnsafePointer<Void>, count: Int) {
73+
public init(bytes pointer: UnsafeRawPointer, count: Int) {
7474

7575
_bytes = ContiguousArray<UInt8>(repeating: 0, count: count)
7676

@@ -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: MemoryLayout<SourceType>.size * buffer.count)
8989
}
9090

9191
// MARK: - Accessors
@@ -100,7 +100,7 @@
100100

101101
public var description: String {
102102

103-
let hexString = bytes.map({ $0.toHexadecimal() }).reduce("", combine: { $0.0 + $0.1 })
103+
let hexString = bytes.map({ $0.toHexadecimal() }).reduce("", { $0.0 + $0.1 })
104104

105105
return "<" + hexString + ">"
106106
}

Sources/SwiftFoundation/FileManager.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public struct FileManager {
7575

7676
let stringBufferSize = Int(PATH_MAX)
7777

78-
let path = UnsafeMutablePointer<CChar>(allocatingCapacity: stringBufferSize)
78+
let path = UnsafeMutablePointer<CChar>.allocate(capacity: stringBufferSize)
7979

80-
defer { path.deallocateCapacity(stringBufferSize) }
80+
defer { path.deallocate(capacity: stringBufferSize) }
8181

8282
getcwd(path, stringBufferSize - 1)
8383

@@ -193,9 +193,9 @@ public struct FileManager {
193193

194194
#endif
195195

196-
let memoryPointer = UnsafeMutablePointer<Byte>(allocatingCapacity: fileSize)
196+
let memoryPointer = UnsafeMutablePointer<Byte>.allocate(capacity: fileSize)
197197

198-
defer { memoryPointer.deallocateCapacity(fileSize) }
198+
defer { memoryPointer.deallocate(capacity: fileSize) }
199199

200200
let readBytes = read(file, memoryPointer, fileSize)
201201

@@ -212,7 +212,7 @@ public struct FileManager {
212212
public static func set(contents data: Data, at path: String) throws {
213213

214214
// get file descriptor for path (open file)
215-
let file = open(path, O_WRONLY)
215+
let file = open(path, O_TRUNC | O_WRONLY)
216216

217217
guard file != -1 else { throw POSIXError.fromErrno! }
218218

Sources/SwiftFoundation/Hash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
public func Hash(_ data: Data) -> Int {
1111

1212
// more expensive than casting but that's not safe for large values.
13-
return data.bytes.map({ Int($0) }).reduce(0, combine: { $0.0 ^ $0.1 })
13+
return data.bytes.map({ Int($0) }).reduce(0) { $0.0 ^ $0.1 }
1414
}

0 commit comments

Comments
 (0)