blob: f9a3e131999719a860426b3a4b576bc17a5f6f5b (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#import <objc/Ice.h>
#import <TestCommon.h>
#import <OperationsTest.h>
#import <Foundation/Foundation.h>
@interface OnewayNewAMICallback : NSObject
{
BOOL called;
NSCondition* cond;
}
-(void) check;
-(void) called;
@end
@implementation OnewayNewAMICallback
-(id) init
{
self = [super init];
if(!self)
{
return nil;
}
cond = [[NSCondition alloc] init];
return self;
}
+(id) create
{
return ICE_AUTORELEASE([[OnewayNewAMICallback alloc] init]);
}
#if defined(__clang__) && !__has_feature(objc_arc)
-(void) dealloc
{
[cond release];
[super dealloc];
}
#endif
-(void) check
{
[cond lock];
while(!called)
{
[cond wait];
}
called = NO;
[cond unlock];
}
-(void) called
{
[cond lock];
called = YES;
[cond signal];
[cond unlock];
}
-(void) opVoidResponse
{
[self called];
}
-(void) opVoidException:(ICEException*)ex
{
test(NO);
}
-(void) opVoidExResponse
{
test(NO);
}
-(void) opVoidExException:(ICEException*)ex
{
test([ex isKindOfClass:[ICENoEndpointException class]]);
[self called];
}
-(void) opByteExResponse
{
test(NO);
}
-(void) opByteEx:(ICEException*)ex
{
test(NO);
}
-(void) opByteExException:(ICEException*)ex
{
test([ex isKindOfClass:[ICETwowayOnlyException class]]);
[self called];
}
@end
void
onewaysNewAMI(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> proxy)
{
id<TestOperationsMyClassPrx> p = [TestOperationsMyClassPrx uncheckedCast:[proxy ice_oneway]];
{
OnewayNewAMICallback* cb = [OnewayNewAMICallback create];
[p begin_opVoid:^() { [cb opVoidResponse]; } exception:^(ICEException* ex) { [cb opVoidException:ex]; }];
}
{
OnewayNewAMICallback* cb = [OnewayNewAMICallback create];
@try
{
[p begin_opByte:0 p2:0 response:^(ICEByte r, ICEByte p3) { [cb opByteExResponse]; } exception:^(ICEException* ex) { [cb opByteExException:ex]; }];
[cb check];
}
@catch(NSException* ex)
{
test([ex name] == NSInvalidArgumentException);
}
}
}
|