os/ossrv/genericopenlibs/cppstdlib/stl/src/libstdcppwsd.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Name        : libstdcppwsd.cpp
sl@0
    15
// Part of     : standard c++ library.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include "stlport_prefix.h"
sl@0
    20
#include "stl/_threads.h"
sl@0
    21
#include <locale>
sl@0
    22
#include <libstdcppwsd.h>
sl@0
    23
#include "locale_impl.h"
sl@0
    24
sl@0
    25
#ifdef __SYMBIAN32__WSD__   //stuff for WSD
sl@0
    26
sl@0
    27
//constructor
sl@0
    28
EXPORT_C _Libcpp_wsd::_Libcpp_wsd()
sl@0
    29
	 : ios_base_Init_S_count(0), 
sl@0
    30
	    _IosInit(NULL),
sl@0
    31
		wsd_cin(NULL),
sl@0
    32
		wsd_cout(NULL),
sl@0
    33
		wsd_cerr(NULL),
sl@0
    34
		wsd_clog(NULL),
sl@0
    35
#ifndef _STLP_NO_WCHAR_T
sl@0
    36
		wsd_wcin(NULL),
sl@0
    37
		wsd_wcout(NULL),
sl@0
    38
		wsd_wcerr(NULL),
sl@0
    39
		wsd_wclog(NULL),
sl@0
    40
#endif	
sl@0
    41
		is_Initialized(false),
sl@0
    42
		_Stl_classic_locale(NULL),
sl@0
    43
		_Stl_global_locale(NULL)
sl@0
    44
		{ /* do nothing */ }
sl@0
    45
	
sl@0
    46
//destructor	
sl@0
    47
EXPORT_C _Libcpp_wsd::~_Libcpp_wsd()
sl@0
    48
		{
sl@0
    49
		//Free the internal allocations
sl@0
    50
		if( _IosInit != NULL )
sl@0
    51
			{
sl@0
    52
			_IosInit->~Init();
sl@0
    53
			WSDFree(_IosInit);
sl@0
    54
			}
sl@0
    55
		if( wsd_cin != NULL )
sl@0
    56
			{
sl@0
    57
			wsd_cin->~basic_istream();
sl@0
    58
			WSDFree(wsd_cin);
sl@0
    59
			}
sl@0
    60
		if( wsd_cout != NULL )
sl@0
    61
			{
sl@0
    62
			wsd_cout->~basic_ostream();
sl@0
    63
			WSDFree(wsd_cout);
sl@0
    64
			}
sl@0
    65
		if( wsd_cerr != NULL )
sl@0
    66
			{
sl@0
    67
			wsd_cerr->~basic_ostream();
sl@0
    68
			WSDFree(wsd_cerr);
sl@0
    69
			}
sl@0
    70
		if( wsd_clog != NULL )
sl@0
    71
			{
sl@0
    72
			wsd_clog->~basic_ostream();
sl@0
    73
			WSDFree(wsd_clog);
sl@0
    74
			}
sl@0
    75
		if( wsd_wcin != NULL )
sl@0
    76
			{
sl@0
    77
			wsd_wcin->~basic_istream();
sl@0
    78
			WSDFree(wsd_wcin);
sl@0
    79
			}
sl@0
    80
		if( wsd_wcout != NULL )
sl@0
    81
			{
sl@0
    82
			wsd_wcout->~basic_ostream();
sl@0
    83
			WSDFree(wsd_wcout);
sl@0
    84
			}
sl@0
    85
		if( wsd_wcerr != NULL )
sl@0
    86
			{
sl@0
    87
			wsd_wcerr->~basic_ostream();
sl@0
    88
			WSDFree(wsd_wcerr);
sl@0
    89
			}
sl@0
    90
		if( wsd_wclog != NULL )
sl@0
    91
			{
sl@0
    92
			wsd_wclog->~basic_ostream();
sl@0
    93
			WSDFree(wsd_wclog);
sl@0
    94
			}
sl@0
    95
		if( _Stl_global_locale != NULL )
sl@0
    96
			{
sl@0
    97
			_Stl_global_locale->~locale();
sl@0
    98
			WSDFree(_Stl_global_locale);
sl@0
    99
			}
sl@0
   100
		if( _Stl_classic_locale != NULL )
sl@0
   101
			{
sl@0
   102
			_Stl_classic_locale->~locale();
sl@0
   103
			WSDFree(_Stl_classic_locale);
sl@0
   104
			}
sl@0
   105
			
sl@0
   106
		if( _Loc_init_S_count != NULL )
sl@0
   107
			WSDFree(_Loc_init_S_count);	
sl@0
   108
		}
sl@0
   109
sl@0
   110
EXPORT_C void CleanupWSD() 
sl@0
   111
	{
sl@0
   112
	_Libcpp_wsd* wsdPtr = Pls<_Libcpp_wsd>(KLibstdcppUID, NULL);
sl@0
   113
	wsdPtr->~_Libcpp_wsd();
sl@0
   114
	}
sl@0
   115
sl@0
   116
EXPORT_C _Libcpp_wsd& get_libcpp_wsd()
sl@0
   117
	{
sl@0
   118
	//get the TLS pointer
sl@0
   119
	_Libcpp_wsd* g_libcpp_wsd = Pls<_Libcpp_wsd>(KLibstdcppUID, NULL);
sl@0
   120
	if(g_libcpp_wsd->is_Initialized != true)
sl@0
   121
		{
sl@0
   122
		//this has to be here to avoid infinite recursion
sl@0
   123
		g_libcpp_wsd->is_Initialized = true;
sl@0
   124
sl@0
   125
#ifdef _STLP_DEBUG
sl@0
   126
		get_Nameless() = new std::string("*");
sl@0
   127
#endif
sl@0
   128
		//initialize allocator static data
sl@0
   129
		stdcpp_allocators_init();
sl@0
   130
sl@0
   131
		//initialize the page size
sl@0
   132
		filebuf_page_size_init();
sl@0
   133
sl@0
   134
		//initialize _S_count of _Loc_init
sl@0
   135
		// Calling placement new on internally alloc'ed memory.
sl@0
   136
		g_libcpp_wsd->_Loc_init_S_count = new (WSDAlloc(sizeof(std::_Refcount_Base))) std::_Refcount_Base(0);
sl@0
   137
sl@0
   138
		std::_Locale_impl::Init::Init();
sl@0
   139
		// Calling placement new on internally alloc'ed memory.
sl@0
   140
		g_libcpp_wsd->_IosInit = new (WSDAlloc(sizeof(std::ios_base::Init))) std::ios_base::Init();
sl@0
   141
		}
sl@0
   142
	return (*g_libcpp_wsd);
sl@0
   143
	}
sl@0
   144
sl@0
   145
sl@0
   146
/******************** threads related *****************/
sl@0
   147
//
sl@0
   148
_STLP_DECLSPEC std::_STLP_STATIC_MUTEX& exp_get_threads_S_swap_lock() 
sl@0
   149
	{
sl@0
   150
	return get_libcpp_wsd()._threads_S_swap_lock;
sl@0
   151
	}
sl@0
   152
sl@0
   153
_STLP_DECLSPEC std::_STLP_STATIC_MUTEX& exp_get_threads_0_S_swap_lock() 
sl@0
   154
	{
sl@0
   155
  	return get_libcpp_wsd()._threads_0_S_swap_lock;
sl@0
   156
	}
sl@0
   157
sl@0
   158
sl@0
   159
sl@0
   160
// locale::id
sl@0
   161
//ACCESS FUNCTIONS
sl@0
   162
_STLP_DECLSPEC std::locale::id&
sl@0
   163
std::codecvt<char, char, mbstate_t>::GetFacetLocaleId()
sl@0
   164
    {
sl@0
   165
    	return get_libcpp_wsd().codecvt_char_char_mbstate_id;
sl@0
   166
    }
sl@0
   167
sl@0
   168
sl@0
   169
_STLP_DECLSPEC std::locale::id&
sl@0
   170
std::codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId()
sl@0
   171
    {
sl@0
   172
   	 	return get_libcpp_wsd().codecvt_wchar_char_mbstate_id;
sl@0
   173
    }
sl@0
   174
sl@0
   175
_STLP_DECLSPEC std::locale::id&
sl@0
   176
std::collate<char>::GetFacetLocaleId()
sl@0
   177
    {
sl@0
   178
   		return get_libcpp_wsd().collate_char_id;
sl@0
   179
    }
sl@0
   180
sl@0
   181
_STLP_DECLSPEC std::locale::id&
sl@0
   182
std::ctype<char>::GetFacetLocaleId()
sl@0
   183
    {
sl@0
   184
    	return get_libcpp_wsd().ctype_char_id;
sl@0
   185
    }
sl@0
   186
sl@0
   187
_STLP_DECLSPEC std::locale::id&
sl@0
   188
std::moneypunct<char, true>::GetFacetLocaleId()
sl@0
   189
	{
sl@0
   190
		return get_libcpp_wsd().moneypunct_char_true_id;
sl@0
   191
	}
sl@0
   192
sl@0
   193
_STLP_DECLSPEC std::locale::id&
sl@0
   194
std::moneypunct<char, false>::GetFacetLocaleId()
sl@0
   195
    {
sl@0
   196
    	return get_libcpp_wsd().moneypunct_char_false_id;
sl@0
   197
    }
sl@0
   198
sl@0
   199
_STLP_DECLSPEC std::locale::id&
sl@0
   200
std::messages<char>::GetFacetLocaleId()
sl@0
   201
    {
sl@0
   202
    	return get_libcpp_wsd().messages_char_id;
sl@0
   203
    }
sl@0
   204
sl@0
   205
_STLP_DECLSPEC std::locale::id&
sl@0
   206
std::numpunct<char>::GetFacetLocaleId()
sl@0
   207
    {
sl@0
   208
    	return get_libcpp_wsd().numpunct_char_id;
sl@0
   209
    }
sl@0
   210
sl@0
   211
_STLP_DECLSPEC std::locale::id&
sl@0
   212
std::collate<wchar_t>::GetFacetLocaleId()
sl@0
   213
	{
sl@0
   214
		return get_libcpp_wsd().collate_wchar_id;
sl@0
   215
	}
sl@0
   216
sl@0
   217
_STLP_DECLSPEC std::locale::id&
sl@0
   218
std::ctype<wchar_t>::GetFacetLocaleId()
sl@0
   219
	{
sl@0
   220
		return get_libcpp_wsd().ctype_wchar_id;
sl@0
   221
	}
sl@0
   222
sl@0
   223
_STLP_DECLSPEC std::locale::id&
sl@0
   224
std::moneypunct<wchar_t, true>::GetFacetLocaleId()
sl@0
   225
	{
sl@0
   226
		return get_libcpp_wsd().moneypunct_wchar_true_id;
sl@0
   227
	}
sl@0
   228
sl@0
   229
_STLP_DECLSPEC std::locale::id&
sl@0
   230
std::moneypunct<wchar_t, false>::GetFacetLocaleId()
sl@0
   231
	{
sl@0
   232
		return get_libcpp_wsd().moneypunct_wchar_false_id;
sl@0
   233
	}
sl@0
   234
sl@0
   235
_STLP_DECLSPEC std::locale::id&
sl@0
   236
std::numpunct<wchar_t>::GetFacetLocaleId()
sl@0
   237
	{
sl@0
   238
		return get_libcpp_wsd().numpunct_wchar_id;
sl@0
   239
	}
sl@0
   240
sl@0
   241
_STLP_DECLSPEC std::locale::id&
sl@0
   242
std::messages<wchar_t>::GetFacetLocaleId()
sl@0
   243
	{
sl@0
   244
		return get_libcpp_wsd().messages_wchar_id;
sl@0
   245
	}
sl@0
   246
sl@0
   247
#endif  /* __SYMBIAN32__WSD__ */