[omniORB] Inout parameter - DII
Gary D. Duzan
gdd0@gte.com
Mon, 25 Jun 2001 14:44:46 -0400
>From the 2.3.1 C++ Mapping Spec, section 1.30.4:
Request has the following special memory management rules:
Ownership of the return values of the target, operation,
arguments, result, env, exceptions, contexts, and ctx functions
is maintained by the Request; these return values must not be
freed by the caller.
That cast of a String_var looked dubious, anyway. Better to create
your own const char * and extract to that.
Gary Duzan
Verizon IT
In Message <33DB02A3ED28D511AEEA00B0D0AA173401870E@SYNERGY> ,
Shanmugam Deveraj <shm@transynergy.net> wrote:
=>Hi!
=>
=>Who holds the memory allocated/re-allocated in execute()?
=>Is it my_inout or sReturn? sReturn asserts while freeing the memory.
=>
=>What happens to the memory for the below redirection?
=> my_inout >>= (char *&)sReturn;
=>
=>Regards,
=>Shanmugam.D.
=>
=>-----Original Message-----
=>From: owner-omniorb-list@uk.research.att.com
=>[mailto:owner-omniorb-list@uk.research.att.com]On Behalf Of Shanmugam
=>Deveraj
=>Sent: Monday, June 25, 2001 8:07 PM
=>To: 'Gary D. Duzan'; 'omniorb-list@uk.research.att.com'
=>Subject: RE: [omniORB] Inout parameter - DII
=>
=>
=>Hi Gary Duzan
=>
=>Thanks a lot. It works with.
=> my_inout >>= (const char *&)sReturn;
=>
=>Regards,
=>Shanmugam.D.
=>
=>-----Original Message-----
=>From: Gary D. Duzan [mailto:gdd0@gte.com]
=>Sent: Monday, June 25, 2001 7:48 PM
=>To: Shanmugam Deveraj
=>Subject: Re: [omniORB] Inout parameter - DII
=>
=>
=>I haven't tried it myself, but this should work:
=>
=> CORBA::Any& my_inout = req->add_inout_arg();
=> my_inout <<= sReturn;
=>
=> // ...
=>
=> req->invoke();
=>
=> // ...
=>
=> my_inout >>= sReturn;
=>
=>I imagine it is replacing the Any contents, not the _var contents,
=>so you have to do it yourself.
=>
=> Gary Duzan
=> Verizon IT
=>
=>
=>
=>In Message <33DB02A3ED28D511AEEA00B0D0AA173401870C@SYNERGY> ,
=> Shanmugam Deveraj <shm@transynergy.net> wrote:
=>
=>=>Hi
=>=>
=>=>Can anyone throw some highlight on why inout parameter doesn't work in
=>=>the DII scenario? Is it not supposed to work? Any pointers please?.
=>=>
=>=>Normal method call:- (This works)
=>=> CORBA::String_var sParam = (const char *)"Nothing for now";
=>=> CORBA::String_var sInput = (const char *)sInputBuf;
=>=> CORBA::String_var sReturn;
=>=> refObj->Execute(sParam,sInput,sReturn);
=>=>
=>=> cout << (const char *)sReturn; // contains the value set in
=>=>execute() method.
=>=>
=>=>DII method call:- (This does not work)
=>=> CORBA::String_var sParam = (const char *)"Nothing for now";
=>=> CORBA::String_var sInput = (const char *)sInputBuf;
=>=> CORBA::String_var sReturn;
=>=>
=>=> CORBA::Request_var req;
=>=> req = obj->_request("Execute");
=>=>
=>=> req->add_in_arg() <<= sParam;
=>=> req->add_in_arg() <<= sInput;
=>=> req->add_inout_arg() <<= sReturn;
=>=>
=>=> req->set_return_type(CORBA::_tc_boolean);
=>=>
=>=> req->invoke();
=>=>
=>=> if( req->env()->exception() ) {
=>=> cerr << "Test : An exception was thrown while invoking a
=>=>corba method!" << endl;
=>=> return;
=>=> }
=>=> cout << (const char *)sReturn; // does not contain the value
=>=>set in execute() method.
=>=>
=>=>I am able to get the 'sParam', 'sInput' values in Execute method. I am
=>=>also able to get 'sReturn' value in execute() but not the return
=>value.
=>=>
=>=>bool CMyObject::Execute(const char *sParam, const char *sInput, char
=>=>*&sReturn)
=>=>{
=>=> ...
=>=> sReturn = CORBA::string_dup("Hi");
=>=>}
=>=>
=>=>Regards,
=>=>Shanmugam.D.
=>=>
=>=>
=>