1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4
5 #include <TestAMDI.h>
6 #include <Ice/Ice.h>
7 #include <TestHelper.h>
8
9 using namespace Test;
10 using namespace std;
11
TestI()12 TestI::TestI()
13 {
14 }
15
16 #ifdef ICE_CPP11_MAPPING
17
18 void
SBaseAsObjectAsync(function<void (const shared_ptr<Ice::Value> &)> response,function<void (exception_ptr)>,const::Ice::Current &)19 TestI::SBaseAsObjectAsync(function<void(const shared_ptr<Ice::Value>&)> response,
20 function<void(exception_ptr)>,
21 const ::Ice::Current&)
22 {
23 auto sb = make_shared<SBase>();
24 sb->sb = "SBase.sb";
25 response(sb);
26 }
27
28 void
SBaseAsSBaseAsync(function<void (const shared_ptr<Test::SBase> &)> response,function<void (exception_ptr)>,const::Ice::Current &)29 TestI::SBaseAsSBaseAsync(function<void(const shared_ptr<Test::SBase>&)> response,
30 function<void(exception_ptr)>,
31 const ::Ice::Current&)
32 {
33 auto sb = make_shared<SBase>();
34 sb->sb = "SBase.sb";
35 response(sb);
36 }
37
38 void
SBSKnownDerivedAsSBaseAsync(function<void (const shared_ptr<Test::SBase> &)> response,function<void (exception_ptr)>,const::Ice::Current &)39 TestI::SBSKnownDerivedAsSBaseAsync(function<void(const shared_ptr<Test::SBase>&)> response,
40 function<void(exception_ptr)>,
41 const ::Ice::Current&)
42 {
43 auto sbskd = make_shared<SBSKnownDerived>();
44 sbskd->sb = "SBSKnownDerived.sb";
45 sbskd->sbskd = "SBSKnownDerived.sbskd";
46 response(sbskd);
47 }
48
49 void
SBSKnownDerivedAsSBSKnownDerivedAsync(function<void (const shared_ptr<Test::SBSKnownDerived> &)> response,function<void (exception_ptr)>,const::Ice::Current &)50 TestI::SBSKnownDerivedAsSBSKnownDerivedAsync(function<void(const shared_ptr<Test::SBSKnownDerived>&)> response,
51 function<void(exception_ptr)>,
52 const ::Ice::Current&)
53 {
54 auto sbskd = make_shared<SBSKnownDerived>();
55 sbskd->sb = "SBSKnownDerived.sb";
56 sbskd->sbskd = "SBSKnownDerived.sbskd";
57 response(sbskd);
58 }
59
60 void
SBSUnknownDerivedAsSBaseAsync(function<void (const shared_ptr<Test::SBase> &)> response,function<void (exception_ptr)>,const::Ice::Current &)61 TestI::SBSUnknownDerivedAsSBaseAsync(function<void(const shared_ptr<Test::SBase>&)> response,
62 function<void(exception_ptr)>,
63 const ::Ice::Current&)
64 {
65 auto sbsud = make_shared<SBSUnknownDerived>();
66 sbsud->sb = "SBSUnknownDerived.sb";
67 sbsud->sbsud = "SBSUnknownDerived.sbsud";
68 response(sbsud);
69 }
70
71 void
SBSUnknownDerivedAsSBaseCompactAsync(function<void (const shared_ptr<Test::SBase> &)> response,function<void (exception_ptr)>,const::Ice::Current &)72 TestI::SBSUnknownDerivedAsSBaseCompactAsync(function<void(const shared_ptr<Test::SBase>&)> response,
73 function<void(exception_ptr)>,
74 const ::Ice::Current&)
75 {
76 auto sbsud = make_shared<SBSUnknownDerived>();
77 sbsud->sb = "SBSUnknownDerived.sb";
78 sbsud->sbsud = "SBSUnknownDerived.sbsud";
79 response(sbsud);
80 }
81
82 void
SUnknownAsObjectAsync(function<void (const shared_ptr<Ice::Value> &)> response,function<void (exception_ptr)>,const::Ice::Current &)83 TestI::SUnknownAsObjectAsync(function<void(const shared_ptr<Ice::Value>&)> response,
84 function<void(exception_ptr)>,
85 const ::Ice::Current&)
86 {
87 auto su = make_shared<SUnknown>();
88 su->su = "SUnknown.su";
89 su->cycle = su;
90 response(su);
91 }
92
93 void
checkSUnknownAsync(Ice::ValuePtr obj,function<void ()> response,function<void (exception_ptr)>,const::Ice::Current & current)94 TestI::checkSUnknownAsync(Ice::ValuePtr obj,
95 function<void()> response,
96 function<void(exception_ptr)>,
97 const ::Ice::Current& current)
98 {
99 auto su = dynamic_pointer_cast<SUnknown>(obj);
100 if(current.encoding == Ice::Encoding_1_0)
101 {
102 test(!su);
103 }
104 else
105 {
106 test(su);
107 test(su->su == "SUnknown.su");
108 }
109 response();
110 }
111
112 void
oneElementCycleAsync(function<void (const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)113 TestI::oneElementCycleAsync(function<void(const shared_ptr<Test::B>&)> response,
114 function<void(exception_ptr)>,
115 const ::Ice::Current&)
116 {
117 auto b = make_shared<B>();
118 b->sb = "B1.sb";
119 b->pb = b;
120 response(b);
121 }
122
123 void
twoElementCycleAsync(function<void (const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)124 TestI::twoElementCycleAsync(function<void(const shared_ptr<Test::B>&)> response,
125 function<void(exception_ptr)>,
126 const ::Ice::Current&)
127 {
128 auto b1 = make_shared<B>();
129 b1->sb = "B1.sb";
130 auto b2 = make_shared<B>();
131 b2->sb = "B2.sb";
132 b2->pb = b1;
133 b1->pb = b2;
134 response(b1);
135 }
136
137 void
D1AsBAsync(function<void (const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)138 TestI::D1AsBAsync(function<void(const shared_ptr<Test::B>&)> response,
139 function<void(exception_ptr)>,
140 const ::Ice::Current&)
141 {
142 auto d1 = make_shared<D1>();
143 d1->sb = "D1.sb";
144 d1->sd1 = "D1.sd1";
145 auto d2 = make_shared<D2>();
146 d2->pb = d1;
147 d2->sb = "D2.sb";
148 d2->sd2 = "D2.sd2";
149 d2->pd2 = d1;
150 d1->pb = d2;
151 d1->pd1 = d2;
152 response(d1);
153 }
154
155 void
D1AsD1Async(function<void (const shared_ptr<Test::D1> &)> response,function<void (exception_ptr)>,const::Ice::Current &)156 TestI::D1AsD1Async(function<void(const shared_ptr<Test::D1>&)> response,
157 function<void(exception_ptr)>,
158 const ::Ice::Current&)
159 {
160 auto d1 = make_shared<D1>();
161 d1->sb = "D1.sb";
162 d1->sd1 = "D1.sd1";
163 auto d2 = make_shared<D2>();
164 d2->pb = d1;
165 d2->sb = "D2.sb";
166 d2->sd2 = "D2.sd2";
167 d2->pd2 = d1;
168 d1->pb = d2;
169 d1->pd1 = d2;
170 response(d1);
171 }
172
173 void
D2AsBAsync(function<void (const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)174 TestI::D2AsBAsync(function<void(const shared_ptr<Test::B>&)> response,
175 function<void(exception_ptr)>,
176 const ::Ice::Current&)
177 {
178 auto d2 = make_shared<D2>();
179 d2->sb = "D2.sb";
180 d2->sd2 = "D2.sd2";
181 auto d1 = make_shared<D1>();
182 d1->pb = d2;
183 d1->sb = "D1.sb";
184 d1->sd1 = "D1.sd1";
185 d1->pd1 = d2;
186 d2->pb = d1;
187 d2->pd2 = d1;
188 response(d2);
189 }
190
191 void
paramTest1Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)192 TestI::paramTest1Async(function<void(const shared_ptr<Test::B>&,
193 const shared_ptr<Test::B>&)> response,
194 function<void(exception_ptr)>,
195 const ::Ice::Current&)
196 {
197 auto d1 = make_shared<D1>();
198 d1->sb = "D1.sb";
199 d1->sd1 = "D1.sd1";
200 D2Ptr d2 = make_shared<D2>();
201 d2->pb = d1;
202 d2->sb = "D2.sb";
203 d2->sd2 = "D2.sd2";
204 d2->pd2 = d1;
205 d1->pb = d2;
206 d1->pd1 = d2;
207 response(d1, d2);
208 }
209
210 void
paramTest2Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)211 TestI::paramTest2Async(function<void(const shared_ptr<Test::B>&, const shared_ptr<Test::B>&)> response,
212 function<void(exception_ptr)>,
213 const ::Ice::Current&)
214 {
215 auto d1 = make_shared<D1>();
216 d1->sb = "D1.sb";
217 d1->sd1 = "D1.sd1";
218 auto d2 = make_shared<D2>();
219 d2->pb = d1;
220 d2->sb = "D2.sb";
221 d2->sd2 = "D2.sd2";
222 d2->pd2 = d1;
223 d1->pb = d2;
224 d1->pd1 = d2;
225 response(d2, d1);
226 }
227
228 void
paramTest3Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)229 TestI::paramTest3Async(function<void(const shared_ptr<Test::B>&,
230 const shared_ptr<Test::B>&,
231 const shared_ptr<Test::B>&)> response,
232 function<void(exception_ptr)>,
233 const ::Ice::Current&)
234 {
235 auto d2 = make_shared<D2>();
236 d2->sb = "D2.sb (p1 1)";
237 d2->pb = nullptr;
238 d2->sd2 = "D2.sd2 (p1 1)";
239
240 auto d1 = make_shared<D1>();
241 d1->sb = "D1.sb (p1 2)";
242 d1->pb = nullptr;
243 d1->sd1 = "D1.sd2 (p1 2)";
244 d1->pd1 = nullptr;
245 d2->pd2 = d1;
246
247 auto d4 = make_shared<D2>();
248 d4->sb = "D2.sb (p2 1)";
249 d4->pb = nullptr;
250 d4->sd2 = "D2.sd2 (p2 1)";
251
252 auto d3 = make_shared<D1>();
253 d3->sb = "D1.sb (p2 2)";
254 d3->pb = nullptr;
255 d3->sd1 = "D1.sd2 (p2 2)";
256 d3->pd1 = nullptr;
257 d4->pd2 = d3;
258
259 response(d3, d2, d4);
260 }
261
262 void
paramTest4Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)263 TestI::paramTest4Async(function<void(const shared_ptr<Test::B>&,
264 const shared_ptr<Test::B>&)> response,
265 function<void(exception_ptr)>,
266 const ::Ice::Current&)
267 {
268 auto d4 = make_shared<D4>();
269 d4->sb = "D4.sb (1)";
270 d4->pb = nullptr;
271 d4->p1 = make_shared<B>();
272 d4->p1->sb = "B.sb (1)";
273 d4->p2 = make_shared<B>();
274 d4->p2->sb = "B.sb (2)";
275 response(d4->p2, d4);
276 }
277
278 void
returnTest1Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)279 TestI::returnTest1Async(function<void(const shared_ptr<Test::B>&,
280 const shared_ptr<Test::B>&,
281 const shared_ptr<Test::B>&)> response,
282 function<void(exception_ptr)>,
283 const ::Ice::Current&)
284 {
285 auto d1 = make_shared<D1>();
286 d1->sb = "D1.sb";
287 d1->sd1 = "D1.sd1";
288 auto d2 = make_shared<D2>();
289 d2->pb = d1;
290 d2->sb = "D2.sb";
291 d2->sd2 = "D2.sd2";
292 d2->pd2 = d1;
293 d1->pb = d2;
294 d1->pd1 = d2;
295 response(d2, d2, d1);
296 }
297
298 void
returnTest2Async(function<void (const shared_ptr<Test::B> &,const shared_ptr<Test::B> &,const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)299 TestI::returnTest2Async(function<void(const shared_ptr<Test::B>&,
300 const shared_ptr<Test::B>&,
301 const shared_ptr<Test::B>&)> response,
302 function<void(exception_ptr)>,
303 const ::Ice::Current&)
304 {
305 auto d1 = make_shared<D1>();
306 d1->sb = "D1.sb";
307 d1->sd1 = "D1.sd1";
308 auto d2 = make_shared<D2>();
309 d2->pb = d1;
310 d2->sb = "D2.sb";
311 d2->sd2 = "D2.sd2";
312 d2->pd2 = d1;
313 d1->pb = d2;
314 d1->pd1 = d2;
315 response(d1, d1, d2);
316 }
317
318 void
returnTest3Async(shared_ptr<::Test::B> p1,shared_ptr<::Test::B>,function<void (const shared_ptr<Test::B> &)> response,function<void (exception_ptr)>,const::Ice::Current &)319 TestI::returnTest3Async(shared_ptr<::Test::B> p1,
320 shared_ptr<::Test::B>,
321 function<void(const shared_ptr<Test::B>&)> response,
322 function<void(exception_ptr)>,
323 const ::Ice::Current&)
324 {
325 response(p1);
326 }
327
328 void
sequenceTestAsync(shared_ptr<::Test::SS1> p1,shared_ptr<::Test::SS2> p2,function<void (const::Test::SS3 &)> response,function<void (exception_ptr)>,const::Ice::Current &)329 TestI::sequenceTestAsync(shared_ptr<::Test::SS1> p1,
330 shared_ptr<::Test::SS2> p2,
331 function<void(const ::Test::SS3&)> response,
332 function<void(exception_ptr)>,
333 const ::Ice::Current&)
334 {
335 SS3 ss;
336 ss.c1 = move(p1);
337 ss.c2 = move(p2);
338 response(ss);
339 }
340
341 void
dictionaryTestAsync(Test::BDict bin,function<void (const::Test::BDict &,const::Test::BDict &)> response,function<void (exception_ptr)>,const::Ice::Current &)342 TestI::dictionaryTestAsync(Test::BDict bin,
343 function<void(const ::Test::BDict&, const ::Test::BDict&)> response,
344 function<void(exception_ptr)>,
345 const ::Ice::Current&)
346 {
347 BDict bout;
348 int i;
349 for(i = 0; i < 10; ++i)
350 {
351 auto b = bin.find(i)->second;
352 auto d2 = make_shared<D2>();
353 d2->sb = b->sb;
354 d2->pb = b->pb;
355 d2->sd2 = "D2";
356 d2->pd2 = d2;
357 bout[i * 10] = d2;
358 }
359 BDict r;
360 for(i = 0; i < 10; ++i)
361 {
362 std::ostringstream s;
363 s << "D1." << i * 20;
364 auto d1 = make_shared<D1>();
365 d1->sb = s.str();
366 d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second);
367 d1->sd1 = s.str();
368 d1->pd1 = d1;
369 r[i * 20] = d1;
370 }
371 response(r, bout);
372 }
373
374 void
exchangePBaseAsync(shared_ptr<::Test::PBase> pb,function<void (const shared_ptr<::Test::PBase> &)> response,function<void (exception_ptr)>,const::Ice::Current &)375 TestI::exchangePBaseAsync(shared_ptr<::Test::PBase> pb,
376 function<void(const shared_ptr<::Test::PBase>&)> response,
377 function<void(exception_ptr)>,
378 const ::Ice::Current&)
379 {
380 response(pb);
381 }
382
383 void
PBSUnknownAsPreservedAsync(function<void (const shared_ptr<::Test::Preserved> &)> response,function<void (exception_ptr)>,const::Ice::Current & current)384 TestI::PBSUnknownAsPreservedAsync(function<void(const shared_ptr<::Test::Preserved>&)> response,
385 function<void(exception_ptr)>,
386 const ::Ice::Current& current)
387 {
388 auto r = make_shared<PSUnknown>();
389 r->pi = 5;
390 r->ps = "preserved";
391 r->psu = "unknown";
392 r->graph = nullptr;
393 if(current.encoding != Ice::Encoding_1_0)
394 {
395 //
396 // 1.0 encoding doesn't support unmarshaling unknown classes even if referenced
397 // from unread slice.
398 //
399 r->cl = make_shared<MyClass>(15);
400 }
401 response(r);
402 }
403
404 void
checkPBSUnknownAsync(shared_ptr<::Test::Preserved> p,function<void ()> response,function<void (exception_ptr)>,const::Ice::Current & current)405 TestI::checkPBSUnknownAsync(shared_ptr<::Test::Preserved> p,
406 function<void()> response,
407 function<void(exception_ptr)>,
408 const ::Ice::Current& current)
409 {
410 auto pu = dynamic_pointer_cast<PSUnknown>(p);
411 if(current.encoding == Ice::Encoding_1_0)
412 {
413 test(!pu);
414 test(p->pi == 5);
415 test(p->ps == "preserved");
416 }
417 else
418 {
419 test(pu);
420 test(pu->pi == 5);
421 test(pu->ps == "preserved");
422 test(pu->psu == "unknown");
423 test(!pu->graph);
424 test(pu->cl && pu->cl->i == 15);
425 }
426 response();
427 }
428
429 void
PBSUnknownAsPreservedWithGraphAsync(function<void (const shared_ptr<::Test::Preserved> &)> response,function<void (exception_ptr)>,const::Ice::Current &)430 TestI::PBSUnknownAsPreservedWithGraphAsync(function<void(const shared_ptr<::Test::Preserved>&)> response,
431 function<void(exception_ptr)>,
432 const ::Ice::Current&)
433 {
434 auto r = make_shared<PSUnknown>();
435 r->pi = 5;
436 r->ps = "preserved";
437 r->psu = "unknown";
438 r->graph = make_shared<PNode>();
439 r->graph->next = make_shared<PNode>();
440 r->graph->next->next = make_shared<PNode>();
441 r->graph->next->next->next = r->graph;
442 response(r);
443 r->graph->next->next->next = nullptr; // Break the cycle.
444 }
445
446 void
checkPBSUnknownWithGraphAsync(shared_ptr<::Test::Preserved> p,function<void ()> response,function<void (exception_ptr)>,const::Ice::Current & current)447 TestI::checkPBSUnknownWithGraphAsync(shared_ptr<::Test::Preserved> p,
448 function<void()> response,
449 function<void(exception_ptr)>,
450 const ::Ice::Current& current)
451 {
452 auto pu = dynamic_pointer_cast<PSUnknown>(p);
453 if(current.encoding == Ice::Encoding_1_0)
454 {
455 test(!pu);
456 test(p->pi == 5);
457 test(p->ps == "preserved");
458 }
459 else
460 {
461 test(pu);
462 test(pu->pi == 5);
463 test(pu->ps == "preserved");
464 test(pu->psu == "unknown");
465 test(pu->graph != pu->graph->next);
466 test(pu->graph->next != pu->graph->next->next);
467 test(pu->graph->next->next->next == pu->graph);
468 pu->graph->next->next->next = nullptr; // Break the cycle.
469 }
470 response();
471 }
472
473 void
PBSUnknown2AsPreservedWithGraphAsync(function<void (const shared_ptr<::Test::Preserved> &)> response,function<void (exception_ptr)>,const::Ice::Current &)474 TestI::PBSUnknown2AsPreservedWithGraphAsync(function<void(const shared_ptr<::Test::Preserved>&)> response,
475 function<void(exception_ptr)>,
476 const ::Ice::Current&)
477 {
478 auto r = make_shared<PSUnknown2>();
479 r->pi = 5;
480 r->ps = "preserved";
481 r->pb = r;
482 response(r);
483 r->pb = nullptr; // Break the cycle.
484 }
485
486 void
checkPBSUnknown2WithGraphAsync(shared_ptr<::Test::Preserved> p,function<void ()> response,function<void (exception_ptr)>,const::Ice::Current & current)487 TestI::checkPBSUnknown2WithGraphAsync(shared_ptr<::Test::Preserved> p,
488 function<void()> response,
489 function<void(exception_ptr)>,
490 const ::Ice::Current& current)
491 {
492 auto pu = dynamic_pointer_cast<PSUnknown2>(p);
493 if(current.encoding == Ice::Encoding_1_0)
494 {
495 test(!pu);
496 test(p->pi == 5);
497 test(p->ps == "preserved");
498 }
499 else
500 {
501 test(pu);
502 test(pu->pi == 5);
503 test(pu->ps == "preserved");
504 test(pu->pb == pu);
505 pu->pb = nullptr; // Break the cycle.
506 }
507 response();
508 }
509
510 void
exchangePNodeAsync(shared_ptr<::Test::PNode> pn,function<void (const shared_ptr<::Test::PNode> &)> response,function<void (exception_ptr)>,const::Ice::Current &)511 TestI::exchangePNodeAsync(shared_ptr<::Test::PNode> pn,
512 function<void(const shared_ptr<::Test::PNode>&)> response,
513 function<void(exception_ptr)>,
514 const ::Ice::Current&)
515 {
516 response(pn);
517 }
518
519 void
throwBaseAsBaseAsync(function<void ()>,function<void (exception_ptr)> exception,const::Ice::Current &)520 TestI::throwBaseAsBaseAsync(function<void()>,
521 function<void(exception_ptr)> exception,
522 const ::Ice::Current&)
523 {
524 try
525 {
526 BaseException be;
527 be.sbe = "sbe";
528 be.pb = make_shared<B>();
529 be.pb->sb = "sb";
530 be.pb->pb = be.pb;
531 throw be;
532 }
533 catch(...)
534 {
535 exception(current_exception());
536 }
537 }
538
539 void
throwDerivedAsBaseAsync(function<void ()>,function<void (exception_ptr)> exception,const::Ice::Current &)540 TestI::throwDerivedAsBaseAsync(function<void()>,
541 function<void(exception_ptr)> exception,
542 const ::Ice::Current&)
543 {
544 try
545 {
546 DerivedException de;
547 de.sbe = "sbe";
548 de.pb = make_shared<B>();
549 de.pb->sb = "sb1";
550 de.pb->pb = de.pb;
551 de.sde = "sde1";
552 de.pd1 = make_shared<D1>();
553 de.pd1->sb = "sb2";
554 de.pd1->pb = de.pd1;
555 de.pd1->sd1 = "sd2";
556 de.pd1->pd1 = de.pd1;
557 throw de;
558 }
559 catch(...)
560 {
561 exception(current_exception());
562 }
563 }
564
565 void
throwDerivedAsDerivedAsync(function<void ()>,function<void (exception_ptr)> exception,const::Ice::Current &)566 TestI::throwDerivedAsDerivedAsync(function<void()>,
567 function<void(exception_ptr)> exception,
568 const ::Ice::Current&)
569 {
570 try
571 {
572 DerivedException de;
573 de.sbe = "sbe";
574 de.pb = make_shared<B>();
575 de.pb->sb = "sb1";
576 de.pb->pb = de.pb;
577 de.sde = "sde1";
578 de.pd1 = make_shared<D1>();
579 de.pd1->sb = "sb2";
580 de.pd1->pb = de.pd1;
581 de.pd1->sd1 = "sd2";
582 de.pd1->pd1 = de.pd1;
583 throw de;
584 }
585 catch(...)
586 {
587 exception(current_exception());
588 }
589 }
590
591 void
throwUnknownDerivedAsBaseAsync(function<void ()>,function<void (exception_ptr)> exception,const::Ice::Current &)592 TestI::throwUnknownDerivedAsBaseAsync(function<void()>,
593 function<void(exception_ptr)> exception,
594 const ::Ice::Current&)
595 {
596 try
597 {
598 auto d2 = make_shared<D2>();
599 d2->sb = "sb d2";
600 d2->pb = d2;
601 d2->sd2 = "sd2 d2";
602 d2->pd2 = d2;
603
604 UnknownDerivedException ude;
605 ude.sbe = "sbe";
606 ude.pb = d2;
607 ude.sude = "sude";
608 ude.pd2 = d2;
609 throw ude;
610 }
611 catch(...)
612 {
613 exception(current_exception());
614 }
615 }
616
617 void
throwPreservedExceptionAsync(function<void ()>,function<void (exception_ptr)> exception,const::Ice::Current &)618 TestI::throwPreservedExceptionAsync(function<void()>,
619 function<void(exception_ptr)> exception,
620 const ::Ice::Current&)
621 {
622 try
623 {
624 PSUnknownException ue;
625 ue.p = make_shared<PSUnknown2>();
626 ue.p->pi = 5;
627 ue.p->ps = "preserved";
628 ue.p->pb = ue.p;
629 ue.p->pb = nullptr; // Break the cycle.
630 throw ue;
631 }
632 catch(...)
633 {
634 exception(current_exception());
635 }
636 }
637
638 void
useForwardAsync(function<void (const shared_ptr<::Test::Forward> &)> response,function<void (exception_ptr)>,const::Ice::Current &)639 TestI::useForwardAsync(function<void(const shared_ptr<::Test::Forward>&)> response,
640 function<void(exception_ptr)>,
641 const ::Ice::Current&)
642 {
643 auto f = make_shared<Forward>();
644 f->h = make_shared<Hidden>();
645 f->h->f = f;
646 response(f);
647 }
648
649 void
shutdownAsync(function<void ()> response,function<void (exception_ptr)>,const::Ice::Current & current)650 TestI::shutdownAsync(function<void()> response,
651 function<void(exception_ptr)>,
652 const ::Ice::Current& current)
653 {
654 current.adapter->getCommunicator()->shutdown();
655 response();
656 }
657 #else
658
659 void
SBaseAsObject_async(const AMD_TestIntf_SBaseAsObjectPtr & cb,const::Ice::Current &)660 TestI::SBaseAsObject_async(const AMD_TestIntf_SBaseAsObjectPtr& cb, const ::Ice::Current&)
661 {
662 SBasePtr sb = new SBase;
663 sb->sb = "SBase.sb";
664 cb->ice_response(sb);
665 }
666
667 void
SBaseAsSBase_async(const AMD_TestIntf_SBaseAsSBasePtr & cb,const::Ice::Current &)668 TestI::SBaseAsSBase_async(const AMD_TestIntf_SBaseAsSBasePtr& cb, const ::Ice::Current&)
669 {
670 SBasePtr sb = new SBase;
671 sb->sb = "SBase.sb";
672 cb->ice_response(sb);
673 }
674
675 void
SBSKnownDerivedAsSBase_async(const AMD_TestIntf_SBSKnownDerivedAsSBasePtr & cb,const::Ice::Current &)676 TestI::SBSKnownDerivedAsSBase_async(const AMD_TestIntf_SBSKnownDerivedAsSBasePtr& cb, const ::Ice::Current&)
677 {
678 SBSKnownDerivedPtr sbskd = new SBSKnownDerived;
679 sbskd->sb = "SBSKnownDerived.sb";
680 sbskd->sbskd = "SBSKnownDerived.sbskd";
681 cb->ice_response(sbskd);
682 }
683
684 void
SBSKnownDerivedAsSBSKnownDerived_async(const AMD_TestIntf_SBSKnownDerivedAsSBSKnownDerivedPtr & cb,const::Ice::Current &)685 TestI::SBSKnownDerivedAsSBSKnownDerived_async(const AMD_TestIntf_SBSKnownDerivedAsSBSKnownDerivedPtr& cb,
686 const ::Ice::Current&)
687 {
688 SBSKnownDerivedPtr sbskd = new SBSKnownDerived;
689 sbskd->sb = "SBSKnownDerived.sb";
690 sbskd->sbskd = "SBSKnownDerived.sbskd";
691 cb->ice_response(sbskd);
692 }
693
694 void
SBSUnknownDerivedAsSBase_async(const AMD_TestIntf_SBSUnknownDerivedAsSBasePtr & cb,const::Ice::Current &)695 TestI::SBSUnknownDerivedAsSBase_async(const AMD_TestIntf_SBSUnknownDerivedAsSBasePtr& cb, const ::Ice::Current&)
696 {
697 SBSUnknownDerivedPtr sbsud = new SBSUnknownDerived;
698 sbsud->sb = "SBSUnknownDerived.sb";
699 sbsud->sbsud = "SBSUnknownDerived.sbsud";
700 cb->ice_response(sbsud);
701 }
702
703 void
SBSUnknownDerivedAsSBaseCompact_async(const AMD_TestIntf_SBSUnknownDerivedAsSBaseCompactPtr & cb,const::Ice::Current &)704 TestI::SBSUnknownDerivedAsSBaseCompact_async(const AMD_TestIntf_SBSUnknownDerivedAsSBaseCompactPtr& cb,
705 const ::Ice::Current&)
706 {
707 SBSUnknownDerivedPtr sbsud = new SBSUnknownDerived;
708 sbsud->sb = "SBSUnknownDerived.sb";
709 sbsud->sbsud = "SBSUnknownDerived.sbsud";
710 cb->ice_response(sbsud);
711 }
712
713 void
SUnknownAsObject_async(const AMD_TestIntf_SUnknownAsObjectPtr & cb,const::Ice::Current &)714 TestI::SUnknownAsObject_async(const AMD_TestIntf_SUnknownAsObjectPtr& cb, const ::Ice::Current&)
715 {
716 SUnknownPtr su = new SUnknown;
717 su->su = "SUnknown.su";
718 su->cycle = su;
719 #ifndef ICE_CPP11_MAPPING
720 su->ice_collectable(true);
721 #endif
722 cb->ice_response(su);
723 }
724
725 void
checkSUnknown_async(const AMD_TestIntf_checkSUnknownPtr & cb,const Ice::ObjectPtr & obj,const::Ice::Current & current)726 TestI::checkSUnknown_async(const AMD_TestIntf_checkSUnknownPtr& cb,
727 const Ice::ObjectPtr& obj,
728 const ::Ice::Current& current)
729 {
730 SUnknownPtr su = SUnknownPtr::dynamicCast(obj);
731 if(current.encoding == Ice::Encoding_1_0)
732 {
733 test(!su);
734 }
735 else
736 {
737 test(su);
738 test(su->su == "SUnknown.su");
739 }
740 cb->ice_response();
741 }
742
743 void
oneElementCycle_async(const AMD_TestIntf_oneElementCyclePtr & cb,const::Ice::Current &)744 TestI::oneElementCycle_async(const AMD_TestIntf_oneElementCyclePtr& cb, const ::Ice::Current&)
745 {
746 BPtr b = new B;
747 b->sb = "B1.sb";
748 b->pb = b;
749 b->ice_collectable(true);
750 cb->ice_response(b);
751 }
752
753 void
twoElementCycle_async(const AMD_TestIntf_twoElementCyclePtr & cb,const::Ice::Current &)754 TestI::twoElementCycle_async(const AMD_TestIntf_twoElementCyclePtr& cb, const ::Ice::Current&)
755 {
756 BPtr b1 = new B;
757 b1->sb = "B1.sb";
758 BPtr b2 = new B;
759 b2->sb = "B2.sb";
760 b2->pb = b1;
761 b1->pb = b2;
762 b1->ice_collectable(true);
763 cb->ice_response(b1);
764 }
765
766 void
D1AsB_async(const AMD_TestIntf_D1AsBPtr & cb,const::Ice::Current &)767 TestI::D1AsB_async(const AMD_TestIntf_D1AsBPtr& cb, const ::Ice::Current&)
768 {
769 D1Ptr d1 = new D1;
770 d1->sb = "D1.sb";
771 d1->sd1 = "D1.sd1";
772 D2Ptr d2 = new D2;
773 d2->pb = d1;
774 d2->sb = "D2.sb";
775 d2->sd2 = "D2.sd2";
776 d2->pd2 = d1;
777 d1->pb = d2;
778 d1->pd1 = d2;
779 d1->ice_collectable(true);
780 d2->ice_collectable(true);
781 cb->ice_response(d1);
782 }
783
784 void
D1AsD1_async(const AMD_TestIntf_D1AsD1Ptr & cb,const::Ice::Current &)785 TestI::D1AsD1_async(const AMD_TestIntf_D1AsD1Ptr& cb, const ::Ice::Current&)
786 {
787 D1Ptr d1 = new D1;
788 d1->sb = "D1.sb";
789 d1->sd1 = "D1.sd1";
790 D2Ptr d2 = new D2;
791 d2->pb = d1;
792 d2->sb = "D2.sb";
793 d2->sd2 = "D2.sd2";
794 d2->pd2 = d1;
795 d1->pb = d2;
796 d1->pd1 = d2;
797 d1->ice_collectable(true);
798 cb->ice_response(d1);
799 }
800
801 void
D2AsB_async(const AMD_TestIntf_D2AsBPtr & cb,const::Ice::Current &)802 TestI::D2AsB_async(const AMD_TestIntf_D2AsBPtr& cb, const ::Ice::Current&)
803 {
804 D2Ptr d2 = new D2;
805 d2->sb = "D2.sb";
806 d2->sd2 = "D2.sd2";
807 D1Ptr d1 = new D1;
808 d1->pb = d2;
809 d1->sb = "D1.sb";
810 d1->sd1 = "D1.sd1";
811 d1->pd1 = d2;
812 d2->pb = d1;
813 d2->pd2 = d1;
814 d2->ice_collectable(true);
815 cb->ice_response(d2);
816 }
817
818 void
paramTest1_async(const AMD_TestIntf_paramTest1Ptr & cb,const::Ice::Current &)819 TestI::paramTest1_async(const AMD_TestIntf_paramTest1Ptr& cb, const ::Ice::Current&)
820 {
821 D1Ptr d1 = new D1;
822 d1->sb = "D1.sb";
823 d1->sd1 = "D1.sd1";
824 D2Ptr d2 = new D2;
825 d2->pb = d1;
826 d2->sb = "D2.sb";
827 d2->sd2 = "D2.sd2";
828 d2->pd2 = d1;
829 d1->pb = d2;
830 d1->pd1 = d2;
831 d1->ice_collectable(true);
832 d2->ice_collectable(true);
833 cb->ice_response(d1, d2);
834 }
835
836 void
paramTest2_async(const AMD_TestIntf_paramTest2Ptr & cb,const::Ice::Current &)837 TestI::paramTest2_async(const AMD_TestIntf_paramTest2Ptr& cb, const ::Ice::Current&)
838 {
839 D1Ptr d1 = new D1;
840 d1->sb = "D1.sb";
841 d1->sd1 = "D1.sd1";
842 D2Ptr d2 = new D2;
843 d2->pb = d1;
844 d2->sb = "D2.sb";
845 d2->sd2 = "D2.sd2";
846 d2->pd2 = d1;
847 d1->pb = d2;
848 d1->pd1 = d2;
849 d1->ice_collectable(true);
850 cb->ice_response(d2, d1);
851 }
852
853 void
paramTest3_async(const AMD_TestIntf_paramTest3Ptr & cb,const::Ice::Current &)854 TestI::paramTest3_async(const AMD_TestIntf_paramTest3Ptr& cb, const ::Ice::Current&)
855 {
856 D2Ptr d2 = new D2;
857 d2->sb = "D2.sb (p1 1)";
858 d2->pb = 0;
859 d2->sd2 = "D2.sd2 (p1 1)";
860
861 D1Ptr d1 = new D1;
862 d1->sb = "D1.sb (p1 2)";
863 d1->pb = 0;
864 d1->sd1 = "D1.sd2 (p1 2)";
865 d1->pd1 = 0;
866 d2->pd2 = d1;
867
868 D2Ptr d4 = new D2;
869 d4->sb = "D2.sb (p2 1)";
870 d4->pb = 0;
871 d4->sd2 = "D2.sd2 (p2 1)";
872
873 D1Ptr d3 = new D1;
874 d3->sb = "D1.sb (p2 2)";
875 d3->pb = 0;
876 d3->sd1 = "D1.sd2 (p2 2)";
877 d3->pd1 = 0;
878 d4->pd2 = d3;
879
880 cb->ice_response(d3, d2, d4);
881 }
882
883 void
paramTest4_async(const AMD_TestIntf_paramTest4Ptr & cb,const::Ice::Current &)884 TestI::paramTest4_async(const AMD_TestIntf_paramTest4Ptr& cb, const ::Ice::Current&)
885 {
886 D4Ptr d4 = new D4;
887 d4->sb = "D4.sb (1)";
888 d4->pb = 0;
889 d4->p1 = new B;
890 d4->p1->sb = "B.sb (1)";
891 d4->p2 = new B;
892 d4->p2->sb = "B.sb (2)";
893 d4->ice_collectable(true);
894 cb->ice_response(d4->p2, d4);
895 }
896
897 void
returnTest1_async(const AMD_TestIntf_returnTest1Ptr & cb,const::Ice::Current &)898 TestI::returnTest1_async(const AMD_TestIntf_returnTest1Ptr& cb, const ::Ice::Current&)
899 {
900 D1Ptr d1 = new D1;
901 d1->sb = "D1.sb";
902 d1->sd1 = "D1.sd1";
903 D2Ptr d2 = new D2;
904 d2->pb = d1;
905 d2->sb = "D2.sb";
906 d2->sd2 = "D2.sd2";
907 d2->pd2 = d1;
908 d1->pb = d2;
909 d1->pd1 = d2;
910 d1->ice_collectable(true);
911 cb->ice_response(d2, d2, d1);
912 }
913
914 void
returnTest2_async(const AMD_TestIntf_returnTest2Ptr & cb,const::Ice::Current &)915 TestI::returnTest2_async(const AMD_TestIntf_returnTest2Ptr& cb, const ::Ice::Current&)
916 {
917 D1Ptr d1 = new D1;
918 d1->sb = "D1.sb";
919 d1->sd1 = "D1.sd1";
920 D2Ptr d2 = new D2;
921 d2->pb = d1;
922 d2->sb = "D2.sb";
923 d2->sd2 = "D2.sd2";
924 d2->pd2 = d1;
925 d1->pb = d2;
926 d1->pd1 = d2;
927 d1->ice_collectable(true);
928 d2->ice_collectable(true);
929 cb->ice_response(d1, d1, d2);
930 }
931
932 void
returnTest3_async(const AMD_TestIntf_returnTest3Ptr & cb,const BPtr & p1,const BPtr &,const::Ice::Current &)933 TestI::returnTest3_async(const AMD_TestIntf_returnTest3Ptr& cb, const BPtr& p1, const BPtr&, const ::Ice::Current&)
934 {
935 cb->ice_response(p1);
936 }
937
938 void
sequenceTest_async(const AMD_TestIntf_sequenceTestPtr & cb,const SS1Ptr & p1,const SS2Ptr & p2,const::Ice::Current &)939 TestI::sequenceTest_async(const AMD_TestIntf_sequenceTestPtr& cb,
940 const SS1Ptr& p1, const SS2Ptr& p2, const ::Ice::Current&)
941 {
942 SS3 ss;
943 ss.c1 = p1;
944 ss.c2 = p2;
945 cb->ice_response(ss);
946 }
947
948 void
dictionaryTest_async(const AMD_TestIntf_dictionaryTestPtr & cb,const BDict & bin,const::Ice::Current &)949 TestI::dictionaryTest_async(const AMD_TestIntf_dictionaryTestPtr& cb, const BDict& bin, const ::Ice::Current&)
950 {
951 BDict bout;
952 int i;
953 for(i = 0; i < 10; ++i)
954 {
955 BPtr b = bin.find(i)->second;
956 D2Ptr d2 = new D2;
957 d2->sb = b->sb;
958 d2->pb = b->pb;
959 d2->sd2 = "D2";
960 d2->pd2 = d2;
961 d2->ice_collectable(true);
962 bout[i * 10] = d2;
963 }
964 BDict r;
965 for(i = 0; i < 10; ++i)
966 {
967 std::ostringstream s;
968 s << "D1." << i * 20;
969 D1Ptr d1 = new D1;
970 d1->sb = s.str();
971 d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second);
972 d1->sd1 = s.str();
973 d1->pd1 = d1;
974 d1->ice_collectable(true);
975 r[i * 20] = d1;
976 }
977 cb->ice_response(r, bout);
978 }
979
980 void
exchangePBase_async(const AMD_TestIntf_exchangePBasePtr & cb,const PBasePtr & pb,const::Ice::Current &)981 TestI::exchangePBase_async(const AMD_TestIntf_exchangePBasePtr& cb, const PBasePtr& pb, const ::Ice::Current&)
982 {
983 cb->ice_response(pb);
984 }
985
986 void
PBSUnknownAsPreserved_async(const Test::AMD_TestIntf_PBSUnknownAsPreservedPtr & cb,const Ice::Current & current)987 TestI::PBSUnknownAsPreserved_async(const Test::AMD_TestIntf_PBSUnknownAsPreservedPtr& cb, const Ice::Current& current)
988 {
989 PSUnknownPtr r = new PSUnknown;
990 r->pi = 5;
991 r->ps = "preserved";
992 r->psu = "unknown";
993 r->graph = 0;
994 if(current.encoding != Ice::Encoding_1_0)
995 {
996 //
997 // 1.0 encoding doesn't support unmarshaling unknown classes even if referenced
998 // from unread slice.
999 //
1000 r->cl = new MyClass(15);
1001 }
1002 cb->ice_response(r);
1003 }
1004
1005 void
checkPBSUnknown_async(const Test::AMD_TestIntf_checkPBSUnknownPtr & cb,const Test::PreservedPtr & p,const Ice::Current & current)1006 TestI::checkPBSUnknown_async(const Test::AMD_TestIntf_checkPBSUnknownPtr& cb, const Test::PreservedPtr& p,
1007 const Ice::Current& current)
1008 {
1009 PSUnknownPtr pu = PSUnknownPtr::dynamicCast(p);
1010 if(current.encoding == Ice::Encoding_1_0)
1011 {
1012 test(!pu);
1013 test(p->pi == 5);
1014 test(p->ps == "preserved");
1015 }
1016 else
1017 {
1018 test(pu);
1019 test(pu->pi == 5);
1020 test(pu->ps == "preserved");
1021 test(pu->psu == "unknown");
1022 test(!pu->graph);
1023 test(pu->cl && pu->cl->i == 15);
1024 }
1025 cb->ice_response();
1026 }
1027
1028 void
PBSUnknownAsPreservedWithGraph_async(const Test::AMD_TestIntf_PBSUnknownAsPreservedWithGraphPtr & cb,const Ice::Current &)1029 TestI::PBSUnknownAsPreservedWithGraph_async(const Test::AMD_TestIntf_PBSUnknownAsPreservedWithGraphPtr& cb,
1030 const Ice::Current&)
1031 {
1032 PSUnknownPtr r = new PSUnknown;
1033 r->pi = 5;
1034 r->ps = "preserved";
1035 r->psu = "unknown";
1036 r->graph = new PNode;
1037 r->graph->next = new PNode;
1038 r->graph->next->next = new PNode;
1039 r->graph->next->next->next = r->graph;
1040 cb->ice_response(r);
1041 r->graph->next->next->next = 0; // Break the cycle.
1042 }
1043
1044 void
checkPBSUnknownWithGraph_async(const Test::AMD_TestIntf_checkPBSUnknownWithGraphPtr & cb,const Test::PreservedPtr & p,const Ice::Current & current)1045 TestI::checkPBSUnknownWithGraph_async(const Test::AMD_TestIntf_checkPBSUnknownWithGraphPtr& cb,
1046 const Test::PreservedPtr& p, const Ice::Current& current)
1047 {
1048 PSUnknownPtr pu = PSUnknownPtr::dynamicCast(p);
1049 if(current.encoding == Ice::Encoding_1_0)
1050 {
1051 test(!pu);
1052 test(p->pi == 5);
1053 test(p->ps == "preserved");
1054 }
1055 else
1056 {
1057 test(pu);
1058 test(pu->pi == 5);
1059 test(pu->ps == "preserved");
1060 test(pu->psu == "unknown");
1061 test(pu->graph != pu->graph->next);
1062 test(pu->graph->next != pu->graph->next->next);
1063 test(pu->graph->next->next->next == pu->graph);
1064 pu->graph->next->next->next = 0; // Break the cycle.
1065 }
1066 cb->ice_response();
1067 }
1068
1069 void
PBSUnknown2AsPreservedWithGraph_async(const Test::AMD_TestIntf_PBSUnknown2AsPreservedWithGraphPtr & cb,const Ice::Current &)1070 TestI::PBSUnknown2AsPreservedWithGraph_async(const Test::AMD_TestIntf_PBSUnknown2AsPreservedWithGraphPtr& cb,
1071 const Ice::Current&)
1072 {
1073 PSUnknown2Ptr r = new PSUnknown2;
1074 r->pi = 5;
1075 r->ps = "preserved";
1076 r->pb = r;
1077 cb->ice_response(r);
1078 r->pb = 0; // Break the cycle.
1079 }
1080
1081 void
checkPBSUnknown2WithGraph_async(const Test::AMD_TestIntf_checkPBSUnknown2WithGraphPtr & cb,const Test::PreservedPtr & p,const Ice::Current & current)1082 TestI::checkPBSUnknown2WithGraph_async(const Test::AMD_TestIntf_checkPBSUnknown2WithGraphPtr& cb,
1083 const Test::PreservedPtr& p, const Ice::Current& current)
1084 {
1085 PSUnknown2Ptr pu = PSUnknown2Ptr::dynamicCast(p);
1086 if(current.encoding == Ice::Encoding_1_0)
1087 {
1088 test(!pu);
1089 test(p->pi == 5);
1090 test(p->ps == "preserved");
1091 }
1092 else
1093 {
1094 test(pu);
1095 test(pu->pi == 5);
1096 test(pu->ps == "preserved");
1097 test(pu->pb == pu);
1098 pu->pb = 0; // Break the cycle.
1099 }
1100 cb->ice_response();
1101 }
1102
1103 void
exchangePNode_async(const AMD_TestIntf_exchangePNodePtr & cb,const PNodePtr & pn,const::Ice::Current &)1104 TestI::exchangePNode_async(const AMD_TestIntf_exchangePNodePtr& cb, const PNodePtr& pn, const ::Ice::Current&)
1105 {
1106 cb->ice_response(pn);
1107 }
1108
1109 void
throwBaseAsBase_async(const AMD_TestIntf_throwBaseAsBasePtr & cb,const::Ice::Current &)1110 TestI::throwBaseAsBase_async(const AMD_TestIntf_throwBaseAsBasePtr& cb, const ::Ice::Current&)
1111 {
1112 BaseException be;
1113 be.sbe = "sbe";
1114 be.pb = new B;
1115 be.pb->sb = "sb";
1116 be.pb->pb = be.pb;
1117 be.pb->ice_collectable(true);
1118 cb->ice_exception(be);
1119 }
1120
1121 void
throwDerivedAsBase_async(const AMD_TestIntf_throwDerivedAsBasePtr & cb,const::Ice::Current &)1122 TestI::throwDerivedAsBase_async(const AMD_TestIntf_throwDerivedAsBasePtr& cb, const ::Ice::Current&)
1123 {
1124 DerivedException de;
1125 de.sbe = "sbe";
1126 de.pb = new B;
1127 de.pb->sb = "sb1";
1128 de.pb->pb = de.pb;
1129 de.sde = "sde1";
1130 de.pd1 = new D1;
1131 de.pd1->sb = "sb2";
1132 de.pd1->pb = de.pd1;
1133 de.pd1->sd1 = "sd2";
1134 de.pd1->pd1 = de.pd1;
1135 de.pb->ice_collectable(true);
1136 de.pd1->ice_collectable(true);
1137 cb->ice_exception(de);
1138 }
1139
1140 void
throwDerivedAsDerived_async(const AMD_TestIntf_throwDerivedAsDerivedPtr & cb,const::Ice::Current &)1141 TestI::throwDerivedAsDerived_async(const AMD_TestIntf_throwDerivedAsDerivedPtr& cb, const ::Ice::Current&)
1142 {
1143 DerivedException de;
1144 de.sbe = "sbe";
1145 de.pb = new B;
1146 de.pb->sb = "sb1";
1147 de.pb->pb = de.pb;
1148 de.sde = "sde1";
1149 de.pd1 = new D1;
1150 de.pd1->sb = "sb2";
1151 de.pd1->pb = de.pd1;
1152 de.pd1->sd1 = "sd2";
1153 de.pd1->pd1 = de.pd1;
1154 de.pb->ice_collectable(true);
1155 de.pd1->ice_collectable(true);
1156 cb->ice_exception(de);
1157 }
1158
1159 void
throwUnknownDerivedAsBase_async(const AMD_TestIntf_throwUnknownDerivedAsBasePtr & cb,const::Ice::Current &)1160 TestI::throwUnknownDerivedAsBase_async(const AMD_TestIntf_throwUnknownDerivedAsBasePtr& cb, const ::Ice::Current&)
1161 {
1162 D2Ptr d2 = new D2;
1163 d2->sb = "sb d2";
1164 d2->pb = d2;
1165 d2->sd2 = "sd2 d2";
1166 d2->pd2 = d2;
1167 d2->ice_collectable(true);
1168
1169 UnknownDerivedException ude;
1170 ude.sbe = "sbe";
1171 ude.pb = d2;
1172 ude.sude = "sude";
1173 ude.pd2 = d2;
1174 cb->ice_exception(ude);
1175 }
1176
1177 void
throwPreservedException_async(const AMD_TestIntf_throwPreservedExceptionPtr & cb,const::Ice::Current &)1178 TestI::throwPreservedException_async(const AMD_TestIntf_throwPreservedExceptionPtr& cb, const ::Ice::Current&)
1179 {
1180 PSUnknownException ue;
1181 ue.p = new PSUnknown2;
1182 ue.p->pi = 5;
1183 ue.p->ps = "preserved";
1184 ue.p->pb = ue.p;
1185 cb->ice_exception(ue);
1186 ue.p->pb = 0; // Break the cycle.
1187 }
1188
1189 void
useForward_async(const AMD_TestIntf_useForwardPtr & cb,const::Ice::Current &)1190 TestI::useForward_async(const AMD_TestIntf_useForwardPtr& cb, const ::Ice::Current&)
1191 {
1192 ForwardPtr f = new Forward;
1193 f->h = new Hidden;
1194 f->h->f = f;
1195 f->ice_collectable(true);
1196 cb->ice_response(f);
1197 }
1198
1199 void
shutdown_async(const AMD_TestIntf_shutdownPtr & cb,const::Ice::Current & current)1200 TestI::shutdown_async(const AMD_TestIntf_shutdownPtr& cb, const ::Ice::Current& current)
1201 {
1202 current.adapter->getCommunicator()->shutdown();
1203 cb->ice_response();
1204 }
1205 #endif
1206