1.1 --- a/epoc32/include/stdapis/stlport/stl/_construct.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_construct.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,252 @@
1.4 -_construct.h
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + * Copyright (c) 1994
1.8 + * Hewlett-Packard Company
1.9 + *
1.10 + * Copyright (c) 1996,1997
1.11 + * Silicon Graphics Computer Systems, Inc.
1.12 + *
1.13 + * Copyright (c) 1997
1.14 + * Moscow Center for SPARC Technology
1.15 + *
1.16 + * Copyright (c) 1999
1.17 + * Boris Fomitchev
1.18 + *
1.19 + * This material is provided "as is", with absolutely no warranty expressed
1.20 + * or implied. Any use is at your own risk.
1.21 + *
1.22 + * Permission to use or copy this software for any purpose is hereby granted
1.23 + * without fee, provided the above notices are retained on all copies.
1.24 + * Permission to modify the code and to distribute modified code is granted,
1.25 + * provided the above notices are retained, and a notice that the code was
1.26 + * modified is included with the above copyright notice.
1.27 + *
1.28 + */
1.29 +
1.30 +/* NOTE: This is an internal header file, included by other STL headers.
1.31 + * You should not attempt to use it directly.
1.32 + */
1.33 +
1.34 +#ifndef _STLP_INTERNAL_CONSTRUCT_H
1.35 +#define _STLP_INTERNAL_CONSTRUCT_H
1.36 +
1.37 +#ifdef _STLP_USE_TRAP_LEAVE
1.38 +#include <e32base.h>
1.39 +#endif // _STLP_USE_TRAP_LEAVE
1.40 +
1.41 +# if defined (_STLP_DEBUG_UNINITIALIZED) && ! defined (_STLP_CSTRING)
1.42 +# include <cstring>
1.43 +# endif
1.44 +
1.45 +# ifndef _STLP_INTERNAL_NEW_HEADER
1.46 +# include <stl/_new.h>
1.47 +# endif
1.48 +
1.49 +
1.50 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.51 +# include <stl/_iterator_base.h>
1.52 +#endif
1.53 +
1.54 +_STLP_BEGIN_NAMESPACE
1.55 +
1.56 +# ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG
1.57 +template <class _Tp>
1.58 +inline void __destroy_aux(_Tp* __pointer, const __false_type&) { __pointer->~_Tp(); }
1.59 +template <class _Tp>
1.60 +inline void __destroy_aux(_Tp* __pointer, const __true_type&) {}
1.61 +# endif
1.62 +
1.63 +template <class _Tp>
1.64 +inline void _Destroy(_Tp* __pointer) {
1.65 +# if _MSC_VER >= 1010
1.66 + __pointer;
1.67 +# endif // _MSC_VER >= 1000
1.68 +# ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG
1.69 + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
1.70 + __destroy_aux(__pointer, _Trivial_destructor());
1.71 +# else
1.72 +# if ( defined (__BORLANDC__) && ( __BORLANDC__ < 0x500 ) )
1.73 + __pointer->_Tp::~_Tp();
1.74 +# else
1.75 + __pointer->~_Tp();
1.76 +# endif
1.77 +# endif
1.78 +# ifdef _STLP_DEBUG_UNINITIALIZED
1.79 + memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp));
1.80 +# endif
1.81 +}
1.82 +
1.83 +# if defined (new)
1.84 +# define _STLP_NEW_REDEFINE new
1.85 +# undef new
1.86 +# endif
1.87 +
1.88 +# ifdef _STLP_DEFAULT_CONSTRUCTOR_BUG
1.89 +template <class _T1>
1.90 +inline void _Construct_aux (_T1* __p, const __false_type&) {
1.91 +_STLP_PLACEMENT_NEW (__p) _T1();
1.92 +}
1.93 +
1.94 +template <class _T1>
1.95 +inline void _Construct_aux (_T1* __p, const __true_type&) {
1.96 +_STLP_PLACEMENT_NEW (__p) _T1(0);
1.97 +}
1.98 +# endif
1.99 +
1.100 +template <class _T1, class _T2>
1.101 +inline void _Construct(_T1* __p, const _T2& __val) {
1.102 +# ifdef _STLP_DEBUG_UNINITIALIZED
1.103 + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
1.104 +# endif
1.105 + _STLP_PLACEMENT_NEW (__p) _T1(__val);
1.106 +}
1.107 +
1.108 +template <class _T1>
1.109 +inline void _Construct(_T1* __p) {
1.110 +# ifdef _STLP_DEBUG_UNINITIALIZED
1.111 + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
1.112 +# endif
1.113 +# ifdef _STLP_DEFAULT_CONSTRUCTOR_BUG
1.114 +typedef typename _Is_integer<_T1>::_Integral _Is_Integral;
1.115 +_Construct_aux (__p, _Is_Integral() );
1.116 +# else
1.117 + _STLP_PLACEMENT_NEW (__p) _T1();
1.118 +# endif
1.119 +}
1.120 +
1.121 +# if defined(_STLP_NEW_REDEFINE)
1.122 +# ifdef DEBUG_NEW
1.123 +# define new DEBUG_NEW
1.124 +# endif
1.125 +# undef _STLP_NEW_REDEFINE
1.126 +# endif
1.127 +
1.128 +template <class _ForwardIterator>
1.129 +_STLP_INLINE_LOOP void
1.130 +__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, const __false_type&) {
1.131 + for ( ; __first != __last; ++__first)
1.132 + _STLP_STD::_Destroy(&*__first);
1.133 +}
1.134 +
1.135 +template <class _ForwardIterator>
1.136 +inline void __destroy_aux(_ForwardIterator, _ForwardIterator, const __true_type&) {}
1.137 +
1.138 +template <class _ForwardIterator, class _Tp>
1.139 +inline void
1.140 +__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) {
1.141 + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
1.142 + __destroy_aux(__first, __last, _Trivial_destructor());
1.143 +}
1.144 +
1.145 +template <class _ForwardIterator>
1.146 +inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
1.147 + __destroy(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
1.148 +}
1.149 +
1.150 +inline void _Destroy(char*, char*) {}
1.151 +# ifdef _STLP_HAS_WCHAR_T // dwa 8/15/97
1.152 +inline void _Destroy(wchar_t*, wchar_t*) {}
1.153 +inline void _Destroy(const wchar_t*, const wchar_t*) {}
1.154 +# endif
1.155 +
1.156 +# ifndef _STLP_NO_ANACHRONISMS
1.157 +// --------------------------------------------------
1.158 +// Old names from the HP STL.
1.159 +
1.160 +template <class _T1, class _T2>
1.161 +inline void construct(_T1* __p, const _T2& __val) {_Construct(__p, __val); }
1.162 +template <class _T1>
1.163 +inline void construct(_T1* __p) { _Construct(__p); }
1.164 +template <class _Tp>
1.165 +inline void destroy(_Tp* __pointer) { _STLP_STD::_Destroy(__pointer); }
1.166 +template <class _ForwardIterator>
1.167 +inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy(__first, __last); }
1.168 +# endif
1.169 +
1.170 +#ifdef _STLP_USE_TRAP_LEAVE
1.171 +
1.172 +struct TCleanupOverlay
1.173 +{
1.174 + TAny *vtable;
1.175 + TAny *iBase;
1.176 + TAny *iTop;
1.177 + TAny *iNext;
1.178 +};
1.179 +
1.180 +template <class _Tp>
1.181 +struct _STLP_StackHelper {
1.182 + static unsigned int Check( void *ptr );
1.183 + static void* _NewLC (size_t __n);
1.184 +};
1.185 +
1.186 +struct _STLP_StackPopper {
1.187 + ~_STLP_StackPopper() { CleanupStack::Pop(); }
1.188 +};
1.189 +
1.190 +template <class _Tp>
1.191 +struct _STLP_Cleanup {
1.192 + static void clear(TAny* __p);
1.193 +};
1.194 +
1.195 +# define _STLP_PUSH_CLEANUP_ITEM(_Tp, __p) CleanupStack::PushL(TCleanupItem(&_STLP_Cleanup< _Tp >::clear, (TAny*)__p));
1.196 +# define _STLP_PUSH_STACK_ITEM(_Tp, __p) _STLP_PUSH_CLEANUP_ITEM(_Tp, __p) _STLP_StackPopper __Popper; _STLP_no_unused_variable_warning( __Popper );
1.197 +# define _STLP_POP_IF_CHECK if (_STLP_StackHelper<bool>::Check(this)) CleanupStack::Pop();
1.198 +# define _STLP_POP_CLEANUP_ITEM CleanupStack::Pop(); _STLP_POP_IF_CHECK
1.199 +
1.200 +# define _STLP_POP_ITEM CleanupStack::Pop();
1.201 +
1.202 +// to be used in complex object constructors
1.203 +template <class _Tp>
1.204 +struct _STLP_StackPusher {
1.205 + _STLP_StackPusher(_Tp * __p) { _STLP_PUSH_CLEANUP_ITEM(_Tp, (void*)__p) }
1.206 +};
1.207 +
1.208 +template <class _Tp>
1.209 +unsigned int _STLP_StackHelper<_Tp>::Check( void *ptr )
1.210 +
1.211 +{
1.212 + TCleanupTrapHandler *handler =
1.213 + (TCleanupTrapHandler *)User::TrapHandler();
1.214 +
1.215 + CCleanup &cleanup = handler->Cleanup();
1.216 +
1.217 + TCleanupOverlay *overlay = (TCleanupOverlay *)( &cleanup );
1.218 +
1.219 + char *raw = (char *)(overlay->iNext) - 4;
1.220 + void *topptr = *( (void **)(raw) );
1.221 +
1.222 + return ( ptr == topptr );
1.223 +}
1.224 +
1.225 +
1.226 +template <class _Tp>
1.227 +void* _STLP_StackHelper<_Tp>::_NewLC(size_t __n) {
1.228 + void* __p = ::operator new (__n, ELeave) ;
1.229 + // constructor will pop it back
1.230 + CleanupStack::PushL(__p);
1.231 + return __p;
1.232 +}
1.233 +
1.234 +template <class _Tp>
1.235 +void _STLP_Cleanup<_Tp>::clear(TAny* __p)
1.236 +{
1.237 + ((_Tp*)__p)->~_Tp();
1.238 +}
1.239 +
1.240 +
1.241 +#else
1.242 +# define _STLP_PUSH_CLEANUP_ITEM(_Tp, __p)
1.243 +# define _STLP_POP_CLEANUP_ITEM
1.244 +# define _STLP_PUSH_STACK_ITEM(_Tp, p)
1.245 +# define _STLP_POP_ITEM
1.246 +# define _STLP_POP_IF_CHECK
1.247 +# define TPush TLeave
1.248 +#endif
1.249 +
1.250 +_STLP_END_NAMESPACE
1.251 +
1.252 +#endif /* _STLP_INTERNAL_CONSTRUCT_H */
1.253 +
1.254 +// Local Variables:
1.255 +// mode:C++
1.256 +// End: