|
Boost-Commit : |
From: ramey_at_[hidden]
Date: 2007-11-22 01:09:41
Author: ramey
Date: 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
New Revision: 41294
URL: http://svn.boost.org/trac/boost/changeset/41294
Log:
tested with statically loaded dlls
Text files modified:
branches/serialization_next_release/boost/libs/serialization/src/basic_iarchive.cpp | 25 +++++---
branches/serialization_next_release/boost/libs/serialization/src/basic_oarchive.cpp | 11 +++
branches/serialization_next_release/boost/libs/serialization/src/codecvt_null.cpp | 1
branches/serialization_next_release/boost/libs/serialization/src/extended_type_info.cpp | 112 +++++++++++++++++++++++----------------
branches/serialization_next_release/boost/libs/serialization/src/extended_type_info_typeid.cpp | 73 +++++++++++++++++--------
branches/serialization_next_release/boost/libs/serialization/src/void_cast.cpp | 6 -
6 files changed, 143 insertions(+), 85 deletions(-)
Modified: branches/serialization_next_release/boost/libs/serialization/src/basic_iarchive.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/basic_iarchive.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/basic_iarchive.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -23,20 +23,23 @@
} // namespace std
#endif
-#define BOOST_ARCHIVE_SOURCE
-#include <boost/archive/detail/auto_link_archive.hpp>
-
#include <boost/limits.hpp>
#include <boost/state_saver.hpp>
#include <boost/throw_exception.hpp>
+#include <boost/serialization/tracking.hpp>
+
+#include <boost/archive/archive_exception.hpp>
+
+#define BOOST_ARCHIVE_SOURCE
+#define BOOST_SERIALIZATION_SOURCE
+#include <boost/archive/detail/decl.hpp>
+#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/basic_iserializer.hpp>
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
#include <boost/archive/detail/basic_iarchive.hpp>
-#include <boost/archive/archive_exception.hpp>
-#include <boost/serialization/tracking.hpp>
-#include <boost/serialization/extended_type_info.hpp>
+#include <boost/archive/detail/auto_link_archive.hpp>
using namespace boost::serialization;
@@ -44,9 +47,6 @@
namespace archive {
namespace detail {
-class basic_iserializer;
-class basic_pointer_iserializer;
-
class basic_iarchive_impl {
friend class basic_iarchive;
version_type m_archive_library_version;
@@ -486,8 +486,15 @@
return bpis_ptr;
}
+} // namespace detail
+} // namespace archive
+} // namespace boost
+
//////////////////////////////////////////////////////////////////////
// implementation of basic_iarchive functions
+namespace boost {
+namespace archive {
+namespace detail {
BOOST_ARCHIVE_DECL(void)
basic_iarchive::next_object_pointer(void *t){
Modified: branches/serialization_next_release/boost/libs/serialization/src/basic_oarchive.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/basic_oarchive.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/basic_oarchive.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -20,8 +20,9 @@
// including this here to work around an ICC in intel 7.0
// normally this would be part of basic_oarchive.hpp below.
#define BOOST_ARCHIVE_SOURCE
-#include <boost/archive/basic_archive.hpp>
+#define BOOST_SERIALIZATION_SOURCE
+#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/basic_oserializer.hpp>
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
#include <boost/archive/detail/basic_oarchive.hpp>
@@ -385,9 +386,17 @@
stored_pointers.insert(oid);
}
+} // namespace detail
+} // namespace archive
+} // namespace boost
+
//////////////////////////////////////////////////////////////////////
// implementation of basic_oarchive functions
+namespace boost {
+namespace archive {
+namespace detail {
+
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
basic_oarchive::basic_oarchive(unsigned int flags)
: pimpl(new basic_oarchive_impl(flags))
Modified: branches/serialization_next_release/boost/libs/serialization/src/codecvt_null.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/codecvt_null.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/codecvt_null.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -7,6 +7,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/codecvt_null.hpp>
// codecvt implementation for passing wchar_t objects to char output
Modified: branches/serialization_next_release/boost/libs/serialization/src/extended_type_info.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/extended_type_info.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/extended_type_info.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -19,6 +19,8 @@
#include <boost/config.hpp> // msvc needs this to suppress warning
+#include "bidirectional_map.hpp"
+
#include <cstring>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::strcmp; }
@@ -42,25 +44,38 @@
const extended_type_info * lhs,
const extended_type_info * rhs
) const {
- return *lhs < *rhs;
+ const char * l = lhs->get_key();
+ assert(NULL != l);
+ const char * r = rhs->get_key();
+ assert(NULL != r);
+ // performance shortcut
+ // shortcut to exploit string pooling
+ if(l == r)
+ return false;
+ // for exported types, use the string key so that
+ // multiple instances in different translation units
+ // can be matched up
+ return -1 == std::strcmp(l, r);
}
};
-typedef std::set<
- const extended_type_info *,
- key_compare
-> ktmap;
-//template ktmap;
+typedef std::multiset<const extended_type_info *, key_compare> ktmap;
class extended_type_info_arg : public extended_type_info
{
public:
- extended_type_info_arg(const char * key){
+ extended_type_info_arg(const char * key) :
+ extended_type_info(NULL)
+ {
m_key = key;
}
~extended_type_info_arg(){
m_key = NULL;
}
+ virtual bool less_than(const extended_type_info &rhs) const {
+ key_compare kc;
+ return kc(this, & rhs);
+ }
};
} // namespace detail
@@ -69,17 +84,31 @@
extended_type_info::key_register(const char *key) {
assert(NULL != key);
m_key = key;
- std::pair<detail::ktmap::const_iterator, bool> result;
- // prohibit duplicates and multiple registrations
- result = singleton<detail::ktmap>::get_mutable_instance().insert(this);
- assert(result.second);
- // would like to throw and exception here but I don't
- // have one conveniently defined
- // throw(?)
+ singleton<detail::ktmap>::get_mutable_instance().insert(this);
+}
+
+BOOST_SERIALIZATION_DECL(void)
+extended_type_info::key_unregister() {
+ assert(NULL != m_key);
+ detail::ktmap & x = singleton<detail::ktmap>::get_mutable_instance();
+ detail::ktmap::iterator start = x.lower_bound(this);
+ detail::ktmap::iterator end = x.upper_bound(this);
+ assert(start != end);
+
+ // remove entry in map which corresponds to this type
+ do{
+ if(this == *start){
+ x.erase(start);
+ break;
+ }
+ }while(++start != end);
+
+ m_key = NULL;
}
BOOST_SERIALIZATION_DECL(const extended_type_info *)
extended_type_info::find(const char *key) {
+ assert(NULL != key);
const detail::ktmap & k = singleton<detail::ktmap>::get_const_instance();
const detail::extended_type_info_arg eti_key(key);
const detail::ktmap::const_iterator it = k.find(& eti_key);
@@ -88,7 +117,11 @@
return *(it);
}
-extended_type_info::extended_type_info() :
+BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
+extended_type_info::extended_type_info(
+ const unsigned int type_info_key
+) :
+ m_type_info_key(type_info_key),
m_key(NULL)
{
// make sure that the ktmap is instantiated before
@@ -98,44 +131,31 @@
BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
extended_type_info::~extended_type_info(){
- if(NULL != m_key){
- unsigned int erase_count;
- erase_count =
- singleton<detail::ktmap>::get_mutable_instance().erase(this);
- assert(1 == erase_count);
- }
+ if(NULL == m_key)
+ return;
+ key_unregister();
}
-BOOST_SERIALIZATION_DECL(bool)
-operator==(
- const extended_type_info & lhs,
- const extended_type_info & rhs
-){
- return (& lhs == & rhs);
+BOOST_SERIALIZATION_DECL(bool)
+extended_type_info::operator<(const extended_type_info &rhs) const {
+ if(m_type_info_key == rhs.m_type_info_key){
+ return less_than(rhs);
+ }
+ if(m_type_info_key < rhs.m_type_info_key)
+ return true;
+ return false;
}
BOOST_SERIALIZATION_DECL(bool)
-operator<(
- const extended_type_info & lhs,
- const extended_type_info & rhs
-){
- // shortcut to exploit string pooling
- const char * l = lhs.get_key();
- const char * r = rhs.get_key();
- // neither have been exported
- if(NULL == l && NULL == r)
- // order by address
- return & lhs < & rhs;
- // exported types are "higher" than non-exported types
- if(NULL == l)
+extended_type_info::operator==(const extended_type_info &rhs) const {
+ if(this == & rhs)
return true;
- if(NULL == r)
+ if(*this < rhs)
return false;
- // for exported types, use the string key so that
- // multiple instances in different translation units
- // can be matched up
- return -1 == std::strcmp(l, r);
-}
+ if(rhs < *this)
+ return false;
+ return true;
+};
} // namespace serialization
} // namespace boost
Modified: branches/serialization_next_release/boost/libs/serialization/src/extended_type_info_typeid.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/extended_type_info_typeid.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/extended_type_info_typeid.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -25,6 +25,8 @@
namespace serialization {
namespace detail {
+#define EXTENDED_TYPE_INFO_TYPE_KEY 1
+
struct type_compare
{
bool
@@ -32,45 +34,68 @@
const extended_type_info_typeid_0 * lhs,
const extended_type_info_typeid_0 * rhs
) const {
- const std::type_info & l = lhs->get_typeid();
- const std::type_info & r = rhs->get_typeid();
- return l.before(r);
+ return lhs->less_than(*rhs);
}
};
-typedef std::set<
+
+typedef std::multiset<
const extended_type_info_typeid_0 *,
type_compare
> tkmap;
-
-//template tkmap;
+
+BOOST_SERIALIZATION_DECL(bool)
+extended_type_info_typeid_0::less_than(
+ const boost::serialization::extended_type_info & rhs
+) const {
+ //assert(this->m_type_info_key == rhs.m_type_info_key);
+ return m_ti->before(
+ *(static_cast<const extended_type_info_typeid_0 &>(rhs).m_ti)
+ );
+}
+
+BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
+extended_type_info_typeid_0::extended_type_info_typeid_0() :
+ extended_type_info(EXTENDED_TYPE_INFO_TYPE_KEY),
+ m_ti(NULL)
+{}
+
+BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
+extended_type_info_typeid_0::~extended_type_info_typeid_0()
+{}
BOOST_SERIALIZATION_DECL(void)
extended_type_info_typeid_0::type_register(const std::type_info & ti){
m_ti = & ti;
- std::pair<tkmap::const_iterator, bool> result;
- result = singleton<tkmap>::get_mutable_instance().insert(this);
- assert(result.second);
- // would like to throw and exception here but I don't
- // have one conveniently defined
- // throw(?)
+ singleton<tkmap>::get_mutable_instance().insert(this);
}
-BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
-extended_type_info_typeid_0::~extended_type_info_typeid_0()
+BOOST_SERIALIZATION_DECL(void)
+extended_type_info_typeid_0::type_unregister()
{
- if(NULL != m_ti){
- // remove entries in maps which correspond to this type
- unsigned int erase_count;
- erase_count
- = singleton<tkmap>::get_mutable_instance().erase(this);
- assert(1 == erase_count);
- }
+ if(NULL == m_ti)
+ return;
+
+ tkmap & x = singleton<tkmap>::get_mutable_instance();
+ tkmap::iterator start = x.lower_bound(this);
+ tkmap::iterator end = x.upper_bound(this);
+ assert(start != end);
+
+ // remove entry in map which corresponds to this type
+ do{
+ if(this == *start){
+ x.erase(start);
+ break;
+ }
+ }while(++start != end);
+
+ m_ti = NULL;
}
// this derivation is used for creating search arguments
class extended_type_info_typeid_arg :
public extended_type_info_typeid_0
{
+private:
public:
extended_type_info_typeid_arg(const std::type_info & ti){
// note absense of self register and key as this is used only as
@@ -84,10 +109,10 @@
};
BOOST_SERIALIZATION_DECL(const extended_type_info *)
-extended_type_info_typeid_0::get_derived_extended_type_info(
+extended_type_info_typeid_0::get_extended_type_info(
const std::type_info & ti
-){
- detail::extended_type_info_typeid_arg etia(ti);
+) const {
+ detail::extended_type_info_typeid_arg etia(ti);
const tkmap & t = singleton<tkmap>::get_const_instance();
const tkmap::const_iterator it = t.find(& etia);
if(t.end() == it)
Modified: branches/serialization_next_release/boost/libs/serialization/src/void_cast.cpp
==============================================================================
--- branches/serialization_next_release/boost/libs/serialization/src/void_cast.cpp (original)
+++ branches/serialization_next_release/boost/libs/serialization/src/void_cast.cpp 2007-11-22 01:09:40 EST (Thu, 22 Nov 2007)
@@ -22,9 +22,9 @@
#include <cassert>
// BOOST
+#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/extended_type_info.hpp>
-#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/void_cast.hpp>
namespace boost {
@@ -41,8 +41,6 @@
) const {
if( lhs->m_derived < rhs->m_derived )
return true;
- if( rhs->m_derived < lhs->m_derived)
- return false;
if( lhs->m_base < rhs->m_base )
return true;
return false;
@@ -52,8 +50,6 @@
typedef std::set<const void_caster *, void_caster_compare> set_type;
typedef boost::serialization::singleton<set_type> void_caster_registry;
-//template void_caster_registry;
-
// implementation of void caster base class
BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY())
void_caster::void_caster(
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