X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e4dd1e19a281da5d1e23b12fd76c9fc242bcb1d6..409e6ce4dcd39c6dfe8b77cbd56d451ffe5c731c:/src/mac/corefoundation/strconv_cf.cpp diff --git a/src/mac/corefoundation/strconv_cf.cpp b/src/mac/corefoundation/strconv_cf.cpp index 94cb8f34af..e68d8e4ef6 100644 --- a/src/mac/corefoundation/strconv_cf.cpp +++ b/src/mac/corefoundation/strconv_cf.cpp @@ -29,8 +29,34 @@ // CoreFoundation conversion classes // ============================================================================ +/* Provide factory functions for unit tests. Not in any header. Do not + * assume ABI compatibility even within a given wxWidgets release. + */ + +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf( const char* name) +{ + wxMBConv_cf *result = new wxMBConv_cf(name); + if(!result->IsOk()) + { + delete result; + return NULL; + } + else + return result; +} + +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding) +{ + wxMBConv_cf *result = new wxMBConv_cf(encoding); + if(!result->IsOk()) + { + delete result; + return NULL; + } + else + return result; +} -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 // Provide a constant for the wchat_t encoding used by the host platform. #ifdef WORDS_BIGENDIAN static const CFStringEncoding wxCFStringEncodingWcharT = kCFStringEncodingUTF32BE; @@ -38,8 +64,6 @@ static const CFStringEncoding wxCFStringEncodingWcharT = kCFStringEncodingUTF32LE; #endif -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */ - size_t wxMBConv_cf::ToWChar(wchar_t * dst, size_t dstSize, const char * src, size_t srcSize) const { wxCHECK(src, wxCONV_FAILED); @@ -74,7 +98,6 @@ * to UTF32. If we are then run against a pre-Tiger system, the encoding * won't be available so we'll defer to the string->UTF-16->UTF-32 conversion. */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if(CFStringIsEncodingAvailable(wxCFStringEncodingWcharT)) { CFRange fullStringRange = CFRangeMake(0, CFStringGetLength(theString)); @@ -105,7 +128,6 @@ return usedBufLen / sizeof(wchar_t); } else -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */ { // NOTE: Includes NULL iff source did /* NOTE: This is an approximation. The eventual UTF-32 will @@ -148,7 +170,6 @@ * from UTF32. If we are then run against a pre-Tiger system, the encoding * won't be available so we'll defer to the UTF-32->UTF-16->string conversion. */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if(CFStringIsEncodingAvailable(wxCFStringEncodingWcharT)) { theString = wxCFRef(CFStringCreateWithBytes( @@ -159,7 +180,6 @@ false)); } else -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */ { wxMBConvUTF16 converter; size_t cbUniBuffer = converter.FromWChar( NULL, 0, src, srcSize );