[orbitcpp-list] Re: C++ mapping of OUT variable-length structures
Status: Beta
Brought to you by:
philipd
From: Diego S. R. <dse...@di...> - 2002-04-24 16:21:09
|
Hi! On Wed, Apr 24, 2002 at 04:04:55PM +0200, ERDI Gergo wrote: | According to a CORBA/C++ spec I've found on the web, the mapping of OUT | arguments for variable-length structures is T*&. However, I see that th= ere | are auxillary _out classes in the main ORBit2/C++ branch.=20 | So my questions are: | 1, What's the point of these _out classes? I hope I can explain it well... Please, take a look at H&V book, pages 300-302. The question is that as the _out types are allocated by the callee, (and are passed by reference), there must be a way to deallocate the previous owned reference if you use a _var type. That is, the pointer contained in the call (the value of the T*&) must be 0 (NULL), so the _out type constructor ensures this for just pointers (for instance char*) and for _var classes. This is:=20 1) it frees any memory allocated with the internal _var variable before=20 calling the method if the actual _var variable is passed as an _out=20 parameter, and 2) it sets any pointer to null (if not using a _var variable). | 2, Where should the allocation happen? Should the server allocate | the structure? Should it be allocated by the client before doing the ca= ll? | Both? Neither? The structure must be allocated by the implementation code for this object written by the object implementation programmer. |=20 | Right now in my ORBit/C++ branch I'm allocating/deallocating on the cli= ent | side via the new/delete operators, but it would be very easy to modify | this scheme to do the Right Thing. In the C++ mapping (contrary to the C mapping) out types are always allocated by the callee and freed by the caller. > So what does the CORBA/C++ spec say | about this? |=20 Hope I explained it well... Best regards. diego. --=20 Diego Sevilla Ruiz http://ditec.um.es/~dsevilla dse...@um... \ /\ Dpto. Ingenier=EDa y Tecnolog=EDa de Computadores http://ditec.um.es ) = ( ') Visiting Extreme! Computing Lab http://extreme.indiana.edu ( / ) Indiana University, Bloomington http://www.iub.edu \(__)| |