Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / DynamicInterface / DII_Arguments_Converter_Impl.cpp
blob3b84a8dd3bcd02fbc731b2f248c539d204a5c4b7
1 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
2 #include "tao/DynamicInterface/DII_Arguments.h"
3 #include "tao/AnyTypeCode/NVList.h"
4 #include "tao/AnyTypeCode/Any_Impl.h"
5 #include "tao/operation_details.h"
6 #include "tao/SystemException.h"
7 #include "tao/CDR.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 void
12 TAO_DII_Arguments_Converter_Impl::convert_request (
13 TAO_ServerRequest & server_request,
14 TAO::Argument * const args[],
15 size_t nargs)
17 // The DII requests on client side always have two arguments
18 // - one is the return argument and the other is NVList_Argument.
19 // Since the argument list in the client side is used by server side
20 // in collocation case and the server expects the list of arguments
21 // and not the NVList_Argument, we need expand the NVList_Argument
22 // to be list of Arguments.
24 // Before expanding NVList_Argument logic was added, the
25 // $TAO_ROOT/tests/DII_Collocated_Tests/run_test.pl should fail.
26 // The servant will get incorrect "IN" parameter from the oneway
27 // operation with single "IN" parameter and get access violation on
28 // get_in_arg () from the oneway operation with multiple "IN"
29 // parameters.
30 CORBA::NVList_ptr lst
31 = static_cast<TAO::NVList_Argument *> (
32 server_request.operation_details ()->args()[1])->arg ();
34 CORBA::ULong const sz = lst->count ();
36 if (sz != nargs - 1)
38 throw ::CORBA::BAD_PARAM ();
41 // To avoid the use of extraction operators on CORBA::Any, we will
42 // marshal the arguments in the NVList into an output cdr and then
43 // demarshal them into the TAO::Argument array.
44 TAO_OutputCDR output;
45 for (CORBA::ULong i = 0; i < sz; ++i)
47 CORBA::NamedValue_ptr theitem = lst->item (i);
49 if (!(theitem->value ()->impl ()->marshal_value (output)))
51 throw ::CORBA::BAD_PARAM ();
55 TAO_InputCDR input (output);
56 for (CORBA::ULong j = 0; j < sz; ++j)
58 if (!(args[j + 1]->demarshal (input)))
60 throw ::CORBA::BAD_PARAM ();
64 TAO_Operation_Details* details
65 = const_cast <TAO_Operation_Details*> (server_request.operation_details ());
67 // The NVList_Argument in operation details is converted to skel
68 // args, the invocation of the dii collocation requests should use
69 // the skel args and not use the stub args.
70 details->use_stub_args (false);
73 void
74 TAO_DII_Arguments_Converter_Impl::dsi_convert_request (
75 TAO_ServerRequest & server_request,
76 TAO_OutputCDR & output)
78 // The DII requests on client side always have two arguments
79 // - one is the return argument and the other is NVList_Argument.
80 CORBA::NVList_ptr lst
81 = static_cast<TAO::NVList_Argument *> (
82 server_request.operation_details ()->args()[1])->arg ();
84 // Only marshal the in(out) arguments since we use this to demarshal
85 // these values in the serverside argument list.
86 lst->_tao_encode (output, CORBA::ARG_IN | CORBA::ARG_INOUT);
89 void
90 TAO_DII_Arguments_Converter_Impl::convert_reply (
91 TAO_ServerRequest & server_request,
92 TAO::Argument * const args[],
93 size_t nargs)
95 TAO_OutputCDR output;
96 errno = 0;
97 for (CORBA::ULong j = 0; j < nargs; ++j)
99 if (!(args[j]->marshal (output)))
101 TAO_OutputCDR::throw_skel_exception (errno);
104 TAO_InputCDR input (output);
105 this->dsi_convert_reply (server_request, input);
108 void
109 TAO_DII_Arguments_Converter_Impl::dsi_convert_reply (
110 TAO_ServerRequest & server_request,
111 TAO_InputCDR & input)
113 TAO::NamedValue_Argument * _ret_val
114 = static_cast<TAO::NamedValue_Argument *> (
115 server_request.operation_details ()->args()[0]);
117 _ret_val->demarshal (input);
119 CORBA::NVList_ptr lst
120 = static_cast<TAO::NVList_Argument *> (
121 server_request.operation_details ()->args()[1])->arg ();
123 lst->_tao_decode (input,
124 CORBA::ARG_INOUT | CORBA::ARG_OUT);
127 void
128 TAO_DII_Arguments_Converter_Impl::handle_corba_exception (
129 TAO_ServerRequest & /*server_request*/,
130 CORBA::Exception *exception)
132 exception->_raise ();
135 // *********************************************************************
137 // Initialization and registration of dynamic service object.
140 TAO_DII_Arguments_Converter_Impl::Initializer ()
142 return ACE_Service_Config::process_directive (
143 ace_svc_desc_TAO_DII_Arguments_Converter_Impl);
147 TAO_END_VERSIONED_NAMESPACE_DECL
149 ACE_STATIC_SVC_DEFINE (
150 TAO_DII_Arguments_Converter_Impl,
151 ACE_TEXT ("DII_Arguments_Converter"),
152 ACE_SVC_OBJ_T,
153 &ACE_SVC_NAME (TAO_DII_Arguments_Converter_Impl),
154 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
158 ACE_FACTORY_DEFINE (TAO_DynamicInterface, TAO_DII_Arguments_Converter_Impl)