Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Param_Test / fixed_array.cpp
blob20118bc7838e43badfb1c380c970f2db960e89c4
2 //=============================================================================
3 /**
4 * @file fixed_array.cpp
6 * tests fixed size arrays
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "fixed_array.h"
16 // ************************************************************************
17 // Test_Fixed_Array
18 // ************************************************************************
20 Test_Fixed_Array::Test_Fixed_Array ()
21 : opname_ (CORBA::string_dup ("test_fixed_array")),
22 ret_ (new Param_Test::Fixed_Array)
26 Test_Fixed_Array::~Test_Fixed_Array ()
28 CORBA::string_free (this->opname_);
29 this->opname_ = 0;
32 const char *
33 Test_Fixed_Array::opname () const
35 return this->opname_;
38 void
39 Test_Fixed_Array::dii_req_invoke (CORBA::Request *req)
41 req->add_in_arg ("s1") <<= Param_Test::Fixed_Array_forany (this->in_);
42 req->add_inout_arg ("s2") <<= Param_Test::Fixed_Array_forany (this->inout_);
43 req->add_out_arg ("s3") <<= Param_Test::Fixed_Array_forany (this->out_);
44 req->set_return_type (Param_Test::_tc_Fixed_Array);
46 req->invoke ();
48 Param_Test::Fixed_Array_forany forany;
49 req->return_value () >>= forany;
50 Param_Test::Fixed_Array_copy (this->ret_, forany.in ());
52 CORBA::NamedValue_ptr arg2 =
53 req->arguments ()->item (1);
54 *arg2->value () >>= forany;
55 Param_Test::Fixed_Array_copy (this->inout_, forany.in ());
57 CORBA::NamedValue_ptr arg3 =
58 req->arguments ()->item (2);
59 Param_Test::Fixed_Array_forany out_any (this->out_);
60 *arg3->value () >>= forany;
61 Param_Test::Fixed_Array_copy (this->out_, forany.in ());
64 int
65 Test_Fixed_Array::init_parameters (Param_Test_ptr /*objref*/
66 /*env*/)
68 Generator *gen = GENERATOR::instance (); // value generator
70 //ACE_UNUSED_ARG (objref);
72 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
74 this->in_ [i] = gen->gen_long ();
77 return 0;
80 int
81 Test_Fixed_Array::reset_parameters ()
83 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
85 this->inout_ [i] = 0;
86 this->out_ [i] = 0;
88 // free the return value array
89 Param_Test::Fixed_Array_free (this->ret_._retn ());
90 // needed for repeated DII calls
91 this->ret_ = new Param_Test::Fixed_Array;
92 return 0;
95 int
96 Test_Fixed_Array::run_sii_test (Param_Test_ptr objref)
98 try
100 this->ret_ = objref->test_fixed_array (this->in_,
101 this->inout_,
102 this->out_);
104 return 0;
106 catch (const CORBA::Exception& ex)
108 ex._tao_print_exception ("Test_Fixed_Array::run_sii_test\n");
110 return -1;
113 CORBA::Boolean
114 Test_Fixed_Array::check_validity ()
116 if (this->compare (this->in_, this->inout_) &&
117 this->compare (this->in_, this->out_) &&
118 this->compare (this->in_, this->ret_.in ()))
119 return 1;
120 else
121 return 0;
124 CORBA::Boolean
125 Test_Fixed_Array::check_validity (CORBA::Request_ptr /*req*/)
127 //ACE_UNUSED_ARG (req);
128 return this->check_validity ();
131 CORBA::Boolean
132 Test_Fixed_Array::compare (const Param_Test::Fixed_Array_slice *a1,
133 const Param_Test::Fixed_Array_slice *a2)
135 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
137 if (a1[i] != a2[i])
138 return 0;
140 return 1; // success
143 void
144 Test_Fixed_Array::print_values ()
146 ACE_DEBUG ((LM_DEBUG, "IN array\n"));
147 this->print (this->in_);
148 ACE_DEBUG ((LM_DEBUG, "INOUT array\n"));
149 this->print (this->inout_);
150 ACE_DEBUG ((LM_DEBUG, "OUT array\n"));
151 this->print (this->out_);
152 ACE_DEBUG ((LM_DEBUG, "RET array\n"));
153 this->print (this->ret_.in ());
156 void
157 Test_Fixed_Array::print (const Param_Test::Fixed_Array_slice *a)
159 for (CORBA::ULong i = 0; i < Param_Test::DIM1; i++)
161 ACE_DEBUG ((LM_DEBUG, "\t\tElement #%d = %d\n",i, a[i]));