From d3a6625db93a6519f334b54a3d2e9087cd33fe36 Mon Sep 17 00:00:00 2001 From: Kye Maloy Date: Thu, 12 Apr 2018 13:31:37 +0100 Subject: [PATCH] Added Swift 4.1 support by fixing warnings (#34) --- .swift-version | 2 +- .travis.yml | 9 ++++++++- Tests/KituraWebSocketTests/KituraTest+Frames.swift | 13 ++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.swift-version b/.swift-version index c4e41f9..7d5c902 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0.3 +4.1 diff --git a/.travis.yml b/.travis.yml index c384556..97f3709 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,17 @@ matrix: - os: linux dist: trusty sudo: required + - os: linux + dist: trusty + sudo: required + env: SWIFT_SNAPSHOT=4.0.3 + - os: osx + osx_image: xcode9.3 + sudo: required - os: osx osx_image: xcode9.2 sudo: required - + env: SWIFT_SNAPSHOT=4.0.3 before_install: - git clone https://github.com/IBM-Swift/Package-Builder.git diff --git a/Tests/KituraWebSocketTests/KituraTest+Frames.swift b/Tests/KituraWebSocketTests/KituraTest+Frames.swift index 68ec35f..ee27ea8 100644 --- a/Tests/KituraWebSocketTests/KituraTest+Frames.swift +++ b/Tests/KituraWebSocketTests/KituraTest+Frames.swift @@ -170,8 +170,11 @@ extension KituraTest { intMask = arc4random() #endif var mask: [UInt8] = [0, 0, 0, 0] + #if swift(>=4.1) + UnsafeMutableRawPointer(mutating: mask).copyMemory(from: &intMask, byteCount: mask.count) + #else UnsafeMutableRawPointer(mutating: mask).copyBytes(from: &intMask, count: mask.count) - + #endif buffer.append(&mask, length: mask.count) let payloadBytes = withPayload.bytes.bindMemory(to: UInt8.self, capacity: withPayload.length) @@ -207,7 +210,11 @@ extension KituraTest { payloadLengthUInt16 = CFSwapInt16HostToBig(tempPayloadLengh) #endif let asBytes = UnsafeMutablePointer(&payloadLengthUInt16) + #if swift(>=4.1) + (UnsafeMutableRawPointer(mutating: bytes)+length+1).copyMemory(from: asBytes, byteCount: 2) + #else (UnsafeMutableRawPointer(mutating: bytes)+length+1).copyBytes(from: asBytes, count: 2) + #endif length += 3 } else { bytes[1] = 127 @@ -219,7 +226,11 @@ extension KituraTest { payloadLengthUInt32 = CFSwapInt32HostToBig(tempPayloadLengh) #endif let asBytes = UnsafeMutablePointer(&payloadLengthUInt32) + #if swift(>=4.1) + (UnsafeMutableRawPointer(mutating: bytes)+length+5).copyMemory(from: asBytes, byteCount: 4) + #else (UnsafeMutableRawPointer(mutating: bytes)+length+5).copyBytes(from: asBytes, count: 4) + #endif length += 9 } if withMasking {