]> git.saurik.com Git - wxWidgets.git/commitdiff
Assume sizeof(wchar_t) is always 4 under OS X.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 5 Nov 2010 21:38:25 +0000 (21:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 5 Nov 2010 21:38:25 +0000 (21:38 +0000)
wchar_t used to be 2 bytes in Mach-O builds but they're not supported any
longer so remove the code checking for sizeof(wchar_t) and just assume it's
always 4.

Closes #10442.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/nonownedwnd.cpp
src/osx/carbon/textctrl.cpp
src/osx/carbon/window.cpp
src/osx/core/cfstring.cpp

index c61fb32f8e7a58a803d57d4cc0b8f7dc2dba1e1a..909e6a3ad1fdc553873a81719e93dd377cdf72eb 100644 (file)
@@ -323,17 +323,13 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
         GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
         charBuf[ numChars - 1 ] = 0;
 
-#if SIZEOF_WCHAR_T == 2
-        uniChar = charBuf[0] ;
-#else
         wxMBConvUTF16 converter ;
         converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ;
-#endif
 
         if ( numChars * 2 > 4 )
             delete[] charBuf ;
     }
-#endif
+#endif // wxUSE_UNICODE
 
     GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
     GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
index 17ba7c86d1aab4bf5217ab945ef245c7a645d701..267680fca8359837608972bc5cc567eef6833903 100644 (file)
@@ -739,10 +739,6 @@ wxString wxMacMLTEControl::GetStringValue() const
             {
                 wxChar *ptr = NULL ;
 
-#if SIZEOF_WCHAR_T == 2
-                ptr = new wxChar[actualSize + 1] ;
-                wxStrncpy( ptr , (wxChar*)(*theText) , actualSize ) ;
-#else
                 SetHandleSize( theText, (actualSize + 1) * sizeof(UniChar) ) ;
                 HLock( theText ) ;
                 (((UniChar*)*theText)[actualSize]) = 0 ;
@@ -755,7 +751,6 @@ wxString wxMacMLTEControl::GetStringValue() const
                 wxASSERT_MSG( noChars != wxCONV_FAILED, wxT("Conversion of string failed!") );
                 ptr[noChars] = 0 ;
                 HUnlock( theText ) ;
-#endif
 
                 ptr[actualSize] = 0 ;
                 result = wxString( ptr ) ;
@@ -764,7 +759,7 @@ wxString wxMacMLTEControl::GetStringValue() const
 
             DisposeHandle( theText ) ;
         }
-#else
+#else // !wxUSE_UNICODE
         Handle theText ;
         err = TXNGetDataEncoded( m_txn , kTXNStartOffset, kTXNEndOffset, &theText, kTXNTextData );
 
@@ -785,7 +780,7 @@ wxString wxMacMLTEControl::GetStringValue() const
 
             DisposeHandle( theText ) ;
         }
-#endif
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
     }
 
 #if '\n' == 10
@@ -1381,10 +1376,6 @@ void wxMacMLTEControl::ShowPosition( long pos )
 void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffset end )
 {
 #if wxUSE_UNICODE
-#if SIZEOF_WCHAR_T == 2
-    size_t len = st.length() ;
-    TXNSetData( m_txn, kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end );
-#else
     wxMBConvUTF16 converter ;
     ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
     wxASSERT_MSG( byteBufferLen != wxCONV_FAILED,
@@ -1393,11 +1384,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse
     converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ;
     TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
     free( unibuf ) ;
-#endif
-#else
+#else // !wxUSE_UNICODE
     wxCharBuffer text = st.mb_str( wxConvLocal ) ;
     TXNSetData( m_txn, kTXNTextData, (void*)text.data(), strlen( text ), start, end ) ;
-#endif
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
 }
 
 wxString wxMacMLTEControl::GetLineText(long lineNo) const
index 831217ef947eea999de7ef768c1f2624a9a6c107..b7ccb7cc434394fbdcf84b3b224347c13c25355c 100644 (file)
@@ -610,14 +610,9 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
         uniChars = new wchar_t[ numChars ] ;
         GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
         charBuf[ numChars - 1 ] = 0;
-#if SIZEOF_WCHAR_T == 2
-        uniChars = (wchar_t*) charBuf ;
-/*        memcpy( uniChars , charBuf , numChars * 2 ) ;*/   // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...)
-#else
         // the resulting string will never have more chars than the utf16 version, so this is safe
         wxMBConvUTF16 converter ;
         numChars = converter.MB2WC( uniChars , (const char*)charBuf , numChars ) ;
-#endif
     }
 
     switch ( GetEventKind( event ) )
index 96bc244d381ca567aef84654fc46312a36f766aa..fa1840f44c6a24d6a8e412ce9211612746471b2e 100644 (file)
@@ -696,10 +696,6 @@ wxString wxCFStringRef::AsString( NSString* ref, wxFontEncoding encoding )
 
 wxMacUniCharBuffer::wxMacUniCharBuffer( const wxString &str )
 {
-    m_chars = str.length() ;
-    m_ubuf = NULL ;
-
-#if SIZEOF_WCHAR_T == 4
     wxMBConvUTF16 converter ;
 #if wxUSE_UNICODE
     size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
@@ -712,17 +708,6 @@ wxMacUniCharBuffer::wxMacUniCharBuffer( const wxString &str )
     converter.WC2MB( (char*) m_ubuf , wchar.data() , unicharlen + 2 ) ;
 #endif
     m_chars = unicharlen / 2 ;
-#else // SIZEOF_WCHAR_T is then 2
-#if wxUSE_UNICODE
-    m_ubuf = malloc( m_chars * 2 + 2 ) ;
-    memcpy( m_ubuf , (UniChar*) str.wc_str() , m_chars * 2 + 2 ) ;
-#else
-    wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
-    m_chars = wxWcslen( wchar.data() ) ;
-    m_ubuf = malloc( m_chars * 2 + 2 ) ;
-    memcpy( m_ubuf , (UniChar*) wchar.data() , m_chars * 2 + 2 ) ;
-#endif
-#endif
 }
 
 wxMacUniCharBuffer::~wxMacUniCharBuffer()