diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/JavaScriptCore/wtf/wx | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/JavaScriptCore/wtf/wx')
-rw-r--r-- | Source/JavaScriptCore/wtf/wx/StringWx.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/Source/JavaScriptCore/wtf/wx/StringWx.cpp b/Source/JavaScriptCore/wtf/wx/StringWx.cpp index fe0fd89..d5f6c57 100644 --- a/Source/JavaScriptCore/wtf/wx/StringWx.cpp +++ b/Source/JavaScriptCore/wtf/wx/StringWx.cpp @@ -25,12 +25,15 @@ #include "config.h" -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - +// The wx headers must come first in this case, because the wtf/text headers +// import windows.h, and we need to allow the wx headers to set its configuration +// first. #include <wx/defs.h> #include <wx/string.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + namespace WTF { String::String(const wxString& wxstr) @@ -39,9 +42,10 @@ String::String(const wxString& wxstr) #error "This code only works in Unicode build of wxWidgets" #endif -#if SIZEOF_WCHAR_T == U_SIZEOF_UCHAR +#if SIZEOF_WCHAR_T == 2 - m_impl = StringImpl::create(wxstr.wc_str(), wxstr.length()); + const UChar* str = wxstr.wc_str(); + const size_t len = wxstr.length(); #else // SIZEOF_WCHAR_T == 4 @@ -58,13 +62,18 @@ String::String(const wxString& wxstr) #endif size_t wideLength = wxstr.length(); - UChar* data; wxMBConvUTF16 conv; - unsigned utf16Length = conv.FromWChar(0, 0, wideString, wideLength); - m_impl = StringImpl::createUninitialized(utf16Length, data); - conv.FromWChar((char*)data, utf16Length, wideString, wideLength); -#endif // SIZEOF_WCHAR_T == 4 + const size_t utf16bufLen = conv.FromWChar(0, 0, wideString, wideLength); + wxCharBuffer utf16buf(utf16bufLen); + + const UChar* str = (const UChar*)utf16buf.data(); + size_t len = conv.FromWChar(utf16buf.data(), utf16bufLen, wideString, wideLength) / 2; + +#endif // SIZEOF_WCHAR_T == 2 + + m_impl = StringImpl::create(str, len); + } String::operator wxString() const |