made wxConvXXX objects usable at static initialization time

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-02 09:03:03 +00:00
parent 1436bf0bed
commit 1e50d914af
2 changed files with 93 additions and 41 deletions

View File

@@ -418,14 +418,35 @@ private:
// declare predefined conversion objects
// ----------------------------------------------------------------------------
// Note: this macro is an implementation detail (see the comment in
// strconv.cpp). The wxGet_XXX() and wxGet_XXXPtr() functions shouldn't be
// used by user code and neither should XXXPtr, use the wxConvXXX macro
// instead.
#define WX_DECLARE_GLOBAL_CONV(klass, name) \
extern WXDLLIMPEXP_DATA_BASE(klass*) name##Ptr; \
extern klass* WXDLLIMPEXP_BASE wxGet_##name##Ptr(); \
inline klass& wxGet_##name() \
{ \
if ( !name##Ptr ) \
name##Ptr = wxGet_##name##Ptr(); \
return *name##Ptr; \
}
// conversion to be used with all standard functions affected by locale, e.g.
// strtol(), strftime(), ...
extern WXDLLIMPEXP_DATA_BASE(wxMBConv&) wxConvLibc;
WX_DECLARE_GLOBAL_CONV(wxMBConv, wxConvLibc)
#define wxConvLibc wxGet_wxConvLibc()
// conversion ISO-8859-1/UTF-7/UTF-8 <-> wchar_t
extern WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvISO8859_1;
extern WXDLLIMPEXP_DATA_BASE(wxMBConvUTF7&) wxConvUTF7;
extern WXDLLIMPEXP_DATA_BASE(wxMBConvUTF8&) wxConvUTF8;
WX_DECLARE_GLOBAL_CONV(wxCSConv, wxConvISO8859_1)
#define wxConvISO8859_1 wxGet_wxConvISO8859_1()
WX_DECLARE_GLOBAL_CONV(wxMBConvUTF8, wxConvUTF8)
#define wxConvUTF8 wxGet_wxConvUTF8()
WX_DECLARE_GLOBAL_CONV(wxMBConvUTF7, wxConvUTF7)
#define wxConvUTF7 wxGet_wxConvUTF7()
// conversion used for the file names on the systems where they're not Unicode
// (basically anything except Windows)
@@ -444,7 +465,8 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName;
extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent;
// the conversion corresponding to the current locale
extern WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal;
WX_DECLARE_GLOBAL_CONV(wxCSConv, wxConvLocal)
#define wxConvLocal wxGet_wxConvLocal()
// the conversion corresponding to the encoding of the standard UI elements
//
@@ -452,6 +474,8 @@ extern WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal;
// needs to use a fixed encoding
extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
#undef WX_DECLARE_GLOBAL_CONV
// ----------------------------------------------------------------------------
// endianness-dependent conversions
// ----------------------------------------------------------------------------