Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / OBV / Truncatable / TruncatableS_impl.cpp
blob5789adcda72d1960254f9ab49ea1236a64ba8e54
1 #include "TruncatableS_impl.h"
2 #include "ace/OS_NS_stdio.h"
4 Test_impl::Test_impl (CORBA::ORB_ptr orb)
5 : orb_ (CORBA::ORB::_duplicate (orb))
9 void
10 Test_impl::op1 (
11 const char * id,
12 ::OBV_TruncatableTest::BaseValue * iv,
13 ::OBV_TruncatableTest::BaseValue_out ov,
14 char *& desc
17 if (TAO_debug_level > 0)
18 ACE_DEBUG((LM_DEBUG,
19 ACE_TEXT("(%P|%t)Test_impl::op1")
20 ACE_TEXT(" id=%s basic_data=%u desc=%s\n"),
21 id, iv->basic_data (), desc));
23 char *tmp = CORBA::string_alloc (
24 static_cast<CORBA::ULong> (ACE_OS::strlen (id) + ACE_OS::strlen (desc) + 2));
25 ACE_OS::sprintf (tmp, "%s: %s", id, desc);
26 CORBA::string_free (desc);
27 desc = tmp;
29 ov = new ::OBV_OBV_TruncatableTest::BaseValue();
30 ov->basic_data (iv->basic_data());
34 void
35 Test_impl::op2 (
36 ::OBV_TruncatableTest::TValue1 * iv,
37 const char * id,
38 ::OBV_TruncatableTest::TValue1_out ov,
39 char *& desc
42 if (TAO_debug_level > 0)
43 ACE_DEBUG((LM_DEBUG,
44 ACE_TEXT("(%P|%t)Test_impl::op2")
45 ACE_TEXT(" id=%s basic_data=%u data1=%u desc=%s\n"),
46 id, iv->basic_data (), iv->data1 (), desc));
47 char *tmp = CORBA::string_alloc (
48 static_cast<CORBA::ULong> (ACE_OS::strlen (id) + ACE_OS::strlen (desc) + 2));
49 ACE_OS::sprintf (tmp, "%s: %s", id, desc);
50 CORBA::string_free (desc);
51 desc = tmp;
53 ov = new ::OBV_OBV_TruncatableTest::TValue1();
54 ov->basic_data (iv->basic_data());
55 ov->data1 (iv->data1());
59 void
60 Test_impl::op3 (
61 const char * id,
62 ::OBV_TruncatableTest::TValue4 * iv,
63 ::OBV_TruncatableTest::TValue4_out ov,
64 char *& desc
67 if (TAO_debug_level > 0)
68 ACE_DEBUG((LM_DEBUG,
69 ACE_TEXT("(%P|%t)Test_impl::op3")
70 ACE_TEXT(" id=%s basic_data=%u data=%u data4=%u desc=%s\n"),
71 id, iv->basic_data (), iv->nv4()->data (), iv->data4 (), desc));
73 char *tmp = CORBA::string_alloc (
74 static_cast<CORBA::ULong> (ACE_OS::strlen (id) + ACE_OS::strlen (desc) + 2));
75 ACE_OS::sprintf (tmp, "%s: %s", id, desc);
76 CORBA::string_free (desc);
77 desc = tmp;
79 ov = new ::OBV_OBV_TruncatableTest::TValue4();
80 ::OBV_OBV_TruncatableTest::NestedValue* nv =
81 new ::OBV_OBV_TruncatableTest::NestedValue();
82 nv->data (iv->nv4()->data ());
83 ov->basic_data (iv->basic_data());
84 ov->nv4 (nv);
85 ov->data4 (iv->data4());
86 CORBA::remove_ref(nv);
90 ::OBV_TruncatableTest::BaseValue *
91 Test_impl::op4 (
92 const char * id,
93 ::OBV_TruncatableTest::TValue1 * iv1,
94 ::CORBA::Short x,
95 ::OBV_TruncatableTest::TValue4 * iv2,
96 ::OBV_TruncatableTest::TValue4 * iv3,
97 ::OBV_TruncatableTest::TValue1 * iv4,
98 char *& desc
101 if (TAO_debug_level > 0)
103 ACE_DEBUG((LM_DEBUG,
104 ACE_TEXT("(%P|%t)Test_impl::op4")
105 ACE_TEXT(" id=%s basic_data=%u data1=%u desc=%s\n"),
106 id, iv1->basic_data (), iv1->data1 (), desc));
107 ACE_DEBUG((LM_DEBUG,
108 ACE_TEXT("(%P|%t)Test_impl::op4")
109 ACE_TEXT(" id=%s basic_data=%u data=%u data4=%u desc=%s\n"),
110 id, iv2->basic_data (), iv2->nv4()->data (),
111 iv2->data4 (), desc));
112 ACE_DEBUG((LM_DEBUG,
113 ACE_TEXT("(%P|%t)Test_impl::op4")
114 ACE_TEXT(" id=%s basic_data=%u data=%u data4=%u desc=%s\n"),
115 id, iv3->basic_data (), iv3->nv4()->data (),
116 iv3->data4 (), desc));
117 ACE_DEBUG((LM_DEBUG,
118 ACE_TEXT("(%P|%t)Test_impl::op4")
119 ACE_TEXT(" id=%s basic_data=%u data1=%u desc=%s\n"),
120 id, iv4->basic_data (), iv4->data1 (), desc));
123 char *tmp = CORBA::string_alloc (
124 static_cast<CORBA::ULong> (ACE_OS::strlen (id) + ACE_OS::strlen (desc) + 2));
125 ACE_OS::sprintf (tmp, "%s: %s", id, desc);
126 CORBA::string_free (desc);
127 desc = tmp;
129 ::OBV_TruncatableTest::BaseValue * ov =
130 new ::OBV_OBV_TruncatableTest::BaseValue();
132 CORBA::ULong total =
133 x * (iv1->basic_data () + iv2->basic_data () +
134 iv3->basic_data () + iv4->basic_data ());
135 ov->basic_data (total);
137 return ov;
141 void
142 Test_impl::op5 (const CORBA::Any& val,
143 const char * id,
144 ::OBV_TruncatableTest::TValue1_out ov,
145 char *& desc
148 ov = new ::OBV_OBV_TruncatableTest::TValue1();
149 ::OBV_TruncatableTest::TValue1_var iv;
150 CORBA::ValueBase_var target;
151 if (!(val >>= CORBA::Any::to_value(target.inout())))
153 ACE_DEBUG ((LM_DEBUG,
154 ACE_TEXT("(%P|%t)Test_impl::op5 extract failed\n")));
155 ov->basic_data (101);
156 ov->data1 (10101);
158 else
160 iv = ::OBV_TruncatableTest::TValue1::_downcast(target._retn());
161 if (TAO_debug_level > 0)
162 ACE_DEBUG((LM_DEBUG,
163 ACE_TEXT("(%P|%t)Test_impl::op5")
164 ACE_TEXT(" id=%s basic_data=%u data1=%u desc=%s\n"),
165 id, iv->basic_data (), iv->data1 (), desc));
166 char *tmp = CORBA::string_alloc (
167 static_cast<CORBA::ULong> (ACE_OS::strlen (id) + ACE_OS::strlen (desc) + 2));
168 ACE_OS::sprintf (tmp, "%s: %s", id, desc);
169 CORBA::string_free (desc);
170 desc = tmp;
172 ov->basic_data (iv->basic_data());
173 ov->data1 (iv->data1());
177 void
178 Test_impl::shutdown ()
180 this->orb_->shutdown (false);