diff options
Diffstat (limited to 'system/include/libcxx/__locale')
-rw-r--r-- | system/include/libcxx/__locale | 118 |
1 files changed, 70 insertions, 48 deletions
diff --git a/system/include/libcxx/__locale b/system/include/libcxx/__locale index 7b7cfcd7..0805ad86 100644 --- a/system/include/libcxx/__locale +++ b/system/include/libcxx/__locale @@ -20,26 +20,35 @@ #include <cctype> #include <locale.h> #if _WIN32 -# include <support/win32/locale.h> -#else // _WIN32 +# include <support/win32/locale_win32.h> +#elif (__GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || EMSCRIPTEN) # include <xlocale.h> -#endif // _WIN32 +#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || EMSCRIPTEN +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header +#endif _LIBCPP_BEGIN_NAMESPACE_STD -class locale; +class _LIBCPP_VISIBLE locale; -template <class _Facet> bool has_facet(const locale&) _NOEXCEPT; -template <class _Facet> const _Facet& use_facet(const locale&); +template <class _Facet> +_LIBCPP_INLINE_VISIBILITY +bool +has_facet(const locale&) _NOEXCEPT; + +template <class _Facet> +_LIBCPP_INLINE_VISIBILITY +const _Facet& +use_facet(const locale&); class _LIBCPP_VISIBLE locale { public: // types: - class facet; - class id; + class _LIBCPP_VISIBLE facet; + class _LIBCPP_VISIBLE id; typedef int category; static const category // values assigned here are for exposition only @@ -117,7 +126,7 @@ class _LIBCPP_VISIBLE locale::id static int32_t __next_id; public: - _LIBCPP_INLINE_VISIBILITY id() {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} private: void __init(); void operator=(const id&); // = delete; @@ -231,22 +240,22 @@ collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, template <class _CharT> long -collate<_CharT>::do_hash(const char_type* lo, const char_type* hi) const +collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const { - size_t h = 0; - const size_t sr = __CHAR_BIT__ * sizeof(size_t) - 8; - const size_t mask = size_t(0xF) << (sr + 4); - for(const char_type* p = lo; p != hi; ++p) + size_t __h = 0; + const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; + const size_t __mask = size_t(0xF) << (__sr + 4); + for(const char_type* __p = __lo; __p != __hi; ++__p) { - h = (h << 4) + *p; - size_t g = h & mask; - h ^= g | (g >> sr); + __h = (__h << 4) + static_cast<size_t>(*__p); + size_t __g = __h & __mask; + __h ^= __g | (__g >> __sr); } - return static_cast<long>(h); + return static_cast<long>(__h); } -extern template class _LIBCPP_VISIBLE collate<char>; -extern template class _LIBCPP_VISIBLE collate<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<wchar_t>) // template <class CharT> class collate_byname; @@ -319,7 +328,7 @@ public: static const mask xdigit = _ISxdigit; static const mask blank = _ISblank; #elif _WIN32 - typedef unsigned __int32 mask; + typedef unsigned short mask; static const mask space = _SPACE; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; static const mask cntrl = _CONTROL; @@ -330,24 +339,13 @@ public: static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; -#elif defined( EMSCRIPTEN ) - #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) - typedef __uint16_t mask; - static const mask upper = _ISbit( 0 ); - static const mask lower = _ISbit( 1 ); - static const mask alpha = _ISbit( 2 ); - static const mask digit = _ISbit( 3 ); - static const mask xdigit = _ISbit( 4 ); - static const mask space = _ISbit( 5 ); - static const mask print = _ISbit( 6 ); - static const mask blank = _ISbit( 8 ); - static const mask cntrl = _ISbit( 9 ); - static const mask punct = _ISbit( 10 ); -#else // __GLIBC__ || _WIN32 -#if defined(__APPLE__) +#elif (__APPLE__ || __FreeBSD__ || EMSCRIPTEN) +#if __APPLE__ typedef __uint32_t mask; #elif __FreeBSD__ typedef unsigned long mask; +#elif EMSCRIPTEN + typedef unsigned short mask; #endif static const mask space = _CTYPE_S; static const mask print = _CTYPE_R; @@ -359,7 +357,31 @@ public: static const mask punct = _CTYPE_P; static const mask xdigit = _CTYPE_X; static const mask blank = _CTYPE_B; -#endif // __GLIBC__ || _WIN32 +#elif __sun__ + typedef unsigned int mask; + static const mask space = _ISSPACE; + static const mask print = _ISPRINT; + static const mask cntrl = _ISCNTRL; + static const mask upper = _ISUPPER; + static const mask lower = _ISLOWER; + static const mask alpha = _ISALPHA; + static const mask digit = _ISDIGIT; + static const mask punct = _ISPUNCT; + static const mask xdigit = _ISXDIGIT; + static const mask blank = _ISBLANK; +#else // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || EMSCRIPTEN || __sun__ + typedef unsigned long mask; + static const mask space = 1<<0; + static const mask print = 1<<1; + static const mask cntrl = 1<<2; + static const mask upper = 1<<3; + static const mask lower = 1<<4; + static const mask alpha = 1<<5; + static const mask digit = 1<<6; + static const mask punct = 1<<7; + static const mask xdigit = 1<<8; + static const mask blank = 1<<9; +#endif // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ static const mask alnum = alpha | digit; static const mask graph = alnum | punct; @@ -484,14 +506,14 @@ public: _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { - return isascii(__c) ? __tab_[__c] & __m : false; + return isascii(__c) ? __tab_[static_cast<int>(__c)] & __m : false; } _LIBCPP_ALWAYS_INLINE const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const { for (; __low != __high; ++__low, ++__vec) - *__vec = isascii(*__low) ? __tab_[*__low] : 0; + *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0; return __low; } @@ -499,7 +521,7 @@ public: const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const { for (; __low != __high; ++__low) - if (isascii(*__low) && (__tab_[*__low] & __m)) + if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)) break; return __low; } @@ -508,7 +530,7 @@ public: const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const { for (; __low != __high; ++__low) - if (!(isascii(*__low) && (__tab_[*__low] & __m))) + if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))) break; return __low; } @@ -570,7 +592,7 @@ public: #endif _LIBCPP_ALWAYS_INLINE const mask* table() const _NOEXCEPT {return __tab_;} static const mask* classic_table() _NOEXCEPT; -#ifndef _LIBCPP_STABLE_APPLE_ABI +#if defined(__GLIBC__) || defined(EMSCRIPTEN) static const int* __classic_upper_table() _NOEXCEPT; static const int* __classic_lower_table() _NOEXCEPT; #endif @@ -1115,14 +1137,14 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() { } -extern template class codecvt_byname<char, char, mbstate_t>; -extern template class codecvt_byname<wchar_t, char, mbstate_t>; -extern template class codecvt_byname<char16_t, char, mbstate_t>; -extern template class codecvt_byname<char32_t, char, mbstate_t>; +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_VISIBLE void __throw_runtime_error(const char*); -template <size_t _N> +template <size_t _Np> struct __narrow_to_utf8 { template <class _OutputIterator, class _CharT> @@ -1212,7 +1234,7 @@ struct __narrow_to_utf8<32> } }; -template <size_t _N> +template <size_t _Np> struct __widen_from_utf8 { template <class _OutputIterator> |