X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/683730003ba8f36fa07496b8f298d40733534aea..a2115c88f381b95cf6d423a5d3128ccbe20c4fa1:/include/wx/dynarray.h diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index e1ee899f16..b5466516d2 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -43,13 +43,7 @@ callback compare function for quick sort must return negative value, 0 or positive value if pItem1 <, = or > pItem2 */ - -#ifdef __VISUALC__ - #define CMPFUNC_CONV _cdecl -#else // !Visual C++ - #define CMPFUNC_CONV -#endif // compiler -typedef int (CMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2); +typedef int (wxCMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2); // ---------------------------------------------------------------------------- /** @@ -157,6 +151,11 @@ private: // template classes // ============================================================================ +// resolves the name conflict between the T() macor and T typedef: we can't +// use T() inside WX_DEFINE_ARRAY! +#define _WX_ERROR_SIZEOF T("illegal use of DEFINE_ARRAY") +#define _WX_ERROR_REMOVE T("removing inexisting element in wxArray::Remove") + // ---------------------------------------------------------------------------- // This macro generates a new array class. It is intended for storage of simple // types of sizeof()<=sizeof(long) or pointers if sizeof(pointer)<=sizeof(long) @@ -172,7 +171,12 @@ class WXDLLEXPORT name : public wxBaseArray \ { \ public: \ name() \ - { wxASSERT( sizeof(T) <= sizeof(long) ); } \ + { \ + size_t type = sizeof(T); \ + size_t sizelong = sizeof(long); \ + if ( type > sizelong ) \ + { wxFAIL_MSG( _WX_ERROR_SIZEOF ); } \ + } \ \ name& operator=(const name& src) \ { wxBaseArray* temp = (wxBaseArray*) this; \ @@ -198,7 +202,7 @@ public: \ void Remove(T Item) \ { int iIndex = Index(Item); \ wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \ - _T("removing inexisting element in wxArray::Remove") ); \ + _WX_ERROR_REMOVE); \ wxBaseArray::Remove((size_t)iIndex); } \ \ void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); } \ @@ -230,7 +234,12 @@ class WXDLLEXPORT name : public wxBaseArray \ { \ public: \ name(SCMPFUNC##T fn) \ - { wxASSERT( sizeof(T) <= sizeof(long) ); m_fnCompare = fn; } \ + { size_t type = sizeof(T); \ + size_t sizelong = sizeof(long); \ + if ( type > sizelong ) \ + { wxFAIL_MSG( _WX_ERROR_SIZEOF ); } \ + m_fnCompare = fn; \ + } \ \ name& operator=(const name& src) \ { wxBaseArray* temp = (wxBaseArray*) this; \ @@ -255,7 +264,7 @@ public: \ void Remove(T Item) \ { int iIndex = Index(Item); \ wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \ - _T("removing inexisting element in wxArray::Remove") ); \ + _WX_ERROR_REMOVE ); \ wxBaseArray::Remove((size_t)iIndex); } \ \ private: \