From 1c2a4da9befa1e038ffc3901e5dedb72e7deaf59 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Sun, 4 Feb 2007 19:59:58 +0000 Subject: Sun Feb 4 19:57:14 2007 Johnny Willemsen --- TAO/ChangeLog | 14 ++++ TAO/tao/Bounded_Basic_String_Sequence_T.h | 6 +- TAO/tao/String_Const_Sequence_Element_T.h | 81 ++++++++++++++++++++++ TAO/tao/String_Sequence_Element_T.h | 9 ++- TAO/tao/Unbounded_Basic_String_Sequence_T.h | 6 +- TAO/tests/Bug_2429_Regression/client.cpp | 2 +- .../Bug_2792_Regression/Bug_2792_Regression.mpc | 9 +++ TAO/tests/Bug_2792_Regression/client.cpp | 28 ++++++++ TAO/tests/Bug_2792_Regression/run_test.pl | 22 ++++++ TAO/tests/ORB_Local_Config/Bug_2612/DllOrb.cpp | 2 +- 10 files changed, 168 insertions(+), 11 deletions(-) create mode 100644 TAO/tao/String_Const_Sequence_Element_T.h create mode 100644 TAO/tests/Bug_2792_Regression/Bug_2792_Regression.mpc create mode 100644 TAO/tests/Bug_2792_Regression/client.cpp create mode 100755 TAO/tests/Bug_2792_Regression/run_test.pl diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 49e18367473..e7ec81e7e3f 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,17 @@ +Sun Feb 4 19:57:14 2007 Johnny Willemsen + + * tao/Bounded_Basic_String_Sequence_T.h: + * tao/String_Const_Sequence_Element_T.h: + * tao/String_Sequence_Element_T.h: + * tao/Unbounded_Basic_String_Sequence_T.h: + Fixed bug 2792, thanks to Frank Pilhofer + for reporting this + + * tao/Bug_2792_Regression/Bug_2792_Regression.mpc: + * tao/Bug_2792_Regression/Bug_2792_Regression/client.cpp: + * tao/Bug_2792_Regression/Bug_2792_Regression/run_test.pl: + New regression test + Sun Feb 4 18:51:14 2007 Johnny Willemsen * tao/Object.cpp diff --git a/TAO/tao/Bounded_Basic_String_Sequence_T.h b/TAO/tao/Bounded_Basic_String_Sequence_T.h index 4865865998f..729a86ef3af 100644 --- a/TAO/tao/Bounded_Basic_String_Sequence_T.h +++ b/TAO/tao/Bounded_Basic_String_Sequence_T.h @@ -13,6 +13,7 @@ #include "tao/String_Traits_T.h" #include "tao/Generic_Sequence_T.h" #include "tao/String_Sequence_Element_T.h" +#include "tao/String_Const_Sequence_Element_T.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -30,6 +31,7 @@ public: typedef details::bounded_reference_allocation_traits allocation_traits; typedef details::string_sequence_element element_type; + typedef details::string_const_sequence_element const_element_type; typedef element_type subscript_type; typedef const_value_type const_subscript_type; @@ -65,8 +67,8 @@ public: impl_.length(length); } /// @copydoc details::generic_sequence::operator[] - inline const_value_type operator[](CORBA::ULong i) const { - return impl_[i]; + inline const_element_type operator[](CORBA::ULong i) const { + return const_element_type (impl_[i], release()); } /// @copydoc details::generic_sequence::operator[] inline element_type operator[](CORBA::ULong i) { diff --git a/TAO/tao/String_Const_Sequence_Element_T.h b/TAO/tao/String_Const_Sequence_Element_T.h new file mode 100644 index 00000000000..83fc94d768e --- /dev/null +++ b/TAO/tao/String_Const_Sequence_Element_T.h @@ -0,0 +1,81 @@ +#ifndef guard_string_const_sequence_element_hpp +#define guard_string_const_sequence_element_hpp +/** + * @file + * + * @brief Implement the type returned by const operator[] in string + * sequences. + * + * $Id$ + * + * @author Carlos O'Ryan and Johnny Willemsen + */ + +#include "tao/Basic_Types.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ +namespace details +{ + +template +class string_const_sequence_element +{ +public: + typedef typename traits::char_type character_type; + typedef character_type * value_type; + typedef character_type * const const_value_type; + typedef typename traits::string_var string_var; + typedef typename traits::string_mgr string_mgr; + +public: + string_const_sequence_element(const_value_type & e, CORBA::Boolean release) + : element_(&e) + , release_(release) + { + } + + string_const_sequence_element( + string_const_sequence_element const & rhs) + : element_(rhs.element_) + , release_(rhs.release_) + { + } + + + ~string_const_sequence_element() + { + } + + inline operator const_value_type() const + { + return *this->element_; + } + + inline const character_type *in (void) const { + return *this->element_; + } + + CORBA::Boolean release() const + { + return this->release_; + } + +private: + // This function is not implemented + string_const_sequence_element(); + string_const_sequence_element & operator=(string_const_sequence_element const & rhs); + +private: + const_value_type * element_; + CORBA::Boolean release_; +}; + +} // namespace details +} // namespace CORBA + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // guard_string_const_sequence_element_hpp diff --git a/TAO/tao/String_Sequence_Element_T.h b/TAO/tao/String_Sequence_Element_T.h index 9d7a2bec549..4cca9a63719 100644 --- a/TAO/tao/String_Sequence_Element_T.h +++ b/TAO/tao/String_Sequence_Element_T.h @@ -31,13 +31,12 @@ public: typedef typename traits::string_mgr string_mgr; private: - inline string_sequence_element & pseudo_copy_swap( - string_var & rhs) + inline string_sequence_element & pseudo_copy_swap(string_var & rhs) { if (release()) - { - traits::release(*element_); - } + { + traits::release(*element_); + } *element_ = rhs._retn(); return *this; } diff --git a/TAO/tao/Unbounded_Basic_String_Sequence_T.h b/TAO/tao/Unbounded_Basic_String_Sequence_T.h index badabecacd5..b43ef6764f6 100644 --- a/TAO/tao/Unbounded_Basic_String_Sequence_T.h +++ b/TAO/tao/Unbounded_Basic_String_Sequence_T.h @@ -13,6 +13,7 @@ #include "tao/String_Traits_T.h" #include "tao/Generic_Sequence_T.h" #include "tao/String_Sequence_Element_T.h" +#include "tao/String_Const_Sequence_Element_T.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -30,6 +31,7 @@ public: typedef details::unbounded_reference_allocation_traits allocation_traits; typedef details::string_sequence_element element_type; + typedef details::string_const_sequence_element const_element_type; typedef details::generic_sequence implementation_type; @@ -73,8 +75,8 @@ public: impl_.length(length); } /// @copydoc details::generic_sequence::operator[] - inline const_value_type operator[](CORBA::ULong i) const { - return impl_[i]; + inline const_element_type operator[](CORBA::ULong i) const { + return const_element_type (impl_[i], release()); } /// @copydoc details::generic_sequence::operator[] inline element_type operator[](CORBA::ULong i) { diff --git a/TAO/tests/Bug_2429_Regression/client.cpp b/TAO/tests/Bug_2429_Regression/client.cpp index 90a229f1e45..14bdeba81b2 100644 --- a/TAO/tests/Bug_2429_Regression/client.cpp +++ b/TAO/tests/Bug_2429_Regression/client.cpp @@ -111,7 +111,7 @@ main(int argc, char *argv[]) try { // Initialize the ORB. - orb = CORBA::ORB_init(argc, argv, 0); + orb = CORBA::ORB_init(argc, argv); // Initialize options based on command-line arguments. int parse_args_result = client_parse_args(argc, argv); diff --git a/TAO/tests/Bug_2792_Regression/Bug_2792_Regression.mpc b/TAO/tests/Bug_2792_Regression/Bug_2792_Regression.mpc new file mode 100644 index 00000000000..8336a76d8bf --- /dev/null +++ b/TAO/tests/Bug_2792_Regression/Bug_2792_Regression.mpc @@ -0,0 +1,9 @@ +// -*- MPC -*- +// $Id$ + +project(*Client): taoclient { + + Source_Files { + client.cpp + } +} diff --git a/TAO/tests/Bug_2792_Regression/client.cpp b/TAO/tests/Bug_2792_Regression/client.cpp new file mode 100644 index 00000000000..2ffebbaf911 --- /dev/null +++ b/TAO/tests/Bug_2792_Regression/client.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "tao/ORB_Core.h" +#include "tao/StringSeqC.h" + +ACE_RCSID(BUg_2792_Regression, client, "$Id$") + +int +main (int, char *[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + CORBA::StringSeq foo; + foo.length (1); + foo[0] = "Hello World"; + const CORBA::StringSeq & bar = foo; + ACE_DEBUG ((LM_DEBUG, "String: %s\n", bar[0].in ())); + } + catch (CORBA::Exception &ex) + { + ACE_ERROR ((LM_ERROR, "Exception caught: %s\"%s\"\n" + , ex._name(), ex._rep_id ())); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_2792_Regression/run_test.pl b/TAO/tests/Bug_2792_Regression/run_test.pl new file mode 100755 index 00000000000..92b78a0b270 --- /dev/null +++ b/TAO/tests/Bug_2792_Regression/run_test.pl @@ -0,0 +1,22 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; + +$status = 0; + +$CL = new PerlACE::Process ("client", ""); + +$client = $CL->SpawnWaitKill (150); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +exit $status; diff --git a/TAO/tests/ORB_Local_Config/Bug_2612/DllOrb.cpp b/TAO/tests/ORB_Local_Config/Bug_2612/DllOrb.cpp index 750c68132fe..2b90056d917 100644 --- a/TAO/tests/ORB_Local_Config/Bug_2612/DllOrb.cpp +++ b/TAO/tests/ORB_Local_Config/Bug_2612/DllOrb.cpp @@ -83,7 +83,7 @@ int DllOrb::init (int argc, char *argv[]) } // Initialize the ORB - mv_orb = CORBA::ORB_init(argc, argv, 0); + mv_orb = CORBA::ORB_init(argc, argv); if (CORBA::is_nil(mv_orb.in())) return -1; -- cgit v1.2.1