[omniORB] long -> Any -> Any

David Riddoch djr@uk.research.att.com
Thu, 2 Sep 1999 17:07:08 +0100 (GMT)


On Thu, 2 Sep 1999, HA Quoc Viet wrote:

> =================================================================================
> 
> long l = 2;
> CORBA::Any any, value;
> 
> any <<= l ;         // works, though not with all orbs (ie mico fails)
> value << any ;
> l=1;
> value >> l ;        // doesn't work. I'd bet value is not storing a long
> but an Any 
> 
> ... finally yelds l=1, and not l=2 as I expected.

As it should -- you have inserted an Any into an Any.
(I assume you mean <<= and >>= not << and >>).


> ==================================================================================
> 
> CORBA::Any src,dst;
> memcpy( (void*)dst , (void*)src , siezof(CORBA::Any) );
> 
> make things very unstable

Yes - this is completely illegal.


> ==================================================================================
> 
> CORBA::Any src,dst;
> dst = src ;
> 
> doesn't work either

In what way does it not work?  It should.

eg.
CORBA::Any a1, a2;
CORBA::Long l1 = 1, l2 = 2;

a1 <<= l1;
a2 = a1;
a2 >>= l2;

assert(l1 == l2);


Let me know if this doesn't work.
David