diff options
author | Jose <jose@zeroc.com> | 2019-06-11 16:01:13 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-06-11 16:01:13 +0200 |
commit | 18ca5f7e1990ee8e79b69a864e146e25e18e7df9 (patch) | |
tree | c6a4967c2bf8cf9b66c6a7193359a2ad397e855a | |
parent | Missing throws clauses (diff) | |
download | ice-18ca5f7e1990ee8e79b69a864e146e25e18e7df9.tar.bz2 ice-18ca5f7e1990ee8e79b69a864e146e25e18e7df9.tar.xz ice-18ca5f7e1990ee8e79b69a864e146e25e18e7df9.zip |
Blobject dispatch fixes
-rw-r--r-- | swift/src/Ice/Blobject.swift | 15 | ||||
-rw-r--r-- | swift/src/Ice/BlobjectAsync.swift | 15 | ||||
-rw-r--r-- | swift/test/Ice/invoke/Server.swift | 4 | ||||
-rw-r--r-- | swift/test/Ice/objects/Collocated.swift | 2 | ||||
-rw-r--r-- | swift/test/Ice/objects/Server.swift | 3 |
5 files changed, 27 insertions, 12 deletions
diff --git a/swift/src/Ice/Blobject.swift b/swift/src/Ice/Blobject.swift index 23a3cf8ab0c..6aa7b4798c6 100644 --- a/swift/src/Ice/Blobject.swift +++ b/swift/src/Ice/Blobject.swift @@ -5,7 +5,7 @@ import Foundation /// Base protocol for dynamic dispatch servants. -public protocol Blobject: Disp { +public protocol Blobject { /// Dispatch an incoming request. /// /// - parameter inEncaps: `Data` - The encoded in-parameters for the operation. @@ -24,10 +24,17 @@ public protocol Blobject: Disp { func ice_invoke(inEncaps: Data, current: Current) throws -> (ok: Bool, outParams: Data) } -public extension Blobject { - func dispatch(incoming inS: Incoming, current: Current) throws { +public struct BlobjectDisp: Disp { + + public let servant: Blobject + + public init(_ servant: Blobject) { + self.servant = servant + } + + public func dispatch(incoming inS: Incoming, current: Current) throws { let inEncaps = try inS.readParamEncaps() - let invokeResult = try ice_invoke(inEncaps: inEncaps, current: current) + let invokeResult = try servant.ice_invoke(inEncaps: inEncaps, current: current) inS.writeParamEncaps(ok: invokeResult.ok, outParams: invokeResult.outParams) } } diff --git a/swift/src/Ice/BlobjectAsync.swift b/swift/src/Ice/BlobjectAsync.swift index 037c48d55cd..41ab0cae062 100644 --- a/swift/src/Ice/BlobjectAsync.swift +++ b/swift/src/Ice/BlobjectAsync.swift @@ -6,7 +6,7 @@ import Foundation import PromiseKit /// Base protocol for dynamic asynchronous dispatch servants. -public protocol BlobjectAsync: Disp { +public protocol BlobjectAsync { /// Dispatch an incoming request. /// /// - parameter inEncaps: `Data` - The encoded in-parameters for the operation. @@ -25,11 +25,18 @@ public protocol BlobjectAsync: Disp { func ice_invokeAsync(inEncaps: Data, current: Current) -> Promise<(ok: Bool, outParams: Data)> } -public extension BlobjectAsync { - func dispatch(incoming inS: Incoming, current: Current) throws { +public struct BlobjectAsyncDisp: Disp { + + public let servant: BlobjectAsync + + public init(_ servant: BlobjectAsync) { + self.servant = servant + } + + public func dispatch(incoming inS: Incoming, current: Current) throws { let inEncaps = try inS.readParamEncaps() firstly { - ice_invokeAsync(inEncaps: inEncaps, current: current) + self.servant.ice_invokeAsync(inEncaps: inEncaps, current: current) }.done(on: nil) { invokeResult in inS.writeParamEncaps(ok: invokeResult.ok, outParams: invokeResult.outParams) }.catch(on: nil) { err in diff --git a/swift/test/Ice/invoke/Server.swift b/swift/test/Ice/invoke/Server.swift index cd45bd97489..65aac7dbedd 100644 --- a/swift/test/Ice/invoke/Server.swift +++ b/swift/test/Ice/invoke/Server.swift @@ -11,9 +11,9 @@ class ServantLocatorI: Ice.ServantLocator { init (_ async: Bool) { if async { - _blobject = BlobjectAsyncI() + _blobject = Ice.BlobjectAsyncDisp(BlobjectAsyncI()) } else { - _blobject = BlobjectI() + _blobject = Ice.BlobjectDisp(BlobjectI()) } } diff --git a/swift/test/Ice/objects/Collocated.swift b/swift/test/Ice/objects/Collocated.swift index df0f0a75cd5..d5dec5c8cdd 100644 --- a/swift/test/Ice/objects/Collocated.swift +++ b/swift/test/Ice/objects/Collocated.swift @@ -30,7 +30,7 @@ class Collocated: TestHelperI { value: getTestEndpoint(num: 0)) let adapter = try communicator.createObjectAdapter("TestAdapter") try adapter.add(servant: InitialDisp(InitialI(adapter)), id: Ice.stringToIdentity("initial")) - try adapter.add(servant: UnexpectedObjectExceptionTestI(), + try adapter.add(servant: BlobjectDisp(UnexpectedObjectExceptionTestI()), id: Ice.stringToIdentity("uoet")) try adapter.activate() diff --git a/swift/test/Ice/objects/Server.swift b/swift/test/Ice/objects/Server.swift index dbff74b4d7f..85477fe85ed 100644 --- a/swift/test/Ice/objects/Server.swift +++ b/swift/test/Ice/objects/Server.swift @@ -24,7 +24,8 @@ class Server: TestHelperI { communicator.getProperties().setProperty(key: "TestAdapter.Endpoints", value: getTestEndpoint(num: 0)) let adapter = try communicator.createObjectAdapter("TestAdapter") try adapter.add(servant: InitialDisp(InitialI(adapter)), id: Ice.stringToIdentity("initial")) - try adapter.add(servant: UnexpectedObjectExceptionTestI(), id: Ice.stringToIdentity("uoet")) + try adapter.add(servant: BlobjectDisp(UnexpectedObjectExceptionTestI()), + id: Ice.stringToIdentity("uoet")) try adapter.activate() serverReady() communicator.waitForShutdown() |