Skip to content

Commit

Permalink
Added Swift 4.1 support by fixing warnings (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyeMaloy97 authored and djones6 committed Apr 12, 2018
1 parent 09c030f commit d3a6625
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.3
4.1
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion Tests/KituraWebSocketTests/KituraTest+Frames.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit d3a6625

Please sign in to comment.