]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/strvararg.h
Applied rowspan patch #15276 (dghart)
[wxWidgets.git] / include / wx / strvararg.h
index cc14ce2ddba1bbd9009dc4980cc4552b9e6a4945..8f2d16551ecc25c592cd497274ef276b1d149699 100644 (file)
@@ -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
         : 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
     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
 #if SIZEOF_INT == SIZEOF_LONG
         Arg_LongInt     = Arg_Int,
 #else
@@ -205,7 +207,7 @@ public:
         { return const_cast<wxFormatString*>(this)->AsChar(); }
 private:
     // InputAsChar() returns the value passed to ctor, only converted
         { return const_cast<wxFormatString*>(this)->AsChar(); }
 private:
     // InputAsChar() returns the value passed to ctor, only converted
-    // to char, while AsChar() takes the the string returned by InputAsChar()
+    // to char, while AsChar() takes the string returned by InputAsChar()
     // and does format string conversion on it as well (and similarly for
     // ..AsWChar() below)
     const char* InputAsChar();
     // and does format string conversion on it as well (and similarly for
     // ..AsWChar() below)
     const char* InputAsChar();
@@ -307,16 +309,19 @@ struct wxFormatStringArgumentFinder<wxWCharBuffer>
     // the correct type (one of wxFormatString::Arg_XXX or-combination in
     // 'expected_mask').
     #define wxASSERT_ARG_TYPE(fmt, index, expected_mask)                    \
     // the correct type (one of wxFormatString::Arg_XXX or-combination in
     // 'expected_mask').
     #define wxASSERT_ARG_TYPE(fmt, index, expected_mask)                    \
-        do                                                                  \
-        {                                                                   \
+        wxSTATEMENT_MACRO_BEGIN                                             \
             if ( !fmt )                                                     \
                 break;                                                      \
             const int argtype = fmt->GetArgumentType(index);                \
             wxASSERT_MSG( (argtype & (expected_mask)) == argtype,           \
                           "format specifier doesn't match argument type" ); \
             if ( !fmt )                                                     \
                 break;                                                      \
             const int argtype = fmt->GetArgumentType(index);                \
             wxASSERT_MSG( (argtype & (expected_mask)) == argtype,           \
                           "format specifier doesn't match argument type" ); \
-        } while ( wxFalse )
+        wxSTATEMENT_MACRO_END
 #else
 #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
 
 
 #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
 
 
@@ -408,14 +413,20 @@ wxFORMAT_STRING_SPECIFIER(long double, wxFormatString::Arg_LongDouble)
 wxFORMAT_STRING_SPECIFIER(wchar_t, wxFormatString::Arg_Char | wxFormatString::Arg_Int)
 #endif
 
 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)
 
 wxFORMAT_STRING_SPECIFIER(int*, wxFormatString::Arg_IntPtr | wxFormatString::Arg_Pointer)
 wxFORMAT_STRING_SPECIFIER(short int*, wxFormatString::Arg_ShortIntPtr | wxFormatString::Arg_Pointer)
@@ -497,8 +508,7 @@ struct wxArgNormalizerWithBuffer
                               unsigned index)
         : m_value(buf)
     {
                               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; }
     }
 
     const CharType *get() const { return m_value; }
@@ -532,8 +542,7 @@ struct WXDLLIMPEXP_BASE wxArgNormalizerNative<const wxCStrData&>
                           unsigned index)
         : m_value(value)
     {
                           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;
     }
 
     const wxStringCharType *get() const;
@@ -593,8 +602,7 @@ struct wxArgNormalizerUtf8<const char*>
                         const wxFormatString *fmt,
                         unsigned index)
     {
                         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 )
         {
 
         if ( wxLocaleIsUtf8 )
         {
@@ -816,7 +824,7 @@ WX_ARG_NORMALIZER_FORWARD(const signed char&, signed char);
 #undef WX_ARG_NORMALIZER_FORWARD
 #undef _WX_ARG_NORMALIZER_FORWARD_IMPL
 
 #undef WX_ARG_NORMALIZER_FORWARD
 #undef _WX_ARG_NORMALIZER_FORWARD_IMPL
 
-#undef wxASSERT_ARG_TYPE
+// NB: Don't #undef wxASSERT_ARG_TYPE here as it's also used in wx/longlong.h.
 
 // ----------------------------------------------------------------------------
 // WX_VA_ARG_STRING
 
 // ----------------------------------------------------------------------------
 // WX_VA_ARG_STRING