X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0f895b0cf5c0ab0f6da406efe7adbff14fd10456..58ce18f2fdadecffb21e27555115af708325cf18:/include/wx/strvararg.h?ds=sidebyside diff --git a/include/wx/strvararg.h b/include/wx/strvararg.h index 2332ed93f2..7dc6612171 100644 --- a/include/wx/strvararg.h +++ b/include/wx/strvararg.h @@ -151,14 +151,16 @@ public: : m_wchar(str), m_str(NULL), m_cstr(NULL) {} // Possible argument types. These are or-combinable for wxASSERT_ARG_TYPE - // convenience. + // convenience. Some of the values are or-combined with another value, this + // expresses "supertypes" for use with wxASSERT_ARG_TYPE masks. For example, + // a char* string is also a pointer and an integer is also a char. enum ArgumentType { Arg_Char = 0x0001, // character as char %c Arg_Pointer = 0x0002, // %p - Arg_String = 0x0004, // any form of string + Arg_String = 0x0004 | Arg_Pointer, // any form of string (%s and %p too) - Arg_Int = 0x0008, + Arg_Int = 0x0008 | Arg_Char, // (ints can be used with %c) #if SIZEOF_INT == SIZEOF_LONG Arg_LongInt = Arg_Int, #else @@ -173,16 +175,19 @@ public: Arg_Double = 0x0040, Arg_LongDouble = 0x0080, -#ifdef wxSIZE_T_IS_UINT +#if defined(wxSIZE_T_IS_UINT) Arg_Size_t = Arg_Int, -#endif -#ifdef wxSIZE_T_IS_ULONG +#elif defined(wxSIZE_T_IS_ULONG) Arg_Size_t = Arg_LongInt, +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_SIZE_T == SIZEOF_LONG_LONG + Arg_Size_t = Arg_LongLongInt, +#else + Arg_Size_t = 0x0100, #endif - Arg_IntPtr = 0x0100, // %n -- store # of chars written - Arg_ShortIntPtr = 0x0200, - Arg_LongIntPtr = 0x0400, + Arg_IntPtr = 0x0200, // %n -- store # of chars written + Arg_ShortIntPtr = 0x0400, + Arg_LongIntPtr = 0x0800, Arg_Unknown = 0x8000 // unrecognized specifier (likely error) }; @@ -313,7 +318,11 @@ struct wxFormatStringArgumentFinder "format specifier doesn't match argument type" ); \ } while ( wxFalse ) #else - #define wxASSERT_ARG_TYPE(fmt, index, expected_mask) + // Just define it to suppress "unused parameter" warnings for the + // parameters which we don't use otherwise + #define wxASSERT_ARG_TYPE(fmt, index, expected_mask) \ + wxUnusedVar(fmt); \ + wxUnusedVar(index) #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL @@ -401,16 +410,24 @@ wxFORMAT_STRING_SPECIFIER(float, wxFormatString::Arg_Double) wxFORMAT_STRING_SPECIFIER(double, wxFormatString::Arg_Double) wxFORMAT_STRING_SPECIFIER(long double, wxFormatString::Arg_LongDouble) +#if wxWCHAR_T_IS_REAL_TYPE wxFORMAT_STRING_SPECIFIER(wchar_t, wxFormatString::Arg_Char | wxFormatString::Arg_Int) +#endif -wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(signed char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(const char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(const unsigned char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(const signed char*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(wchar_t*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(const wchar_t*, wxFormatString::Arg_String | wxFormatString::Arg_Pointer) +#if !wxUSE_UNICODE +wxFORMAT_STRING_SPECIFIER(char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) +wxFORMAT_STRING_SPECIFIER(signed char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) +wxFORMAT_STRING_SPECIFIER(unsigned char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) +#endif + +wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(signed char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(const char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(const unsigned char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(const signed char*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(wchar_t*, wxFormatString::Arg_String) +wxFORMAT_STRING_SPECIFIER(const wchar_t*, wxFormatString::Arg_String) wxFORMAT_STRING_SPECIFIER(int*, wxFormatString::Arg_IntPtr | wxFormatString::Arg_Pointer) wxFORMAT_STRING_SPECIFIER(short int*, wxFormatString::Arg_ShortIntPtr | wxFormatString::Arg_Pointer) @@ -492,8 +509,7 @@ struct wxArgNormalizerWithBuffer unsigned index) : m_value(buf) { - wxASSERT_ARG_TYPE( fmt, index, - wxFormatString::Arg_String | wxFormatString::Arg_Pointer ); + wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); } const CharType *get() const { return m_value; } @@ -527,8 +543,7 @@ struct WXDLLIMPEXP_BASE wxArgNormalizerNative unsigned index) : m_value(value) { - wxASSERT_ARG_TYPE( fmt, index, - wxFormatString::Arg_String | wxFormatString::Arg_Pointer ); + wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); } const wxStringCharType *get() const; @@ -588,8 +603,7 @@ struct wxArgNormalizerUtf8 const wxFormatString *fmt, unsigned index) { - wxASSERT_ARG_TYPE( fmt, index, - wxFormatString::Arg_String | wxFormatString::Arg_Pointer ); + wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); if ( wxLocaleIsUtf8 ) {