Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55349 - branches/release/boost/serialization
From: ramey_at_[hidden]
Date: 2009-08-01 19:32:14


Author: ramey
Date: 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
New Revision: 55349
URL: http://svn.boost.org/trac/boost/changeset/55349

Log:
Merge trunk to release

Added:
   branches/release/boost/serialization/bitset.hpp
      - copied unchanged from r55347, /trunk/boost/serialization/bitset.hpp
Properties modified:
   branches/release/boost/serialization/ (props changed)
Text files modified:
   branches/release/boost/serialization/access.hpp | 12 ++++++++-
   branches/release/boost/serialization/base_object.hpp | 12 +++++----
   branches/release/boost/serialization/complex.hpp | 2
   branches/release/boost/serialization/extended_type_info.hpp | 20 ++++++++--------
   branches/release/boost/serialization/extended_type_info_no_rtti.hpp | 3 ++
   branches/release/boost/serialization/factory.hpp | 2
   branches/release/boost/serialization/serialization.hpp | 2
   branches/release/boost/serialization/tracking.hpp | 1
   branches/release/boost/serialization/vector.hpp | 23 ++++++++----------
   branches/release/boost/serialization/void_cast.hpp | 48 +++++++++++++++++++++++----------------
   10 files changed, 72 insertions(+), 53 deletions(-)

Modified: branches/release/boost/serialization/access.hpp
==============================================================================
--- branches/release/boost/serialization/access.hpp (original)
+++ branches/release/boost/serialization/access.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -115,13 +115,21 @@
         // benign on everything else
         delete const_cast<T *>(t);
     }
- template<class Archive, class T>
- static void construct(Archive & /* ar */, T * t){
+ template<class T>
+ static void construct(T * t){
         // default is inplace invocation of default constructor
         // Note the :: before the placement new. Required if the
         // class doesn't have a class-specific placement new defined.
         ::new(t)T;
     }
+ template<class T, class U>
+ static T & cast_reference(U & u){
+ return static_cast<T &>(u);
+ }
+ template<class T, class U>
+ static T * cast_pointer(U * u){
+ return static_cast<T *>(u);
+ }
 };
 
 } // namespace serialization

Modified: branches/release/boost/serialization/base_object.hpp
==============================================================================
--- branches/release/boost/serialization/base_object.hpp (original)
+++ branches/release/boost/serialization/base_object.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -34,6 +34,7 @@
 #include <boost/type_traits/is_polymorphic.hpp>
 
 #include <boost/static_assert.hpp>
+#include <boost/serialization/access.hpp>
 #include <boost/serialization/force_include.hpp>
 #include <boost/serialization/void_cast_fwd.hpp>
 
@@ -62,7 +63,9 @@
     {
         struct polymorphic {
             static void const * invoke(){
- return &void_cast_register((Derived const*)0, (Base const*)0);
+ Base const * const b = 0;
+ Derived const * const d = 0;
+ return & void_cast_register(d, b);
             }
         };
         struct non_polymorphic {
@@ -81,15 +84,14 @@
     };
 
 } // namespace detail
-
-#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
+#if defined(__BORLANDC__) && __BORLANDC__ < 0x610
 template<class Base, class Derived>
 const Base &
 base_object(const Derived & d)
 {
     BOOST_STATIC_ASSERT(! is_pointer<Derived>::value);
     detail::base_register<Base, Derived>::invoke();
- return static_cast<const Base &>(d);
+ return access::cast_reference<const Base, Derived>(d);
 }
 #else
 template<class Base, class Derived>
@@ -100,7 +102,7 @@
     BOOST_STATIC_ASSERT(! is_pointer<Derived>::value);
     typedef BOOST_DEDUCED_TYPENAME detail::base_cast<Base, Derived>::type type;
     detail::base_register<type, Derived>::invoke();
- return static_cast<type &>(d);
+ return access::cast_reference<type, Derived>(d);
 }
 #endif
 

Modified: branches/release/boost/serialization/complex.hpp
==============================================================================
--- branches/release/boost/serialization/complex.hpp (original)
+++ branches/release/boost/serialization/complex.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -39,7 +39,7 @@
 template<class Archive, class T>
 inline void save(
     Archive & ar,
- std::complex<T> const& t,
+ std::complex<T> const & t,
     const unsigned int /* file_version */
 ){
     const T re = t.real();

Modified: branches/release/boost/serialization/extended_type_info.hpp
==============================================================================
--- branches/release/boost/serialization/extended_type_info.hpp (original)
+++ branches/release/boost/serialization/extended_type_info.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -24,6 +24,8 @@
 #include <boost/config.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/serialization/config.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
 #ifdef BOOST_MSVC
@@ -39,20 +41,14 @@
     private boost::noncopyable
 {
 private:
+ boost::shared_ptr<const extended_type_info> m_this;
+
     // used to uniquely identify the type of class derived from this one
     // so that different derivations of this class can be simultaneously
     // included in implementation of sets and maps.
     const unsigned int m_type_info_key;
- virtual bool
- is_less_than(const extended_type_info & /*rhs*/) const {
- assert(false);
- return false;
- };
- virtual bool
- is_equal(const extended_type_info & /*rhs*/) const {
- assert(false);
- return false;
- };
+ virtual bool is_less_than(const extended_type_info & /*rhs*/) const = 0;
+ virtual bool is_equal(const extended_type_info & /*rhs*/) const = 0;
     void key_unregister();
 protected:
     const char * m_key;
@@ -75,6 +71,10 @@
     bool operator!=(const extended_type_info &rhs) const {
         return !(operator==(rhs));
     }
+ boost::weak_ptr<const extended_type_info>
+ get_weak_ptr() const {
+ return m_this;
+ }
     static const extended_type_info * find(const char *key);
     // for plugins
     virtual void * construct(unsigned int /*count*/ = 0, ...) const {

Modified: branches/release/boost/serialization/extended_type_info_no_rtti.hpp
==============================================================================
--- branches/release/boost/serialization/extended_type_info_no_rtti.hpp (original)
+++ branches/release/boost/serialization/extended_type_info_no_rtti.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -63,6 +63,9 @@
     public singleton<extended_type_info_no_rtti<T> >
 {
 public:
+ extended_type_info_no_rtti() :
+ detail::extended_type_info_no_rtti_0()
+ {}
     const extended_type_info *
     get_derived_extended_type_info(const T & t) const {
         // find the type that corresponds to the most derived type.

Modified: branches/release/boost/serialization/factory.hpp
==============================================================================
--- branches/release/boost/serialization/factory.hpp (original)
+++ branches/release/boost/serialization/factory.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -16,7 +16,7 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-#include <cstdarg>
+#include <cstdarg> // valist
 #include <cstddef> // NULL
 
 #include <boost/preprocessor/control/if.hpp>

Modified: branches/release/boost/serialization/serialization.hpp
==============================================================================
--- branches/release/boost/serialization/serialization.hpp (original)
+++ branches/release/boost/serialization/serialization.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -95,7 +95,7 @@
     // default just uses the default constructor. going
     // through access permits usage of otherwise private default
     // constructor
- access::construct(ar, t);
+ access::construct(t);
 }
 
 /////////////////////////////////////////////////////////////////////////////

Modified: branches/release/boost/serialization/tracking.hpp
==============================================================================
--- branches/release/boost/serialization/tracking.hpp (original)
+++ branches/release/boost/serialization/tracking.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -29,6 +29,7 @@
 #include <boost/type_traits/is_pointer.hpp>
 #include <boost/serialization/level.hpp>
 #include <boost/serialization/tracking_enum.hpp>
+#include <boost/serialization/type_info_implementation.hpp>
 
 namespace boost {
 namespace serialization {

Modified: branches/release/boost/serialization/vector.hpp
==============================================================================
--- branches/release/boost/serialization/vector.hpp (original)
+++ branches/release/boost/serialization/vector.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -31,10 +31,9 @@
 
 // default is being compatible with version 1.34.1 files, not 1.35 files
 #ifndef BOOST_SERIALIZATION_VECTOR_VERSION
-#define BOOST_SERIALIZATION_VECTOR_VERSION 3
+#define BOOST_SERIALIZATION_VECTOR_VERSION 4
 #endif
 
-
 namespace boost {
 namespace serialization {
 
@@ -83,12 +82,10 @@
 ){
     const collection_size_type count(t.size());
     ar << BOOST_SERIALIZATION_NVP(count);
- if(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version()) {
- const unsigned int item_version = version<U>::value;
- ar << BOOST_SERIALIZATION_NVP(item_version);
- }
- if (!t.empty())
- ar << make_array(detail::get_data(t),t.size());
+ const unsigned int item_version = version<U>::value;
+ ar << BOOST_SERIALIZATION_NVP(item_version);
+ if (!t.empty())
+ ar << make_array(detail::get_data(t),t.size());
 }
 
 template<class Archive, class U, class Allocator>
@@ -105,7 +102,7 @@
     if(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version())
         ar >> BOOST_SERIALIZATION_NVP(item_version);
     if (!t.empty())
- ar >> make_array(detail::get_data(t),t.size());
+ ar >> make_array(detail::get_data(t),t.size());
   }
 
 // dispatch to either default or optimized versions
@@ -118,8 +115,8 @@
 ){
     typedef BOOST_DEDUCED_TYPENAME
     boost::serialization::use_array_optimization<Archive>::template apply<
- BOOST_DEDUCED_TYPENAME remove_const<U>::type
- >::type use_optimized;
+ BOOST_DEDUCED_TYPENAME remove_const<U>::type
+ >::type use_optimized;
     save(ar,t,file_version, use_optimized());
 }
 
@@ -131,8 +128,8 @@
 ){
     typedef BOOST_DEDUCED_TYPENAME
     boost::serialization::use_array_optimization<Archive>::template apply<
- BOOST_DEDUCED_TYPENAME remove_const<U>::type
- >::type use_optimized;
+ BOOST_DEDUCED_TYPENAME remove_const<U>::type
+ >::type use_optimized;
     load(ar,t,file_version, use_optimized());
 }
 

Modified: branches/release/boost/serialization/void_cast.hpp
==============================================================================
--- branches/release/boost/serialization/void_cast.hpp (original)
+++ branches/release/boost/serialization/void_cast.hpp 2009-08-01 19:32:13 EDT (Sat, 01 Aug 2009)
@@ -9,7 +9,7 @@
 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
 // void_cast.hpp: interface for run-time casting of void pointers.
 
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// (C) Copyright 2002-2009 Robert Ramey - http://www.rrsd.com .
 // Use, modification and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -18,11 +18,15 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 
 #include <cstddef> // for ptrdiff_t
+#include <boost/weak_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
 #include <boost/serialization/config.hpp>
 #include <boost/serialization/smart_cast.hpp>
 #include <boost/serialization/singleton.hpp>
 #include <boost/serialization/force_include.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
+#include <boost/serialization/extended_type_info.hpp>
 #include <boost/type_traits/is_virtual_base_of.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
@@ -84,7 +88,8 @@
 
 namespace void_cast_detail {
 
-class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) void_caster
+class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) void_caster :
+ private boost::noncopyable
 {
     friend
     BOOST_SERIALIZATION_DECL(void const *)
@@ -100,8 +105,6 @@
         extended_type_info const & base,
         void const * const
     );
- // cw 8.3 requires this!!
- void_caster& operator=(void_caster const &);
 protected:
     void recursive_register(bool includes_virtual_base = false) const;
     void recursive_unregister() const;
@@ -109,19 +112,20 @@
     // Data members
     const extended_type_info * m_derived;
     const extended_type_info * m_base;
- const std::ptrdiff_t m_difference;
- virtual bool is_shortcut() const {
- return false;
- }
+ boost::weak_ptr<const extended_type_info> m_derived_observer;
+ boost::weak_ptr<const extended_type_info> m_base_observer;
+ /*const*/ std::ptrdiff_t m_difference;
+ const bool m_heap; // allocated on the heap
+
     // note that void_casters are keyed on value of
- // addresses to member extended type info records
- bool operator<(const void_caster & lhs) const {
- if(m_derived < lhs.m_derived)
- return true;
- if(m_derived == lhs.m_derived)
- if(m_base < lhs.m_base)
- return true;
- return false;
+ // member extended type info records - NOT their
+ // addresses. This is necessary in order for the
+ // void cast operations to work across dll and exe
+ // module boundries.
+ bool operator<(const void_caster & rhs) const;
+
+ const void_caster & operator*(){
+ return *this;
     }
     // each derived class must re-implement these;
     virtual void const * upcast(void const * const t) const = 0;
@@ -130,11 +134,15 @@
     void_caster(
         extended_type_info const * derived,
         extended_type_info const * base,
- std::ptrdiff_t difference = 0
+ std::ptrdiff_t difference = 0,
+ bool heap = false
     ) :
         m_derived(derived),
         m_base(base),
- m_difference(difference)
+ m_derived_observer(derived->get_weak_ptr()),
+ m_base_observer(base->get_weak_ptr()),
+ m_difference(difference),
+ m_heap(heap)
     {}
     virtual ~void_caster(){}
 };
@@ -210,8 +218,8 @@
 template <class Derived, class Base>
 void_caster_virtual_base<Derived,Base>::void_caster_virtual_base() :
     void_caster(
- & type_info_implementation<Derived>::type::get_const_instance(),
- & type_info_implementation<Base>::type::get_const_instance()
+ & (type_info_implementation<Derived>::type::get_const_instance()),
+ & (type_info_implementation<Base>::type::get_const_instance())
     )
 {
     recursive_register(true);


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