From 24260be089da8538e3dcb4bc94946a8c4bff101b Mon Sep 17 00:00:00 2001 From: coryan Date: Fri, 10 Mar 2000 19:31:32 +0000 Subject: ChangeLogTag:Fri Mar 10 11:28:17 2000 Carlos O'Ryan --- TAO/ChangeLogs/ChangeLog-02a | 10 ++++ TAO/tao/Any.cpp | 5 +- TAO/tao/GIOPC.cpp | 140 +++++++------------------------------------ TAO/tao/GIOPC.h | 2 + 4 files changed, 37 insertions(+), 120 deletions(-) diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 49ebb88deab..fece095e405 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,13 @@ +Fri Mar 10 11:28:17 2000 Carlos O'Ryan + + * tao/Any.cpp: + The >>= operator for 'const Any*' was not working properly, + thanks to Jeff for letting me know. + + * tao/GIOPC.h: + * tao/GIOPC.cpp: + Another pair of files updated. + Fri Mar 10 12:49:21 2000 Jeff Paraons * TAO_IDL/be/be_codegen.cpp diff --git a/TAO/tao/Any.cpp b/TAO/tao/Any.cpp index 6cf993c58d1..42ade0776ac 100644 --- a/TAO/tao/Any.cpp +++ b/TAO/tao/Any.cpp @@ -1363,8 +1363,9 @@ CORBA_Any::operator>>= (const CORBA::Any *&a) const } else { - CORBA::Any_var tmp; - ACE_NEW_RETURN (tmp.out (), CORBA::Any, 0); + CORBA::Any *x; + ACE_NEW_RETURN (x, CORBA::Any, 0); + CORBA::Any_var tmp = x; TAO_InputCDR stream (this->cdr_, this->byte_order_); if (!(stream >> tmp.inout ())) diff --git a/TAO/tao/GIOPC.cpp b/TAO/tao/GIOPC.cpp index 400edc567ab..202e7c59179 100644 --- a/TAO/tao/GIOPC.cpp +++ b/TAO/tao/GIOPC.cpp @@ -388,28 +388,29 @@ TAO_NAMESPACE_BEGIN (GIOP) TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_TargetAddress, &_tc_TAO_tc_GIOP_TargetAddress) TAO_NAMESPACE_END +VOID +GIOP::IORAddressingInfo::_tao_any_destructor (void *x) +{ + GIOP::IORAddressingInfo *tmp = ACE_static_cast (GIOP::IORAddressingInfo*,x); + delete x; +} + void operator<<= (CORBA::Any &_tao_any, const GIOP::IORAddressingInfo &_tao_elem) // copying { - GIOP::IORAddressingInfo *_any_val = 0; - ACE_NEW (_any_val, GIOP::IORAddressingInfo (_tao_elem)); - if (!_any_val) return; ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - stream << *_any_val; + stream << _tao_elem; _tao_any._tao_replace ( GIOP::_tc_IORAddressingInfo, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _any_val, ACE_TRY_ENV ); ACE_TRY_CHECK; } ACE_CATCHANY { - delete _any_val; } ACE_ENDTRY; } @@ -426,6 +427,7 @@ void operator<<= (CORBA::Any &_tao_any, GIOP::IORAddressingInfo *_tao_elem) // n stream.begin (), 1, _tao_elem, + GIOP::IORAddressingInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -433,7 +435,6 @@ void operator<<= (CORBA::Any &_tao_any, GIOP::IORAddressingInfo *_tao_elem) // n ACE_CATCHANY { delete _tao_elem; - _tao_elem = 0; } ACE_ENDTRY; } @@ -467,6 +468,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, GIOP::IORAddressingInfo GIOP::_tc_IORAddressingInfo, 1, ACE_reinterpret_cast (void *, _tao_elem), + GIOP::IORAddressingInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -491,53 +493,14 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, GIOP::IORAddressingInfo CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const GIOP::IORAddressingInfo *&_tao_elem) { - ACE_TRY_NEW_ENV - { - CORBA::TypeCode_var type = _tao_any.type (); - if (!type->equivalent (GIOP::_tc_IORAddressingInfo, ACE_TRY_ENV)) // not equal - { - _tao_elem = 0; - return 0; - } - ACE_TRY_CHECK; - if (_tao_any.any_owns_data ()) - { - _tao_elem = (GIOP::IORAddressingInfo *)_tao_any.value (); - return 1; - } - else - { - ACE_NEW_RETURN (_tao_elem, GIOP::IORAddressingInfo, 0); - TAO_InputCDR stream ( - _tao_any._tao_get_cdr (), - _tao_any._tao_byte_order () - ); - if (stream >> *(GIOP::IORAddressingInfo *)_tao_elem) - { - ((CORBA::Any *)&_tao_any)->_tao_replace ( - GIOP::_tc_IORAddressingInfo, - 1, - ACE_reinterpret_cast (void *, ACE_const_cast (GIOP::IORAddressingInfo *&, _tao_elem)), - ACE_TRY_ENV - ); - ACE_TRY_CHECK; - return 1; - } - else - { - delete ACE_const_cast (GIOP::IORAddressingInfo *&, _tao_elem); - _tao_elem = 0; - } - } - } - ACE_CATCHANY - { - delete ACE_const_cast (GIOP::IORAddressingInfo *&, _tao_elem); - _tao_elem = 0; - return 0; - } - ACE_ENDTRY; - return 0; + return _tao_any >>= ACE_const_cast(GIOP::IORAddressingInfo*&,_tao_elem); +} + +void +GIOP::TargetAddress::_tao_any_destructor (void *x) +{ + GIOP::TargetAddress *tmp = ACE_static_cast (GIOP::TargetAddress*,x); + delete tmp; } void operator<<= ( @@ -545,31 +508,22 @@ void operator<<= ( const GIOP::TargetAddress &_tao_elem ) { - GIOP::TargetAddress *_any_val = 0; - ACE_NEW (_any_val, GIOP::TargetAddress (_tao_elem)); ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - if (stream << *_any_val) + if (stream << _tao_elem) { _tao_any._tao_replace ( GIOP::_tc_TargetAddress, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _any_val, ACE_TRY_ENV ); ACE_TRY_CHECK; } - else - { - delete _any_val; - } } ACE_CATCHANY { - delete _any_val; } ACE_ENDTRY; } @@ -590,19 +544,14 @@ void operator<<= ( stream.begin (), 1, _tao_elem, + GIOP::IORAddressingInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; } - else - { - delete _tao_elem; - } } ACE_CATCHANY { - delete _tao_elem; - _tao_elem = 0; } ACE_ENDTRY; } @@ -640,6 +589,7 @@ CORBA::Boolean operator>>= ( GIOP::_tc_TargetAddress, 1, ACE_reinterpret_cast (void *, _tao_elem), + GIOP::IORAddressingInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -666,53 +616,7 @@ CORBA::Boolean operator>>= ( const GIOP::TargetAddress *&_tao_elem ) { - ACE_TRY_NEW_ENV - { - CORBA::TypeCode_var type = _tao_any.type (); - if (!type->equivalent (GIOP::_tc_TargetAddress, ACE_TRY_ENV)) // not equal - { - _tao_elem = 0; - return 0; - } - ACE_TRY_CHECK; - if (_tao_any.any_owns_data ()) - { - _tao_elem = (GIOP::TargetAddress *)_tao_any.value (); - return 1; - } - else - { - ACE_NEW_RETURN (_tao_elem, GIOP::TargetAddress, 0); - TAO_InputCDR stream ( - _tao_any._tao_get_cdr (), - _tao_any._tao_byte_order () - ); - - if (stream >> *(GIOP::TargetAddress *)_tao_elem) - { - ((CORBA::Any *)&_tao_any)->_tao_replace ( - GIOP::_tc_TargetAddress, - 1, - ACE_reinterpret_cast (void *, ACE_const_cast (GIOP::TargetAddress *&, _tao_elem)), - ACE_TRY_ENV - ); - ACE_TRY_CHECK; - return 1; - } - else - { - delete ACE_const_cast (GIOP::TargetAddress *&, _tao_elem); - _tao_elem = 0; - } - } - } - ACE_CATCHANY - { - delete ACE_const_cast (GIOP::TargetAddress *&, _tao_elem); - _tao_elem = 0; - } - ACE_ENDTRY; - return 0; + return _tao_any >>= ACE_const_cast (GIOP::TargetAddress*&,_tao_elem); } #if !defined _TAO_CDR_OP_GIOP_TargetAddress__tao_seq_Octet_CPP_ diff --git a/TAO/tao/GIOPC.h b/TAO/tao/GIOPC.h index faa96814ed9..3e9765144f1 100644 --- a/TAO/tao/GIOPC.h +++ b/TAO/tao/GIOPC.h @@ -86,6 +86,7 @@ TAO_NAMESPACE GIOP typedef IORAddressingInfo_ptr _ptr_type; typedef IORAddressingInfo_var _var_type; #endif /* ! __GNUC__ || g++ >= 2.8 */ + static void _tao_any_destructor (void*); CORBA::ULong selected_profile_index; IOP::IOR ior; @@ -161,6 +162,7 @@ TAO_NAMESPACE GIOP typedef TargetAddress_ptr _ptr_type; typedef TargetAddress_var _var_type; #endif /* ! __GNUC__ || g++ >= 2.8 */ + static void _tao_any_destructor (void*); #if !defined (_GIOP_TARGETADDRESS__TAO_SEQ_OCTET_CH_) #define _GIOP_TARGETADDRESS__TAO_SEQ_OCTET_CH_ -- cgit v1.2.1