|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55737 - trunk/boost/serialization
From: ramey_at_[hidden]
Date: 2009-08-23 15:26:13
Author: ramey
Date: 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
New Revision: 55737
URL: http://svn.boost.org/trac/boost/changeset/55737
Log:
Improved implemenation of boost_serializer_map
Improved support for serialization of types in DLLS
New exception for violations of ODR when using DLLS
Fix error in recent update of export.hpp
Added class names to exception messages
Text files modified:
trunk/boost/serialization/export.hpp | 57 +++++++++++++++++++++------------------
trunk/boost/serialization/extended_type_info.hpp | 1
trunk/boost/serialization/extended_type_info_no_rtti.hpp | 7 +++-
trunk/boost/serialization/extended_type_info_typeid.hpp | 3 ++
trunk/boost/serialization/nvp.hpp | 5 ++-
trunk/boost/serialization/void_cast.hpp | 22 +++++++++++++++
6 files changed, 64 insertions(+), 31 deletions(-)
Modified: trunk/boost/serialization/export.hpp
==============================================================================
--- trunk/boost/serialization/export.hpp (original)
+++ trunk/boost/serialization/export.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -29,16 +29,17 @@
#include <boost/preprocessor/stringize.hpp>
#include <boost/type_traits/is_polymorphic.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/bool.hpp>
+
#include <boost/serialization/static_warning.hpp>
#include <boost/serialization/assume_abstract.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/archive/detail/register_archive.hpp>
-#include <boost/mpl/assert.hpp>
-#include <boost/mpl/and.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/mpl/bool.hpp>
#include <iostream>
@@ -114,50 +115,52 @@
);
}
-} // namespace detail
-} // namespace archive
-} // namespace boost
-
namespace {
template<class T>
struct guid_initializer
{
- void export_guid(boost::mpl::false_){
+ void export_guid(mpl::false_) const {
// generates the statically-initialized objects whose constructors
// register the information allowing serialization of T objects
// through pointers to their base classes.
- boost::archive::detail::instantiate_ptr_serialization(
- (T*)0,
- 0,
- boost::archive::detail::adl_tag()
- );
+ instantiate_ptr_serialization((T*)0, 0, adl_tag());
}
- void export_guid(boost::mpl::true_){}
- guid_initializer(){
+ const void export_guid(mpl::true_) const {
+ }
+ guid_initializer const & export_guid() const {
BOOST_STATIC_WARNING(boost::is_polymorphic<T>::value);
// note: exporting an abstract base class will have no effect
// and cannot be used to instantitiate serialization code
// (one might be using this in a DLL to instantiate code)
//BOOST_STATIC_WARNING(! boost::serialization::is_abstract<T>::value);
export_guid(boost::serialization::is_abstract<T>());
+ return *this;
}
};
-template<class T>
-struct init_guid {
- static guid_initializer< T > const & g;
-};
+template<typename T>
+struct init_guid;
} // anonymous
+} // namespace detail
+} // namespace archive
+} // namespace boost
-#define BOOST_CLASS_EXPORT_IMPLEMENT(T) \
- namespace { \
- template <> guid_initializer< T > const & init_guid< T >::g = \
- ::boost::serialization::singleton< \
- guid_initializer< T > \
- >::get_mutable_instance(); \
- } \
+#define BOOST_CLASS_EXPORT_IMPLEMENT(T) \
+ namespace boost { \
+ namespace archive { \
+ namespace detail { \
+ namespace { \
+ template<> \
+ struct init_guid< T > { \
+ static guid_initializer< T > const & g; \
+ }; \
+ guid_initializer< T > const & init_guid< T >::g = \
+ ::boost::serialization::singleton< \
+ guid_initializer< T > \
+ >::get_mutable_instance().export_guid(); \
+ }}}} \
/**/
#define BOOST_CLASS_EXPORT_KEY2(T, K) \
Modified: trunk/boost/serialization/extended_type_info.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info.hpp (original)
+++ trunk/boost/serialization/extended_type_info.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -82,6 +82,7 @@
const char * get_key() const {
return m_key;
}
+ virtual const char * get_debug_info() const = 0;
bool operator<(const extended_type_info &rhs) const;
bool operator==(const extended_type_info &rhs) const;
bool operator!=(const extended_type_info &rhs) const {
Modified: trunk/boost/serialization/extended_type_info_no_rtti.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info_no_rtti.hpp (original)
+++ trunk/boost/serialization/extended_type_info_no_rtti.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -113,7 +113,10 @@
const char * get_key() const{
return action<guid_defined<T>::value >::invoke();
}
- void * construct(unsigned int count, ...) const{
+ virtual const char * get_debug_info() const{
+ return action<guid_defined<T>::value >::invoke();
+ }
+ virtual void * construct(unsigned int count, ...) const{
// count up the arguments
std::va_list ap;
va_start(ap, count);
@@ -134,7 +137,7 @@
return NULL;
}
}
- void destroy(void const * const p) const{
+ virtual void destroy(void const * const p) const{
delete static_cast<T const *>(p) ;
}
};
Modified: trunk/boost/serialization/extended_type_info_typeid.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info_typeid.hpp (original)
+++ trunk/boost/serialization/extended_type_info_typeid.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -47,6 +47,9 @@
class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_typeid_0 :
public extended_type_info
{
+ virtual const char * get_debug_info() const {
+ return m_ti->name();
+ }
protected:
const std::type_info * m_ti;
extended_type_info_typeid_0(const char * key);
Modified: trunk/boost/serialization/nvp.hpp
==============================================================================
--- trunk/boost/serialization/nvp.hpp (original)
+++ trunk/boost/serialization/nvp.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -43,9 +43,10 @@
public std::pair<const char *, T *>,
public wrapper_traits<nvp<T> >
{
- explicit nvp(const char * name, T & t) :
+ explicit nvp(const char * name_, T & t) :
// note: redundant cast works around borland issue
- std::pair<const char *, T *>(name, (T*)(& t))
+ // note: added _ to suppress useless gcc warning
+ std::pair<const char *, T *>(name_, (T*)(& t))
{}
nvp(const nvp & rhs) :
// note: redundant cast works around borland issue
Modified: trunk/boost/serialization/void_cast.hpp
==============================================================================
--- trunk/boost/serialization/void_cast.hpp (original)
+++ trunk/boost/serialization/void_cast.hpp 2009-08-23 15:26:12 EDT (Sun, 23 Aug 2009)
@@ -230,6 +230,22 @@
recursive_unregister();
}
+template <class Derived, class Base>
+struct void_caster_base :
+ public void_caster
+{
+ typedef
+ BOOST_DEDUCED_TYPENAME mpl::eval_if<boost::is_virtual_base_of<Base,Derived>,
+ mpl::identity<
+ void_cast_detail::void_caster_virtual_base<Derived, Base>
+ >
+ ,// else
+ mpl::identity<
+ void_cast_detail::void_caster_primitive<Derived, Base>
+ >
+ >::type type;
+};
+
} // void_cast_detail
// Register a base/derived pair. This indicates that it is possible
@@ -262,6 +278,12 @@
return singleton<typex>::get_const_instance();
}
+template<class Derived, class Base>
+class void_caster :
+ public void_cast_detail::void_caster_base<Derived, Base>::type
+{
+};
+
} // namespace serialization
} // namespace boost
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