Added wxDECLARE_ANY_TYPE(CLS, DECL) and documented for what kind of situation it is intended: wxAny used across DLL and EXE boundaries.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -479,6 +479,53 @@ WX_ANY_DEFINE_SUB_TYPE(float, Double)
|
|||||||
WX_ANY_DEFINE_SUB_TYPE(double, Double)
|
WX_ANY_DEFINE_SUB_TYPE(double, Double)
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Defines a dummy wxAnyValueTypeImpl<> with given export
|
||||||
|
// declaration. This is needed if a class is used with
|
||||||
|
// wxAny in both user shared library and application.
|
||||||
|
//
|
||||||
|
#define wxDECLARE_ANY_TYPE(CLS, DECL) \
|
||||||
|
template<> \
|
||||||
|
class DECL wxAnyValueTypeImpl<CLS> : \
|
||||||
|
public wxAnyValueTypeImplBase<CLS> \
|
||||||
|
{ \
|
||||||
|
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<CLS>) \
|
||||||
|
public: \
|
||||||
|
wxAnyValueTypeImpl() : \
|
||||||
|
wxAnyValueTypeImplBase<CLS>() { } \
|
||||||
|
virtual ~wxAnyValueTypeImpl() { } \
|
||||||
|
\
|
||||||
|
virtual bool ConvertValue(const wxAnyValueBuffer& src, \
|
||||||
|
wxAnyValueType* dstType, \
|
||||||
|
wxAnyValueBuffer& dst) const \
|
||||||
|
{ \
|
||||||
|
wxUnusedVar(src); \
|
||||||
|
wxUnusedVar(dstType); \
|
||||||
|
wxUnusedVar(dst); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Make sure some of wx's own types get the right wxAnyValueType export
|
||||||
|
// (this is needed only for types that are referred to from wxBase.
|
||||||
|
// currently we may not use any of these types from there, but let's
|
||||||
|
// use the macro on at least one to make sure it compiles since we can't
|
||||||
|
// really test it properly in unittests since a separate DLL would
|
||||||
|
// be needed).
|
||||||
|
#if wxUSE_DATETIME
|
||||||
|
#include "wx/datetime.h"
|
||||||
|
wxDECLARE_ANY_TYPE(wxDateTime, WXDLLIMPEXP_BASE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#include "wx/object.h"
|
||||||
|
//wxDECLARE_ANY_TYPE(wxObject*, WXDLLIMPEXP_BASE)
|
||||||
|
|
||||||
|
//#include "wx/arrstr.h"
|
||||||
|
//wxDECLARE_ANY_TYPE(wxArrayString, WXDLLIMPEXP_BASE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __VISUALC6__
|
#ifdef __VISUALC6__
|
||||||
// Re-enable useless VC6 warnings
|
// Re-enable useless VC6 warnings
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
|
@@ -63,6 +63,25 @@
|
|||||||
Note that pointers to any and all classes are already automatically
|
Note that pointers to any and all classes are already automatically
|
||||||
declared as movable data.
|
declared as movable data.
|
||||||
|
|
||||||
|
@warning Caveat with shared libraries (DLLs): If you have a scenario where
|
||||||
|
you use wxAny across application's shared library and application
|
||||||
|
itself (or, with another of your shared libraries), then you must
|
||||||
|
use wxDECLARE_ANY_TYPE() macro in your shared library code to
|
||||||
|
correctly make sure that the wxAnyValueType implementation is
|
||||||
|
generated correctly. Failure to do this will result in breakage
|
||||||
|
of the wxAny type recognition with type in question. Below is an
|
||||||
|
example how to use the macro.
|
||||||
|
@code
|
||||||
|
// In your shared library/DLL-only
|
||||||
|
wxDECLARE_ANY_TYPE(MyClass, WXEXPORT)
|
||||||
|
|
||||||
|
// In your shared library/DLL source code
|
||||||
|
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
|
||||||
|
|
||||||
|
// In code using said shared library/DLL
|
||||||
|
wxDECLARE_ANY_TYPE(MyClass, WXIMPORT)
|
||||||
|
@endcode
|
||||||
|
|
||||||
@library{wxbase}
|
@library{wxbase}
|
||||||
@category{data}
|
@category{data}
|
||||||
|
|
||||||
|
@@ -339,6 +339,10 @@ WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplString)
|
|||||||
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)
|
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)
|
||||||
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble)
|
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble)
|
||||||
|
|
||||||
|
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxDateTime>)
|
||||||
|
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxObject*>)
|
||||||
|
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxArrayString>)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// wxAnyNullValueType implementation
|
// wxAnyNullValueType implementation
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user