THRIFT-4902: Swift 4 and 5 compatibility (#1827)
diff --git a/lib/swift/Sources/TBinaryProtocol.swift b/lib/swift/Sources/TBinaryProtocol.swift
index a97249a..85acce0 100644
--- a/lib/swift/Sources/TBinaryProtocol.swift
+++ b/lib/swift/Sources/TBinaryProtocol.swift
@@ -325,7 +325,7 @@
}
public func write(_ value: UInt8) throws {
- let buff = Data(bytes: [value])
+ let buff = Data([value])
try ProtocolTransportTry(error: TProtocolError(message: "Transport write failed")) {
try self.transport.write(data: buff)
@@ -334,8 +334,8 @@
public func write(_ value: Int16) throws {
var buff = Data()
- buff.append(Data(bytes: [UInt8(0xff & (value >> 8))]))
- buff.append(Data(bytes: [UInt8(0xff & (value))]))
+ buff.append(Data([UInt8(0xff & (value >> 8))]))
+ buff.append(Data([UInt8(0xff & (value))]))
try ProtocolTransportTry(error: TProtocolError(message: "Transport write failed")) {
try self.transport.write(data: buff)
}
@@ -343,10 +343,10 @@
public func write(_ value: Int32) throws {
var buff = Data()
- buff.append(Data(bytes: [UInt8(0xff & (value >> 24))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 16))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 8))]))
- buff.append(Data(bytes: [UInt8(0xff & (value))]))
+ buff.append(Data([UInt8(0xff & (value >> 24))]))
+ buff.append(Data([UInt8(0xff & (value >> 16))]))
+ buff.append(Data([UInt8(0xff & (value >> 8))]))
+ buff.append(Data([UInt8(0xff & (value))]))
try ProtocolTransportTry(error: TProtocolError(message: "Transport write failed")) {
try self.transport.write(data: buff)
@@ -355,14 +355,14 @@
public func write(_ value: Int64) throws {
var buff = Data()
- buff.append(Data(bytes: [UInt8(0xff & (value >> 56))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 48))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 40))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 32))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 24))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 16))]))
- buff.append(Data(bytes: [UInt8(0xff & (value >> 8))]))
- buff.append(Data(bytes: [UInt8(0xff & (value))]))
+ buff.append(Data([UInt8(0xff & (value >> 56))]))
+ buff.append(Data([UInt8(0xff & (value >> 48))]))
+ buff.append(Data([UInt8(0xff & (value >> 40))]))
+ buff.append(Data([UInt8(0xff & (value >> 32))]))
+ buff.append(Data([UInt8(0xff & (value >> 24))]))
+ buff.append(Data([UInt8(0xff & (value >> 16))]))
+ buff.append(Data([UInt8(0xff & (value >> 8))]))
+ buff.append(Data([UInt8(0xff & (value))]))
try ProtocolTransportTry(error: TProtocolError(message: "Transport write failed")) {
try self.transport.write(data: buff)