diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-12-02 09:43:41 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-12-02 09:43:41 +0000 |
commit | 0c3c0c65057a058342b46552a924d3dc499d3429 (patch) | |
tree | 85788c2def9accf5582674948068fe3b131c03fb /TAO | |
parent | 08e7573845b7eea9a248febf52df21c04bb4389d (diff) | |
download | ATCD-0c3c0c65057a058342b46552a924d3dc499d3429.tar.gz |
Exception handling macros integration
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/tao/CDR.i | 12 | ||||
-rw-r--r-- | TAO/tao/Exception.cpp | 16 | ||||
-rw-r--r-- | TAO/tao/Marshal.i | 6 | ||||
-rw-r--r-- | TAO/tao/Typecode.cpp | 551 | ||||
-rw-r--r-- | TAO/tao/decode.cpp | 149 | ||||
-rw-r--r-- | TAO/tao/deep_free.cpp | 514 |
6 files changed, 567 insertions, 681 deletions
diff --git a/TAO/tao/CDR.i b/TAO/tao/CDR.i index 921f5d83ac5..43635caf4c6 100644 --- a/TAO/tao/CDR.i +++ b/TAO/tao/CDR.i @@ -681,9 +681,9 @@ TAO_InputCDR::skip (CORBA::TypeCode_ptr tc, TAO_Marshal_Object *mobj = this->factory_->make_marshal_object (tc, env); - if (env.exception() == 0 && mobj != 0) - return mobj->skip (tc, this, env); - return CORBA::TypeCode::TRAVERSE_STOP; + TAO_CHECK_CONDITION_ENV_RETURN (env, || mobj == 0, CORBA::TypeCode::TRAVERSE_STOP); + + return mobj->skip (tc, this, env); } ACE_INLINE size_t @@ -1141,7 +1141,7 @@ TAO_OutputCDR::append (CORBA::TypeCode_ptr tc, TAO_Marshal_Object *mobj = this->factory_->make_marshal_object (tc, env); - if (env.exception() == 0 && mobj != 0) - return mobj->append (tc, src, this, env); - return CORBA::TypeCode::TRAVERSE_STOP; + TAO_CHECK_CONDITION_ENV_RETURN (env, || mobj == 0, CORBA::TypeCode::TRAVERSE_STOP); + + return mobj->append (tc, src, this, env); } diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp index 3d4e18e06b2..cb39203fd27 100644 --- a/TAO/tao/Exception.cpp +++ b/TAO/tao/Exception.cpp @@ -280,10 +280,7 @@ TAO_Exceptions::make_unknown_user_typecode (CORBA::TypeCode_ptr &tcp, || stream.encode (CORBA::_tc_TypeCode, &CORBA::_tc_any, 0, env) != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - env.exception (new CORBA_INITIALIZE (CORBA::COMPLETED_NO)); - return; - } + TAO_THROW_ENV (CORBA_INITIALIZE (CORBA::COMPLETED_NO), env); tcp = new CORBA::TypeCode (CORBA::tk_except, stream.length (), @@ -346,10 +343,8 @@ TAO_Exceptions::make_standard_typecode (CORBA::TypeCode_ptr &tcp, env) != CORBA::TypeCode::TRAVERSE_CONTINUE || stream.encode (CORBA::_tc_TypeCode, &TC_completion_status, 0, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE) { - env.exception (new CORBA_INITIALIZE (CORBA::COMPLETED_NO)); - return; - } + env) != CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_THROW_ENV (CORBA_INITIALIZE (CORBA::COMPLETED_NO), env); // OK, we stuffed the buffer we were given (or grew a bigger one; // hope to avoid that during initialization). Now build and return @@ -598,10 +593,7 @@ CORBA_ExceptionList::item (CORBA::ULong index, CORBA::TypeCode_ptr *tc; env.clear (); if (this->tc_list_.get (tc, index) == -1) - { - env.exception (new CORBA::TypeCode::Bounds); - return 0; - } + TAO_THROW_ENV (CORBA::TypeCode::Bounds (), env); else { return CORBA::TypeCode::_duplicate (*tc); diff --git a/TAO/tao/Marshal.i b/TAO/tao/Marshal.i index d4c9655ccb1..13f0faeb246 100644 --- a/TAO/tao/Marshal.i +++ b/TAO/tao/Marshal.i @@ -147,11 +147,7 @@ TAO_Marshal_Factory::make_marshal_object (CORBA::TypeCode_ptr tc, { if (tc && tc->kind_ >= 0 && tc->kind_ < CORBA::TC_KIND_COUNT) return this->mobj_table_[tc->kind_].obj_; - else - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); } // *************** deep_free methods ****************** diff --git a/TAO/tao/Typecode.cpp b/TAO/tao/Typecode.cpp index 25a68c329f6..bbd0df3e920 100644 --- a/TAO/tao/Typecode.cpp +++ b/TAO/tao/Typecode.cpp @@ -294,10 +294,7 @@ CORBA_TypeCode::member_type (CORBA::ULong index, if (index < this->private_state_->tc_member_count_) return this->private_state_->tc_member_type_list_[index]; else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, 0); } else return this->private_member_type (index, env); @@ -335,10 +332,7 @@ CORBA_TypeCode::member_label (CORBA::ULong index, if (index < this->private_state_->tc_member_count_) return this->private_state_->tc_member_label_list_[index]; else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, 0); } else return this->private_member_label (index, env); @@ -348,36 +342,26 @@ CORBA_TypeCode::member_label (CORBA::ULong index, CORBA::TypeCode_ptr CORBA_TypeCode::discriminator_type (CORBA::Environment &env) const { - if (this->kind_ == CORBA::tk_union) - { - if (this->private_state_->tc_discriminator_type_known_) - return this->private_state_->tc_discriminator_type_; - else - return this->private_discriminator_type (env); - } + if (this->kind_ != CORBA::tk_union) + TAO_THROW_ENV_RETURN (CORBA::TypeCode::BadKind (), env, (CORBA::TypeCode_ptr)0); + + if (this->private_state_->tc_discriminator_type_known_) + return this->private_state_->tc_discriminator_type_; else - { - env.exception (new CORBA::TypeCode::BadKind ()); - return (CORBA::TypeCode_ptr)0; - } + return this->private_discriminator_type (env); } // only applicable to CORBA::tk_unions CORBA::Long CORBA_TypeCode::default_index (CORBA::Environment &env) const { - if (this->kind_ == CORBA::tk_union) - { - if (this->private_state_->tc_default_index_used_known_) - return this->private_state_->tc_default_index_used_; - else - return this->private_default_index (env); - } + if (this->kind_ != CORBA::tk_union) + TAO_THROW_ENV_RETURN (CORBA::TypeCode::BadKind (), env, 0); + + if (this->private_state_->tc_default_index_used_known_) + return this->private_state_->tc_default_index_used_; else - { - env.exception (new CORBA::TypeCode::BadKind ()); - return 0; - } + return this->private_default_index (env); } // returns the length. Applicable only to string, sequence, and arrays @@ -426,18 +410,13 @@ CORBA_TypeCode::content_type (CORBA::Environment &env) const CORBA::ULong CORBA_TypeCode::TAO_discrim_pad_size (CORBA::Environment &env) { - if (this->kind_ == CORBA::tk_union) - { - if (this->private_state_->tc_discrim_pad_size_known_) - return this->private_state_->tc_discrim_pad_size_; - else - return this->private_discrim_pad_size (env); - } + if (this->kind_ != CORBA::tk_union) + TAO_THROW_ENV_RETURN (CORBA::TypeCode::BadKind (), env, 0); + + if (this->private_state_->tc_discrim_pad_size_known_) + return this->private_state_->tc_discrim_pad_size_; else - { - env.exception (new CORBA::TypeCode::BadKind ()); - return 0; - } + return this->private_discrim_pad_size (env); } // skip a typecode encoding in a given CDR stream @@ -1322,10 +1301,7 @@ CORBA_TypeCode::private_member_count (CORBA::Environment &env) const if (!stream.skip_string () // ID || !stream.skip_string () // struct name || !stream.read_ulong (members)) - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); this->private_state_->tc_member_count_known_ = 1; this->private_state_->tc_member_count_ = members; @@ -1351,21 +1327,16 @@ CORBA_TypeCode::private_member_count (CORBA::Environment &env) const || !skip_typecode (stream) // discriminant TC || !stream.read_ulong (members) // default used || !stream.read_ulong (members)) // real member count - { - // this is a system exception indicating something is wrong with - // the typecode itself. - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); this->private_state_->tc_member_count_known_ = 1; this->private_state_->tc_member_count_ = members; return this->private_state_->tc_member_count_; } default: - env.exception (new CORBA::TypeCode::BadKind ()); - return 0; + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); } + ACE_NOTREACHED (return 0); } // NOTE special calling convention for stream.decode () when we're @@ -1394,174 +1365,148 @@ CORBA_TypeCode::private_member_type (CORBA::ULong index, case CORBA::tk_except: case CORBA::tk_struct: // index from 0 mcount = this->member_count (env); // clears env - if (env.exception () == 0) - { - // Double checked locking... - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, - this->private_state_->mutex_, 0); - if (this->private_state_->tc_member_type_list_known_) - if (index < mcount) - return this->private_state_->tc_member_type_list_[index]; - else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return CORBA::TypeCode::_nil (); - } + // @@EXC@@ Why are we rethrowing a different exception here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, (CORBA::TypeCode_ptr)0); + TAO_CHECK_ENV_RETURN (env, (CORBA::TypeCode_ptr)0); + + { + // Double checked locking... + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, + this->private_state_->mutex_, 0); + if (this->private_state_->tc_member_type_list_known_) + if (index < mcount) + return this->private_state_->tc_member_type_list_[index]; + else + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, CORBA::TypeCode::_nil ()); - // the first time in. Precompute and store types of all members + // the first time in. Precompute and store types of all members - // Allocate a list to hold the member typecodes - this->private_state_->tc_member_type_list_ = new CORBA::TypeCode_ptr [mcount]; + // Allocate a list to hold the member typecodes + // @@EXC@@ Need to check for allocation failure here. + this->private_state_->tc_member_type_list_ = new CORBA::TypeCode_ptr [mcount]; - if (this->private_state_->tc_member_type_list_) - { - // skip the id, name, and member_count part - if (!stream.skip_string () // type ID, hidden - || !stream.skip_string () // typedef name - || !stream.read_ulong (temp)) // member count - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return (CORBA::TypeCode_ptr)0; - } - else - { - // compute the typecodes for all the members and - // return the required one. - for (CORBA::ULong i = 0; i < mcount; i++) - // the ith entry will have the typecode of the ith guy - if (!stream.skip_string () // skip the name - || stream.decode (CORBA::_tc_TypeCode, - // the typecode will be - // retrieved at the i-th - // location. The decode - // routine will allocate the - // storage to hold a - // typecode - &this->private_state_-> - tc_member_type_list_[i], - this, - // pass ourselves since we - // will be the parent. This - // is the case where the 3rd - // parameter is used in a - // decode method - env) != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + if (this->private_state_->tc_member_type_list_ == 0) + TAO_THROW_ENV_RETURN (CORBA::NO_MEMORY (CORBA::COMPLETED_NO), env, (CORBA::TypeCode_ptr)0); - this->private_state_->tc_member_type_list_known_ = 1; + // skip the id, name, and member_count part + if (!stream.skip_string () // type ID, hidden + || !stream.skip_string () // typedef name + || !stream.read_ulong (temp)) // member count + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, (CORBA::TypeCode_ptr)0); - if (index < mcount) - return this->private_state_->tc_member_type_list_[index]; - else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return (CORBA::TypeCode_ptr)0; - } - } - } - else // no memory for the member_list - { - env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO)); - return (CORBA::TypeCode_ptr)0; - } - } - else // out of bounds - { - env.exception (new CORBA::TypeCode::Bounds ()); - return (CORBA::TypeCode_ptr)0; - } + // compute the typecodes for all the members and + // return the required one. + for (CORBA::ULong i = 0; i < mcount; i++) + // the ith entry will have the typecode of the ith guy + { + if (!stream.skip_string ()) // skip the name + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + CORBA::TypeCode::traverse_status status = + stream.decode (CORBA::_tc_TypeCode, + // the typecode will be + // retrieved at the i-th + // location. The decode + // routine will allocate the + // storage to hold a + // typecode + &this->private_state_-> + tc_member_type_list_[i], + this, + // pass ourselves since we + // will be the parent. This + // is the case where the 3rd + // parameter is used in a + // decode method + env); + TAO_CHECK_ENV_RETURN (env, 0); + + if (status != CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + } + + this->private_state_->tc_member_type_list_known_ = 1; + + if (index < mcount) + return this->private_state_->tc_member_type_list_[index]; + else + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, (CORBA::TypeCode_ptr)0); + } ACE_NOTREACHED (break;) case CORBA::tk_union: // index from 0 mcount = this->member_count (env); // clears env - if (env.exception () == 0) - { - // Double checked locking... - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, - this->private_state_->mutex_, 0); - if (this->private_state_->tc_member_type_list_known_) - if (index < mcount) - return this->private_state_->tc_member_type_list_[index]; - else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return CORBA::TypeCode::_nil (); - } - - // the first time in. Precompute and store types of all members - this->private_state_->tc_member_type_list_ = new CORBA::TypeCode_ptr [mcount]; - if (this->private_state_->tc_member_type_list_) - { - // skip the id, name, and discrimant type part - if (!stream.skip_string () // type ID, hidden - || !stream.skip_string () // typedef name - || !skip_typecode (stream)) // skip typecode for discriminant - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return (CORBA::TypeCode_ptr)0; - } - else if (!stream.read_ulong (temp) // default used - || !stream.read_ulong (temp)) // member count - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } - else - { - // Always big enough because labels can only be of a - // few different types of which "long" has the - // largest size. - CORBA::Long scratch; + // @@EXC@@ Why are we rethrowing a different exception here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, (CORBA::TypeCode_ptr)0); + TAO_CHECK_ENV_RETURN (env, (CORBA::TypeCode_ptr)0); - // get the typecode for the discriminator - tc = this->discriminator_type (env); - // compute the typecodes for all the members and return the - // required one - - for (CORBA::ULong i = 0; i < mcount; i++) - // the ith entry will have the typecode of the ith guy - if (stream.decode (tc, &scratch, this, env) // member label - != CORBA::TypeCode::TRAVERSE_CONTINUE - || !stream.skip_string () // skip the name - || stream.decode (CORBA::_tc_TypeCode, // get the typecode - &private_state_->tc_member_type_list_[i], - this, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - env.exception (new CORBA::BAD_TYPECODE - (CORBA::COMPLETED_NO)); - return 0; - } - this->private_state_->tc_member_type_list_known_ = 1; + { + // Double checked locking... + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, + this->private_state_->mutex_, 0); + if (this->private_state_->tc_member_type_list_known_) + if (index < mcount) + return this->private_state_->tc_member_type_list_[index]; + else + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, CORBA::TypeCode::_nil ()); + + // the first time in. Precompute and store types of all members + // @@EXC@@ Need to check allocation failure. + this->private_state_->tc_member_type_list_ = new CORBA::TypeCode_ptr [mcount]; + if (this->private_state_->tc_member_type_list_ == 0) + TAO_THROW_ENV_RETURN (CORBA::NO_MEMORY (CORBA::COMPLETED_NO), env, (CORBA::TypeCode_ptr)0); + + // skip the id, name, and discrimant type part + if (!stream.skip_string () // type ID, hidden + || !stream.skip_string () // typedef name + || !skip_typecode (stream)) // skip typecode for discriminant + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, (CORBA::TypeCode_ptr)0); + else if (!stream.read_ulong (temp) // default used + || !stream.read_ulong (temp)) // member count + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + // Always big enough because labels can only be of a + // few different types of which "long" has the + // largest size. + CORBA::Long scratch; + + // get the typecode for the discriminator + tc = this->discriminator_type (env); + // compute the typecodes for all the members and return the + // required one + TAO_CHECK_ENV_RETURN (env, 0); + + for (CORBA::ULong i = 0; i < mcount; i++) + // the ith entry will have the typecode of the ith guy + { + CORBA::TypeCode::traverse_status status = + stream.decode (tc, &scratch, this, env); + // member label + TAO_CHECK_ENV_RETURN (env, 0); + + if (status != CORBA::TypeCode::TRAVERSE_CONTINUE + || !stream.skip_string ()) // skip the name + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + + status = stream.decode (CORBA::_tc_TypeCode, // get the typecode + &private_state_->tc_member_type_list_[i], + this, + env); + TAO_CHECK_ENV_RETURN (env, 0); + + if (status != CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + } + this->private_state_->tc_member_type_list_known_ = 1; - if (index < mcount) - return this->private_state_->tc_member_type_list_[index]; - else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return (CORBA::TypeCode_ptr)0; - } - } - } - else // no memory for the member_list - { - env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO)); - return (CORBA::TypeCode_ptr)0; - } - } - else // out of bounds - { - env.exception (new CORBA::TypeCode::Bounds ()); - return (CORBA::TypeCode_ptr)0; - } + if (index < mcount) + return this->private_state_->tc_member_type_list_[index]; + else + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, (CORBA::TypeCode_ptr)0); + } + ACE_NOTREACHED (break); default: // bad kind - env.exception (new CORBA::TypeCode::BadKind ()); - return (CORBA::TypeCode_ptr)0; + TAO_THROW_ENV_RETURN (CORBA::TypeCode::BadKind (), env, (CORBA::TypeCode_ptr)0); } } @@ -1825,97 +1770,98 @@ CORBA_TypeCode::private_member_label (CORBA::ULong n, env.clear (); // this function is only applicable to the CORBA::tk_union TC - if (this->kind_ == CORBA::tk_union) - { - TAO_InputCDR stream (this->buffer_+4, this->length_-4, - this->byte_order_); + if (this->kind_ != CORBA::tk_union) + TAO_THROW_ENV_RETURN (CORBA::TypeCode::BadKind (), env, 0); + + TAO_InputCDR stream (this->buffer_+4, this->length_-4, + this->byte_order_); - // skip ID and name, and then get the discriminant TC - CORBA::TypeCode_ptr tc = 0; + // skip ID and name, and then get the discriminant TC + CORBA::TypeCode_ptr tc = 0; - if (!stream.skip_string () // type ID, hidden - || !stream.skip_string () // typedef name - || !skip_typecode (stream)) // skip discriminant typecode - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + if (!stream.skip_string () // type ID, hidden + || !stream.skip_string () // typedef name + || !skip_typecode (stream)) // skip discriminant typecode + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); // skip default used, and get member count - CORBA::ULong member_count; + CORBA::ULong member_count; - if (!stream.read_ulong (member_count) // default used - || !stream.read_ulong (member_count)) // member count - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - dmsg ("TypeCode::private_member_label -- error reading from stream"); - return 0; - } + if (!stream.read_ulong (member_count) // default used + || !stream.read_ulong (member_count)) // member count + { + dmsg ("TypeCode::private_member_label -- error reading from stream"); + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + } - // Double checked locking... - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, - this->private_state_->mutex_, 0); - if (this->private_state_->tc_member_label_list_known_) - if (n < member_count) - return this->private_state_->tc_member_label_list_[n]; - else - { - env.exception (new CORBA::TypeCode::Bounds ()); - return 0; - } + // Double checked locking... + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, + this->private_state_->mutex_, 0); + if (this->private_state_->tc_member_label_list_known_) + if (n < member_count) + return this->private_state_->tc_member_label_list_[n]; + else + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, 0); // member labels are of type Any. However, the actual types are // restricted to simple types - this->private_state_->tc_member_label_list_ = new CORBA::Any_ptr [member_count]; - if (this->private_state_->tc_member_label_list_) + // @@EXC@@ We need a macro here to use new (nothrow()) xxx. + this->private_state_->tc_member_label_list_ = new CORBA::Any_ptr [member_count]; + if (this->private_state_->tc_member_label_list_ == 0) + TAO_THROW_ENV_RETURN (CORBA::NO_MEMORY (CORBA::COMPLETED_NO), env, 0); + + tc = this->discriminator_type (env); + // retrieve the discriminator type as this decides what the + // label is + TAO_CHECK_ENV_RETURN (env, 0); + + for (CORBA::ULong i = 0; i < member_count; i++) + { + // allocate buffer to hold the member label value + // @@EXC@@ Also need to check for buf == 0. + CORBA::Octet *buf = 0; + buf = new CORBA::Octet [tc->size (env)]; + TAO_CHECK_ENV_RETURN (env, 0); + + CORBA::TypeCode::traverse_status status = + CORBA::TypeCode::TRAVERSE_STOP; + + TAO_TRY_SYS { - tc = this->discriminator_type (env); // retrieve the discriminator - // type as this decides what the - // label is - for (CORBA::ULong i = 0; i < member_count; i++) - { - // allocate buffer to hold the member label value - CORBA::Octet *buf = new CORBA::Octet [tc->size (env)]; - if (stream.decode (tc, buf, this, env) - != CORBA::TypeCode::TRAVERSE_CONTINUE - || !stream.skip_string () // member name - || !skip_typecode (stream)) // member type - { // member TC - dmsg1 ("TypeCode::private_member_label -- error getting typecode for member %d",i); - delete [] buf; - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } - else - { - this->private_state_->tc_member_label_list_[i] = new - CORBA::Any (tc, buf, 1); - } - } + status = stream.decode (tc, buf, this, env); + TAO_CHECK_ENV_SYS; + } + TAO_CATCHANY + { + delete [] buf; + TAO_RETHROW_RETURN_SYS (0); + } + TAO_ENDTRY; + + if (status != CORBA::TypeCode::TRAVERSE_CONTINUE + || !stream.skip_string () // member name + || !skip_typecode (stream)) // member type + { // member TC + dmsg1 ("TypeCode::private_member_label -- error getting typecode for member %d",i); + delete [] buf; + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); } else { - env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO)); - return 0; + // @@EXC@@ Need to check memory allocation failure. + this->private_state_->tc_member_label_list_[i] = new + CORBA::Any (tc, buf, 1); } + } - this->private_state_->tc_member_label_list_known_ = 1; + this->private_state_->tc_member_label_list_known_ = 1; // If caller asked for the label for a nonexistent member, they get // an error report! - if (n >= member_count) - { - env.exception (new CORBA::TypeCode::Bounds ()); - return 0; - } - else - return this->private_state_->tc_member_label_list_[n]; - } - else // wrong typecode - { - env.exception (new CORBA::TypeCode::BadKind ()); - return 0; - } + if (n >= member_count) + TAO_THROW_ENV_RETURN (CORBA::TypeCode::Bounds (), env, 0); + else + return this->private_state_->tc_member_label_list_[n]; } CORBA::TypeCode_ptr @@ -1937,15 +1883,10 @@ CORBA_TypeCode::private_discriminator_type (CORBA::Environment &env) const || stream.decode (CORBA::_tc_TypeCode, &this->private_state_->tc_discriminator_type_, this, env) != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } - else - { - this->private_state_->tc_discriminator_type_known_ = 1; - return this->private_state_->tc_discriminator_type_; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + + this->private_state_->tc_discriminator_type_known_ = 1; + return this->private_state_->tc_discriminator_type_; } CORBA::Long @@ -1966,15 +1907,10 @@ CORBA_TypeCode::private_default_index (CORBA::Environment &env) const || !stream.skip_string () // typedef name || !skip_typecode (stream) // skip discriminant || !stream.read_long (this->private_state_->tc_default_index_used_)) - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } - else - { - this->private_state_->tc_default_index_used_known_ = 1; - return this->private_state_->tc_default_index_used_; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + + this->private_state_->tc_default_index_used_known_ = 1; + return this->private_state_->tc_default_index_used_; } CORBA::Long @@ -2118,14 +2054,11 @@ CORBA_TypeCode::private_discrim_pad_size (CORBA::Environment &env) overall_align, discrim_size, env); - if (env. exception () == 0) - { - this->private_state_->tc_discrim_pad_size_known_ = 1; - this->private_state_->tc_discrim_pad_size_ = discrim_size; - return discrim_size; - } - else - return 0; + TAO_CHECK_ENV_RETURN (env, 0); + + this->private_state_->tc_discrim_pad_size_known_ = 1; + this->private_state_->tc_discrim_pad_size_ = discrim_size; + return discrim_size; } // ************ The following are deprecated **************** @@ -2467,10 +2400,8 @@ size_t CORBA::TypeCode::private_size (CORBA::Environment &env) { if (kind_ >= CORBA::TC_KIND_COUNT) - { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return 0; - } + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, 0); + env.clear (); // Double checked locking... diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index 9744f8e74c9..a9eb4c3a073 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -102,9 +102,9 @@ TAO_Marshal_Primitive::decode (CORBA::TypeCode_ptr tc, return CORBA::TypeCode::TRAVERSE_CONTINUE; else { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); dmsg ("TAO_Marshal_Primitive::decode detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; + TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, + CORBA::TypeCode::TRAVERSE_STOP); } } @@ -128,78 +128,83 @@ TAO_Marshal_Any::decode (CORBA::TypeCode_ptr, CORBA::TypeCode::TRAVERSE_CONTINUE; // Decode the typecode description for the element. - if ((retval = stream->decode (CORBA::_tc_TypeCode, - &elem_tc.out (), - 0, - env)) - == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - // Let the Any maintain a pointer to the CDR stream - // @@ ASG + CORYAN - The following commented line would have been a great - // optimization. However, it turns out that although the Message_Block is - // heap-allocated, the actual buffer i.e., data block is allocated on the - // function call stack. Once we are out of these chain of functions and - // return into the stub, we have lost the activation record for the - // actual buffer. Hence it makes no sense keeping pointers to stack - // memory. - // - // See IIOP_Object.cpp::do_static_call in which a GIOP_Invocation is - // allocated on stack + retval = stream->decode (CORBA::_tc_TypeCode, + &elem_tc.out (), + 0, + env); + TAO_CHECK_CONDITION_ENV_RETURN (env, \ + || retval != CORBA::TypeCode::TRAVERSE_CONTINUE, \ + retval); + + // Let the Any maintain a pointer to the CDR stream + // @@ ASG + CORYAN - The following commented line would have been a great + // optimization. However, it turns out that although the Message_Block is + // heap-allocated, the actual buffer i.e., data block is allocated on the + // function call stack. Once we are out of these chain of functions and + // return into the stub, we have lost the activation record for the + // actual buffer. Hence it makes no sense keeping pointers to stack + // memory. + // + // See IIOP_Object.cpp::do_static_call in which a GIOP_Invocation is + // allocated on stack #if 0 - any->cdr_ = ACE_Message_Block::duplicate ((ACE_Message_Block *) - stream->start ()); + any->cdr_ = ACE_Message_Block::duplicate ((ACE_Message_Block *) + stream->start ()); #endif - // one solution is to heap allocate the GIOP_Invocation. However, that - // would be bad since not all requests will use Anys. - // - // One solution is to allocate a new Message_Block with its own heap - // allocated data_block. (We may optimize this using allocators for known - // sizes). We allocate a Message_Block of the size that is required by - // the data type held by the Any. To find what is the size of this data - // in the CDR, we traverse the CDR by skipping past this data type. We - // then get an offset using the "begin" and "end" shown below that tells - // us the size. The skipping is done on a temporary CDR stream and not on - // the actual incoming CDR stream. Once we have allocated a new - // Message_Block, we simply append the data into it from the original CDR - // stream. - char *begin, *end; - TAO_InputCDR temp (*stream); - - begin = stream->rd_ptr (); - retval = temp.skip (elem_tc.in (), env); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - end = temp.rd_ptr (); - - ACE_Message_Block* cdr; - - // We need to allocate more memory than in the original - // stream, first to guarantee that the buffer is aligned in - // memory and next because the realignment may introduce - // extra padding. 2*MAX_ALIGNMENT should be enough. - ACE_NEW_RETURN (cdr, - ACE_Message_Block (end - begin - + 2*CDR::MAX_ALIGNMENT), - CORBA::TypeCode::TRAVERSE_STOP); - // Align the buffer before creating the CDR stream. - CDR::mb_align (cdr); - TAO_OutputCDR out (cdr); - - retval = out.append (elem_tc.in (), stream, env); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - ACE_Message_Block::release (any->cdr_); - if (any->any_owns_data_ && any->value_ != 0) - DEEP_FREE (any->type_, any->value_, 0, env); - if (env.exception () != 0) - return CORBA::TypeCode::TRAVERSE_STOP; - any->cdr_ = cdr; - any->value_ = 0; - any->type_ = elem_tc._retn (); - any->any_owns_data_ = 1; - } - } - } + // one solution is to heap allocate the GIOP_Invocation. However, that + // would be bad since not all requests will use Anys. + // + // One solution is to allocate a new Message_Block with its own heap + // allocated data_block. (We may optimize this using allocators for known + // sizes). We allocate a Message_Block of the size that is required by + // the data type held by the Any. To find what is the size of this data + // in the CDR, we traverse the CDR by skipping past this data type. We + // then get an offset using the "begin" and "end" shown below that tells + // us the size. The skipping is done on a temporary CDR stream and not on + // the actual incoming CDR stream. Once we have allocated a new + // Message_Block, we simply append the data into it from the original CDR + // stream. + char *begin, *end; + TAO_InputCDR temp (*stream); + + begin = stream->rd_ptr (); + retval = temp.skip (elem_tc.in (), env); + TAO_CHECK_CONDITION_ENV_RETURN (env, \ + || retval != CORBA::TypeCode::TRAVERSE_CONTINUE, \ + retval); + + end = temp.rd_ptr (); + + ACE_Message_Block* cdr; + + // We need to allocate more memory than in the original + // stream, first to guarantee that the buffer is aligned in + // memory and next because the realignment may introduce + // extra padding. 2*MAX_ALIGNMENT should be enough. + // @@EXC@@ This doesn't seem to be exception safe. + ACE_NEW_RETURN (cdr, + ACE_Message_Block (end - begin + + 2*CDR::MAX_ALIGNMENT), + CORBA::TypeCode::TRAVERSE_STOP); + // Align the buffer before creating the CDR stream. + CDR::mb_align (cdr); + TAO_OutputCDR out (cdr); + + retval = out.append (elem_tc.in (), stream, env); + TAO_CHECK_CONDITION_ENV_RETURN (env, \ + || retval != CORBA::TypeCode::TRAVERSE_CONTINUE, \ + retval); + + ACE_Message_Block::release (any->cdr_); + if (any->any_owns_data_ && any->value_ != 0) + DEEP_FREE (any->type_, any->value_, 0, env); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + any->cdr_ = cdr; + any->value_ = 0; + any->type_ = elem_tc._retn (); + any->any_owns_data_ = 1; + if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) { env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); diff --git a/TAO/tao/deep_free.cpp b/TAO/tao/deep_free.cpp index 0770de60a1b..ac5841be9c7 100644 --- a/TAO/tao/deep_free.cpp +++ b/TAO/tao/deep_free.cpp @@ -115,49 +115,43 @@ TAO_Marshal_Primitive::deep_free (CORBA::TypeCode_ptr tc, { CORBA::TCKind my_kind; - if (tc) + if (!tc) { - my_kind = tc->kind (env); - - if (env.exception () == 0) - { - switch (my_kind) - { - case CORBA::tk_null: - case CORBA::tk_void: - case CORBA::tk_char: - case CORBA::tk_octet: - case CORBA::tk_short: - case CORBA::tk_ushort: - case CORBA::tk_wchar: - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - case CORBA::tk_double: - case CORBA::tk_longdouble: - case CORBA::tk_boolean: - return CORBA::TypeCode::TRAVERSE_CONTINUE; - default: - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE)); - dmsg ("TAO_Marshal_Primitive::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else - { - dmsg ("TAO_Marshal_Primitive::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } + dmsg ("TAO_Marshal_Primitive::deep_free detected error"); + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); } - else + + my_kind = tc->kind (env); + + // @@EXC@@ Don't know how to print the following debug info. + // Anyhow, currently, tc->kind won't throw any exception. + // dmsg ("TAO_Marshal_Primitive::deep_free detected error"); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + switch (my_kind) { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE) ); + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_char: + case CORBA::tk_octet: + case CORBA::tk_short: + case CORBA::tk_ushort: + case CORBA::tk_wchar: + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_enum: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_double: + case CORBA::tk_longdouble: + case CORBA::tk_boolean: + break; + default: dmsg ("TAO_Marshal_Primitive::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); } + return CORBA::TypeCode::TRAVERSE_CONTINUE; } // deep_free structs @@ -167,128 +161,119 @@ TAO_Marshal_Struct::deep_free (CORBA::TypeCode_ptr tc, const void *dest, CORBA::Environment &env) { + if (!tc) + { + dmsg ("TAO_Marshal_Struct::deep_free detected error"); + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + } + CORBA::TypeCode::traverse_status retval = CORBA::TypeCode::TRAVERSE_CONTINUE; CORBA::TypeCode_ptr param; CORBA::Long size; - if (tc) + // compute the number of fields in the struct + int member_count = tc->member_count (env); + + // @@EXC@@ Don't know how to print out this error message using + // the TAO_CHECK... macro. Is it necessary? + // dmsg ("TAO_Marshal_Struct::deep_free detected error"); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + for (int i = 0; i < member_count && retval == + CORBA::TypeCode::TRAVERSE_CONTINUE; i++) { - // compute the number of fields in the struct - int member_count = tc->member_count (env); - if (env.exception () == 0) - { - for (int i = 0; i < member_count && retval == - CORBA::TypeCode::TRAVERSE_CONTINUE; i++) - { - // get the typecode for the ith field - param = tc->member_type (i, env); - if (env.exception () == 0) - { - // get the size of the field - size = param->size (env); - if (env.exception () == 0) - { - switch (param->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - case CORBA::tk_short: - case CORBA::tk_ushort: - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - case CORBA::tk_boolean: - case CORBA::tk_char: - case CORBA::tk_octet: - case CORBA::tk_longdouble: - case CORBA::tk_wchar: - break; - case CORBA::tk_any: - retval = TAO_Marshal_Any::deep_free (param, source, dest, env); - break; - case CORBA::tk_TypeCode: - retval = TAO_Marshal_TypeCode::deep_free (param, source, dest, env); - break; - case CORBA::tk_Principal: - retval = TAO_Marshal_Principal::deep_free (param, source, dest, env); - break; - - case CORBA::tk_objref: - { - TAO_Object_Field* field = - ACE_reinterpret_cast (TAO_Object_Field *, - ACE_const_cast (void *, source)); - field->_release (); - retval = CORBA::TypeCode::TRAVERSE_CONTINUE; - } - break; - - case CORBA::tk_struct: - retval = TAO_Marshal_Struct::deep_free (param, source, dest, env); - break; - case CORBA::tk_union: - retval = TAO_Marshal_Union::deep_free (param, source, dest, env); - break; - case CORBA::tk_string: - retval = TAO_Marshal_String::deep_free (param, source, dest, env); - break; - case CORBA::tk_sequence: - retval = TAO_Marshal_Sequence::deep_free (param, source, dest, env); - break; - case CORBA::tk_array: - retval = TAO_Marshal_Array::deep_free (param, source, dest, env); - break; - case CORBA::tk_alias: - retval = TAO_Marshal_Alias::deep_free (param, source, dest, env); - break; - case CORBA::tk_except: - retval = TAO_Marshal_Except::deep_free (param, source, dest, env); - break; - case CORBA::tk_wstring: - retval = TAO_Marshal_WString::deep_free (param, source, dest, env); - break; - default: - retval = CORBA::TypeCode::TRAVERSE_STOP; - } // end of switch - source = (char *)source + size; - } - else // exception computing size - { - dmsg ("TAO_Marshal_Struct::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else // exception computing typecode - { - dmsg ("TAO_Marshal_Struct::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } // end of loop - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - dmsg ("TAO_Marshal_Struct::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else // exception getting member count + // get the typecode for the ith field + param = tc->member_type (i, env); + + // @@EXC@@ Don't know how to print out this error message using + // the TAO_CHECK... macro. Is it necessary? + // dmsg ("TAO_Marshal_Struct::deep_free detected error"); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + // get the size of the field + size = param->size (env); + + // @@EXC@@ Don't know how to print out this error message using + // the TAO_CHECK... macro. Is it necessary? + // dmsg ("TAO_Marshal_Struct::deep_free detected error"); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + switch (param->kind_) { - dmsg ("TAO_Marshal_Struct::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else // no typecode + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_short: + case CORBA::tk_ushort: + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_enum: + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_boolean: + case CORBA::tk_char: + case CORBA::tk_octet: + case CORBA::tk_longdouble: + case CORBA::tk_wchar: + break; + case CORBA::tk_any: + retval = TAO_Marshal_Any::deep_free (param, source, dest, env); + break; + case CORBA::tk_TypeCode: + retval = TAO_Marshal_TypeCode::deep_free (param, source, dest, env); + break; + case CORBA::tk_Principal: + retval = TAO_Marshal_Principal::deep_free (param, source, dest, env); + break; + + case CORBA::tk_objref: + { + TAO_Object_Field* field = + ACE_reinterpret_cast (TAO_Object_Field *, + ACE_const_cast (void *, source)); + field->_release (); + retval = CORBA::TypeCode::TRAVERSE_CONTINUE; + } + break; + + case CORBA::tk_struct: + retval = TAO_Marshal_Struct::deep_free (param, source, dest, env); + break; + case CORBA::tk_union: + retval = TAO_Marshal_Union::deep_free (param, source, dest, env); + break; + case CORBA::tk_string: + retval = TAO_Marshal_String::deep_free (param, source, dest, env); + break; + case CORBA::tk_sequence: + retval = TAO_Marshal_Sequence::deep_free (param, source, dest, env); + break; + case CORBA::tk_array: + retval = TAO_Marshal_Array::deep_free (param, source, dest, env); + break; + case CORBA::tk_alias: + retval = TAO_Marshal_Alias::deep_free (param, source, dest, env); + break; + case CORBA::tk_except: + retval = TAO_Marshal_Except::deep_free (param, source, dest, env); + break; + case CORBA::tk_wstring: + retval = TAO_Marshal_WString::deep_free (param, source, dest, env); + break; + default: + retval = CORBA::TypeCode::TRAVERSE_STOP; + } // end of switch + source = (char *)source + size; + } // end of loop + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) { - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_MAYBE)); dmsg ("TAO_Marshal_Struct::deep_free detected error"); - return CORBA::TypeCode::TRAVERSE_STOP; + TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); } + return CORBA::TypeCode::TRAVERSE_CONTINUE; } // deep_free for union @@ -312,138 +297,115 @@ TAO_Marshal_Union::deep_free (CORBA::TypeCode_ptr tc, discrim_tc = tc->discriminator_type (env); // get the discriminator type - if (env.exception () == 0) + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + // deep_free the discriminator value + retval = DEEP_FREE (discrim_tc, data, data2, env); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + + discrim_size_with_pad = tc->TAO_discrim_pad_size (env); + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + discrim_val = data; + // save the pointer to the discriminator value + + data = (char *)data + discrim_size_with_pad; + data2 = (char *)data2 + discrim_size_with_pad; + // move the pointer to point to the actual value + + default_index = tc->default_index (env); + // now get ready to marshal the actual union value + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + member_count = tc->member_count (env); + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + // check which label value matches with the discriminator + // value. Accordingly, marshal the corresponding + // member_type. If none match, check if default exists + // and marshal accordingly. Otherwise it is an error. + for (i = 0; member_count-- != 0; i++) { - // deep_free the discriminator value - retval = DEEP_FREE (discrim_tc, data, data2, env); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) + member_label = tc->member_label (i, env); + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + // do the matching + CORBA::TypeCode_var type = member_label->type (); + switch (type->kind (env)) { - discrim_size_with_pad = tc->TAO_discrim_pad_size (env); - if (env.exception () == 0) - { - discrim_val = data; // save the pointer to the discriminator - // value - // move the pointer to point to the actual value - data = (char *)data + discrim_size_with_pad; - data2 = (char *)data2 + discrim_size_with_pad; - // now get ready to marshal the actual union value - default_index = tc->default_index (env); - if (env.exception () == 0) - { - member_count = tc->member_count (env); - if (env.exception () == 0) - { - // check which label value matches with the discriminator - // value. Accordingly, marshal the corresponding - // member_type. If none match, check if default exists - // and marshal accordingly. Otherwise it is an error. - for (i = 0; member_count-- != 0; i++) - { - member_label = tc->member_label (i, env); - if (env.exception () == 0) - { - // do the matching - CORBA::TypeCode_var type = member_label->type (); - switch (type->kind (env)) - { - case CORBA::tk_short: - case CORBA::tk_ushort: - if (*(CORBA::Short *)member_label->value () == - *(CORBA::Short *)discrim_val) - discrim_matched = 1; - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_enum: - if (*(CORBA::ULong *)member_label->value () == - *(CORBA::ULong *)discrim_val) - discrim_matched = 1; - break; - case CORBA::tk_char: - if (*(CORBA::Char *)member_label->value () == - *(CORBA::Char *)discrim_val) - discrim_matched = 1; - break; - case CORBA::tk_wchar: - if (*(CORBA::WChar *)member_label->value () == - *(CORBA::WChar *)discrim_val) - discrim_matched = 1; - break; - case CORBA::tk_boolean: - if (*(CORBA::Boolean *)member_label->value () == - *(CORBA::Boolean *)discrim_val) - discrim_matched = 1; - break; - default: - env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO)); - return CORBA::TypeCode::TRAVERSE_STOP; - }// end of switch - - // get the member typecode - member_tc = tc->member_type (i, env); - if (env.exception () == 0) - { - if (default_index >= 0 && default_index-- == 0) - { - // have we reached the default label?, if so, - // save a handle to the typecode for the default - default_tc = member_tc; - } - if (discrim_matched) - // marshal according to the matched typecode - return DEEP_FREE (member_tc, data, - data2, env); - } - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } - - } - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } // end of while - // we are here only if there was no match - if (default_tc) - return DEEP_FREE (default_tc, data, data2, env); - else - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } - } - else + case CORBA::tk_short: + case CORBA::tk_ushort: + if (*(CORBA::Short *)member_label->value () == + *(CORBA::Short *)discrim_val) + discrim_matched = 1; + break; + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_enum: + if (*(CORBA::ULong *)member_label->value () == + *(CORBA::ULong *)discrim_val) + discrim_matched = 1; + break; + case CORBA::tk_char: + if (*(CORBA::Char *)member_label->value () == + *(CORBA::Char *)discrim_val) + discrim_matched = 1; + break; + case CORBA::tk_wchar: + if (*(CORBA::WChar *)member_label->value () == + *(CORBA::WChar *)discrim_val) + discrim_matched = 1; + break; + case CORBA::tk_boolean: + if (*(CORBA::Boolean *)member_label->value () == + *(CORBA::Boolean *)discrim_val) + discrim_matched = 1; + break; + default: + TAO_THROW_ENV_RETURN (CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO), env, CORBA::TypeCode::TRAVERSE_STOP); + }// end of switch + + // get the member typecode + member_tc = tc->member_type (i, env); + // @@EXC@@ Why are we changing the exception thrown here? + // if (env.exception ()) TAO_THROW_ENV_RETURN (CORBA::MARSHAL (CORBA::COMPLETED_MAYBE), env, CORBA::TypeCode::TRAVERSE_STOP); + TAO_CHECK_ENV_RETURN (env, CORBA::TypeCode::TRAVERSE_STOP); + + if (default_index >= 0 && default_index-- == 0) { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; + // have we reached the default label?, if so, + // save a handle to the typecode for the default + default_tc = member_tc; } - } + if (discrim_matched) + // marshal according to the matched typecode + // @@EXC@@ No need to check env. + return DEEP_FREE (member_tc, data, + data2, env); + } // end of while + + // we are here only if there was no match + if (default_tc) + return DEEP_FREE (default_tc, data, data2, env); else - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_MAYBE)); - return CORBA::TypeCode::TRAVERSE_STOP; - } + return CORBA::TypeCode::TRAVERSE_CONTINUE; } +// @@EXC@@ Exception modification progress. -- Nanbor + // deep_free for Sequence CORBA::TypeCode::traverse_status TAO_Marshal_Sequence::deep_free (CORBA::TypeCode_ptr tc, |