summaryrefslogtreecommitdiff
path: root/swift/src
diff options
context:
space:
mode:
Diffstat (limited to 'swift/src')
-rw-r--r--swift/src/Ice/InputStream.swift12
-rw-r--r--swift/src/Ice/Proxy.swift169
-rw-r--r--swift/src/IceObjc/BlobjectFacade.mm1
-rw-r--r--swift/src/IceObjc/InputStream.h24
-rw-r--r--swift/src/IceObjc/InputStream.mm30
-rw-r--r--swift/src/IceObjc/ObjectAdapter.mm1
-rw-r--r--swift/src/IceObjc/ObjectPrx.h15
-rw-r--r--swift/src/IceObjc/ObjectPrx.mm24
-rw-r--r--swift/src/IceObjc/module.map1
9 files changed, 133 insertions, 144 deletions
diff --git a/swift/src/Ice/InputStream.swift b/swift/src/Ice/InputStream.swift
index 4713ed4bb3e..aa35246ce8d 100644
--- a/swift/src/Ice/InputStream.swift
+++ b/swift/src/Ice/InputStream.swift
@@ -7,9 +7,7 @@ import IceObjc
public class InputStream {
// The underlying storage of an input stream can beeither:
// - Pointers to the C++ unmarshaling buffer (bytes not owned by Buffer)
- // - An ICEInputStream that holds a vector<Byte> (bytes not owned by Buffer)
// - A byte array passed and copied during initialization (bytes owned by Buffer)
- private var handle: ICEInputStream!
private var bytes: [UInt8]!
private var buf: Buffer // buf overlays the C++ unmarshal buffer stored in ICEInputStream or user buffer
@@ -48,16 +46,6 @@ public class InputStream {
classResolverPrefix = (communicator as! CommunicatorI).initData.classResolverPrefix
}
- init(communicator: Communicator, inputStream handle: ICEInputStream, encoding: EncodingVersion) {
- self.communicator = communicator
- self.encoding = encoding
- self.handle = handle
- buf = Buffer(start: handle.data(), count: handle.size())
- traceSlicing = communicator.getProperties().getPropertyAsIntWithDefault(key: "Ice.Trace.Slicing", value: 0) > 0
- classGraphDepthMax = (communicator as! CommunicatorI).classGraphDepthMax
- classResolverPrefix = (communicator as! CommunicatorI).initData.classResolverPrefix
- }
-
init(communicator: Communicator, start: UnsafeRawPointer, count: Int, encoding: EncodingVersion) {
self.communicator = communicator
self.encoding = encoding
diff --git a/swift/src/Ice/Proxy.swift b/swift/src/Ice/Proxy.swift
index f5af9ec191d..3c36a1ddd6e 100644
--- a/swift/src/Ice/Proxy.swift
+++ b/swift/src/Ice/Proxy.swift
@@ -192,17 +192,39 @@ public extension ObjectPrx {
mode: OperationMode,
inEncaps: [UInt8] = [],
context: Context? = nil) throws -> (ok: Bool, outEncaps: [UInt8]) {
- return try inEncaps.withUnsafeBufferPointer {
- var ok = Bool()
- let ins = try InputStream(communicator: _impl._communicator,
- inputStream: _impl._handle.iceInvoke(operation,
- mode: mode.rawValue,
- inParams: $0.baseAddress,
- inSize: inEncaps.count,
- context: context,
- returnValue: &ok),
- encoding: _impl._encoding)
- return _impl._isTwoway ? (ok, try ins.readEncapsulation().bytes) : (ok, [UInt8]())
+ return try inEncaps.withUnsafeBufferPointer { b in
+ if self._impl._isTwoway {
+ let p = Promise<(ok: Bool, outEncaps: [UInt8])> { seal in
+ try _impl._handle.iceInvokeAsync(operation,
+ mode: Int(mode.rawValue),
+ inParams: b.baseAddress,
+ inSize: inEncaps.count,
+ context: context,
+ response: { ok, start, count in
+ do {
+ let istr = InputStream(communicator: self._impl._communicator,
+ start: start,
+ count: count,
+ encoding: self._impl._encoding)
+ seal.fulfill((ok, try istr.readEncapsulation().bytes))
+ } catch {
+ seal.reject(error)
+ }
+ },
+ exception: { error in
+ seal.reject(error)
+ },
+ sent: nil)
+ }
+ return try p.wait()
+ } else {
+ try _impl._handle.iceOnewayInvoke(operation,
+ mode: mode.rawValue,
+ inParams: b.baseAddress,
+ inSize: inEncaps.count,
+ context: context)
+ return (true, [UInt8]())
+ }
}
}
@@ -215,7 +237,7 @@ public extension ObjectPrx {
sentFlags: DispatchWorkItemFlags? = nil) -> Promise<(ok: Bool, outEncaps: [UInt8])> {
return inEncaps.withUnsafeBufferPointer { b in
if self._impl._isTwoway {
- return Promise<(ok: Bool, outEncaps: [UInt8])> { p in
+ return Promise<(ok: Bool, outEncaps: [UInt8])> { seal in
try _impl._handle.iceInvokeAsync(operation,
mode: Int(mode.rawValue),
inParams: b.baseAddress,
@@ -227,13 +249,13 @@ public extension ObjectPrx {
start: start,
count: count,
encoding: self._impl._encoding)
- p.fulfill((ok, try istr.readEncapsulation().bytes))
+ seal.fulfill((ok, try istr.readEncapsulation().bytes))
} catch {
- p.reject(error)
+ seal.reject(error)
}
},
exception: { error in
- p.reject(error)
+ seal.reject(error)
},
sent: createSentCallback(sent: sent,
sentOn: sentOn,
@@ -241,7 +263,7 @@ public extension ObjectPrx {
}
} else {
let sentCB = createSentCallback(sent: sent, sentOn: sentOn, sentFlags: sentFlags)
- return Promise<(ok: Bool, outEncaps: [UInt8])> { p in
+ return Promise<(ok: Bool, outEncaps: [UInt8])> { seal in
try _impl._handle.iceInvokeAsync(operation,
mode: Int(mode.rawValue),
inParams: b.baseAddress,
@@ -251,10 +273,10 @@ public extension ObjectPrx {
precondition(false)
},
exception: { error in
- p.reject(error)
+ seal.reject(error)
},
sent: {
- p.fulfill((true, []))
+ seal.fulfill((true, []))
if let sentCB = sentCB {
sentCB($0)
}
@@ -724,20 +746,42 @@ open class _ObjectPrxI: ObjectPrx {
write(ostr)
ostr.endEncapsulation()
}
- var ok = Bool()
- let istrHandle = try _handle.iceInvoke(operation,
- mode: mode.rawValue,
- inParams: ostr.getConstBytes(),
- inSize: ostr.getCount(),
- context: context,
- returnValue: &ok)
if _isTwoway {
- let istr = InputStream(communicator: _communicator, inputStream: istrHandle, encoding: _encoding)
- if ok == false {
- try _throwUserException(istr: istr, userException: userException)
+ let p = Promise<Void> { seal in
+ try _handle.iceInvokeAsync(operation,
+ mode: Int(mode.rawValue),
+ inParams: ostr.getBytes(),
+ inSize: ostr.getCount(),
+ context: context,
+ response: { ok, start, count in
+ do {
+ let istr = InputStream(communicator: self._communicator,
+ start: start,
+ count: count,
+ encoding: self._encoding)
+ if ok == false {
+ try self._throwUserException(istr: istr,
+ userException: userException)
+ }
+ _ = try istr.skipEmptyEncapsulation()
+ seal.fulfill(())
+ } catch {
+ seal.reject(error)
+ }
+ },
+ exception: { error in
+ seal.reject(error)
+ },
+ sent: nil)
}
- _ = try istr.skipEmptyEncapsulation()
+ try p.wait()
+ } else {
+ try _impl._handle.iceOnewayInvoke(operation,
+ mode: mode.rawValue,
+ inParams: ostr.getBytes(),
+ inSize: ostr.getCount(),
+ context: context)
}
}
@@ -745,7 +789,7 @@ open class _ObjectPrxI: ObjectPrx {
mode: OperationMode,
format: FormatType = FormatType.DefaultFormat,
write: ((OutputStream) -> Void)? = nil,
- read: (InputStream) throws -> T,
+ read: @escaping (InputStream) throws -> T,
userException: ((UserException) throws -> Void)? = nil,
context: Context? = nil) throws -> T {
if !_isTwoway {
@@ -758,21 +802,36 @@ open class _ObjectPrxI: ObjectPrx {
ostr.endEncapsulation()
}
- var ok = Bool()
- let istrHandle = try _handle.iceInvoke(operation,
- mode: mode.rawValue,
- inParams: ostr.getConstBytes(),
- inSize: ostr.getCount(),
- context: context,
- returnValue: &ok)
- let istr = InputStream(communicator: _communicator, inputStream: istrHandle, encoding: _encoding)
- if ok == false {
- try _throwUserException(istr: istr, userException: userException)
+ let p = Promise<T> { seal in
+ try _handle.iceInvokeAsync(operation,
+ mode: Int(mode.rawValue),
+ inParams: ostr.getBytes(),
+ inSize: ostr.getCount(),
+ context: context,
+ response: { ok, start, count in
+ do {
+ let istr = InputStream(communicator: self._communicator,
+ start: start,
+ count: count,
+ encoding: self._encoding)
+ if ok == false {
+ try self._throwUserException(istr: istr,
+ userException: userException)
+ }
+ _ = try istr.startEncapsulation()
+ let l = try read(istr)
+ try istr.endEncapsulation()
+ seal.fulfill(l)
+ } catch {
+ seal.reject(error)
+ }
+ },
+ exception: { error in
+ seal.reject(error)
+ },
+ sent: nil)
}
- _ = try istr.startEncapsulation()
- let l = try read(istr)
- try istr.endEncapsulation()
- return l
+ return try p.wait()
}
public func _invokeAsync(operation: String,
@@ -794,7 +853,7 @@ open class _ObjectPrxI: ObjectPrx {
ostr.endEncapsulation()
}
if _isTwoway {
- return Promise<Void> { p in
+ return Promise<Void> { seal in
try _handle.iceInvokeAsync(operation,
mode: Int(mode.rawValue),
inParams: ostr.getBytes(),
@@ -811,18 +870,18 @@ open class _ObjectPrxI: ObjectPrx {
userException: userException)
}
_ = try istr.skipEmptyEncapsulation()
- p.fulfill(())
+ seal.fulfill(())
} catch {
- p.reject(error)
+ seal.reject(error)
}
},
exception: { error in
- p.reject(error)
+ seal.reject(error)
},
sent: createSentCallback(sent: sent, sentOn: sentOn, sentFlags: sentFlags))
}
} else {
- return Promise<Void> { p in
+ return Promise<Void> { seal in
let sentCB = createSentCallback(sent: sent, sentOn: sentOn, sentFlags: sentFlags)
try _handle.iceInvokeAsync(operation,
mode: Int(mode.rawValue),
@@ -833,10 +892,10 @@ open class _ObjectPrxI: ObjectPrx {
precondition(false)
},
exception: { error in
- p.reject(error)
+ seal.reject(error)
},
sent: {
- p.fulfill(())
+ seal.fulfill(())
if let sentCB = sentCB {
sentCB($0)
}
@@ -864,7 +923,7 @@ open class _ObjectPrxI: ObjectPrx {
write(ostr)
ostr.endEncapsulation()
}
- return Promise<T> { p in
+ return Promise<T> { seal in
try _handle.iceInvokeAsync(operation,
mode: Int(mode.rawValue),
inParams: ostr.getBytes(),
@@ -883,13 +942,13 @@ open class _ObjectPrxI: ObjectPrx {
_ = try istr.startEncapsulation()
let l = try read(istr)
try istr.endEncapsulation()
- p.fulfill(l)
+ seal.fulfill(l)
} catch {
- p.reject(error)
+ seal.reject(error)
}
},
exception: { error in
- p.reject(error)
+ seal.reject(error)
},
sent: createSentCallback(sent: sent, sentOn: sentOn, sentFlags: sentFlags))
}
diff --git a/swift/src/IceObjc/BlobjectFacade.mm b/swift/src/IceObjc/BlobjectFacade.mm
index 43329ff3e71..52e44690f8e 100644
--- a/swift/src/IceObjc/BlobjectFacade.mm
+++ b/swift/src/IceObjc/BlobjectFacade.mm
@@ -6,7 +6,6 @@
#import "ObjectAdapter.h"
#import "Util.h"
-#import "InputStream.h"
#import "Connection.h"
void
diff --git a/swift/src/IceObjc/InputStream.h b/swift/src/IceObjc/InputStream.h
deleted file mode 100644
index 26dfbbefe76..00000000000
--- a/swift/src/IceObjc/InputStream.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Copyright (c) ZeroC, Inc. All rights reserved.
-//
-
-#import "Config.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface ICEInputStream : NSObject
--(instancetype) init ICE_SWIFT_UNAVAILABLE("ICEInputStream cannot be initialized from Swift");
--(void*) data;
--(size_t) size;
-@end
-
-#ifdef __cplusplus
-
-@interface ICEInputStream()
-@property (nonatomic, readonly) std::vector<Ice::Byte> bytes;
--(instancetype) initWithBytes:(std::vector<Ice::Byte>)bytes;
-@end
-
-#endif
-
-NS_ASSUME_NONNULL_END
diff --git a/swift/src/IceObjc/InputStream.mm b/swift/src/IceObjc/InputStream.mm
deleted file mode 100644
index 59215add38f..00000000000
--- a/swift/src/IceObjc/InputStream.mm
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// Copyright (c) ZeroC, Inc. All rights reserved.
-//
-
-#import "InputStream.h"
-
-@implementation ICEInputStream
-
--(instancetype) initWithBytes:(std::vector<Ice::Byte>)bytes;
-{
- self = [super init];
- if(!self)
- {
- return nil;
- }
- self->_bytes = std::move(bytes);
- return self;
-}
-
--(void*) data
-{
- return _bytes.data();
-}
-
--(size_t) size
-{
- return _bytes.size();
-}
-
-@end
diff --git a/swift/src/IceObjc/ObjectAdapter.mm b/swift/src/IceObjc/ObjectAdapter.mm
index c3008a2dcb6..867ae0521d3 100644
--- a/swift/src/IceObjc/ObjectAdapter.mm
+++ b/swift/src/IceObjc/ObjectAdapter.mm
@@ -6,7 +6,6 @@
#import "ObjectAdapter.h"
#import "Util.h"
#import "ObjectPrx.h"
-#import "InputStream.h"
#import "Connection.h"
#import "Communicator.h"
#import "BlobjectFacade.h"
diff --git a/swift/src/IceObjc/ObjectPrx.h b/swift/src/IceObjc/ObjectPrx.h
index 08da811b31a..77cc45ba6d6 100644
--- a/swift/src/IceObjc/ObjectPrx.h
+++ b/swift/src/IceObjc/ObjectPrx.h
@@ -94,13 +94,14 @@ NS_ASSUME_NONNULL_BEGIN
encodingMajor:(uint8_t)encodingMajor
encodingMinor:(uint8_t)encodingMinor;
--(nullable ICEInputStream*) iceInvoke:(NSString* _Nonnull)op
- mode:(uint8_t)mode
- inParams:(const void* _Null_unspecified)inParams
- inSize:(size_t)inSize
- context:(NSDictionary* _Nullable)context
- returnValue:(bool*)returnValue
- error:(NSError* _Nullable * _Nullable)error;
+
+// Sync invocation on oneway proxy
+-(BOOL) iceOnewayInvoke:(NSString* _Nonnull)op
+ mode:(uint8_t)mode
+ inParams:(const void* _Null_unspecified)inParams
+ inSize:(size_t)inSize
+ context:(NSDictionary* _Nullable)context
+ error:(NSError* _Nullable * _Nullable)error;
-(BOOL) iceInvokeAsync:(NSString* _Nonnull)op
mode:(NSInteger)mode
diff --git a/swift/src/IceObjc/ObjectPrx.mm b/swift/src/IceObjc/ObjectPrx.mm
index cd365a3e02d..67aa4b8766c 100644
--- a/swift/src/IceObjc/ObjectPrx.mm
+++ b/swift/src/IceObjc/ObjectPrx.mm
@@ -6,7 +6,6 @@
#import "Communicator.h"
#import "Connection.h"
-#import "InputStream.h"
#import "OutputStream.h"
#import "Util.h"
@@ -579,13 +578,12 @@ encodingMinor:(uint8_t)minor
[os copy:p.first count:[NSNumber numberWithInt:count]];
}
--(ICEInputStream*) iceInvoke:(NSString*)op
- mode:(uint8_t)mode
- inParams:(const void* _Null_unspecified)inParams
- inSize:(size_t)inSize
- context:(NSDictionary*)context
- returnValue:(bool*)returnValue
- error:(NSError**)error
+-(BOOL) iceOnewayInvoke:(NSString*)op
+ mode:(uint8_t)mode
+ inParams:(const void* _Null_unspecified)inParams
+ inSize:(size_t)inSize
+ context:(NSDictionary*)context
+ error:(NSError**)error
{
std::pair<const Ice::Byte*, const Ice::Byte*> params(0, 0);
params.first = reinterpret_cast<const Ice::Byte*>(inParams);
@@ -599,15 +597,15 @@ encodingMinor:(uint8_t)minor
fromNSDictionary(context, ctx);
}
- std::vector<Ice::Byte> v;
- *returnValue = _prx->ice_invoke(fromNSString(op), static_cast<Ice::OperationMode>(mode), params, v,
- context ? ctx : Ice::noExplicitContext);
- return [[ICEInputStream alloc] initWithBytes:std::move(v)];
+ std::vector<Ice::Byte> ignored;
+ _prx->ice_invoke(fromNSString(op), static_cast<Ice::OperationMode>(mode), params, ignored,
+ context ? ctx : Ice::noExplicitContext);
+ return YES;
}
catch(const std::exception& ex)
{
*error = convertException(ex);
- return nil;
+ return NO;
}
}
diff --git a/swift/src/IceObjc/module.map b/swift/src/IceObjc/module.map
index bac88a51243..daee52e09e4 100644
--- a/swift/src/IceObjc/module.map
+++ b/swift/src/IceObjc/module.map
@@ -8,7 +8,6 @@ module IceObjc {
header "Exception.h"
header "IceUtil.h"
header "ImplicitContext.h"
- header "InputStream.h"
header "LocalObject.h"
header "Logger.h"
header "ObjectAdapter.h"