Use char16_t when available, and when it is, don't test for -fshort-wchar. (Bug 502298) r=bsmedberg

This commit is contained in:
L. David Baron
2009-07-20 07:04:41 -04:00
parent b76fa84f5d
commit 782ed45fa9
6 changed files with 44 additions and 62 deletions

View File

@@ -1050,12 +1050,17 @@ private:
* Under GCC, this define should only be set if compiling with -fshort-wchar.
*/
#ifdef HAVE_CPP_2BYTE_WCHAR_T
#if defined(HAVE_CPP_CHAR16_T) || defined(HAVE_CPP_2BYTE_WCHAR_T)
#if defined(HAVE_CPP_CHAR16_T)
PR_STATIC_ASSERT(sizeof(char16_t) == 2);
#define NS_LL(s) u##s
#else
PR_STATIC_ASSERT(sizeof(wchar_t) == 2);
#define NS_LL(s) L##s
#define NS_MULTILINE_LITERAL_STRING(s) nsDependentString(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
#define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
#define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) const nsDependentString n(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
#endif
#define NS_MULTILINE_LITERAL_STRING(s) nsDependentString(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/2)-1))
#define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/2)-1))
#define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) const nsDependentString n(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/2)-1))
typedef nsDependentString nsLiteralString;
#else
#define NS_LL(s) s