Update Swift Library and tests
diff --git a/lib/swift/Sources/TBinaryProtocol.swift b/lib/swift/Sources/TBinaryProtocol.swift
index 47f3f28..a97249a 100644
--- a/lib/swift/Sources/TBinaryProtocol.swift
+++ b/lib/swift/Sources/TBinaryProtocol.swift
@@ -79,7 +79,7 @@
messageName = try read()
} else {
if strictRead {
- let errorMessage = "Missing message version, old client? Message Name: \(currentMessageName)"
+ let errorMessage = "Missing message version, old client? Message Name: \(currentMessageName ?? "")"
throw TProtocolError(error: .invalidData,
message: errorMessage)
}
@@ -233,7 +233,7 @@
public func read() throws -> Double {
let val = try read() as Int64
- return unsafeBitCast(val, to: Double.self)
+ return Double(bitPattern: UInt64(bitPattern: val))
}
public func read() throws -> Data {
@@ -371,7 +371,7 @@
public func write(_ value: Double) throws {
// Notably unsafe, since Double and Int64 are the same size, this should work fine
- try self.write(unsafeBitCast(value, to: Int64.self))
+ try self.write(Int64(bitPattern: value.bitPattern))
}
public func write(_ data: Data) throws {
diff --git a/lib/swift/Sources/TClient.swift b/lib/swift/Sources/TClient.swift
index c404c9a..cc3288a 100644
--- a/lib/swift/Sources/TClient.swift
+++ b/lib/swift/Sources/TClient.swift
@@ -22,12 +22,12 @@
public let inProtocol: TProtocol
public let outProtocol: TProtocol
- public init(inoutProtocol: TProtocol) {
+ required public init(inoutProtocol: TProtocol) {
self.inProtocol = inoutProtocol
self.outProtocol = inoutProtocol
}
- public init(inProtocol: TProtocol, outProtocol: TProtocol) {
+ required public init(inProtocol: TProtocol, outProtocol: TProtocol) {
self.inProtocol = inProtocol
self.outProtocol = outProtocol
}
diff --git a/lib/swift/Sources/TCompactProtocol.swift b/lib/swift/Sources/TCompactProtocol.swift
index ac5b35a..59773c3 100644
--- a/lib/swift/Sources/TCompactProtocol.swift
+++ b/lib/swift/Sources/TCompactProtocol.swift
@@ -222,11 +222,11 @@
///
/// - returns: zigzaged UInt32
func i32ToZigZag(_ n : Int32) -> UInt32 {
- return UInt32(n << 1) ^ UInt32(n >> 31)
+ return UInt32(bitPattern: Int32(n << 1) ^ Int32(n >> 31))
}
func i64ToZigZag(_ n : Int64) -> UInt64 {
- return UInt64(n << 1) ^ UInt64(n >> 63)
+ return UInt64(bitPattern: Int64(n << 1) ^ Int64(n >> 63))
}
func zigZagToi32(_ n: UInt32) -> Int32 {
@@ -379,7 +379,7 @@
return UnsafePointer<UInt64>(OpaquePointer(ptr)).pointee
}
let bits = CFSwapInt64LittleToHost(i64)
- return unsafeBitCast(bits, to: Double.self)
+ return Double(bitPattern: bits)
}
public func read() throws -> Data {
@@ -557,7 +557,7 @@
}
public func write(_ value: Double) throws {
- var bits = CFSwapInt64HostToLittle(unsafeBitCast(value, to: UInt64.self))
+ var bits = CFSwapInt64HostToLittle(value.bitPattern)
let data = withUnsafePointer(to: &bits) {
return Data(bytes: UnsafePointer<UInt8>(OpaquePointer($0)), count: MemoryLayout<UInt64>.size)
}
diff --git a/lib/swift/Sources/TList.swift b/lib/swift/Sources/TList.swift
index 0077156..c239d10 100644
--- a/lib/swift/Sources/TList.swift
+++ b/lib/swift/Sources/TList.swift
@@ -18,7 +18,7 @@
*/
public struct TList<Element : TSerializable> : RandomAccessCollection, MutableCollection, ExpressibleByArrayLiteral, TSerializable, Hashable {
- typealias Storage = Array<Element>
+ public typealias Storage = Array<Element>
public typealias Indices = Storage.Indices
internal var storage = Storage()
diff --git a/lib/swift/Sources/TMap.swift b/lib/swift/Sources/TMap.swift
index f8b02d2..8980377 100644
--- a/lib/swift/Sources/TMap.swift
+++ b/lib/swift/Sources/TMap.swift
@@ -18,7 +18,7 @@
*/
public struct TMap<Key : TSerializable & Hashable, Value : TSerializable>: Collection, ExpressibleByDictionaryLiteral, Hashable, TSerializable {
- typealias Storage = Dictionary<Key, Value>
+ public typealias Storage = Dictionary<Key, Value>
public typealias Element = Storage.Element
public typealias Index = Storage.Index
public typealias IndexDistance = Storage.IndexDistance
diff --git a/lib/swift/Sources/TSet.swift b/lib/swift/Sources/TSet.swift
index 3e014c1..1ecd170 100644
--- a/lib/swift/Sources/TSet.swift
+++ b/lib/swift/Sources/TSet.swift
@@ -21,7 +21,7 @@
public struct TSet<Element : TSerializable & Hashable> : SetAlgebra, Hashable, Collection, ExpressibleByArrayLiteral, TSerializable {
/// Typealias for Storage type
- typealias Storage = Set<Element>
+ public typealias Storage = Set<Element>
/// Internal Storage used for TSet (Set\<Element\>)
diff --git a/lib/swift/Sources/TSocketTransport.swift b/lib/swift/Sources/TSocketTransport.swift
index 891bd27..0316e37 100644
--- a/lib/swift/Sources/TSocketTransport.swift
+++ b/lib/swift/Sources/TSocketTransport.swift
@@ -83,8 +83,8 @@
CFWriteStreamSetProperty(writeStream, .shouldCloseNativeSocket, kCFBooleanTrue)
if secure {
- CFReadStreamSetProperty(readStream, .socketSecurityLevel, StreamSocketSecurityLevel.negotiatedSSL._rawValue)
- CFWriteStreamSetProperty(writeStream, .socketSecurityLevel, StreamSocketSecurityLevel.negotiatedSSL._rawValue)
+ CFReadStreamSetProperty(readStream, .socketSecurityLevel, StreamSocketSecurityLevel.negotiatedSSL.rawValue as CFString)
+ CFWriteStreamSetProperty(writeStream, .socketSecurityLevel, StreamSocketSecurityLevel.negotiatedSSL.rawValue as CFString)
}
inputStream = readStream as InputStream
diff --git a/lib/swift/Sources/Thrift.swift b/lib/swift/Sources/Thrift.swift
index afa3096..5bd1758 100644
--- a/lib/swift/Sources/Thrift.swift
+++ b/lib/swift/Sources/Thrift.swift
@@ -1,3 +1,3 @@
class Thrift {
- let version = "0.0.1"
+ let version = "1.1.0"
}