You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2013/05/17 17:51:01 UTC

svn commit: r1483880 - in /openoffice/branches/rejuvenate01/main/stlport/systemstl: functional hash_map hash_set numeric slist vector

Author: hdu
Date: Fri May 17 15:51:01 2013
New Revision: 1483880

URL: http://svn.apache.org/r1483880
Log:
#i122208# updating stl wrappers for stlport4 emulation

these thin wrappers emulate the stlport4 semantic for
AOO's use cases by employing the system's prefered STL:
- on Windows MSVC's tr1 library
- on Mac the libc++ library
- on others the boost/tr1 library

This approach allows AOO to become binary compatible with the system's
C++ libraries while AOO's main codebase can remain mostly untouched
for now. Compiler diagnostics will help with the cleanup later when
one after the other wrapper part is disabled or removed.

Modified:
    openoffice/branches/rejuvenate01/main/stlport/systemstl/functional
    openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_map
    openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_set
    openoffice/branches/rejuvenate01/main/stlport/systemstl/numeric
    openoffice/branches/rejuvenate01/main/stlport/systemstl/slist
    openoffice/branches/rejuvenate01/main/stlport/systemstl/vector

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/functional
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/functional?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/functional (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/functional Fri May 17 15:51:01 2013
@@ -22,14 +22,19 @@
 #ifndef SYSTEM_STL_FUNCTIONAL
 #define SYSTEM_STL_FUNCTIONAL
 
-#ifdef HAVE_STL_INCLUDE_PATH
+#undef HASH_NS
+#if defined(HAVE_STL_INCLUDE_PATH)
 	// TODO: use computed include file name
 	#include_next <functional>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/functional>
+#if 1 // TODO: enable only when std::_Swap_adl is not available
+	// note: VS2008SP1 has known problems after a security update (KB971092,KB974479,KB974223)
+	namespace std{ template<class _T> void _Swap_adl(_T& l, _T& r) {swap(l,r);} }
+#endif	
 #else // fall back to boost/tr1
-	#include <boost/tr1/functional.hpp>
-	#undef TR1_NS
-	#define TR1_NS std::tr1
-	#define TR1_INNER_NS tr1
+	#include <boost/tr1/tr1/functional>
+	#include <boost/functional/hash.hpp>
 #endif
 
 
@@ -43,8 +48,6 @@ template< typename T, typename U> struct
 template<typename P> struct select1st : public unary_function<P, typename P::first_type> { const typename P::first_type& operator()(const P& p) const { return p.first; }};
 template<typename P> struct select2nd : public unary_function<P, typename P::second_type> { const typename P::second_type& operator()(const P& p) const { return p.second; }};
 
-//template<typename I, typename V> inline void iota( I first, I last, V value) { while(first!=last) *(first++) = value++; }
-
 #if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(__GXX_EXPERIMENTAL_CXX0X__)
 template<typename T> inline T&& forward( typename identity<T>::type&& t) { return t; }
 #endif // C++11 move semantics
@@ -52,35 +55,15 @@ template<typename T> inline T&& forward(
 template<typename Op1, typename Op2> class unary_compose : public unary_function<typename Op2::argument_type, typename Op1::result_type> 
 {
 protected:
-  Op1 aOp1;
-  Op2 aOp2;
+	Op1 aOp1;
+	Op2 aOp2;
 public:
-  unary_compose( const Op1& rOp1, const Op2& rOp2) : aOp1(rOp1), aOp2(rOp2) {}
-  typename Op1::result_type operator()( const typename Op2::argument_type& x) const { return aOp1(aOp2(x)); }
+	unary_compose( const Op1& rOp1, const Op2& rOp2) : aOp1(rOp1), aOp2(rOp2) {}
+	typename Op1::result_type operator()( const typename Op2::argument_type& x) const { return aOp1(aOp2(x)); }
 };
 
 template<typename Op1, typename Op2> inline unary_compose<Op1,Op2> compose1( const Op1& rOp1, const Op2& rOp2) { return unary_compose<Op1,Op2>(rOp1, rOp2); }
 
-// empty equal_to specializations to detect invocations
-// that are dangerous because their semantic might
-// differ significantly from the stlport<=4 semantic
-template<> struct equal_to<const signed char*> {void operator()(void){}};
-template<> struct equal_to<const unsigned char*> {void operator()(void){}};
-
-#if defined(TR1_INNER_NS)
-namespace TR1_INNER_NS {
-#endif
-    // empty hash specializations to detect invocations
-    // that are dangerous because their semantic might
-    // differ significantly from the stlport<=4 semantic
-    template<> struct hash<char*> {void operator()(void){}};
-    template<> struct hash<const unsigned char*> {void operator()(){}};
-    template<> struct hash<const signed char*> {void operator()(){}};
-#if defined(TR1_INNER_NS)
-}
-using TR1_NS::hash;
-#endif
-
 } // namespace std
 
 #endif // NO_STLPORT4_EMULATION

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_map
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_map?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_map (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_map Fri May 17 15:51:01 2013
@@ -25,10 +25,12 @@
 #ifdef HAVE_STL_INCLUDE_PATH
 	// TODO: use computed include file name
 	#include_next <unordered_map>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/unordered_map>
+	#define STLP4_EMUBASE_NS ::std::tr1
 #else // fall back to boost/tr1
-	#include <boost/tr1/unordered_map.hpp>
-	#undef TR1_NS
-	#define TR1_NS std::tr1
+	#include <boost/tr1/tr1/unordered_map>
+	#define STLP4_EMUBASE_NS ::boost
 #endif
 
 
@@ -36,56 +38,70 @@
 
 namespace std
 {
-#ifdef TR1_NS
-using TR1_NS::hash;
-using TR1_NS::unordered_map;
-using TR1_NS::unordered_multimap;
+#ifdef STLP4_EMUBASE_NS
+	using STLP4_EMUBASE_NS::hash;
+	using STLP4_EMUBASE_NS::unordered_map;
+	using STLP4_EMUBASE_NS::unordered_multimap;
+	#undef STLP4_EMUBASE_NS
 #endif
 
+
 template<
-	typename K,
-	typename T,
-	typename H = hash<K>,
-	typename E = equal_to<K>,
-	typename A = allocator<pair<K,T> > >
+	typename __K,
+	typename __T,
+	typename __H = hash<__K>,
+	typename __E = equal_to<__K>,
+	typename __A = allocator<pair<__K,__T> > >
 class hash_map
-:	public unordered_map<K,T,H,E,A>
+:	public unordered_map<__K,__T,__H,__E,__A>
 {
 public:
-	typedef unordered_map<K,T,H,E,A> _super;
-	typedef typename _super::mapped_type data_type;
+	typedef unordered_map<__K,__T,__H,__E,__A> _super;
+	typedef __T data_type;
 
 	hash_map( void) {}
 	hash_map( size_t n) : _super( n) {}
-	hash_map& operator=( const hash_map& r) { hash_map t(r); _super::swap(t); return *this;} //####################
+
+#ifdef BOOST_TR1_UNORDERED_MAP_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem 
+	// in derived classes the copy assignment operator can only be declared implicitly if
+	// its base class's assignment operator has the canonical signature.
+	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
+	hash_map& operator=( const hash_map& r) { hash_map c(r); this->swap(c); return *this; }
+#endif
 
 	void resize( size_t n) { _super::rehash(n); }
 private:
 	// setting the hasher dynamically is not supported in the emulation!
-	hash_map( size_t, const H&, const E& rE=E(), const A& rA=A()); // not implemented
+	hash_map( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
 };
 
 template<
-	typename K,
-	typename T,
-	typename H = hash<K>,
-	typename E = equal_to<K>,
-	typename A = allocator<pair<K,T> > >
+	typename __K,
+	typename __T,
+	typename __H = hash<__K>,
+	typename __E = equal_to<__K>,
+	typename __A = allocator<pair<__K,__T> > >
 class hash_multimap
-:	public unordered_multimap<K,T,H,E,A>
+:	public unordered_multimap<__K,__T,__H,__E,__A>
 {
 public:
-	typedef unordered_multimap<K,T,H,E,A> _super;
-	typedef typename _super::mapped_type data_type;
+	typedef unordered_multimap<__K,__T,__H,__E,__A> _super;
+	typedef __T data_type;
 
 	hash_multimap( void) {}
 	hash_multimap( size_t n) : _super( n) {}
-	hash_multimap& operator=( const hash_multimap& r) { hash_multimap t(r); _super::swap(t); return *this;}//####################
+
+#ifdef BOOST_TR1_UNORDERED_MAP_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem
+	// in derived classes the copy assignment operator can only be declared implicitly if
+	// its base class's assignment operator has the canonical signature.
+	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
+	hash_multimap& operator=( const hash_multimap& r) { hash_multimap c(r); this->swap(c); return *this; }
+#endif
 
 	void resize( size_t n) { _super::rehash(n); }
 private:
 	// setting the hasher dynamically is not supported in the emulation!
-	hash_multimap( size_t, const H&, const E& rE=E(), const A& rA=A()); // not implemented
+	hash_multimap( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
 };
 
 } // namespace std

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_set
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_set?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_set (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/hash_set Fri May 17 15:51:01 2013
@@ -25,10 +25,12 @@
 #ifdef HAVE_STL_INCLUDE_PATH
 	// TODO: use computed include file name
 	#include_next <unordered_set>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/unordered_set>
+	#define STLP4_EMUBASE_NS ::std::tr1
 #else // fall back to boost/tr1
-	#include <boost/tr1/unordered_set.hpp>
-	#undef TR1_NS
-	#define TR1_NS std::tr1
+	#include <boost/tr1/tr1/unordered_set>
+	#define STLP4_EMUBASE_NS ::boost
 #endif
 
 
@@ -36,48 +38,64 @@
 
 namespace std
 {
-#ifdef TR1_NS
-using TR1_NS::hash;
-using TR1_NS::unordered_set;
-using TR1_NS::unordered_multiset;
-#endif // TR1_NS
+#ifdef STLP4_EMUBASE_NS
+	using STLP4_EMUBASE_NS::hash;
+	using STLP4_EMUBASE_NS::unordered_set;
+	using STLP4_EMUBASE_NS::unordered_multiset;
+	#undef STLP4_EMUBASE_NS
+#endif
+
 
 template<
-	typename K,
-	typename H = hash<K>,
-	typename E = equal_to<K>,
-	typename A = allocator<K> >
+	typename __K,
+	typename __H = hash<__K>,
+	typename __E = equal_to<__K>,
+	typename __A = allocator<__K> >
 class hash_set
-:	public unordered_set<K,H,E,A>
+:	public unordered_set<__K,__H,__E,__A>
 {
-	typedef unordered_set<K,H,E,A> _super;
+	typedef unordered_set<__K,__H,__E,__A> _super;
 public:
 	hash_set( void) {}
 	hash_set( size_t n) : _super(n) {}
-	hash_set& operator=(const hash_set& r) { hash_set t(r); _super::swap(t); return *this;};//#################
 	void resize( size_t n) { _super::rehash( n); }
+
+#ifdef BOOST_TR1_UNORDERED_SET_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem 
+	// in derived classes the copy assignment operator can only be declared implicitly if
+	// its base class's assignment operator has the canonical signature.
+	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
+	hash_set& operator=( const hash_set& r) { hash_set c(r); this->swap(c); return *this; }
+#endif
+
 private:
 	// setting the hasher dynamically is not supported in the emulation!
-	hash_set( size_t, const H&, const E& rE=E(), const A& rA=A()); // not implemented
+	hash_set( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
 };
 
 template<
-	typename K,
-	typename H = hash<K>,
-	typename E = equal_to<K>,
-	typename A = allocator<K> >
+	typename __K,
+	typename __H = hash<__K>,
+	typename __E = equal_to<__K>,
+	typename __A = allocator<__K> >
 class hash_multiset
-:	public unordered_multiset<K,H,E,A>
+:	public unordered_multiset<__K,__H,__E,__A>
 {
-	typedef unordered_multiset<K,H,E,A> _super;
+	typedef unordered_multiset<__K,__H,__E,__A> _super;
 public:
 	hash_multiset( void) {}
 	hash_multiset( size_t n) : _super( n) {}
-	hash_multiset& operator=(const hash_multiset& r) { hash_multiset t(r); _super::swap(t); return *this;}//#################
 	void resize( size_t n) { _super::rehash( n); }
+
+#ifdef BOOST_TR1_UNORDERED_SET_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem 
+	// in derived classes the copy assignment operator can only be declared implicitly if
+	// its base class's assignment operator has the canonical signature.
+	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
+	hash_multiset& operator=( const hash_multiset& r) { hash_multiset c(r); this->swap(c); return *this; }
+#endif
+
 private:
 	// setting the hasher dynamically is not supported in the emulation!
-	hash_multiset( size_t, const H&, const E& rE=E(), const A& rA=A()); // not implemented
+	hash_multiset( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
 };
 
 } // namespace std

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/numeric
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/numeric?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/numeric (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/numeric Fri May 17 15:51:01 2013
@@ -25,8 +25,11 @@
 #ifdef HAVE_STL_INCLUDE_PATH
 	// TODO: use computed include file name
 	#include_next <numeric>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/numeric>
 #else // fall back to boost/tr1
-	#include <boost/tr1/tr1/numeric.hpp>
+	#include <boost/tr1/tr1/numeric>
+// template<typename I, typename V> inline void iota( I first, I last, V value) { while(first!=last) *(first++) = value++; }
 #endif
 
 #endif

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/slist
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/slist?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/slist (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/slist Fri May 17 15:51:01 2013
@@ -25,12 +25,15 @@
 #ifdef HAVE_STL_INCLUDE_PATH
 	// TODO: use computed include file name
 	#include_next <forward_list>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/list>
+	#define STLP4_SLIST_WITH_LIST
 #else // fall back to boost/tr1 (forward_list or plain list)
 	#include <boost/config.hpp>
 	#ifndef BOOST_NO_0X_HDR_FORWARD_LIST
-		#include <boost/tr1/tr1/forward_list.hpp>
+		#include <boost/tr1/tr1/forward_list>
 	#else // fall back to the classic list
-		#include <boost/tr1/tr1/list.hpp>
+		#include <boost/tr1/tr1/list>
 		#define STLP4_SLIST_WITH_LIST
 	#endif
 #endif

Modified: openoffice/branches/rejuvenate01/main/stlport/systemstl/vector
URL: http://svn.apache.org/viewvc/openoffice/branches/rejuvenate01/main/stlport/systemstl/vector?rev=1483880&r1=1483879&r2=1483880&view=diff
==============================================================================
--- openoffice/branches/rejuvenate01/main/stlport/systemstl/vector (original)
+++ openoffice/branches/rejuvenate01/main/stlport/systemstl/vector Fri May 17 15:51:01 2013
@@ -25,8 +25,10 @@
 #ifdef HAVE_STL_INCLUDE_PATH
 	// TODO: use computed include file name
 	#include_next <vector>
+#elif defined(_MSC_VER)
+	#include <../../VC/include/vector>
 #else // fall back to boost/tr1
-	#include <boost/tr1/tr1/vector.hpp>
+	#include <boost/tr1/tr1/vector>
 #endif
 
 
@@ -37,9 +39,10 @@ namespace std
     typedef vector<bool> bit_vector;
 }
 
+// workaround some STL implementations having problems with their vector<bool>::count() specialization
 inline int std_bitset_count( std::bit_vector::const_iterator it, std::bit_vector::const_iterator itEnd, bool bValue)
 {
-#if false && defined(_LIBCPP___BIT_REFERENCE) // TODO: reenable for libc++ >= r156543/r156546/etc.
+#if 0 && defined(_LIBCPP___BIT_REFERENCE) // TODO: reenable for libc++ >= r156543/r156546/etc.
 	int nCount = std::count( it, itEnd, bValue);
 #else
 	int nCount = 0;