Author: hdu
Date: Thu May 30 14:01:24 2013
New Revision: 1487865
URL: http://svn.apache.org/r1487865
Log:
#i122208# update STL header wrappers
>From a binary perspective the wrappers allow dropping stlport4 itself
immediately and replacing it by standard compliant system or compiler
standard template libraries.
>From a source code perspective the other parts of the codebase
can remain untouched for now. They can be gradually converted
from stlport4 to the TR1 or C++11 standard at a comfortable pace
later. The header wrappers will assist this source-code conversion.
Modified:
openoffice/trunk/main/stlport/makefile.mk
openoffice/trunk/main/stlport/systemstl/functional
openoffice/trunk/main/stlport/systemstl/hash_map
openoffice/trunk/main/stlport/systemstl/hash_set
openoffice/trunk/main/stlport/systemstl/numeric
openoffice/trunk/main/stlport/systemstl/slist
openoffice/trunk/main/stlport/systemstl/vector
Modified: openoffice/trunk/main/stlport/makefile.mk
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/makefile.mk?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/makefile.mk (original)
+++ openoffice/trunk/main/stlport/makefile.mk Thu May 30 14:01:24 2013
@@ -46,6 +46,9 @@ $(INCCOM)$/stlport$/hash_map \
$(INCCOM)$/stlport$/hash_set \
$(INCCOM)$/stlport$/numeric \
$(INCCOM)$/stlport$/slist \
+$(INCCOM)$/stlport$/list \
+$(INCCOM)$/stlport$/map \
+$(INCCOM)$/stlport$/set \
$(INCCOM)$/stlport$/vector: systemstl$/$$(@:f)
$(MKDIRHIER) $(@:d)
$(COPY) $< $@
Modified: openoffice/trunk/main/stlport/systemstl/functional
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/functional?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/functional (original)
+++ openoffice/trunk/main/stlport/systemstl/functional Thu May 30 14:01:24 2013
@@ -22,35 +22,51 @@
#ifndef SYSTEM_STL_FUNCTIONAL
#define SYSTEM_STL_FUNCTIONAL
-#ifdef GCC
-# ifdef __MINGW32__
-# define _SYSTEM_STL_MAKE_HEADER(path,header) <path/header>
-# include _SYSTEM_STL_MAKE_HEADER(GXX_INCLUDE_PATH,functional)
-# else
-# include <ext/../functional>
-# endif
-# include <ext/functional>
+#if defined(HAVE_STL_INCLUDE_PATH)
+ // TODO: use computed include file name
+ #include_next <functional>
+#elif defined(_MSC_VER)
+ #include <../../VC/include/functional>
+ namespace std { using tr1::hash; }
+#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/tr1/functional>
+ #include <boost/functional/hash.hpp>
+#endif
+
+
+#ifndef NO_STLPORT4_EMULATION
namespace std
{
- using __gnu_cxx::project1st;
- using __gnu_cxx::project2nd;
- using __gnu_cxx::select1st;
- using __gnu_cxx::select2nd;
- using __gnu_cxx::compose1;
- using __gnu_cxx::compose2;
- using __gnu_cxx::unary_compose;
- using __gnu_cxx::binary_compose;
-# ifndef __GXX_EXPERIMENTAL_CXX0X__
- using __gnu_cxx::identity;
- using __gnu_cxx::mem_fun1;
- using __gnu_cxx::mem_fun1_ref;
-# endif
-}
+// emulate SGI extensions to the STL using
http://www.sgi.com/tech/stl/stl_function.h as reference
+template< typename T> struct identity : unary_function<T,T> { T
operator()(const T& t) const { return t;} };
+template< typename T, typename U> struct project2nd : public
binary_function<T,U,U> { U operator()(const T&, const U& u) const { return u;}};
+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; }};
-#else
-# error UNSUPPORTED COMPILER
-#endif
+#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
+
+template<typename Op1, typename Op2> class unary_compose : public
unary_function<typename Op2::argument_type, typename Op1::result_type>
+{
+protected:
+ 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)); }
+};
+
+template<typename Op1, typename Op2> inline unary_compose<Op1,Op2> compose1(
const Op1& rOp1, const Op2& rOp2) { return unary_compose<Op1,Op2>(rOp1, rOp2); }
+
+} // namespace std
+
+#endif // NO_STLPORT4_EMULATION
#endif
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+
Modified: openoffice/trunk/main/stlport/systemstl/hash_map
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/hash_map?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/hash_map (original)
+++ openoffice/trunk/main/stlport/systemstl/hash_map Thu May 30 14:01:24 2013
@@ -22,54 +22,91 @@
#ifndef SYSTEM_STL_HASHMAP
#define SYSTEM_STL_HASHMAP
-#ifdef GCC
+#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/tr1/unordered_map>
+ #define STLP4_EMUBASE_NS ::boost
+#endif
-# include <functional>
-# define _BACKWARD_BACKWARD_WARNING_H 1
-# include <ext/hash_map>
-# undef _BACKWARD_BACKWARD_WARNING_H
+#ifndef NO_STLPORT4_EMULATION
-namespace __gnu_cxx
+namespace std
{
- template<> struct hash < std::string >
- {
- size_t operator()(const std::string & x) const
- {
- return hash< const char* >()(x.c_str());
- }
- };
-
- template<> struct hash< long long int >
- {
- size_t operator()(long long int __x) const
- {
- return __x;
- }
- };
-
- template<> struct hash< unsigned long long int >
- {
- size_t operator()(unsigned long long int __x) const
- {
- return __x;
- }
- };
-}
+#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
-namespace std
+
+template<
+ 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>
{
-# ifndef __GXX_EXPERIMENTAL_CXX0X__
- using __gnu_cxx::hash;
-# endif
- using __gnu_cxx::hash_map;
- using __gnu_cxx::hash_multimap;
-}
+public:
+ typedef unordered_map<__K,__T,__H,__E,__A> _super;
+ typedef __T data_type;
+
+ hash_map( void) {}
+ hash_map( size_t n) : _super( n) {}
+
+#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
-#else
-# error UNSUPPORTED COMPILER
+ 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
+};
+
+template<
+ 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:
+ typedef unordered_multimap<__K,__T,__H,__E,__A> _super;
+ typedef __T data_type;
+
+ hash_multimap( void) {}
+ hash_multimap( size_t n) : _super( n) {}
+
+#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
+};
+
+} // namespace std
+
+#endif // NO_STLPORT4_EMULATION
#endif
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+
Modified: openoffice/trunk/main/stlport/systemstl/hash_set
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/hash_set?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/hash_set (original)
+++ openoffice/trunk/main/stlport/systemstl/hash_set Thu May 30 14:01:24 2013
@@ -22,25 +22,85 @@
#ifndef SYSTEM_STL_HASHSET
#define SYSTEM_STL_HASHSET
-#ifdef GCC
+#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/tr1/unordered_set>
+ #define STLP4_EMUBASE_NS ::boost
+#endif
-# include <functional>
-# define _BACKWARD_BACKWARD_WARNING_H 1
-# include <ext/hash_set>
-# undef _BACKWARD_BACKWARD_WARNING_H
+#ifndef NO_STLPORT4_EMULATION
namespace std
{
-# ifndef __GXX_EXPERIMENTAL_CXX0X__
- using __gnu_cxx::hash;
-# endif
- using __gnu_cxx::hash_set;
- using __gnu_cxx::hash_multiset;
-}
-#else
-# error UNSUPPORTED COMPILER
+#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> >
+class hash_set
+: public unordered_set<__K,__H,__E,__A>
+{
+ typedef unordered_set<__K,__H,__E,__A> _super;
+public:
+ hash_set( void) {}
+ hash_set( size_t n) : _super(n) {}
+ 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
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+
+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
+};
+
+template<
+ 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>
+{
+ typedef unordered_multiset<__K,__H,__E,__A> _super;
+public:
+ hash_multiset( void) {}
+ hash_multiset( size_t n) : _super( n) {}
+ 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
+};
+
+} // namespace std
+
+#endif // NO_STLPORT4_EMULATION
+
+#endif
+
Modified: openoffice/trunk/main/stlport/systemstl/numeric
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/numeric?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/numeric (original)
+++ openoffice/trunk/main/stlport/systemstl/numeric Thu May 30 14:01:24 2013
@@ -22,26 +22,14 @@
#ifndef SYSTEM_STL_NUMERIC
#define SYSTEM_STL_NUMERIC
-#ifdef GCC
-# include <functional>
-# ifdef __MINGW32__
-# define _SYSTEM_STL_MAKE_HEADER(path,header) <path/header>
-# include _SYSTEM_STL_MAKE_HEADER(GXX_INCLUDE_PATH,numeric)
-# else
-# include <ext/../numeric>
-# endif
-# include <ext/numeric>
-
-# ifndef __GXX_EXPERIMENTAL_CXX0X__
-namespace std
-{
- using __gnu_cxx::iota;
-}
-# endif
-
-#else
-# error UNSUPPORTED COMPILER
+#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>
#endif
#endif
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+
Modified: openoffice/trunk/main/stlport/systemstl/slist
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/slist?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/slist (original)
+++ openoffice/trunk/main/stlport/systemstl/slist Thu May 30 14:01:24 2013
@@ -22,18 +22,54 @@
#ifndef SYSTEM_STL_SLIST
#define SYSTEM_STL_SLIST
-#ifdef GCC
+#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
+ // MSVC's list would cause a lot of expression-result-unused warnings
+ // unless it is compiled in iterator-debugging mode. Silence this noise
+ #pragma warning(disable:4555)
+#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>
+ #else // fall back to the classic list
+ #include <boost/tr1/tr1/list>
+ #define STLP4_SLIST_WITH_LIST
+ #endif
+#endif
+
+
+#ifndef NO_STLPORT4_EMULATION
-#include <ext/slist>
+#ifndef STLP4_SLIST_WITH_LIST
+ #define STLP4_SLIST_EMUBASE std::forward_list
+#else
+ #define STLP4_SLIST_EMUBASE std::list
+#endif
namespace std
{
- using __gnu_cxx::slist;
-}
-#else
-#error UNSUPPORTED COMPILER
+using STLP4_SLIST_EMUBASE;
+
+// lame emulation of the pre-C++11 slist using the std::forward_list (or
std::list)
+template< typename T, class A=allocator<T> >
+class slist : public STLP4_SLIST_EMUBASE<T,A>
+{
+public:
+ typedef typename STLP4_SLIST_EMUBASE<T,A> _super;
+ typedef typename _super::iterator slist_mit;
+ typedef typename _super::const_iterator slist_cit;
+#ifndef STLP4_SLIST_WITH_LIST
+ slist_mit insert( slist_cit aI, const T& rT) { return
_super::insert_after( aI, rT); }
#endif
+};
+}
+
+#endif // NO_STLPORT4_EMULATION
#endif
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+
Modified: openoffice/trunk/main/stlport/systemstl/vector
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/stlport/systemstl/vector?rev=1487865&r1=1487864&r2=1487865&view=diff
==============================================================================
--- openoffice/trunk/main/stlport/systemstl/vector (original)
+++ openoffice/trunk/main/stlport/systemstl/vector Thu May 30 14:01:24 2013
@@ -22,22 +22,38 @@
#ifndef SYSTEM_STL_VECTOR
#define SYSTEM_STL_VECTOR
-#ifdef GCC
-
-#ifdef __MINGW32__
-# define _SYSTEM_STL_MAKE_HEADER(path,header) <path/header>
-# include _SYSTEM_STL_MAKE_HEADER(GXX_INCLUDE_PATH,vector)
-#else
-# include <ext/../vector>
+#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>
#endif
+
+#ifndef NO_STLPORT4_EMULATION
+
namespace std
{
- typedef vector<bool, std::allocator<bool> > bit_vector;
+ 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 0 && defined(_LIBCPP___BIT_REFERENCE) // TODO: reenable for libc++ >=
r156543/r156546/etc.
+ int nCount = std::count( it, itEnd, bValue);
#else
-#error UNSUPPORTED COMPILER
+ int nCount = 0;
+ for(; it != itEnd; ++it)
+ if( *it == bValue)
+ ++nCount;
#endif
+ return nCount;
+}
+
+#endif // NO_STLPORT4_EMULATION
+
#endif
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
+