diff options
author | Joe George <joe@zeroc.com> | 2019-03-07 13:52:00 -0500 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2019-03-07 13:57:10 -0500 |
commit | b4131f02675cf9f80c86cc8a2dd85be3f23b4bda (patch) | |
tree | adc92ea5db11498803b12c86c115045fdbc28828 /swift/src | |
parent | Readme update (diff) | |
download | ice-b4131f02675cf9f80c86cc8a2dd85be3f23b4bda.tar.bz2 ice-b4131f02675cf9f80c86cc8a2dd85be3f23b4bda.tar.xz ice-b4131f02675cf9f80c86cc8a2dd85be3f23b4bda.zip |
More stream fixes
Diffstat (limited to 'swift/src')
-rw-r--r-- | swift/src/Ice/Exception.swift | 1 | ||||
-rw-r--r-- | swift/src/Ice/InputStream.swift | 19 | ||||
-rw-r--r-- | swift/src/Ice/OutputStream.swift | 41 | ||||
-rw-r--r-- | swift/src/Ice/ValueFactoryManagerI.swift | 1 |
4 files changed, 35 insertions, 27 deletions
diff --git a/swift/src/Ice/Exception.swift b/swift/src/Ice/Exception.swift index 36971c4966c..89230429773 100644 --- a/swift/src/Ice/Exception.swift +++ b/swift/src/Ice/Exception.swift @@ -45,7 +45,6 @@ public extension UserException { _iceWriteImpl(to: ostr) ostr.endException() } - } #warning("TODO: Add proper LocalException CustomStringConvertible impl") diff --git a/swift/src/Ice/InputStream.swift b/swift/src/Ice/InputStream.swift index 33656384134..67349e78ec1 100644 --- a/swift/src/Ice/InputStream.swift +++ b/swift/src/Ice/InputStream.swift @@ -244,11 +244,11 @@ public class InputStream { } } - func skip(_ count: Int32) throws { + public func skip(_ count: Int32) throws { try buf.skip(count: Int(count)) } - func skipSize() throws { + public func skipSize() throws { let b: UInt8 = try read() if b == 255 { try buf.skip(count: 4) @@ -700,14 +700,21 @@ public extension InputStream { return try read() as ProxyImpl? } - func read() throws -> ObjectPrx? { - return try read() as _ObjectPrxI? - } - func read(tag: Int32) throws -> ObjectPrx? { return try read(tag: tag) as _ObjectPrxI? } + func read(cb: ((Value?) -> Void)?) throws { + initEncaps() + if let cb = cb { + try encaps.decoder.readValue { value in + cb(value) + } + } else { + try encaps.decoder.readValue(cb: nil) + } + } + func read<ValueType>(value cls: ValueType.Type, cb: ((ValueType?) -> Void)?) throws where ValueType: Value { initEncaps() if let cb = cb { diff --git a/swift/src/Ice/OutputStream.swift b/swift/src/Ice/OutputStream.swift index ff285a87a99..a21740cb63a 100644 --- a/swift/src/Ice/OutputStream.swift +++ b/swift/src/Ice/OutputStream.swift @@ -166,17 +166,12 @@ public extension OutputStream { private func writeNumeric<Element>(_ v: [Element]) where Element: Numeric { write(size: v.count) if v.count > 0 { - write(size: v.count) v.forEach { e in writeNumeric(e) } } } - private func writeNumeric<Element>(_ tag: Int32, _ v: [Element]) where Element: Numeric { - - } - // // UInt8 // @@ -193,8 +188,12 @@ public extension OutputStream { } func write(tag: Int32, value v: [UInt8]?) { - if let val = v { - writeNumeric(tag, val) + guard let val = v else { + return + } + + if writeOptional(tag: tag, format: OptionalFormat.VSize) { + write(val) } } @@ -212,7 +211,6 @@ public extension OutputStream { func write(_ v: [Bool]) { write(size: v.count) if v.count > 0 { - write(size: v.count) v.forEach { e in write(e) } @@ -220,7 +218,10 @@ public extension OutputStream { } func write(tag: Int32, value v: [Bool]?) { - if let val = v { + guard let val = v else { + return + } + if writeOptional(tag: tag, format: OptionalFormat.VSize) { write(val) } } @@ -242,8 +243,8 @@ public extension OutputStream { func write(tag: Int32, value v: [Int16]?) { if let val = v { - if writeOptionalVSize(tag: tag, len: Int32(val.count), elemSize: 2) { - writeNumeric(tag, val) + if writeOptionalVSize(tag: tag, len: val.count, elemSize: 2) { + write(val) } } } @@ -265,8 +266,8 @@ public extension OutputStream { func write(tag: Int32, value v: [Int32]?) { if let val = v { - if writeOptionalVSize(tag: tag, len: Int32(val.count), elemSize: 4) { - writeNumeric(tag, val) + if writeOptionalVSize(tag: tag, len: val.count, elemSize: 4) { + write(val) } } } @@ -288,8 +289,8 @@ public extension OutputStream { func write(tag: Int32, value v: [Int64]?) { if let val = v { - if writeOptionalVSize(tag: tag, len: Int32(val.count), elemSize: 8) { - writeNumeric(tag, val) + if writeOptionalVSize(tag: tag, len: val.count, elemSize: 8) { + write(val) } } } @@ -311,8 +312,8 @@ public extension OutputStream { func write(tag: Int32, value v: [Float]?) { if let val = v { - if writeOptionalVSize(tag: tag, len: Int32(val.count), elemSize: 4) { - writeNumeric(tag, val) + if writeOptionalVSize(tag: tag, len: val.count, elemSize: 4) { + write(val) } } } @@ -334,8 +335,8 @@ public extension OutputStream { func write(tag: Int32, value v: [Double]?) { if let val = v { - if writeOptionalVSize(tag: tag, len: Int32(val.count), elemSize: 8) { - writeNumeric(tag, val) + if writeOptionalVSize(tag: tag, len: val.count, elemSize: 8) { + write(val) } } } @@ -493,7 +494,7 @@ public extension OutputStream { return true } - func writeOptionalVSize(tag: Int32, len: Int32, elemSize: Int32) -> Bool { + func writeOptionalVSize(tag: Int32, len: Int, elemSize: Int) -> Bool { if writeOptional(tag: tag, format: OptionalFormat.VSize) { if len == 0 { write(size: 1) diff --git a/swift/src/Ice/ValueFactoryManagerI.swift b/swift/src/Ice/ValueFactoryManagerI.swift index 67b88bb4a24..e439324b9a8 100644 --- a/swift/src/Ice/ValueFactoryManagerI.swift +++ b/swift/src/Ice/ValueFactoryManagerI.swift @@ -8,6 +8,7 @@ // ********************************************************************** class ValueFactoryManagerI: ValueFactoryManager { + var factories = [String: ValueFactory]() var mutex = Mutex() |