Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Resolve deprecation warnings for swift 4.1 #33

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Sources/KituraWebSocket/WSFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ struct WSFrame {
payloadLengthUInt16 = CFSwapInt16HostToBig(tempPayloadLengh)
#endif
let asBytes = UnsafeMutablePointer(&payloadLengthUInt16)
(UnsafeMutableRawPointer(mutating: bytes)+length+1).copyBytes(from: asBytes, count: 2)
#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 @@ -62,7 +66,11 @@ struct WSFrame {
payloadLengthUInt32 = CFSwapInt32HostToBig(tempPayloadLengh)
#endif
let asBytes = UnsafeMutablePointer(&payloadLengthUInt32)
(UnsafeMutableRawPointer(mutating: bytes)+length+5).copyBytes(from: asBytes, count: 4)
#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
}
buffer.append(bytes, length: length)
Expand Down
6 changes: 5 additions & 1 deletion Sources/KituraWebSocket/WSFrameParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ struct WSFrameParser {

if bytesConsumed > 0 {
if length - from - bytesConsumed >= maskSize {
UnsafeMutableRawPointer(mutating: mask).copyBytes(from: bytes+from+bytesConsumed, count: maskSize)
#if swift(>=4.1)
UnsafeMutableRawPointer(mutating: mask).copyMemory(from: bytes+from+bytesConsumed, byteCount: maskSize)
#else
UnsafeMutableRawPointer(mutating: mask).copyBytes(from: bytes+from+bytesConsumed, count: maskSize)
#endif
bytesConsumed += maskSize
}
else {
Expand Down