Define wxNO_UNSAFE_WXSTRING_CONV if wxUSE_UNSAFE_WXSTRING_CONV==0
This doesn't really change anything, but allows to simplify the tests, as we can now check only for wxNO_UNSAFE_WXSTRING_CONV and this covers both the case of the library compiled without support for the unsafe conversions at all and the case when the conversions are disabled by explicitly defining wxNO_UNSAFE_WXSTRING_CONV when building the application.
This commit is contained in:
parent
5119d35d3b
commit
4913857ef7
3 changed files with 14 additions and 8 deletions
|
|
@ -90,7 +90,13 @@ class WXDLLIMPEXP_FWD_BASE wxString;
|
|||
#error wxNO_IMPLICIT_WXSTRING_ENCODING cannot be used in UTF-8 only builds
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||
|
||||
#if !wxUSE_UNSAFE_WXSTRING_CONV
|
||||
#ifndef wxNO_UNSAFE_WXSTRING_CONV
|
||||
#define wxNO_UNSAFE_WXSTRING_CONV
|
||||
#endif
|
||||
#endif // wxUSE_UNSAFE_WXSTRING_CONV
|
||||
|
||||
namespace wxPrivate
|
||||
{
|
||||
|
|
@ -1287,9 +1293,9 @@ public:
|
|||
// they conflict with the implicit conversions to "const char/wchar_t *"
|
||||
// which we use for backwards compatibility but do provide them if
|
||||
// explicitly requested.
|
||||
#if wxUSE_UNSAFE_WXSTRING_CONV && !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
#if !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
operator wxStringToStdStringRetType() const { return ToStdString(); }
|
||||
#endif // wxUSE_UNSAFE_WXSTRING_CONV
|
||||
#endif // !wxNO_UNSAFE_WXSTRING_CONV
|
||||
operator wxStringToStdWstringRetType() const { return ToStdWstring(); }
|
||||
#endif // wxUSE_STD_STRING_CONV_IN_WXSTRING
|
||||
|
||||
|
|
@ -1537,13 +1543,13 @@ public:
|
|||
#if wxUSE_CHAR_CONV_IN_WXSTRING
|
||||
operator const wchar_t*() const { return c_str(); }
|
||||
|
||||
#if wxUSE_UNSAFE_WXSTRING_CONV && !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
#if !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
operator const char*() const { return c_str(); }
|
||||
// implicit conversion to untyped pointer for compatibility with previous
|
||||
// wxWidgets versions: this is the same as conversion to const char * so it
|
||||
// may fail!
|
||||
operator const void*() const { return c_str(); }
|
||||
#endif // wxUSE_UNSAFE_WXSTRING_CONV && !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
#endif // !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
|
||||
#endif // wxUSE_CHAR_CONV_IN_WXSTRING
|
||||
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
|
|||
|
||||
wxString s4("hello");
|
||||
|
||||
#if wxUSE_STD_STRING_CONV_IN_WXSTRING && wxUSE_UNSAFE_WXSTRING_CONV
|
||||
#if wxUSE_STD_STRING_CONV_IN_WXSTRING && !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
std::string s5 = s4;
|
||||
#else
|
||||
std::string s5 = s4.ToStdString();
|
||||
|
|
@ -629,7 +629,7 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
|
|||
CHECK( s6 == L"hello" );
|
||||
|
||||
#if wxUSE_STD_STRING_CONV_IN_WXSTRING
|
||||
#if wxUSE_UNSAFE_WXSTRING_CONV
|
||||
#if !defined(wxNO_UNSAFE_WXSTRING_CONV)
|
||||
std::string s7(s4);
|
||||
CHECK( s7 == "hello" );
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1020,7 +1020,7 @@ TEST_CASE("StringCStrDataImplicitConversion", "[wxString]")
|
|||
|
||||
#if wxUSE_CHAR_CONV_IN_WXSTRING
|
||||
CHECK( CheckStrConstWChar(s, s) );
|
||||
#if wxUSE_UNSAFE_WXSTRING_CONV
|
||||
#ifndef wxNO_UNSAFE_WXSTRING_CONV
|
||||
CHECK( CheckStrConstChar(s, s) );
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue