]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxDECLARE_ANY_TYPE(CLS, DECL) and documented for what kind of situation it...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 3 Oct 2009 10:43:21 +0000 (10:43 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 3 Oct 2009 10:43:21 +0000 (10:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/any.h
interface/wx/any.h
src/common/any.cpp

index 0784b66480e9e0bc18e236a274230ca1673bcd90..52d8480b66bc4510df27fd0ecf6ef6ef42e4bb8c 100644 (file)
@@ -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__
     // Re-enable useless VC6 warnings
     #pragma warning (pop)
 #ifdef __VISUALC6__
     // Re-enable useless VC6 warnings
     #pragma warning (pop)
index c1893fbfe6ba1fba0101c534811552ac07d8972c..d8e69cbc58efcf88612db5f2f23301043984f873 100644 (file)
     Note that pointers to any and all classes are already automatically
     declared as movable data.
 
     Note that pointers to any and all classes are already automatically
     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}
     @category{data}
 
     @library{wxbase}
     @category{data}
 
index 01658ab8b738b69a56c682941c26aa6d6ee28922..1b12110c3f45e6528cc67b0aa74ffa004c99f160 100644 (file)
@@ -339,6 +339,10 @@ WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplString)
 WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)
 WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble)
 
 WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)
 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
 //-------------------------------------------------------------------------