summaryrefslogtreecommitdiff
path: root/swift/src/IceImpl/BlobjectFacade.mm
blob: 446535fdd301cfeef16d603f5c7893e70d513a7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#import "BlobjectFacade.h"
#import "ObjectAdapter.h"
#import "Convert.h"

#import "Connection.h"

void
BlobjectFacade::ice_invokeAsync(std::pair<const Byte*, const Byte*> inEncaps,
                                std::function<void(bool, const std::pair<const Byte*, const Byte*>&)> response,
                                std::function<void(std::exception_ptr)> error,
                                const Ice::Current& current)
{
    ICEBlobjectResponse responseCallback = ^(bool ok, const void* outParams, long count) {
        const Ice::Byte* start = static_cast<const Ice::Byte*>(outParams);
        response(ok, std::make_pair(start, start + static_cast<size_t>(count)));
    };

    ICEBlobjectException exceptionCallback = ^(ICERuntimeException* e) {
        error(convertException(e));
    };

    ICEObjectAdapter* adapter = [ICEObjectAdapter getHandle:current.adapter];
    ICEConnection* con = [ICEConnection getHandle:current.con];

    @autoreleasepool
    {
        [_facade facadeInvoke:adapter
                    inEncapsBytes:const_cast<Ice::Byte*>(inEncaps.first)
                    inEncapsCount:static_cast<long>(inEncaps.second - inEncaps.first)
                              con:con
                             name:toNSString(current.id.name) category:toNSString(current.id.category)
                            facet:toNSString(current.facet)
                        operation:toNSString(current.operation)
                             mode:static_cast<uint8_t>(current.mode)
                          context:toNSDictionary(current.ctx)
                        requestId:current.requestId
                    encodingMajor:current.encoding.major
                    encodingMinor:current.encoding.minor
                         response:responseCallback
                        exception:exceptionCallback];
    }
}