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);
// ----------------------------------------------------------------------------
/**
// 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)
// ----------------------------------------------------------------------------
#define _WX_DEFINE_ARRAY(T, name) \
typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \
-class WXDLLEXPORTLOCAL name : public wxBaseArray \
+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; \
void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); } \
void Remove(T Item) \
{ int iIndex = Index(Item); \
- wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
- "removing inexisting element in wxArray::Remove" ); \
- wxBaseArray::Remove((size_t)iIndex); } \
+ wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
+ _WX_ERROR_REMOVE); \
+ wxBaseArray::Remove((size_t)iIndex); } \
\
void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); } \
}
// ----------------------------------------------------------------------------
#define _WX_DEFINE_SORTED_ARRAY(T, name) \
typedef int (CMPFUNC_CONV *SCMPFUNC##T)(T pItem1, T pItem2); \
-class WXDLLEXPORTLOCAL name : public wxBaseArray \
+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; \
void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); } \
void Remove(T Item) \
{ int iIndex = Index(Item); \
- wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
- "removing inexisting element in wxArray::Remove" ); \
+ wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
+ _WX_ERROR_REMOVE ); \
wxBaseArray::Remove((size_t)iIndex); } \
\
private: \
// ----------------------------------------------------------------------------
#define _WX_DECLARE_OBJARRAY(T, name) \
typedef int (CMPFUNC_CONV *CMPFUNC##T)(T** pItem1, T** pItem2); \
-class WXDLLEXPORTLOCAL name : public wxBaseArray \
+class WXDLLEXPORT name : public wxBaseArray \
{ \
public: \
name() { } \
// # overhead if not used?
// ----------------------------------------------------------------------------
-#define WXDLLEXPORTLOCAL WXDLLEXPORT
-
//@{
/** @name ArrayInt */
WX_DEFINE_ARRAY(int, wxArrayInt);
//@}
-#undef WXDLLEXPORTLOCAL
-#define WXDLLEXPORTLOCAL
-
// -----------------------------------------------------------------------------
// convinience macros
// -----------------------------------------------------------------------------