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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
#include "testC.h"
#include "tao/CDR.h"
namespace
{
template<typename T>
int
marshal (TAO_OutputCDR &out, T const &t)
{
if (!(out << t))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot marshal\n"),
-1);
}
return 0;
}
template<typename T>
int
demarshal (TAO_InputCDR &in, T &t,
test::Enumeration wrong_disc,
test::Enumeration expect_disc)
{
if (!(in >> t))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot demarshal (test::Enumeration)\n"),
-1);
}
if (t._d () == wrong_disc || t._d () != expect_disc)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Demarshalled (test::Enumeration) _d=%d, wrong=%d, expected=%d\n",
t._d (), wrong_disc, expect_disc),
-1);
}
return 0;
}
template<typename T>
int
demarshal (TAO_InputCDR &in, T &t,
CORBA::Boolean wrong_disc,
CORBA::Boolean expect_disc)
{
if (!(in >> t))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot demarshal (CORBA::Boolean)\n"),
-1);
}
if (t._d () == wrong_disc || t._d () != expect_disc)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Demarshalled (CORBA::Boolean) _d=%d, wrong=%d, expected=%d\n",
t._d (), wrong_disc, expect_disc),
-1);
}
return 0;
}
template<typename T>
int
demarshal (TAO_InputCDR &in, T &t,
CORBA::Char wrong_disc,
CORBA::Char expect_disc)
{
if (!(in >> t))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot demarshal (CORBA::Char)\n"),
-1);
}
if (t._d () == wrong_disc || t._d () != expect_disc)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Demarshalled (CORBA::Char) _d=%d, wrong=%d, expected=%d\n",
t._d (), wrong_disc, expect_disc),
-1);
}
return 0;
}
template<typename T>
int
demarshal (TAO_InputCDR &in, T &t,
CORBA::Long wrong_disc,
CORBA::Long expect_disc)
{
if (!(in >> t))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot demarshal (CORBA::Long)\n"),
-1);
}
if (t._d () == wrong_disc || t._d () != expect_disc)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Demarshalled (CORBA::Long) _d=%d, wrong=%d, expected=%d\n",
t._d (), wrong_disc, expect_disc),
-1);
}
return 0;
}
}
int
ACE_TMAIN (int, ACE_TCHAR *[])
{
int error= 0;
try
{
// Marshal part.
TAO_OutputCDR cdr_out;
test::UnionAllCovered_EnumerationDiscriminant uac_ed_out;
// UnionAllCovered_EnumerationDiscriminant must have _default()
// despite it has cases for all possible
// values of enumeration. But since enumeration is just int it has
// much more values than those listed in IDL.
uac_ed_out._default ();
marshal (cdr_out, uac_ed_out);
test::UnionAllCovered_EnumerationDiscriminant uac_ed2_out;
uac_ed2_out._d (static_cast<test::Enumeration> (10));
marshal (cdr_out, uac_ed2_out);
test::UnionWithDefault_EnumerationDiscriminant uwd_ed_out;
uwd_ed_out._d (static_cast<test::Enumeration> (20));
marshal (cdr_out, uwd_ed_out);
test::UnionWithImplicitDefault_EnumerationDiscriminant uwid_ed_out;
uwid_ed_out._default ();
marshal (cdr_out, uwid_ed_out);
test::UnionWithImplicitDefault_EnumerationDiscriminant uwid_ed2_out;
uwid_ed2_out._d (static_cast<test::Enumeration> (30));
marshal (cdr_out, uwid_ed2_out);
test::UnionAllCovered_TypedefedEnumerationDiscriminant uac_ted_out;
// UnionAllCovered_TypedefedEnumerationDiscriminant must have _default()
// despite it has cases for all possible
// values of enumeration. But since enumeration is just int it has
// much more values than those listed in IDL.
uac_ted_out._default ();
marshal (cdr_out, uac_ted_out);
test::UnionAllCovered_TypedefedEnumerationDiscriminant uac_ted2_out;
uac_ted2_out._d (static_cast<test::Enumeration> (40));
marshal (cdr_out, uac_ted2_out);
test::UnionWithDefault_TypedefedEnumerationDiscriminant uwd_ted_out;
uwd_ted_out._d (static_cast<test::Enumeration> (50));
marshal (cdr_out, uwd_ted_out);
test::UnionWithImplicitDefault_TypedefedEnumerationDiscriminant uwid_ted_out;
uwid_ted_out._default ();
marshal (cdr_out, uwid_ted_out);
test::UnionWithImplicitDefault_TypedefedEnumerationDiscriminant uwid_ted2_out;
uwid_ted2_out._d (static_cast<test::Enumeration> (60));
marshal (cdr_out, uwid_ted2_out);
test::UnionAllCovered_BooleanDiscriminant uac_bd_out;
// uac_bd_out._default (); // no _default() since all labels are covered.
uac_bd_out._d (static_cast<CORBA::Boolean> (3));
marshal (cdr_out, uac_bd_out);
test::UnionAllCovered_BooleanDiscriminant uac_bd2_out;
uac_bd2_out._d (static_cast<CORBA::Boolean> (5));
marshal (cdr_out, uac_bd2_out);
test::UnionWithDefault_BooleanDiscriminant uwd_bd_out;
uwd_bd_out._d (static_cast<CORBA::Boolean> (7));
marshal (cdr_out, uwd_bd_out);
test::UnionWithImplicitDefault_BooleanDiscriminant uwid_bd_out;
uwid_bd_out._default ();
marshal (cdr_out, uwid_bd_out);
test::UnionWithImplicitDefault_BooleanDiscriminant uwid_bd2_out;
uwid_bd2_out._d (static_cast<CORBA::Boolean> (9));
marshal (cdr_out, uwid_bd2_out);
test::UnionAllCovered_CharDiscriminant uac_cd_out;
// uac_cd_out._default (); // no _default() since all labels are covered.
marshal (cdr_out, uac_cd_out);
test::UnionAllCovered_CharDiscriminant uac_cd2_out;
uac_cd2_out._d (100);
marshal (cdr_out, uac_cd2_out);
test::UnionWithDefault_CharDiscriminant uwd_cd_out;
uwd_cd_out._d (110);
marshal (cdr_out, uwd_cd_out);
test::UnionWithImplicitDefault_CharDiscriminant uwid_cd_out;
uwid_cd_out._default ();
marshal (cdr_out, uwid_cd_out);
test::UnionWithImplicitDefault_CharDiscriminant uwid_cd2_out;
uwid_cd2_out._d (120);
marshal (cdr_out, uwid_cd2_out);
test::UnionWithDefault_LongDiscriminant uwd_ld_out;
uwd_ld_out._d (1000);
marshal (cdr_out, uwd_ld_out);
test::UnionWithImplicitDefault_LongDiscriminant uwid_ld_out;
uwid_ld_out._default ();
marshal (cdr_out, uwid_ld_out);
test::UnionWithImplicitDefault_LongDiscriminant uwid_ld2_out;
uwid_ld2_out._d (2000);
marshal (cdr_out, uwid_ld2_out);
// Demarshal part.
TAO_InputCDR cdr_in (cdr_out);
test::UnionAllCovered_EnumerationDiscriminant uac_ed_in;
uac_ed_in._d (test::Enum1);
demarshal (cdr_in, uac_ed_in, test::Enum1, uac_ed_out._d ());
test::UnionAllCovered_EnumerationDiscriminant uac_ed2_in;
uac_ed2_in._d (test::Enum1);
demarshal (cdr_in, uac_ed2_in, test::Enum1, uac_ed2_out._d ());
test::UnionWithDefault_EnumerationDiscriminant uwd_ed_in;
uwd_ed_in._d (test::Enum1);
demarshal (cdr_in, uwd_ed_in, test::Enum1, uwd_ed_out._d ());
test::UnionWithImplicitDefault_EnumerationDiscriminant uwid_ed_in;
uwid_ed_in._d (test::Enum1);
demarshal (cdr_in, uwid_ed_in, test::Enum1, uwid_ed_out._d ());
test::UnionWithImplicitDefault_EnumerationDiscriminant uwid_ed2_in;
uwid_ed2_in._d (test::Enum1);
demarshal (cdr_in, uwid_ed2_in, test::Enum1, uwid_ed2_out._d ());
test::UnionAllCovered_TypedefedEnumerationDiscriminant uac_ted_in;
uac_ted_in._d (test::Enum1);
demarshal (cdr_in, uac_ted_in, test::Enum1, uac_ted_out._d ());
test::UnionAllCovered_TypedefedEnumerationDiscriminant uac_ted2_in;
uac_ted2_in._d (test::Enum1);
demarshal (cdr_in, uac_ted2_in, test::Enum1, uac_ted2_out._d ());
test::UnionWithDefault_TypedefedEnumerationDiscriminant uwd_ted_in;
uwd_ted_in._d (test::Enum1);
demarshal (cdr_in, uwd_ted_in, test::Enum1, uwd_ted_out._d ());
test::UnionWithImplicitDefault_TypedefedEnumerationDiscriminant uwid_ted_in;
uwid_ted_in._d (test::Enum1);
demarshal (cdr_in, uwid_ted_in, test::Enum1, uwid_ted_out._d ());
test::UnionWithImplicitDefault_TypedefedEnumerationDiscriminant uwid_ted2_in;
uwid_ted2_in._d (test::Enum1);
demarshal (cdr_in, uwid_ted2_in, test::Enum1, uwid_ted2_out._d ());
test::UnionAllCovered_BooleanDiscriminant uac_bd_in;
uac_bd_in._d (false);
demarshal (cdr_in, uac_bd_in, false, uac_bd_out._d ());
test::UnionAllCovered_BooleanDiscriminant uac_bd2_in;
uac_bd2_in._d (false);
demarshal (cdr_in, uac_bd2_in, false, uac_bd2_out._d ());
test::UnionWithDefault_BooleanDiscriminant uwd_bd_in;
uwd_bd_in._d (false);
demarshal (cdr_in, uwd_bd_in, false, uwd_bd_out._d ());
test::UnionWithImplicitDefault_BooleanDiscriminant uwid_bd_in;
uwid_bd_in._d (true);
demarshal (cdr_in, uwid_bd_in, true, uwid_bd_out._d ());
test::UnionWithImplicitDefault_BooleanDiscriminant uwid_bd2_in;
uwid_bd2_in._d (false);
demarshal (cdr_in, uwid_bd2_in, false, uwid_bd2_out._d ());
test::UnionAllCovered_CharDiscriminant uac_cd_in;
uac_cd_in._d ('a');
demarshal (cdr_in, uac_cd_in, 'a', uac_cd_out._d ());
test::UnionAllCovered_CharDiscriminant uac_cd2_in;
uac_cd2_in._d ('a');
demarshal (cdr_in, uac_cd2_in, 'a', uac_cd2_out._d ());
test::UnionWithDefault_CharDiscriminant uwd_cd_in;
uwd_cd_in._d ('\1');
demarshal (cdr_in, uwd_cd_in, '\1', uwd_cd_out._d ());
test::UnionWithImplicitDefault_CharDiscriminant uwid_cd_in;
uwid_cd_in._d ('\1');
demarshal (cdr_in, uwid_cd_in, '\1', uwid_cd_out._d ());
test::UnionWithImplicitDefault_CharDiscriminant uwid_cd2_in;
uwid_cd2_in._d ('\1');
demarshal (cdr_in, uwid_cd2_in, '\1', uwid_cd2_out._d ());
test::UnionWithDefault_LongDiscriminant uwd_ld_in;
uwd_ld_in._d (1);
demarshal (cdr_in, uwd_ld_in, 1, uwd_ld_out._d ());
test::UnionWithImplicitDefault_LongDiscriminant uwid_ld_in;
uwid_ld_in._d (1);
demarshal (cdr_in, uwid_ld_in, 1, uwid_ld_out._d ());
test::UnionWithImplicitDefault_LongDiscriminant uwid_ld2_in;
uwid_ld2_in._d (1);
demarshal (cdr_in, uwid_ld2_in, 1, uwid_ld2_out._d ());
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
error= 1;
}
return error;
}
|