]> git.saurik.com Git - wxWidgets.git/commitdiff
fix compation with Watcom after latest vararg templates changes
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 6 May 2007 14:11:14 +0000 (14:11 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 6 May 2007 14:11:14 +0000 (14:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/dcpsg.h
include/wx/log.h
include/wx/mimetype.h
include/wx/msgout.h
include/wx/string.h
include/wx/strvararg.h
include/wx/wxcrtvararg.h
src/common/log.cpp

index 8a1f5dfa90e98387dd111b06b9441ea0dc740195..9e0af45f895a8db9a91b39d48bbf4929c0f810c3 100644 (file)
@@ -99,10 +99,14 @@ public:
                                DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
 #ifdef __WATCOMC__
     // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-    WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*),
-                               DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
-    WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*),
-                               DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
+    WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const wxString&),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const wxCStrData&),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const char*),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const wchar_t*),
+                                (wxFormatString(f1)));
 #endif
 
     void PsPrint( const wxString& psdata );
index 8b02aff700110e424babf3b70ab2665a8e952b1f..089e21f8ea6fbee64e0e73142128e792c28cf148 100644 (file)
@@ -488,18 +488,18 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
     // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
     // something too big for Borland C++ to handle
     #define DECLARE_LOG_FUNCTION_WATCOM(level)                              \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
+                                   1, (const wxString&),                    \
+                                   (wxFormatString(f1)))                    \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
+                                   1, (const wxCStrData&),                  \
+                                   (wxFormatString(f1)))                    \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
                                    1, (const char*),                        \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)                    \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
+                                   (wxFormatString(f1)))                    \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
                                    1, (const wchar_t*),                     \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)                    \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
-                                   1, (const wxCStrData&),                  \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)
+                                   (wxFormatString(f1)))
 #else
     #define DECLARE_LOG_FUNCTION_WATCOM(level)
 #endif
@@ -523,18 +523,18 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
     // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
     // something too big for Borland C++ to handle
     #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
+                                   2, (argclass, const wxString&),          \
+                                   (f1, wxFormatString(f2)))                \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
+                                   2, (argclass, const wxCStrData&),        \
+                                   (f1, wxFormatString(f2)))                \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
                                    2, (argclass, const char*),              \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)                    \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
+                                   (f1, wxFormatString(f2)))                \
+        WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level,                     \
                                    2, (argclass, const wchar_t*),           \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)                    \
-        WX_DEFINE_VARARG_FUNC_VOID(wxLog##level,                            \
-                                   2, (argclass, const wxCStrData&),        \
-                                   wxDoLog##level##Wchar,                   \
-                                   wxDoLog##level##Utf8)
+                                   (f1, wxFormatString(f2)))
 #else
     #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl)
 #endif
@@ -558,7 +558,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
         WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxCStrData&))     \
     )                                                                       \
     inline void wxVLog##level(const wxString& WXUNUSED(format),             \
-                               va_list WXUNUSED(argptr)) { }                \
+                              va_list WXUNUSED(argptr)) { }                 \
 
 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl)            \
     WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxString&)) \
@@ -568,8 +568,8 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
         WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \
     )                                                                       \
     inline void wxVLog##level(argclass WXUNUSED(arg),                       \
-                               const wxString& WXUNUSED(format),            \
-                               va_list WXUNUSED(argptr)) {}
+                              const wxString& WXUNUSED(format),             \
+                              va_list WXUNUSED(argptr)) {}
 
 // Empty Class to fake wxLogNull
 class WXDLLIMPEXP_BASE wxLogNull
index 7c3fff5c463262bdd9a8bf47dc55e4fb0e38ca85..b0f732f08f15d3146ec0bd62834fcec2cefc6e57 100644 (file)
@@ -155,23 +155,56 @@ public:
     //               // extensions
     //               ...);
     WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
-                               4, (const wxString&, const wxString&,
-                                   const wxString&, const wxString&),
+                               // NB: these are not format strings, using
+                               //     wxFormatString here is a hack to get
+                               //     implicit conversion to wchar_t*/char*
+                               4, (const wxFormatString&,
+                                   const wxFormatString&,
+                                   const wxFormatString&,
+                                   const wxFormatString&),
                                VarArgInitWchar, VarArgInitUtf8)
 #ifdef __WATCOMC__
     // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-    WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
-                               4, (const char*, const char*,
-                                   const char*, const char*),
-                               VarArgInitWchar, VarArgInitUtf8)
-    WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
-                               4, (const wchar_t*, const wchar_t*,
-                                   const wchar_t*, const wchar_t*),
-                               VarArgInitWchar, VarArgInitUtf8)
-    WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
-                               4, (const wxCStrData&, const wxCStrData&,
-                                   const wxCStrData&, const wxCStrData&),
-                               VarArgInitWchar, VarArgInitUtf8)
+    WX_VARARG_WATCOM_WORKAROUND_CTOR(
+                                wxFileTypeInfo,
+                                4, (const wxString&,
+                                    const wxString&,
+                                    const wxString&,
+                                    const wxString&),
+                                (wxFormatString(f1),
+                                 wxFormatString(f2),
+                                 wxFormatString(f3),
+                                 wxFormatString(f4)));
+    WX_VARARG_WATCOM_WORKAROUND_CTOR(
+                                wxFileTypeInfo,
+                                4, (const wxCStrData&,
+                                    const wxCStrData&,
+                                    const wxCStrData&,
+                                    const wxCStrData&),
+                                (wxFormatString(f1),
+                                 wxFormatString(f2),
+                                 wxFormatString(f3),
+                                 wxFormatString(f4)));
+    WX_VARARG_WATCOM_WORKAROUND_CTOR(
+                                wxFileTypeInfo,
+                                4, (const char*,
+                                    const char*,
+                                    const char*,
+                                    const char*),
+                                (wxFormatString(f1),
+                                 wxFormatString(f2),
+                                 wxFormatString(f3),
+                                 wxFormatString(f4)));
+    WX_VARARG_WATCOM_WORKAROUND_CTOR(
+                                wxFileTypeInfo,
+                                4, (const wchar_t*,
+                                    const wchar_t*,
+                                    const wchar_t*,
+                                    const wchar_t*),
+                                (wxFormatString(f1),
+                                 wxFormatString(f2),
+                                 wxFormatString(f3),
+                                 wxFormatString(f4)));
 #endif
 
         // the array elements correspond to the parameters of the ctor above in
index b2029e252de76fccf38e41f836d89098f657720b..56b11a6244e3136b2e822200b74f19b10297969f 100755 (executable)
@@ -41,12 +41,14 @@ public:
                                DoPrintfWchar, DoPrintfUtf8)
 #ifdef __WATCOMC__
     // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-    WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*),
-                               DoPrintfWchar, DoPrintfUtf8)
-    WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*),
-                               DoPrintfWchar, DoPrintfUtf8)
-    WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&),
-                               DoPrintfWchar, DoPrintfUtf8)
+    WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxCStrData&),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*),
+                                (wxFormatString(f1)));
+    WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wchar_t*),
+                                (wxFormatString(f1)));
 #endif
 
 protected:
index 3890dd07d1e343d0a574b2a77d8017d17c9edbae..dac27573fa722cdd517a24d943101786b4fc0716 100644 (file)
@@ -1579,12 +1579,15 @@ public:
   WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
                         DoPrintfWchar, DoPrintfUtf8)
 #ifdef __WATCOMC__
-  WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const char*),
-                        DoPrintfWchar, DoPrintfUtf8)
-  WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wchar_t*),
-                        DoPrintfWchar, DoPrintfUtf8)
-  WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxCStrData&),
-                        DoPrintfWchar, DoPrintfUtf8)
+  // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
+  WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxString&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxCStrData&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const char*),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wchar_t*),
+                              (wxFormatString(f1)));
 #endif
 #endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN
     // as vprintf(), returns the number of characters written or < 0 on error
@@ -1597,12 +1600,14 @@ public:
                         DoFormatWchar, DoFormatUtf8)
 #ifdef __WATCOMC__
   // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-  WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const char*),
-                        DoFormatWchar, DoFormatUtf8)
-  WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wchar_t*),
-                        DoFormatWchar, DoFormatUtf8)
-  WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxCStrData&),
-                        DoFormatWchar, DoFormatUtf8)
+  WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxString&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxCStrData&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const char*),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wchar_t*),
+                              (wxFormatString(f1)));
 #endif
 #endif
     // the same as above, but takes a va_list
@@ -1644,12 +1649,14 @@ public:
                         DoPrintfWchar, DoPrintfUtf8)
 #ifdef __WATCOMC__
   // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-  WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const char*),
-                        DoPrintfWchar, DoPrintfUtf8)
-  WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wchar_t*),
-                        DoPrintfWchar, DoPrintfUtf8)
-  WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxCStrData&),
-                        DoPrintfWchar, DoPrintfUtf8)
+  WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxString&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxCStrData&),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const char*),
+                              (wxFormatString(f1)));
+  WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wchar_t*),
+                              (wxFormatString(f1)));
 #endif
 #endif // wxNEEDS_WXSTRING_PRINTF_MIXIN
 
index 05460711d76568e5fc848c5c459990aca09a7ecd..c1aa0364f64f65c8a3b3335a6d2b479a9778afef 100644 (file)
@@ -732,4 +732,65 @@ private:
     inline void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed))         \
     {}
 
+
+// ----------------------------------------------------------------------------
+// workaround for OpenWatcom bug #351
+// ----------------------------------------------------------------------------
+
+#ifdef __WATCOMC__
+// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
+
+// This macro can be used to forward a 'vararg' template to another one with
+// different fixed arguments types. Parameters are same as for
+// WX_DEFINE_VARARG_FUNC (rettype=void can be used here), 'convfixed' is how
+// to convert fixed arguments. For example, this is typical code for dealing
+// with different forms of format string:
+//
+// WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&),
+//                            DoPrintfWchar, DoPrintfUtf8)
+// #ifdef __WATCOMC__
+// WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&),
+//                             (wxFormatString(f1)))
+// WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*),
+//                             (wxFormatString(f1)))
+// ...
+#define WX_VARARG_WATCOM_WORKAROUND(rettype, name, numfixed, fixed, convfixed)\
+    _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS,                                      \
+                    _WX_VARARG_WATCOM_WORKAROUND,                             \
+                    rettype, name, convfixed, dummy, numfixed, fixed)
+
+#define WX_VARARG_WATCOM_WORKAROUND_CTOR(name, numfixed, fixed, convfixed)    \
+    _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS,                                      \
+                    _WX_VARARG_WATCOM_WORKAROUND_CTOR,                        \
+                    dummy, name, convfixed, dummy, numfixed, fixed)
+
+#define _WX_VARARG_WATCOM_UNPACK_1(a1)               a1
+#define _WX_VARARG_WATCOM_UNPACK_2(a1, a2)           a1, a2
+#define _WX_VARARG_WATCOM_UNPACK_3(a1, a2, a3)       a1, a2, a3
+#define _WX_VARARG_WATCOM_UNPACK_4(a1, a2, a3, a4)   a1, a2, a3, a4
+#define _WX_VARARG_WATCOM_UNPACK(N, convfixed) \
+        _WX_VARARG_WATCOM_UNPACK_##N convfixed
+
+#define _WX_VARARG_WATCOM_WORKAROUND(N, rettype, name,                        \
+                                     convfixed, dummy, numfixed, fixed)       \
+    template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)>                            \
+    rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed),                    \
+                 _WX_VARARG_JOIN(N, _WX_VARARG_ARG))                          \
+    {                                                                         \
+         return name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed),           \
+                     _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR));              \
+    }
+
+#define _WX_VARARG_WATCOM_WORKAROUND_CTOR(N, dummy1, name,                    \
+                                     convfixed, dummy2, numfixed, fixed)      \
+    template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)>                            \
+    name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed),                            \
+                 _WX_VARARG_JOIN(N, _WX_VARARG_ARG))                          \
+    {                                                                         \
+         name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed),                  \
+                     _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR));              \
+    }
+
+#endif // __WATCOMC__
+
 #endif // _WX_STRVARARG_H_
index 8b25fb62f6f5fa9c62e443d3e9dabd362320b712..99b7df61751800f906969e6dbc005027d63944b4 100644 (file)
@@ -364,13 +364,13 @@ wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
     #undef wxSnprintf
 
     #define wxPrintf(fmt, ...) \
-            wxPrintf_Impl(wxString(fmt), __VA_ARGS__)
+            wxPrintf_Impl(wxFormatString(fmt), __VA_ARGS__)
     #define wxFprintf(f, fmt, ...) \
-            wxFprintf_Impl(f, wxString(fmt), __VA_ARGS__)
+            wxFprintf_Impl(f, wxFormatString(fmt), __VA_ARGS__)
     #define wxSprintf(s, fmt, ...) \
-            wxSprintf_Impl(s, wxString(fmt), __VA_ARGS__)
+            wxSprintf_Impl(s, wxFormatString(fmt), __VA_ARGS__)
     #define wxSnprintf(s, n, fmt, ...) \
-            wxSnprintf_Impl(s, n, wxString(fmt), __VA_ARGS__)
+            wxSnprintf_Impl(s, n, wxFormatString(fmt), __VA_ARGS__)
 #endif // __WATCOMC__
 
 
index 37a37b80ede4fb8c6272c88026939e33578084ce..8c477ef29c0b4d69da199cb6c99d9758e6ed7b10 100644 (file)
@@ -337,7 +337,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
 
 #ifdef __WATCOMC__
   // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-  void wxDoLogTrace(int mask, const wxChar *format, ...)
+  void wxDoLogTraceWchar(int mask, const wxChar *format, ...)
   {
     va_list argptr;
     va_start(argptr, format);
@@ -345,7 +345,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
     va_end(argptr);
   }
 
-  void wxDoLogTrace(const char *mask, const wxChar *format, ...)
+  void wxDoLogTraceWchar(const char *mask, const wxChar *format, ...)
   {
     va_list argptr;
     va_start(argptr, format);
@@ -353,7 +353,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
     va_end(argptr);
   }
 
-  void wxDoLogTrace(const wchar_t *mask, const wxChar *format, ...)
+  void wxDoLogTraceWchar(const wchar_t *mask, const wxChar *format, ...)
   {
     va_list argptr;
     va_start(argptr, format);
@@ -441,7 +441,7 @@ void WXDLLEXPORT wxDoLogSysErrorUtf8(long lErrCode, const char *format, ...)
 
 #ifdef __WATCOMC__
 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
-void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxChar *format, ...)
+void WXDLLEXPORT wxDoLogSysErrorWchar(unsigned long lErrCode, const wxChar *format, ...)
 {
     va_list argptr;
     va_start(argptr, format);
@@ -449,7 +449,7 @@ void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxChar *format, .
     va_end(argptr);
 }
 
-void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxChar *format, va_list argptr)
+void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxString& format, va_list argptr)
     { wxVLogSysError((long)err, format, argptr); }
 #endif // __WATCOMC__