fix compation with Watcom after latest vararg templates changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-06 14:11:14 +00:00
parent f74a73b365
commit 59a14f6984
8 changed files with 183 additions and 76 deletions

View File

@@ -99,10 +99,14 @@ public:
DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8) DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*), WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const wxString&),
DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*), WX_VARARG_WATCOM_WORKAROUND(void, PsPrintf, 1, (const wxCStrData&),
DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8) (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 #endif
void PsPrint( const wxString& psdata ); void PsPrint( const wxString& psdata );

View 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 // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
// something too big for Borland C++ to handle // something too big for Borland C++ to handle
#define DECLARE_LOG_FUNCTION_WATCOM(level) \ #define DECLARE_LOG_FUNCTION_WATCOM(level) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
1, (const char*), \ 1, (const wxString&), \
wxDoLog##level##Wchar, \ (wxFormatString(f1))) \
wxDoLog##level##Utf8) \ WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const wchar_t*), \
wxDoLog##level##Wchar, \
wxDoLog##level##Utf8) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const wxCStrData&), \ 1, (const wxCStrData&), \
wxDoLog##level##Wchar, \ (wxFormatString(f1))) \
wxDoLog##level##Utf8) WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
1, (const char*), \
(wxFormatString(f1))) \
WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
1, (const wchar_t*), \
(wxFormatString(f1)))
#else #else
#define DECLARE_LOG_FUNCTION_WATCOM(level) #define DECLARE_LOG_FUNCTION_WATCOM(level)
#endif #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 // can't use WX_WATCOM_ONLY_CODE here because the macro would expand to
// something too big for Borland C++ to handle // something too big for Borland C++ to handle
#define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \ #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 char*), \ 2, (argclass, const wxString&), \
wxDoLog##level##Wchar, \ (f1, wxFormatString(f2))) \
wxDoLog##level##Utf8) \ WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
WX_DEFINE_VARARG_FUNC_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&), \ 2, (argclass, const wxCStrData&), \
wxDoLog##level##Wchar, \ (f1, wxFormatString(f2))) \
wxDoLog##level##Utf8) WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
2, (argclass, const char*), \
(f1, wxFormatString(f2))) \
WX_VARARG_WATCOM_WORKAROUND(void, wxLog##level, \
2, (argclass, const wchar_t*), \
(f1, wxFormatString(f2)))
#else #else
#define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl)
#endif #endif
@@ -558,7 +558,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxCStrData&)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxCStrData&)) \
) \ ) \
inline void wxVLog##level(const wxString& WXUNUSED(format), \ 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) \ #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxString&)) \ 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&)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \
) \ ) \
inline void wxVLog##level(argclass WXUNUSED(arg), \ inline void wxVLog##level(argclass WXUNUSED(arg), \
const wxString& WXUNUSED(format), \ const wxString& WXUNUSED(format), \
va_list WXUNUSED(argptr)) {} va_list WXUNUSED(argptr)) {}
// Empty Class to fake wxLogNull // Empty Class to fake wxLogNull
class WXDLLIMPEXP_BASE wxLogNull class WXDLLIMPEXP_BASE wxLogNull

View File

@@ -155,23 +155,56 @@ public:
// // extensions // // extensions
// ...); // ...);
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
4, (const wxString&, const wxString&, // NB: these are not format strings, using
const wxString&, const wxString&), // wxFormatString here is a hack to get
// implicit conversion to wchar_t*/char*
4, (const wxFormatString&,
const wxFormatString&,
const wxFormatString&,
const wxFormatString&),
VarArgInitWchar, VarArgInitUtf8) VarArgInitWchar, VarArgInitUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_VARARG_WATCOM_WORKAROUND_CTOR(
4, (const char*, const char*, wxFileTypeInfo,
const char*, const char*), 4, (const wxString&,
VarArgInitWchar, VarArgInitUtf8) const wxString&,
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, const wxString&,
4, (const wchar_t*, const wchar_t*, const wxString&),
const wchar_t*, const wchar_t*), (wxFormatString(f1),
VarArgInitWchar, VarArgInitUtf8) wxFormatString(f2),
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, wxFormatString(f3),
4, (const wxCStrData&, const wxCStrData&, wxFormatString(f4)));
const wxCStrData&, const wxCStrData&), WX_VARARG_WATCOM_WORKAROUND_CTOR(
VarArgInitWchar, VarArgInitUtf8) 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 #endif
// the array elements correspond to the parameters of the ctor above in // the array elements correspond to the parameters of the ctor above in

View File

@@ -41,12 +41,14 @@ public:
DoPrintfWchar, DoPrintfUtf8) DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*), WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*), WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxCStrData&),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&), WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wchar_t*),
(wxFormatString(f1)));
#endif #endif
protected: protected:

View File

@@ -1579,12 +1579,15 @@ public:
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&), WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
DoPrintfWchar, DoPrintfUtf8) DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const char*), // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
DoPrintfWchar, DoPrintfUtf8) WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxString&),
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wchar_t*), (wxFormatString(f1)));
DoPrintfWchar, DoPrintfUtf8) WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxCStrData&),
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxCStrData&), (wxFormatString(f1)));
DoPrintfWchar, DoPrintfUtf8) 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
#endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN #endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN
// as vprintf(), returns the number of characters written or < 0 on error // as vprintf(), returns the number of characters written or < 0 on error
@@ -1597,12 +1600,14 @@ public:
DoFormatWchar, DoFormatUtf8) DoFormatWchar, DoFormatUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const char*), WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxString&),
DoFormatWchar, DoFormatUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wchar_t*), WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxCStrData&),
DoFormatWchar, DoFormatUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxCStrData&), WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const char*),
DoFormatWchar, DoFormatUtf8) (wxFormatString(f1)));
WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wchar_t*),
(wxFormatString(f1)));
#endif #endif
#endif #endif
// the same as above, but takes a va_list // the same as above, but takes a va_list
@@ -1644,12 +1649,14 @@ public:
DoPrintfWchar, DoPrintfUtf8) DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const char*), WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wchar_t*), WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxCStrData&),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxCStrData&), WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const char*),
DoPrintfWchar, DoPrintfUtf8) (wxFormatString(f1)));
WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wchar_t*),
(wxFormatString(f1)));
#endif #endif
#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN #endif // wxNEEDS_WXSTRING_PRINTF_MIXIN

View File

@@ -732,4 +732,65 @@ private:
inline void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed)) \ 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_ #endif // _WX_STRVARARG_H_

View File

@@ -364,13 +364,13 @@ wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
#undef wxSnprintf #undef wxSnprintf
#define wxPrintf(fmt, ...) \ #define wxPrintf(fmt, ...) \
wxPrintf_Impl(wxString(fmt), __VA_ARGS__) wxPrintf_Impl(wxFormatString(fmt), __VA_ARGS__)
#define wxFprintf(f, fmt, ...) \ #define wxFprintf(f, fmt, ...) \
wxFprintf_Impl(f, wxString(fmt), __VA_ARGS__) wxFprintf_Impl(f, wxFormatString(fmt), __VA_ARGS__)
#define wxSprintf(s, fmt, ...) \ #define wxSprintf(s, fmt, ...) \
wxSprintf_Impl(s, wxString(fmt), __VA_ARGS__) wxSprintf_Impl(s, wxFormatString(fmt), __VA_ARGS__)
#define wxSnprintf(s, n, fmt, ...) \ #define wxSnprintf(s, n, fmt, ...) \
wxSnprintf_Impl(s, n, wxString(fmt), __VA_ARGS__) wxSnprintf_Impl(s, n, wxFormatString(fmt), __VA_ARGS__)
#endif // __WATCOMC__ #endif // __WATCOMC__

View File

@@ -337,7 +337,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // 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_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -345,7 +345,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
va_end(argptr); va_end(argptr);
} }
void wxDoLogTrace(const char *mask, const wxChar *format, ...) void wxDoLogTraceWchar(const char *mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -353,7 +353,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
va_end(argptr); 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_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -441,7 +441,7 @@ void WXDLLEXPORT wxDoLogSysErrorUtf8(long lErrCode, const char *format, ...)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // 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_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -449,7 +449,7 @@ void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxChar *format, .
va_end(argptr); 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); } { wxVLogSysError((long)err, format, argptr); }
#endif // __WATCOMC__ #endif // __WATCOMC__