Boost logo

Boost-Commit :

From: ramey_at_[hidden]
Date: 2007-09-26 21:53:47


Author: ramey
Date: 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
New Revision: 39562
URL: http://svn.boost.org/trac/boost/changeset/39562

Log:
improvements to extended type info system - unfortunately, these break the export.
Text files modified:
   branches/serialization_next_release/boost/boost/serialization/base_object.hpp | 28 +++++++---------
   branches/serialization_next_release/boost/boost/serialization/config.hpp | 2
   branches/serialization_next_release/boost/boost/serialization/export.hpp | 9 ++---
   branches/serialization_next_release/boost/boost/serialization/extended_type_info.hpp | 54 +++++++++++----------------------
   branches/serialization_next_release/boost/boost/serialization/extended_type_info_no_rtti.hpp | 61 +++++--------------------------------
   branches/serialization_next_release/boost/boost/serialization/extended_type_info_typeid.hpp | 65 ++++++++++++++++++++-------------------
   branches/serialization_next_release/boost/boost/serialization/optional.hpp | 2
   branches/serialization_next_release/boost/boost/serialization/void_cast.hpp | 41 +++++++++----------------
   8 files changed, 94 insertions(+), 168 deletions(-)

Modified: branches/serialization_next_release/boost/boost/serialization/base_object.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/base_object.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/base_object.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -27,10 +27,10 @@
 #include <boost/mpl/int.hpp>
 #include <boost/type_traits/is_base_and_derived.hpp>
 #include <boost/type_traits/is_pointer.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
 #include <boost/type_traits/is_const.hpp>
 
 #include <boost/static_assert.hpp>
-#include <boost/serialization/type_info_implementation.hpp>
 #include <boost/serialization/force_include.hpp>
 #include <boost/serialization/void_cast_fwd.hpp>
 
@@ -45,33 +45,29 @@
   {
       static void const* execute(mpl::false_) { return 0; }
 
- static void const* execute(mpl::true_)
- {
- return &void_cast_register((Derived const*)0, (Base const*)0);
+ static void const* execute(mpl::true_){
+ return & void_cast_register((Derived const*)0, (Base const*)0);
       }
             
- static void const* invoke()
- {
- typedef mpl::bool_<
- type_info_implementation<Base>::type::is_polymorphic::value
- > is_polymorphic;
-
- return execute(is_polymorphic());
+ static void const* invoke(){
+ return execute(
+ BOOST_DEDUCED_TYPENAME boost::is_polymorphic<Base>::type()
+ );
       }
   };
 
   // get the base type for a given derived type
   // preserving the const-ness
- template<class B, class D>
+ template<class Base, class Derived>
   struct base_cast
   {
       typedef BOOST_DEDUCED_TYPENAME
       mpl::if_<
- is_const<D>,
- const B,
- B
+ is_const<Derived>,
+ const Base,
+ Base
>::type type;
- BOOST_STATIC_ASSERT(is_const<type>::value == is_const<D>::value);
+ BOOST_STATIC_ASSERT(is_const<type>::value == is_const<Derived>::value);
   };
 } // namespace detail
 

Modified: branches/serialization_next_release/boost/boost/serialization/config.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/config.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/config.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -65,7 +65,7 @@
 //
 // And include the header that does the work:
 //
-#include <boost/config/auto_link.hpp>
+#include <boost/archive/detail/auto_link_archive.hpp>
 
 #endif // !defined(BOOST_SERIALIZATION_SOURCE) && !defined(BOOST_ARCHIVE_SOURCE)
 

Modified: branches/serialization_next_release/boost/boost/serialization/export.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/export.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/export.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -26,8 +26,8 @@
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/preprocessor/stringize.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
 
-#include <boost/archive/detail/dynamically_initialized.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
 #include <boost/serialization/is_abstract.hpp>
 #include <boost/serialization/force_include.hpp>
@@ -76,7 +76,7 @@
     
     static void export_register(const char *key)
     {
- eti_type::export_register(key);
+ eti_type::find()->key_register(key);
     }
     
     static const guid_initializer& get_instance(char const* key)
@@ -188,9 +188,8 @@
 // need to export it.
 #define BOOST_CLASS_EXPORT_CHECK(T) \
     BOOST_STATIC_WARNING( \
- boost::serialization::type_info_implementation< T > \
- ::type::is_polymorphic::value \
- ); \
+ BOOST_DEDUCED_TYPENAME boost::is_polymorphic<T>::value \
+ );
     /**/
 
 // the default exportable class identifier is the class name

Modified: branches/serialization_next_release/boost/boost/serialization/extended_type_info.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/extended_type_info.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/extended_type_info.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -36,52 +36,34 @@
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info :
     private boost::noncopyable
 {
-private:
- virtual bool
- less_than(const extended_type_info &rhs) const = 0;
- int type_info_key_cmp(const extended_type_info & rhs) const;
-
- // 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 char * m_type_info_key;
- // flag to indicate wheter its been registered by type;
- bool m_self_registered;
- // flag to indicate wheter its been registered by type;
- bool m_key_registered;
- // flag indicating that no virtual function should be called here
- // this is necessary since it seems that at least one compiler (borland
- // and one version of gcc call less_than above when erasing even
- // when given an iterator argument.
- bool m_is_destructing;
 protected:
- const char * m_key;
- extended_type_info(const char * type_info_key);
- // account for bogus gcc warning
- #if defined(__GNUC__)
- virtual
- #endif
+ // this class can't be used as is. It's just the
+ // common functionality for all type_info replacement
+ // systems. Hence, make these protected
+ extended_type_info();
     ~extended_type_info();
+ const char * m_key;
 public:
- void self_register();
     void key_register(const char *key);
- bool is_destructing() const {
- return m_is_destructing;
- }
- bool operator<(const extended_type_info &rhs) const;
- bool operator==(const extended_type_info &rhs) const {
- return this == & rhs;
- }
- bool operator!=(const extended_type_info &rhs) const {
- return this != & rhs;
- }
     const char * get_key() const {
         return m_key;
     }
     static const extended_type_info * find(const char *key);
- static const extended_type_info * find(const extended_type_info * t);
 };
 
+// in order
+BOOST_SERIALIZATION_DECL(bool)
+operator==(
+ const extended_type_info & lhs,
+ const extended_type_info & rhs
+);
+
+BOOST_SERIALIZATION_DECL(bool)
+operator<(
+ const extended_type_info & lhs,
+ const extended_type_info & rhs
+);
+
 } // namespace serialization
 } // namespace boost
 

Modified: branches/serialization_next_release/boost/boost/serialization/extended_type_info_no_rtti.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/extended_type_info_no_rtti.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/extended_type_info_no_rtti.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -32,42 +32,16 @@
 
 namespace boost {
 namespace serialization {
-namespace detail {
-///////////////////////////////////////////////////////////////////////
-// define a special type_info that doesn't depend on rtti which is not
-// available in all situations.
-
-// common base class to share type_info_key. This is used to
-// identify the method used to keep track of the extended type
-class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_no_rtti_0 :
- public extended_type_info
-{
- virtual bool
- less_than(const boost::serialization::extended_type_info &rhs) const ;
-protected:
- extended_type_info_no_rtti_0();
- // account for bogus gcc warning
- #if defined(__GNUC__)
- virtual
- #endif
- ~extended_type_info_no_rtti_0();
-public:
- struct is_polymorphic
- {
- typedef boost::mpl::bool_<true> type;
- BOOST_STATIC_CONSTANT(bool, value = is_polymorphic::type::value);
- };
-};
 
 template<class T>
-class extended_type_info_no_rtti_1 :
- public extended_type_info_no_rtti_0
+class extended_type_info_no_rtti :
+ public extended_type_info
 {
-protected:
- extended_type_info_no_rtti_1(){}
+ // private constructor to inhibit any existence other than the
+ // static one
+ extended_type_info_no_rtti(){}
+ ~extended_type_info_no_rtti(){};
 public:
- // note borland complains at making this destructor protected
- ~extended_type_info_no_rtti_1(){};
     static const boost::serialization::extended_type_info *
     get_derived_extended_type_info(const T & t){
         // find the type that corresponds to the most derived type.
@@ -80,28 +54,11 @@
         return boost::serialization::extended_type_info::find(derived_key);
     }
     static boost::serialization::extended_type_info *
- get_instance(){
- static extended_type_info_no_rtti_1<T> instance;
+ find(){
+ // is this thread safe? probably not - does it need to be?
+ static extended_type_info_no_rtti<T> instance;
         return & instance;
     }
- static void
- export_register(const char * key){
- boost::serialization::extended_type_info * eti;
- eti = get_instance();
- eti->key_register(key); // initialize key and add to table
- eti->self_register(); // add type to type table
- }
-};
-} // namespace detail
-
-template<class T>
-class extended_type_info_no_rtti :
- public detail::extended_type_info_no_rtti_1<const T>
-{
- // private constructor to inhibit any existence other than the
- // static one
- extended_type_info_no_rtti(){}
- ~extended_type_info_no_rtti(){};
 };
 
 } // namespace serialization

Modified: branches/serialization_next_release/boost/boost/serialization/extended_type_info_typeid.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/extended_type_info_typeid.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/extended_type_info_typeid.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -19,10 +19,10 @@
 
 #include <typeinfo>
 #include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
 
 //#include <boost/static_warning.hpp>
 #include <boost/static_assert.hpp>
-#include <boost/type_traits/is_polymorphic.hpp>
 #include <boost/type_traits/is_const.hpp>
 #include <boost/preprocessor/stringize.hpp>
 
@@ -36,26 +36,24 @@
 
 namespace boost {
 namespace serialization {
-
 namespace detail {
 
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_typeid_0 :
     public extended_type_info
 {
-private:
- virtual bool
- less_than(const extended_type_info &rhs) const;
 protected:
+ const std::type_info * m_ti;
+ extended_type_info_typeid_0() :
+ m_ti(NULL)
+ {}
+ ~extended_type_info_typeid_0();
+ void type_register(const std::type_info & ti);
     static const extended_type_info *
     get_derived_extended_type_info(const std::type_info & ti);
- extended_type_info_typeid_0();
- // account for bogus gcc warning
- #if defined(__GNUC__)
- virtual
- #endif
- ~extended_type_info_typeid_0();
 public:
- virtual const std::type_info & get_eti() const = 0;
+ const std::type_info & get_typeid() const {
+ return *m_ti;
+ }
 };
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -64,24 +62,17 @@
 class extended_type_info_typeid_1 :
     public detail::extended_type_info_typeid_0
 {
-private:
- virtual const std::type_info & get_eti() const {
- return typeid(T);
- }
 protected:
- // private constructor to inhibit any existence other than the
- // static one
     extended_type_info_typeid_1() :
         detail::extended_type_info_typeid_0()
     {
- self_register(); // add type to type table
+ type_register(typeid(T));
     }
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
+public:
+#endif
+ ~extended_type_info_typeid_1(){}
 public:
- struct is_polymorphic
- {
- typedef BOOST_DEDUCED_TYPENAME boost::is_polymorphic<T>::type type;
- BOOST_STATIC_CONSTANT(bool, value = is_polymorphic::type::value);
- };
     static const extended_type_info *
     get_derived_extended_type_info(const T & t){
         // note: this implementation - based on usage of typeid (rtti)
@@ -89,17 +80,17 @@
 // BOOST_STATIC_WARNING(
 // static_cast<bool>(is_polymorphic::value)
 // );
- return detail::extended_type_info_typeid_0::get_derived_extended_type_info(typeid(t));
+ return
+ detail::extended_type_info_typeid_0::get_derived_extended_type_info(
+ typeid(t)
+ );
     }
     static extended_type_info *
- get_instance(){
+ find(){
+ // is this thread safe? probably not - does it need to be?
         static extended_type_info_typeid_1<T> instance;
         return & instance;
     }
- static void
- export_register(const char * key){
- get_instance()->key_register(key);
- }
 };
 
 } // namespace detail
@@ -108,7 +99,19 @@
 template<class T>
 class extended_type_info_typeid :
     public detail::extended_type_info_typeid_1<const T>
-{};
+{
+public:
+ static const extended_type_info *
+ get_derived_extended_type_info(const T & t){
+ return detail::extended_type_info_typeid_1<T>
+ ::get_derived_extended_type_info(t);
+ }
+ static extended_type_info *
+ find(){
+ // is this thread safe? probably not - does it need to be?
+ return detail::extended_type_info_typeid_1<T>::find();
+ }
+};
 
 } // namespace serialization
 } // namespace boost

Modified: branches/serialization_next_release/boost/boost/serialization/optional.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/optional.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/optional.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -53,7 +53,7 @@
     bool tflag;
     ar >> boost::serialization::make_nvp("initialized", tflag);
     if (tflag){
- unsigned int v;
+ unsigned int v = 0;
         if(3 < ar.get_library_version()){
             ar >> make_nvp("item_version", v);
         }

Modified: branches/serialization_next_release/boost/boost/serialization/void_cast.hpp
==============================================================================
--- branches/serialization_next_release/boost/boost/serialization/void_cast.hpp (original)
+++ branches/serialization_next_release/boost/boost/serialization/void_cast.hpp 2007-09-26 21:53:46 EDT (Wed, 26 Sep 2007)
@@ -89,32 +89,17 @@
 // note: can't be abstract because an instance is used as a search argument
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) void_caster
 {
- friend struct void_caster_compare ;
- friend
- BOOST_SERIALIZATION_DECL(void const *)
- boost::serialization::void_upcast(
- const extended_type_info & derived_type,
- const extended_type_info & base_type,
- const void * t,
- bool top
- );
- friend
- BOOST_SERIALIZATION_DECL(void const *)
- boost::serialization::void_downcast(
- const extended_type_info & derived_type,
- const extended_type_info & base_type,
- const void * t,
- bool top
- );
- // each derived class must re-implement these;
- virtual void const * upcast(void const * t) const = 0;
- virtual void const * downcast(void const * t) const = 0;
- // Data members
- extended_type_info const & m_derived_type;
- extended_type_info const & m_base_type;
+ friend BOOST_SERIALIZATION_DECL(bool)
+ operator<(const void_caster & lhs, const void_caster & rhs);
 protected:
     static void static_register(const void_caster *);
 public:
+ // Data members
+ extended_type_info const & m_derived_type;
+ extended_type_info const & m_base_type;
+ // each derived class must re-implement these;
+ virtual void const * upcast(void const * t) const = 0;
+ virtual void const * downcast(void const * t) const = 0;
     // Constructor
     void_caster(
         extended_type_info const & derived_type_,
@@ -122,13 +107,16 @@
     );
     // predicate used to determine if this void caster includes
     // a particular eti *
- bool includes(const extended_type_info * eti) const;
+// bool includes(const extended_type_info * eti) const;
     virtual ~void_caster();
 private:
     // cw 8.3 requires this!!
     void_caster& operator=(void_caster const&);
 };
 
+BOOST_SERIALIZATION_DECL(bool)
+operator<(const void_caster & lhs, const void_caster & rhs);
+
 template <class Derived, class Base>
 class void_caster_primitive :
     public void_caster
@@ -179,8 +167,8 @@
 template <class Derived, class Base>
 BOOST_DLLEXPORT void_caster_primitive<Derived, Base>::void_caster_primitive() :
     void_caster(
- * type_info_implementation<Derived>::type::get_instance(),
- * type_info_implementation<Base>::type::get_instance()
+ * type_info_implementation<Derived>::type::find(),
+ * type_info_implementation<Base>::type::find()
     )
 {
     // calling get_instance() causes infinite recursion, and the
@@ -207,6 +195,7 @@
     const Derived * dnull,
     const Base * bnull
 ) BOOST_USED;
+
 template<class Derived, class Base>
 BOOST_DLLEXPORT
 inline const void_cast_detail::void_caster & void_cast_register(


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