ACE+TAO-6_5_17
[ACE_TAO.git] / TAO / tests / Param_Test / param_test_i.cpp
blobfa4f6948cc8378a29e19fa2396e8ca42228fb8ac
2 //=============================================================================
3 /**
4 * @file param_test_i.cpp
6 * @author Aniruddha Gokhale
7 */
8 //=============================================================================
11 #include "param_test_i.h"
13 #include "tao/debug.h"
14 #include "ace/OS_NS_stdio.h"
15 #include "ace/OS_NS_wchar.h"
16 #include "ace/OS_NS_string.h"
18 // ********* class Coffee_i ****************
19 // Constructor
21 Coffee_i::Coffee_i (const char *name)
22 : name_ (name)
26 // Destructor
28 Coffee_i::~Coffee_i (void)
32 // get attribute
33 Coffee::Desc *
34 Coffee_i::description ( /*env*/)
36 Coffee::Desc *desc = new Coffee::Desc;
37 desc->name = CORBA::string_dup (this->name_.in ());
38 return desc;
41 // set attribute
42 void
43 Coffee_i::description (const Coffee::Desc &description
44 /*env*/)
46 this->name_ = CORBA::string_dup (description.name);
50 // ********* class Param_Test_i ****************
52 // Constructor
54 Param_Test_i::Param_Test_i (const char *coffee_name,
55 CORBA::ORB_ptr orb)
56 : orb_ (CORBA::ORB::_duplicate (orb)),
57 obj_ (coffee_name)
61 // Destructor
63 Param_Test_i::~Param_Test_i (void)
67 // test shorts
68 CORBA::Short
69 Param_Test_i::test_short (CORBA::Short s1,
70 CORBA::Short &s2,
71 CORBA::Short_out s3)
73 s2 = (CORBA::Short) (s1 * 2);
74 s3 = (CORBA::Short) (s1 * 3);
75 if (TAO_debug_level > 0)
77 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*SERVER SIDE=*=*=*=*=*=*=\n"));
78 ACE_DEBUG ((LM_DEBUG, " in = %d, inout = %d, out = %d\n",
79 s1, s2, s3));
81 return (CORBA::Short) (s1 * 4);
84 // test long long
85 CORBA::ULongLong
86 Param_Test_i::test_ulonglong (CORBA::ULongLong s1,
87 CORBA::ULongLong &s2,
88 CORBA::ULongLong_out s3)
90 s2 = s1 * 2;
91 s3 = s1 * 3;
92 return s1 * 4;
95 // test unbounded strings. For return and out types, we return duplicates of
96 // the in string. For the inout, we append the same string to itself and send
97 // it back
98 char *
99 Param_Test_i::test_unbounded_string (const char *s1,
100 char *&s2,
101 CORBA::String_out s3)
103 char *retstr = CORBA::string_dup (s1);
104 s3 = CORBA::string_dup (s1);
105 char *tmp = CORBA::string_alloc (2*ACE_OS::strlen (s2));
106 ACE_OS::sprintf (tmp, "%s%s", s2, s2);
107 CORBA::string_free (s2);
108 s2 = tmp;
109 return retstr;
112 // test bounded strings. For return and out types, we return duplicates of
113 // the in string. For the inout, we append the same string to itself and send
114 // it back
115 char *
116 Param_Test_i::test_bounded_string (const char *s1,
117 char *&s2,
118 CORBA::String_out s3)
120 char *retstr = CORBA::string_dup (s1);
121 s3 = CORBA::string_dup (s1);
122 char *tmp = CORBA::string_alloc (2*ACE_OS::strlen (s2));
123 ACE_OS::sprintf (tmp, "%s%s", s2, s2);
124 CORBA::string_free (s2);
125 s2 = tmp;
126 return retstr;
129 // test unbounded strings. For return and out types, we return duplicates of
130 // the in string. For the inout, we append the same string to itself and send
131 // it back
132 CORBA::WChar *
133 Param_Test_i::test_unbounded_wstring (const CORBA::WChar *ws1,
134 CORBA::WChar *&ws2,
135 CORBA::WString_out ws3)
137 CORBA::WChar *retwstr = CORBA::wstring_dup (ws1);
138 ws3 = CORBA::wstring_dup (ws1);
139 CORBA::ULong len = ACE_OS::wslen (ws2);
140 CORBA::WChar *tmp = CORBA::wstring_alloc (2*len);
141 for (CORBA::ULong i = 0; i < 2; i++)
142 for (CORBA::ULong j = 0; j < len; j++)
143 tmp[j + i*len] = ws2[j];
144 tmp[2*len] = 0;
145 CORBA::wstring_free (ws2);
146 ws2 = tmp;
147 return retwstr;
150 // test bounded strings. For return and out types, we return duplicates of
151 // the in string. For the inout, we append the same string to itself and send
152 // it back
153 CORBA::WChar *
154 Param_Test_i::test_bounded_wstring (const CORBA::WChar *ws1,
155 CORBA::WChar *&ws2,
156 CORBA::WString_out ws3)
158 CORBA::WChar *retwstr = CORBA::wstring_dup (ws1);
159 ws3 = CORBA::wstring_dup (ws1);
160 CORBA::ULong len = ACE_OS::wslen (ws2);
161 CORBA::WChar *tmp = CORBA::wstring_alloc (2*len);
162 for (CORBA::ULong i = 0; i < 2; i++)
163 for (CORBA::ULong j = 0; j < len; j++)
164 tmp[j + i*len] = ws2[j];
165 tmp[2*len] = 0;
166 CORBA::wstring_free (ws2);
167 ws2 = tmp;
168 return retwstr;
171 // test for fixed structures. Just copy the in parameter into all the others
172 Param_Test::Fixed_Struct
173 Param_Test_i::test_fixed_struct (const Param_Test::Fixed_Struct &s1,
174 Param_Test::Fixed_Struct &s2,
175 Param_Test::Fixed_Struct_out s3)
177 s2 = s1;
178 s3 = s1;
179 return s1;
182 // = Sequences
184 CORBA::LongSeq *
185 Param_Test_i::test_long_sequence (const CORBA::LongSeq & s1,
186 CORBA::LongSeq & s2,
187 CORBA::LongSeq_out s3)
189 CORBA::LongSeq
190 *ret = new CORBA::LongSeq,
191 *out = new CORBA::LongSeq;
193 s2 = s1;
194 *out = s1;
195 *ret = s1;
196 s3 = out;
197 return ret;
200 CORBA::ShortSeq *
201 Param_Test_i::test_short_sequence (const CORBA::ShortSeq & s1,
202 CORBA::ShortSeq & s2,
203 CORBA::ShortSeq_out s3)
205 CORBA::ShortSeq
206 *ret = new CORBA::ShortSeq,
207 *out = new CORBA::ShortSeq;
209 s2 = s1;
210 *out = s1;
211 *ret = s1;
212 s3 = out;
213 return ret;
216 Param_Test::Bounded_Short_Seq *
217 Param_Test_i::test_bounded_short_sequence (const Param_Test::Bounded_Short_Seq & s1,
218 Param_Test::Bounded_Short_Seq & s2,
219 Param_Test::Bounded_Short_Seq_out s3)
221 Param_Test::Bounded_Short_Seq
222 *ret = new Param_Test::Bounded_Short_Seq,
223 *out = new Param_Test::Bounded_Short_Seq;
225 s2 = s1;
226 *out = s1;
227 *ret = s1;
228 s3 = out;
229 return ret;
232 Param_Test::Bounded_Long_Seq *
233 Param_Test_i::test_bounded_long_sequence (const Param_Test::Bounded_Long_Seq & s1,
234 Param_Test::Bounded_Long_Seq & s2,
235 Param_Test::Bounded_Long_Seq_out s3)
237 Param_Test::Bounded_Long_Seq
238 *ret = new Param_Test::Bounded_Long_Seq,
239 *out = new Param_Test::Bounded_Long_Seq;
241 s2 = s1;
242 *out = s1;
243 *ret = s1;
244 s3 = out;
245 return ret;
248 CORBA::StringSeq *
249 Param_Test_i::test_strseq (const CORBA::StringSeq &s1,
250 CORBA::StringSeq &s2,
251 CORBA::StringSeq_out s3)
253 // we copy the "in" sequences into all the inout, out and return sequences.
255 CORBA::StringSeq
256 *ret = new CORBA::StringSeq,
257 *out = new CORBA::StringSeq;
259 if (TAO_debug_level > 0)
261 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*SERVER SIDE=*=*=*=*=*=*=\n"));
262 for (CORBA::ULong i=0; (i < s2.length ()); i++)
264 ACE_DEBUG ((LM_DEBUG,
265 "Element #%d\n"
266 "in : %s\n",
268 (s2[i]? (const char *)s2[i]:"<nul>")));
270 if (s2.length () == 0)
271 ACE_DEBUG ((LM_DEBUG, "\ninout sequence is NUL\n"));
274 // now copy all elements of s1 into the others using the assignment operator
275 s2 = s1;
276 *out = s1;
277 *ret = s1;
278 s3 = out;
279 return ret;
282 Param_Test::Bounded_StrSeq *
283 Param_Test_i::test_bounded_strseq (const Param_Test::Bounded_StrSeq & s1,
284 Param_Test::Bounded_StrSeq & s2,
285 Param_Test::Bounded_StrSeq_out s3)
287 // we copy the "in" sequences into all the inout, out and return sequences.
289 Param_Test::Bounded_StrSeq
290 *ret = new Param_Test::Bounded_StrSeq,
291 *out = new Param_Test::Bounded_StrSeq;
293 // now copy all elements of s1 into the others using the assignment operator
294 s2 = s1;
295 *out = s1;
296 *ret = s1;
297 s3 = out;
298 return ret;
301 CORBA::WStringSeq *
302 Param_Test_i::test_wstrseq (const CORBA::WStringSeq &ws1,
303 CORBA::WStringSeq &ws2,
304 CORBA::WStringSeq_out ws3)
306 // we copy the "in" sequences into all the inout, out and return sequences.
308 CORBA::WStringSeq
309 *ret = new CORBA::WStringSeq,
310 *out = new CORBA::WStringSeq;
312 // now copy all elements of s1 into the others using the assignment operator
313 ws2 = ws1;
314 *out = ws1;
315 *ret = ws1;
316 ws3 = out;
317 return ret;
320 Param_Test::Bounded_WStrSeq *
321 Param_Test_i::test_bounded_wstrseq (const Param_Test::Bounded_WStrSeq & ws1,
322 Param_Test::Bounded_WStrSeq & ws2,
323 Param_Test::Bounded_WStrSeq_out ws3)
325 // we copy the "in" sequences into all the inout, out and return sequences.
327 Param_Test::Bounded_WStrSeq
328 *ret = new Param_Test::Bounded_WStrSeq,
329 *out = new Param_Test::Bounded_WStrSeq;
331 // now copy all elements of s1 into the others using the assignment operator
332 ws2 = ws1;
333 *out = ws1;
334 *ret = ws1;
335 ws3 = out;
336 return ret;
339 // test for struct sequences
340 Param_Test::StructSeq *
341 Param_Test_i::test_struct_sequence (const Param_Test::StructSeq &s1,
342 Param_Test::StructSeq &s2,
343 Param_Test::StructSeq_out s3)
345 // we copy the "in" sequences into all the inout, out and return sequences.
347 Param_Test::StructSeq
348 *ret = new Param_Test::StructSeq,
350 *out = new Param_Test::StructSeq;
352 // now copy all elements of s1 into the others using the assignment operator
353 s2 = s1;
354 *out = s1;
355 *ret = s1;
356 s3 = out;
357 return ret;
360 // test for bounded struct sequences
361 Param_Test::Bounded_StructSeq *
362 Param_Test_i::test_bounded_struct_sequence (const Param_Test::Bounded_StructSeq & s1,
363 Param_Test::Bounded_StructSeq & s2,
364 Param_Test::Bounded_StructSeq_out s3)
366 Param_Test::Bounded_StructSeq
367 *ret = new Param_Test::Bounded_StructSeq,
368 *out = new Param_Test::Bounded_StructSeq;
370 s2 = s1;
371 *out = s1;
372 *ret = s1;
373 s3 = out;
374 return ret;
378 Param_Test::PathSpec *
379 Param_Test_i::test_unbounded_struct_sequence (const Param_Test::PathSpec & s1,
380 Param_Test::PathSpec & s2,
381 Param_Test::PathSpec_out s3)
383 Param_Test::PathSpec
384 *ret = new Param_Test::PathSpec,
385 *out = new Param_Test::PathSpec;
388 Param_Test::PathSpec_var rPathSpec = new Param_Test::PathSpec;
389 rPathSpec->length(2);
391 rPathSpec[0u].name.id = CORBA::string_dup("staff");
392 rPathSpec[0u].name.kind = CORBA::string_dup("staff");
393 rPathSpec[0u].process = 1;
395 rPathSpec[1u].name.id = CORBA::string_dup("john");
396 rPathSpec[1u].name.kind = CORBA::string_dup("john");
397 rPathSpec[1u].process = 1;
399 s2 = s1;
400 *out = s1;
401 *ret = s1;
402 s3 = out;
404 return ret;
408 // test for array sequences
409 Param_Test::ArraySeq *
410 Param_Test_i::test_array_sequence (const Param_Test::ArraySeq &s1,
411 Param_Test::ArraySeq &s2,
412 Param_Test::ArraySeq_out s3)
414 // we copy the "in" sequences into all the inout, out and return sequences.
416 Param_Test::ArraySeq
417 *ret = new Param_Test::ArraySeq,
419 *out = new Param_Test::ArraySeq;
421 // now copy all elements of s1 into the others using the assignment operator
422 s2 = s1;
423 *out = s1;
424 *ret = s1;
425 s3 = out;
426 return ret;
429 // test for bounded array sequences
430 Param_Test::Bounded_ArraySeq *
431 Param_Test_i::test_bounded_array_sequence (const Param_Test::Bounded_ArraySeq & s1,
432 Param_Test::Bounded_ArraySeq & s2,
433 Param_Test::Bounded_ArraySeq_out s3)
435 Param_Test::Bounded_ArraySeq
436 *ret = new Param_Test::Bounded_ArraySeq,
437 *out = new Param_Test::Bounded_ArraySeq;
439 s2 = s1;
440 *out = s1;
441 *ret = s1;
442 s3 = out;
443 return ret;
446 Param_Test::Coffee_Mix *
447 Param_Test_i::test_coffe_mix (const Param_Test::Coffee_Mix & s1,
448 Param_Test::Coffee_Mix & s2,
449 Param_Test::Coffee_Mix_out s3)
451 Param_Test::Coffee_Mix
452 *ret = new Param_Test::Coffee_Mix,
453 *out = new Param_Test::Coffee_Mix;
455 #if 0
456 ACE_DEBUG ((LM_DEBUG,
457 "maximum = %d\n"
458 "length = %d\n",
459 s1.maximum (),
460 s1.length ()));
461 ACE_DEBUG ((LM_DEBUG, "Elements -\n"));
462 for (CORBA::ULong i = 0; i < s1.length (); ++i)
464 Coffee_ptr c = s1[i];
465 if (CORBA::is_nil (c))
467 ACE_DEBUG ((LM_DEBUG,
468 "Element #%d is nil\n", i));
469 continue;
471 ACE_DEBUG ((LM_DEBUG,
472 "Element #%d\n"
473 "\ttype = <%s>\n",
475 c->_interface_repository_id ()));
477 #endif /* 0 */
480 s2 = s1;
481 *out = s1;
482 *ret = s1;
483 s3 = out;
484 return ret;
487 Param_Test::Bounded_Coffee_Mix *
488 Param_Test_i::test_bounded_coffe_mix (const Param_Test::Bounded_Coffee_Mix & s1,
489 Param_Test::Bounded_Coffee_Mix & s2,
490 Param_Test::Bounded_Coffee_Mix_out s3)
492 Param_Test::Bounded_Coffee_Mix
493 *ret = new Param_Test::Bounded_Coffee_Mix,
494 *out = new Param_Test::Bounded_Coffee_Mix;
496 #if 0
497 ACE_DEBUG ((LM_DEBUG,
498 "maximum = %d\n"
499 "length = %d\n",
500 s1.maximum (),
501 s1.length ()));
502 ACE_DEBUG ((LM_DEBUG, "Elements -\n"));
503 for (CORBA::ULong i = 0; i < s1.length (); ++i)
505 Coffee_ptr c = s1[i];
506 if (CORBA::is_nil (c))
508 ACE_DEBUG ((LM_DEBUG,
509 "Element #%d is nil\n", i));
510 continue;
512 ACE_DEBUG ((LM_DEBUG,
513 "Element #%d\n"
514 "\ttype = <%s>\n",
516 c->_interface_repository_id ()));
518 #endif /* 0 */
521 s2 = s1;
522 *out = s1;
523 *ret = s1;
524 s3 = out;
525 return ret;
528 CORBA::AnySeq *
529 Param_Test_i::test_anyseq (const CORBA::AnySeq &s1,
530 CORBA::AnySeq &s2,
531 CORBA::AnySeq_out s3)
533 // we copy the "in" sequences into all the inout, out and return sequences.
535 CORBA::AnySeq
536 *ret = new CORBA::AnySeq,
537 *out = new CORBA::AnySeq;
539 // now copy all elements of s1 into the others using the assignment operator
540 s2 = s1;
541 *out = s1;
542 *ret = s1;
543 s3 = out;
544 return ret;
547 // = end of sequences...
549 // test for variable structs
550 Param_Test::Var_Struct *
551 Param_Test_i::test_var_struct (const Param_Test::Var_Struct &s1,
552 Param_Test::Var_Struct &s2,
553 Param_Test::Var_Struct_out s3)
555 // we copy the "in" sequences into all the inout, out and return sequences.
557 Param_Test::Var_Struct
558 *ret = new Param_Test::Var_Struct,
559 *out = new Param_Test::Var_Struct;
561 // now copy all elements of s1 into the others
562 s2 = s1;
563 *out = s1;
564 *ret = s1;
565 s3 = out;
566 return ret;
569 // test for nested structs
570 Param_Test::Nested_Struct *
571 Param_Test_i::test_nested_struct (const Param_Test::Nested_Struct &s1,
572 Param_Test::Nested_Struct &s2,
573 Param_Test::Nested_Struct_out s3)
575 // we copy the "in" sequences into all the inout, out and return sequences.
577 Param_Test::Nested_Struct
578 *ret = new Param_Test::Nested_Struct,
579 *out = new Param_Test::Nested_Struct;
581 // now copy all elements of s1 into the others
582 s2 = s1;
583 *out = s1;
584 *ret = s1;
585 s3 = out;
586 return ret;
589 // test for recursive structs
590 Param_Test::Recursive_Struct *
591 Param_Test_i::test_recursive_struct (const Param_Test::Recursive_Struct &s1,
592 Param_Test::Recursive_Struct &s2,
593 Param_Test::Recursive_Struct_out s3)
595 // we copy the "in" structs into all the inout, out and return sequences.
597 Param_Test::Recursive_Struct
598 *ret = new Param_Test::Recursive_Struct,
599 *out = new Param_Test::Recursive_Struct;
601 // now copy all elements of s1 into the others
602 s2 = s1;
603 *out = s1;
604 *ret = s1;
605 s3 = out;
606 return ret;
609 Param_Test::Objref_Struct *
610 Param_Test_i::test_objref_struct (const Param_Test::Objref_Struct &s1,
611 Param_Test::Objref_Struct &s2,
612 Param_Test::Objref_Struct_out s3)
614 // we copy the "in" sequences into all the inout, out and return sequences.
616 Param_Test::Objref_Struct
617 *ret = new Param_Test::Objref_Struct,
618 *out = new Param_Test::Objref_Struct;
620 // now copy all elements of s1 into the others
621 s2 = s1;
622 *out = s1;
623 *ret = s1;
624 s3 = out;
625 return ret;
628 // make a Coffee object
629 Coffee_ptr
630 Param_Test_i::make_coffee (void)
632 return this->obj_._this ();
635 // test for object references
636 Coffee_ptr
637 Param_Test_i::test_objref (Coffee_ptr o1,
638 Coffee_ptr &o2,
639 Coffee_out o3)
641 Coffee_ptr ret = Coffee::_nil ();
645 Coffee_var myobj = obj_._this ();
647 if (!CORBA::is_nil (o2))
648 CORBA::release (o2);
650 CORBA::Boolean equiv = myobj->_is_equivalent (o1);
652 if (equiv)
654 o2 = Coffee::_duplicate (myobj.in ());
655 o3 = Coffee::_duplicate (myobj.in ());
656 ret = Coffee::_duplicate (myobj.in ());
658 else
660 o2 = Coffee::_nil ();
661 o3 = Coffee::_nil ();
664 catch (const CORBA::SystemException& sysex)
666 sysex._tao_print_exception ("System Exception");
668 catch (const CORBA::UserException& userex)
670 userex._tao_print_exception ("User Exception");
673 return ret;
676 // test for typecodes
677 CORBA::TypeCode_ptr
678 Param_Test_i::test_typecode (CORBA::TypeCode_ptr t1,
679 CORBA::TypeCode_ptr &t2,
680 CORBA::TypeCode_out t3
681 /*env*/)
683 // we simply assign t1 to the others
684 CORBA::TypeCode_ptr retval = CORBA::TypeCode::_duplicate (t1);
685 t2 = CORBA::TypeCode::_duplicate (t1);
686 t3 = CORBA::TypeCode::_duplicate (t1);
687 return retval;
690 // test for Anys
691 CORBA::Any *
692 Param_Test_i::test_any (const CORBA::Any &a1,
693 CORBA::Any &a2,
694 CORBA::Any_out a3)
696 CORBA::Any *ret;
697 CORBA::Short short_in;
698 const char *str_in;
699 Coffee_ptr coffee;
700 Param_Test::Fixed_Array_forany array;
701 const CORBA::ShortSeq *ub_short_sequence;
702 const Param_Test::Bounded_Short_Seq *bd_short_sequence;
703 const Param_Test::Fixed_Struct *fixed_structure;
704 const Param_Test::Big_Union *big_union;
705 const Param_Test::Small_Union *small_union;
707 a2 = a1;
708 a3 = new CORBA::Any (a1);
709 ret = new CORBA::Any (a1);
712 if (TAO_debug_level > 0)
714 CORBA::TypeCode_var tc = a1.type ();
715 int kind = tc->kind ();
717 ACE_DEBUG ((LM_DEBUG,
718 "Received any contents are <%d>\n",
719 kind));
722 // debug the incoming Any
723 if (a1 >>= short_in)
725 if (TAO_debug_level > 0)
726 ACE_DEBUG ((LM_DEBUG, "Received short = %d\n", short_in));
727 a2 >>= short_in;
728 if (TAO_debug_level > 0)
729 ACE_DEBUG ((LM_DEBUG, "inout short = %d\n", short_in));
730 *a3.ptr () >>= short_in;
731 if (TAO_debug_level > 0)
732 ACE_DEBUG ((LM_DEBUG, "out short = %d\n", short_in));
733 *ret >>= short_in;
734 if (TAO_debug_level > 0)
735 ACE_DEBUG ((LM_DEBUG, "ret short = %d\n", short_in));
737 else if (a1 >>= str_in)
739 if (TAO_debug_level > 0)
740 ACE_DEBUG ((LM_DEBUG, "Received unbounded string = %s\n", str_in));
742 else if (a1 >>= coffee)
744 if (TAO_debug_level > 0)
745 ACE_DEBUG ((LM_DEBUG, "Received Coffee object\n"));
747 else if (a1 >>= array)
749 if (TAO_debug_level > 0)
751 ACE_DEBUG ((LM_DEBUG, "Received Fixed_Array:"));
752 for (CORBA::ULong i = 0; i < Param_Test::DIM1; i++)
753 ACE_DEBUG ((LM_DEBUG, " %d", array[i]));
754 ACE_DEBUG ((LM_DEBUG, "\n"));
756 for (CORBA::ULong i = 0; i < Param_Test::DIM1; i++)
757 array[i] = i * i;
758 a2 <<= Param_Test::Fixed_Array_forany (array);
759 *ret <<= Param_Test::Fixed_Array_forany (array);
761 else if (a1 >>= ub_short_sequence)
763 if (TAO_debug_level > 0)
765 ACE_DEBUG ((LM_DEBUG, "Received Unbounded Short_Seq:"));
766 for (size_t i = 0; i < ub_short_sequence->length (); i++)
767 ACE_DEBUG ((LM_DEBUG, " %d", (*ub_short_sequence)[i]));
768 ACE_DEBUG ((LM_DEBUG, "\n"));
770 CORBA::ShortSeq newseq (*ub_short_sequence);
771 for (size_t i = 0; i < ub_short_sequence->length (); i++)
772 newseq[i] = (CORBA::Short) (i * i);
773 a2 <<= newseq;
774 *ret <<= newseq;
776 else if (a1 >>= bd_short_sequence)
778 if (TAO_debug_level > 0)
780 ACE_DEBUG ((LM_DEBUG, "Received Bounded_Short_Seq:"));
781 for (size_t i = 0; i < bd_short_sequence->length (); i++)
782 ACE_DEBUG ((LM_DEBUG, " %d", (*bd_short_sequence)[i]));
783 ACE_DEBUG ((LM_DEBUG, "\n"));
785 Param_Test::Bounded_Short_Seq newseq (*bd_short_sequence);
786 for (size_t i = 0; i < bd_short_sequence->length (); i++)
787 newseq[i] = (CORBA::Short) (i * i);
788 a2 <<= newseq;
789 *ret <<= newseq;
791 else if (a1 >>= fixed_structure)
793 if (TAO_debug_level > 0)
794 ACE_DEBUG ((LM_DEBUG, "Received Fixed_Struct\n"));
796 else if (a1 >>= big_union)
798 const Param_Test::Big_Union *bu_in, *bu_inout, *bu_out, *bu_ret;
799 a1 >>= bu_in;
801 // Insert copies....
802 a2 <<= *bu_in;
803 *a3 <<= *bu_in;
804 *ret <<= *bu_in;
806 // Extract the value to compare...
807 a2 >>= bu_inout;
808 *a3 >>= bu_out;
809 *ret >>= bu_ret;
811 if (TAO_debug_level > 0)
812 ACE_DEBUG ((LM_DEBUG, "Received Big Union\n"
813 " in %d\n"
814 " inout %d\n"
815 " out %d\n"
816 " ret %d\n",
817 bu_in->the_long (),
818 bu_inout->the_long (),
819 bu_out->the_long (),
820 bu_ret->the_long () ));
822 else if (a1 >>= small_union)
824 const Param_Test::Small_Union *bu_in, *bu_inout, *bu_out, *bu_ret;
825 a1 >>= bu_in;
827 // Insert copies....
828 a2 <<= *bu_in;
829 *a3 <<= *bu_in;
830 *ret <<= *bu_in;
832 // Extract the value to compare...
833 a2 >>= bu_inout;
834 *a3 >>= bu_out;
835 *ret >>= bu_ret;
837 if (TAO_debug_level > 0)
838 ACE_DEBUG ((LM_DEBUG, "Received Small Union\n"
839 " in %d\n"
840 " inout %d\n"
841 " out %d\n"
842 " ret %d\n",
843 bu_in->the_long (),
844 bu_inout->the_long (),
845 bu_out->the_long (),
846 bu_ret->the_long () ));
848 else
850 ACE_DEBUG ((LM_DEBUG, "Received UNKNOWN type\n"));
853 return ret;
856 // test for fixed arrays
857 Param_Test::Fixed_Array_slice *
858 Param_Test_i::test_fixed_array (const Param_Test::Fixed_Array a1,
859 Param_Test::Fixed_Array a2,
860 Param_Test::Fixed_Array_out a3)
862 Param_Test::Fixed_Array_slice *ret;
864 Param_Test::Fixed_Array_copy (a2, a1);
865 Param_Test::Fixed_Array_copy (a3, a1);
866 ret = Param_Test::Fixed_Array_dup (a1);
867 return ret;
870 // test for var arrays
871 Param_Test::Var_Array_slice *
872 Param_Test_i::test_var_array (const Param_Test::Var_Array a1,
873 Param_Test::Var_Array a2,
874 Param_Test::Var_Array_out a3)
876 Param_Test::Var_Array_slice *ret;
878 Param_Test::Var_Array_copy (a2, a1);
879 a3 = Param_Test::Var_Array_dup (a1);
880 ret = Param_Test::Var_Array_dup (a1);
881 return ret;
884 CORBA::ULong
885 Param_Test_i::test_exception (CORBA::ULong s1,
886 CORBA::ULong& s2,
887 CORBA::ULong_out s3)
889 CORBA::ULong d = s1 % 4;
891 // No exceptions to throw.
892 if (d == 0)
894 s2 = s1 * 2;
895 s3 = s1 * 3;
896 return s1 * 4;
898 // Throw a known user exception type to test the user exception.
899 else if (d == 1)
901 throw Param_Test::Ooops (" % 4 == 1", d);
903 // Throw a CORBA::SystemException type CORBA::NO_MEMORY to test
904 // the system exception.
905 else if (d == 2)
907 throw CORBA::NO_MEMORY ();
910 // This will avoid the compiler
911 // warning that test_exception is throwing an exception
912 // not in its THROW_SPEC, but still test TAO's
913 // conversion of such an exception to UNKNOWN.
914 this->throw_badboy ();
916 return 0;
919 Param_Test::Big_Union*
920 Param_Test_i::test_big_union (const Param_Test::Big_Union& u1,
921 Param_Test::Big_Union& u2,
922 Param_Test::Big_Union_out u3)
924 Param_Test::Big_Union_var ret (new Param_Test::Big_Union (u1));
925 u2 = u1;
926 u3 = new Param_Test::Big_Union (u1);
927 return ret._retn ();
930 Param_Test::Small_Union
931 Param_Test_i::test_small_union (const Param_Test::Small_Union& u1,
932 Param_Test::Small_Union& u2,
933 Param_Test::Small_Union_out u3)
935 u2 = u1;
936 u3 = u1;
937 return u1;
940 Param_Test::Recursive_Union*
941 Param_Test_i::test_recursive_union (const Param_Test::Recursive_Union& ru1,
942 Param_Test::Recursive_Union& ru2,
943 Param_Test::Recursive_Union_out ru3)
945 Param_Test::Recursive_Union_var ret (new Param_Test::Recursive_Union (ru1));
946 ru2 = ru1;
947 ru3 = new Param_Test::Recursive_Union (ru1);
948 return ret._retn ();
951 CORBA::Any*
952 Param_Test_i::test_complex_any (const CORBA::Any &a1,
953 CORBA::Any &a2,
954 CORBA::Any_out a3)
956 CORBA::Any_var ret (new CORBA::Any (a1));
957 a2 = a1;
958 a3 = new CORBA::Any (a1);
959 return ret._retn ();
962 Param_Test::Multdim_Array_slice *
963 Param_Test_i::test_multdim_array (const Param_Test::Multdim_Array a1,
964 Param_Test::Multdim_Array a2,
965 Param_Test::Multdim_Array_out a3)
967 Param_Test::Multdim_Array_slice *ret;
969 Param_Test::Multdim_Array_copy (a2, a1);
970 Param_Test::Multdim_Array_copy (a3, a1);
971 ret = Param_Test::Multdim_Array_dup (a1);
972 return ret;
975 void
976 Param_Test_i::shutdown (void)
978 this->orb_->shutdown ();
981 void
982 Param_Test_i::throw_badboy (void)
984 throw Param_Test::BadBoy ();