Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54754 - trunk/libs/serialization/src
From: ramey_at_[hidden]
Date: 2009-07-07 00:01:59


Author: ramey
Date: 2009-07-07 00:01:59 EDT (Tue, 07 Jul 2009)
New Revision: 54754
URL: http://svn.boost.org/trac/boost/changeset/54754

Log:
Fixed misc bugs
void cast
added dll tests
Text files modified:
   trunk/libs/serialization/src/extended_type_info.cpp | 10 ++++++++
   trunk/libs/serialization/src/void_cast.cpp | 46 ++++++++++++++++++++++++++++++---------
   2 files changed, 45 insertions(+), 11 deletions(-)

Modified: trunk/libs/serialization/src/extended_type_info.cpp
==============================================================================
--- trunk/libs/serialization/src/extended_type_info.cpp (original)
+++ trunk/libs/serialization/src/extended_type_info.cpp 2009-07-07 00:01:59 EDT (Tue, 07 Jul 2009)
@@ -62,6 +62,16 @@
 
 class extended_type_info_arg : public extended_type_info
 {
+ 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;
+ };
 public:
     extended_type_info_arg(const char * key) :
         extended_type_info()

Modified: trunk/libs/serialization/src/void_cast.cpp
==============================================================================
--- trunk/libs/serialization/src/void_cast.cpp (original)
+++ trunk/libs/serialization/src/void_cast.cpp 2009-07-07 00:01:59 EDT (Tue, 07 Jul 2009)
@@ -34,6 +34,27 @@
 namespace serialization {
 namespace void_cast_detail {
 
+// note that void_casters are keyed on value of
+// 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 void_caster::operator<(const void_caster & rhs) const {
+ // include short cut to save time and eliminate
+ // problems when when base class aren't virtual
+ if(m_derived != rhs.m_derived){
+ if(*m_derived < *rhs.m_derived)
+ return true;
+ if(*rhs.m_derived < *m_derived)
+ return false;
+ }
+ // m_derived == rhs.m_derived
+ if(m_base != rhs.m_base)
+ return *m_base < *rhs.m_base;
+ else
+ return false;
+}
+
 struct void_caster_compare {
     bool operator()(const void_caster * lhs, const void_caster * rhs) const {
         return *lhs < *rhs;
@@ -105,9 +126,11 @@
                 const void * t_new;
                 t_new = void_downcast(*(*it)->m_base, *m_base, t);
                 // if we were successful
- if(NULL != t_new)
+ if(NULL != t_new){
                     // recast to our derived
- return (*it)->downcast(t_new);
+ const void_caster * vc = *it;
+ return vc->downcast(t_new);
+ }
             }
         }
     }
@@ -170,17 +193,16 @@
     s.insert(this);
 
     // generate all implied void_casts.
-
     void_cast_detail::set_type::const_iterator it;
     for(it = s.begin(); it != s.end(); ++it){
- if(m_derived == (*it)->m_base)
+ if(* m_derived == * (*it)->m_base)
             new void_caster_shortcut(
                 (*it)->m_derived,
                 m_base,
                 m_difference + (*it)->m_difference,
                 includes_virtual_base
             );
- if((*it)->m_derived == m_base)
+ if(* (*it)->m_derived == * m_base)
             new void_caster_shortcut(
                 m_derived,
                 (*it)->m_base,
@@ -198,14 +220,18 @@
     void_cast_detail::set_type & s
         = void_caster_registry::get_mutable_instance();
 
- // delete all implied void_casts.
+ // delete all shortcuts which use this primitive
     void_cast_detail::set_type::iterator it;
     for(it = s.begin(); it != s.end(); ++it){
         if((*it)->is_shortcut()){
             if(m_derived == (*it)->m_base
             || (*it)->m_derived == m_base){
+ // save pointer to set member
+ const void_caster * vc = *it;
+ // and erase first
                 s.erase(it);
- delete *it;
+ // since recursion could invalidate it
+ delete vc;
                 it = s.begin();
             }
         }
@@ -219,8 +245,6 @@
     s.erase(it);
 }
 
-
-
 } // namespace void_cast_detail
 
 // Given a void *, assume that it really points to an instance of one type
@@ -240,7 +264,7 @@
     // check to see if base/derived pair is found in the registry
     const void_cast_detail::set_type & s
         = void_cast_detail::void_caster_registry::get_const_instance();
- void_cast_detail::void_caster_argument ca(& derived, & base);
+ const void_cast_detail::void_caster_argument ca(& derived, & base);
 
     void_cast_detail::set_type::const_iterator it;
     it = s.find(& ca);
@@ -263,7 +287,7 @@
     // check to see if base/derived pair is found in the registry
     const void_cast_detail::set_type & s
         = void_cast_detail::void_caster_registry::get_const_instance();
- void_cast_detail::void_caster_argument ca(& derived, & base);
+ const void_cast_detail::void_caster_argument ca(& derived, & base);
 
     void_cast_detail::set_type::const_iterator it;
     it = s.find(&ca);


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