Boost logo

Boost-Commit :

From: ramey_at_[hidden]
Date: 2007-12-22 20:58:27


Author: ramey
Date: 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
New Revision: 42253
URL: http://svn.boost.org/trac/boost/changeset/42253

Log:
Corrections to address TRAK tickets
Text files modified:
   branches/serialization_next_release/boost/boost/archive/basic_binary_iprimitive.hpp | 2
   branches/serialization_next_release/boost/boost/archive/detail/basic_pointer_oserializer.hpp | 2
   branches/serialization_next_release/boost/boost/archive/detail/iserializer.hpp | 7 +++
   branches/serialization_next_release/boost/boost/archive/detail/oserializer.hpp | 66 ++++++++++++++++++++++-----------------
   branches/serialization_next_release/boost/boost/archive/detail/polymorphic_iarchive_route.hpp | 1
   branches/serialization_next_release/boost/boost/archive/detail/polymorphic_oarchive_route.hpp | 1
   branches/serialization_next_release/boost/boost/archive/polymorphic_iarchive.hpp | 7 +++-
   branches/serialization_next_release/boost/boost/archive/polymorphic_oarchive.hpp | 7 +++-
   branches/serialization_next_release/boost/boost/archive/xml_wiarchive.hpp | 2
   branches/serialization_next_release/boost/boost/archive/xml_woarchive.hpp | 2 +
   10 files changed, 60 insertions(+), 37 deletions(-)

Modified: branches/serialization_next_release/boost/boost/archive/basic_binary_iprimitive.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/basic_binary_iprimitive.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/basic_binary_iprimitive.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -160,7 +160,7 @@
             boost::throw_exception(
                 archive_exception(archive_exception::stream_error)
             );
- std::memcpy(address, &t, s);
+ std::memcpy(static_cast<char*>(address) + (count - s), &t, s);
     }
 }
 

Modified: branches/serialization_next_release/boost/boost/archive/detail/basic_pointer_oserializer.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/detail/basic_pointer_oserializer.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/detail/basic_pointer_oserializer.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -40,12 +40,12 @@
     explicit basic_pointer_oserializer(
         const boost::serialization::extended_type_info & type_
     );
+public:
     // account for bogus gcc warning
     #if defined(__GNUC__)
     virtual
     #endif
     ~basic_pointer_oserializer();
-public:
     virtual const basic_oserializer & get_basic_serializer() const = 0;
     virtual void save_object_ptr(
         basic_oarchive & ar,

Modified: branches/serialization_next_release/boost/boost/archive/detail/iserializer.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/detail/iserializer.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/detail/iserializer.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -375,6 +375,11 @@
> > >::type typex;
 
     static void invoke(Archive & ar, T &t){
+ // check that we're not trying to serialize something that
+ // has been marked not to be serialized. If this your program
+ // traps here, you've tried to serialize a class whose trait
+ // has been marked "non-serializable". Either reset the trait
+ // (see level.hpp) or change program not to serialize items of this class
         BOOST_STATIC_ASSERT((
             mpl::greater_equal<
                 boost::serialization::implementation_level<T>,
@@ -413,7 +418,7 @@
         // virtual serialize functions used for plug-ins
         typedef BOOST_DEDUCED_TYPENAME
             mpl::eval_if<
- serialization::is_abstract<T>,
+ serialization::is_abstract<const T>,
                 mpl::identity<abstract<T> >,
                 mpl::identity<non_abstract<T> >
>::type typex;

Modified: branches/serialization_next_release/boost/boost/archive/detail/oserializer.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/detail/oserializer.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/detail/oserializer.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -33,22 +33,22 @@
 
 #include <boost/type_traits/is_pointer.hpp>
 #include <boost/type_traits/is_enum.hpp>
-#include <boost/type_traits/is_volatile.hpp>
+//#include <boost/type_traits/is_volatile.hpp>
 #include <boost/type_traits/is_const.hpp>
-#include <boost/type_traits/is_same.hpp>
+//#include <boost/type_traits/is_same.hpp>
 #include <boost/type_traits/is_polymorphic.hpp>
 #include <boost/type_traits/remove_all_extents.hpp>
 #include <boost/serialization/is_abstract.hpp>
 
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/and.hpp>
-#include <boost/mpl/less.hpp>
+//#include <boost/mpl/less.hpp>
 #include <boost/mpl/greater_equal.hpp>
 #include <boost/mpl/equal_to.hpp>
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/identity.hpp>
-#include <boost/mpl/list.hpp>
-#include <boost/mpl/empty.hpp>
+//#include <boost/mpl/list.hpp>
+//#include <boost/mpl/empty.hpp>
 #include <boost/mpl/not.hpp>
 
  #ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
@@ -119,8 +119,6 @@
>= boost::serialization::object_class_info;
     }
     virtual bool tracking(const unsigned int /* flags */) const {
-// if(0 != (flags & no_tracking))
-// return false;
         return boost::serialization::tracking_level<T>::value == boost::serialization::track_always
             || (boost::serialization::tracking_level<T>::value == boost::serialization::track_selectively
                 && serialized_as_pointer());
@@ -141,6 +139,7 @@
 ) const {
     // make sure call is routed through the highest interface that might
     // be specialized by the user.
+ BOOST_STATIC_ASSERT(boost::is_const<T>::value == false);
     boost::serialization::serialize_adl(
         boost::smart_cast_reference<Archive &>(ar),
         * static_cast<T *>(const_cast<void *>(x)),
@@ -152,12 +151,8 @@
 class pointer_oserializer
   : public archive_pointer_oserializer<Archive>
 {
+ const basic_oserializer & get_basic_serializer() const;
 private:
- virtual const basic_oserializer & get_basic_serializer() const {
- return boost::serialization::singleton<
- oserializer<Archive, T>
- >::get_const_instance();
- }
     virtual void save_object_ptr(
         basic_oarchive & ar,
         const void * x
@@ -167,6 +162,14 @@
 };
 
 template<class Archive, class T>
+const basic_oserializer &
+pointer_oserializer<Archive, T>::get_basic_serializer() const {
+ return boost::serialization::singleton<
+ oserializer<Archive, T>
+ >::get_const_instance();
+}
+
+template<class Archive, class T>
 void pointer_oserializer<Archive, T>::save_object_ptr(
     basic_oarchive & ar,
     const void * x
@@ -272,7 +275,7 @@
         // else
             // do a fast save only tracking is turned off
             mpl::identity<save_conditional>
- > > >::type typex;
+ > > >::type typex;
 
     static void invoke(Archive & ar, const T & t){
         // check that we're not trying to serialize something that
@@ -298,7 +301,7 @@
         static const basic_pointer_oserializer * register_type(Archive & /* ar */){
             // it has? to be polymorphic
             BOOST_STATIC_ASSERT(boost::is_polymorphic<T>::value);
- return static_cast<const basic_pointer_oserializer *>(NULL);
+ return NULL;
         }
     };
 
@@ -330,11 +333,14 @@
     {
         static void save(
             Archive &ar,
- const T & t,
- const basic_pointer_oserializer * bpos_ptr
+ T & t
         ){
+ const basic_pointer_oserializer & bpos =
+ boost::serialization::singleton<
+ pointer_oserializer<Archive, T>
+ >::get_const_instance();
             // save the requested pointer type
- ar.save_pointer(& t, bpos_ptr);
+ ar.save_pointer(& t, & bpos);
         }
     };
 
@@ -343,8 +349,7 @@
     {
         static void save(
             Archive &ar,
- const T & t,
- const basic_pointer_oserializer * bpos_ptr
+ T & t
         ){
             BOOST_DEDUCED_TYPENAME boost::serialization::type_info_implementation<T>::type
                 const & i = boost::serialization::type_info_implementation<T>::type
@@ -358,6 +363,7 @@
 
             const boost::serialization::extended_type_info * true_type =
                 i.get_derived_extended_type_info(t);
+
             // note:if this exception is thrown, be sure that derived pointer
             // is either registered or exported.
             if(NULL == true_type){
@@ -369,7 +375,8 @@
             // if its not a pointer to a more derived type
             const void *vp = static_cast<const void *>(&t);
             if(*this_type == *true_type){
- ar.save_pointer(vp, bpos_ptr);
+ const basic_pointer_oserializer * bpos = register_type(ar, t);
+ ar.save_pointer(vp, bpos);
                 return;
             }
             // convert pointer to more derived type. if this is thrown
@@ -384,13 +391,14 @@
             // since true_type is valid, and this only gets made if the
             // pointer oserializer object has been created, this should never
             // fail
- bpos_ptr = archive_pointer_oserializer<Archive>::find(* true_type);
- assert(NULL != bpos_ptr);
- if(NULL == bpos_ptr)
+ const basic_pointer_oserializer * bpos
+ = archive_pointer_oserializer<Archive>::find(* true_type);
+ assert(NULL != bpos);
+ if(NULL == bpos)
                 boost::throw_exception(
                     archive_exception(archive_exception::unregistered_class)
                 );
- ar.save_pointer(vp, bpos_ptr);
+ ar.save_pointer(vp, bpos);
         }
     };
 
@@ -404,13 +412,13 @@
>::type type;
     };
 
+ // used to convert TPtr in to a pointer to a T
     template<class T>
     static void save(
         Archive & ar,
- const T &t,
- const basic_pointer_oserializer * bpos_ptr
+ const T & t
     ){
- conditional<T>::type::save(ar, const_cast<T &>(t), bpos_ptr);
+ conditional<T>::type::save(ar, const_cast<T &>(t));
     }
 
     template<class T>
@@ -431,14 +439,14 @@
         #else
             // otherwise remove the const
         #endif
- const basic_pointer_oserializer * bpos_ptr = register_type(ar, * t);
+ register_type(ar, * t);
         if(NULL == t){
             basic_oarchive & boa = boost::smart_cast_reference<basic_oarchive &>(ar);
             boa.save_null_pointer();
             save_access::end_preamble(ar);
             return;
         }
- save(ar, * t, bpos_ptr);
+ save(ar, * t);
     };
 };
 

Modified: branches/serialization_next_release/boost/boost/archive/detail/polymorphic_iarchive_route.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/detail/polymorphic_iarchive_route.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/detail/polymorphic_iarchive_route.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -184,6 +184,7 @@
     ) :
         ArchiveImplementation(is, flags)
     {}
+ virtual ~polymorphic_iarchive_route(){};
 };
 
 } // namespace detail

Modified: branches/serialization_next_release/boost/boost/archive/detail/polymorphic_oarchive_route.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/detail/polymorphic_oarchive_route.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/detail/polymorphic_oarchive_route.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -172,6 +172,7 @@
     ) :
         ArchiveImplementation(os, flags)
     {}
+ virtual ~polymorphic_oarchive_route(){};
 };
 
 } // namespace detail

Modified: branches/serialization_next_release/boost/boost/archive/polymorphic_iarchive.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/polymorphic_iarchive.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/polymorphic_iarchive.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -123,7 +123,7 @@
         load_end(t.name());
     }
 protected:
- virtual ~polymorphic_iarchive_impl(){}
+ virtual ~polymorphic_iarchive_impl(){};
 public:
     // utility function implemented by all legal archives
     virtual void set_library_version(unsigned int archive_library_version) = 0;
@@ -166,7 +166,10 @@
 class polymorphic_iarchive :
     public polymorphic_iarchive_impl,
     public detail::shared_ptr_helper
-{};
+{
+public:
+ virtual ~polymorphic_iarchive(){};
+};
 
 } // namespace archive
 } // namespace boost

Modified: branches/serialization_next_release/boost/boost/archive/polymorphic_oarchive.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/polymorphic_oarchive.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/polymorphic_oarchive.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -123,7 +123,7 @@
         save_end(t.name());
     }
 protected:
- virtual ~polymorphic_oarchive_impl(){}
+ virtual ~polymorphic_oarchive_impl(){};
 public:
     // utility functions implemented by all legal archives
     virtual unsigned int get_flags() const = 0;
@@ -143,7 +143,10 @@
 // note: preserve naming symmetry
 class polymorphic_oarchive :
     public polymorphic_oarchive_impl
-{};
+{
+public:
+ virtual ~polymorphic_oarchive(){};
+};
 
 } // namespace archive
 } // namespace boost

Modified: branches/serialization_next_release/boost/boost/archive/xml_wiarchive.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/xml_wiarchive.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/xml_wiarchive.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -88,7 +88,7 @@
 };
 
 // do not derive from the classes below. If you want to extend this functionality
-// via inhertance, derived from text_iarchive_impl instead. This will
+// via inhertance, derived from xml_wiarchive_impl instead. This will
 // preserve correct static polymorphism.
 
 // same as xml_wiarchive below - without the shared_ptr_helper

Modified: branches/serialization_next_release/boost/boost/archive/xml_woarchive.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/archive/xml_woarchive.hpp (original)
+++ branches/serialization_next_release/boost/boost/archive/xml_woarchive.hpp 2007-12-22 20:58:26 EST (Sat, 22 Dec 2007)
@@ -39,11 +39,13 @@
 namespace boost {
 namespace archive {
 
+#if 0
 BOOST_WARCHIVE_DECL(std::wostream &)
 operator<<(std::wostream &os, const char *t);
 
 BOOST_WARCHIVE_DECL(std::wostream &)
 operator<<(std::wostream &os, const char t);
+#endif
 
 template<class Archive>
 class xml_woarchive_impl :


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk