]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxIsPod<>. Use it in wxAny instead of wxIsMovable<>.
authorJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 14 Jun 2010 15:12:37 +0000 (15:12 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 14 Jun 2010 15:12:37 +0000 (15:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

24 files changed:
Makefile.in
build/bakefiles/files.bkl
build/msw/wx_base.dsp
build/msw/wx_vc7_base.vcproj
build/msw/wx_vc8_base.vcproj
build/msw/wx_vc9_base.vcproj
include/wx/any.h
include/wx/meta/movable.h
include/wx/meta/pod.h [new file with mode: 0644]
interface/wx/any.h
tests/Makefile.in
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/misc/metatest.cpp [new file with mode: 0644]
tests/test.bkl
tests/test_test.dsp
tests/test_vc7_test.vcproj
tests/test_vc8_test.vcproj
tests/test_vc9_test.vcproj
wxGTK.spec
wxMotif.spec
wxX11.spec

index 8f0abc7312cce96f7196df9cf79f154c107d6acb..8f5e004d6cef194516e0f2a7207eb60dedaca655 100644 (file)
@@ -471,6 +471,7 @@ ALL_BASE_HEADERS =  \
        wx/meta/if.h \
        wx/meta/int2type.h \
        wx/meta/movable.h \
        wx/meta/if.h \
        wx/meta/int2type.h \
        wx/meta/movable.h \
+       wx/meta/pod.h \
        wx/fswatcher.h \
        wx/generic/fswatcher.h \
        $(BASE_PLATFORM_HDR) \
        wx/fswatcher.h \
        wx/generic/fswatcher.h \
        $(BASE_PLATFORM_HDR) \
@@ -639,6 +640,7 @@ ALL_PORTS_BASE_HEADERS =  \
        wx/meta/if.h \
        wx/meta/int2type.h \
        wx/meta/movable.h \
        wx/meta/if.h \
        wx/meta/int2type.h \
        wx/meta/movable.h \
+       wx/meta/pod.h \
        wx/fswatcher.h \
        wx/generic/fswatcher.h \
        wx/unix/app.h \
        wx/fswatcher.h \
        wx/generic/fswatcher.h \
        wx/unix/app.h \
index e13803eb0d08d156b32273484dd26a4233689414..b1186639629f4bea34dca37384e039a60526a9ad 100644 (file)
@@ -556,6 +556,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/meta/if.h
     wx/meta/int2type.h
     wx/meta/movable.h
     wx/meta/if.h
     wx/meta/int2type.h
     wx/meta/movable.h
+    wx/meta/pod.h
     wx/fswatcher.h
     wx/generic/fswatcher.h
 </set>
     wx/fswatcher.h
     wx/generic/fswatcher.h
 </set>
index fcb0246ac423adbc0d33aefd5c775ca52f510c12..3880a5314c22238757e98559719bdc85fa5f2b05 100644 (file)
@@ -1423,6 +1423,10 @@ SOURCE=..\..\include\wx\platinfo.h
 # End Source File\r
 # Begin Source File\r
 \r
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\include\wx\meta\pod.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\include\wx\power.h\r
 # End Source File\r
 # Begin Source File\r
 SOURCE=..\..\include\wx\power.h\r
 # End Source File\r
 # Begin Source File\r
index 14b0613c64d1c7249c0e504b7650cf6ef0e4fc11..44bd7cc4e0d75efab5cdd76278cfb9aabb4dd1b2 100644 (file)
                        <File\r
                                RelativePath="..\..\include\wx\platinfo.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\platinfo.h">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\include\wx\meta\pod.h">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h">\r
                        </File>\r
index a54045eda0c79f637d5e8c0762b8ebd6109f8397..23726bbf5063b0369a12afd21872beb8c4291fb1 100644 (file)
                                RelativePath="..\..\include\wx\platinfo.h"\r
                                >\r
                        </File>\r
                                RelativePath="..\..\include\wx\platinfo.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\include\wx\meta\pod.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h"\r
                                >\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h"\r
                                >\r
index 4a8a4dc9c9cf2a1cf32bc73226d690af383b5d8c..3656c710dbae0912236b69fabd8d735378d92063 100644 (file)
                                RelativePath="..\..\include\wx\platinfo.h"\r
                                >\r
                        </File>\r
                                RelativePath="..\..\include\wx\platinfo.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\include\wx\meta\pod.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h"\r
                                >\r
                        <File\r
                                RelativePath="..\..\include\wx\power.h"\r
                                >\r
index 0e3e4a9bea56feeb6f6b03320a01101f98a73370..366f4bc5e3c4ceecac4b8be47b8119e46ff0aeb6 100644 (file)
@@ -17,7 +17,7 @@
 #if wxUSE_ANY
 
 #include "wx/string.h"
 #if wxUSE_ANY
 
 #include "wx/string.h"
-#include "wx/meta/movable.h"
+#include "wx/meta/pod.h"
 #include "wx/meta/if.h"
 #include "wx/typeinfo.h"
 
 #include "wx/meta/if.h"
 #include "wx/typeinfo.h"
 
@@ -193,7 +193,7 @@ namespace wxPrivate
 {
 
 template<typename T>
 {
 
 template<typename T>
-class wxAnyValueTypeOpsMovable
+class wxAnyValueTypeOpsPOD
 {
 public:
     static void DeleteValue(wxAnyValueBuffer& buf)
 {
 public:
     static void DeleteValue(wxAnyValueBuffer& buf)
@@ -270,9 +270,9 @@ public:
 template<typename T>
 class wxAnyValueTypeImplBase : public wxAnyValueType
 {
 template<typename T>
 class wxAnyValueTypeImplBase : public wxAnyValueType
 {
-    typedef typename wxIf< wxIsMovable<T>::value &&
+    typedef typename wxIf< wxIsPod<T>::value &&
                                 sizeof(T) <= WX_ANY_VALUE_BUFFER_SIZE,
                                 sizeof(T) <= WX_ANY_VALUE_BUFFER_SIZE,
-                           wxPrivate::wxAnyValueTypeOpsMovable<T>,
+                           wxPrivate::wxAnyValueTypeOpsPOD<T>,
                            wxPrivate::wxAnyValueTypeOpsGeneric<T> >::value
             Ops;
 
                            wxPrivate::wxAnyValueTypeOpsGeneric<T> >::value
             Ops;
 
index f8624d1fb904260ccfe03cb06ec92cd551a2c862..8c934874724a06f4a2aecc523406ff95529ed164 100644 (file)
 #ifndef _WX_META_MOVABLE_H_
 #define _WX_META_MOVABLE_H_
 
 #ifndef _WX_META_MOVABLE_H_
 #define _WX_META_MOVABLE_H_
 
-#include "wx/defs.h"
+#include "wx/meta/pod.h"
 #include "wx/string.h" // for wxIsMovable<wxString> specialization
 
 #include "wx/string.h" // for wxIsMovable<wxString> specialization
 
-// This macro declares something called "value" inside a class declaration.
-//
-// It has to be used because VC6 doesn't handle initialization of the static
-// variables in the class declaration itself while BCC5.82 doesn't understand
-// enums (it compiles the template fine but can't use it later)
-#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7)
-    #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) enum { value = val }
-#else
-    #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val
-#endif
-
 // Helper to decide if an object of type T is "movable", i.e. if it can be
 // copied to another memory location using memmove() or realloc() C functions.
 // C++ only gurantees that POD types (including primitive types) are
 // Helper to decide if an object of type T is "movable", i.e. if it can be
 // copied to another memory location using memmove() or realloc() C functions.
 // C++ only gurantees that POD types (including primitive types) are
@@ -32,7 +21,7 @@
 template<typename T>
 struct wxIsMovable
 {
 template<typename T>
 struct wxIsMovable
 {
-    wxDEFINE_TEMPLATE_BOOL_VALUE(false);
+    wxDEFINE_TEMPLATE_BOOL_VALUE(wxIsPod<T>::value);
 };
 
 // Macro to add wxIsMovable<T> specialization for given type that marks it
 };
 
 // Macro to add wxIsMovable<T> specialization for given type that marks it
@@ -43,46 +32,6 @@ struct wxIsMovable
         wxDEFINE_TEMPLATE_BOOL_VALUE(true);                 \
     };
 
         wxDEFINE_TEMPLATE_BOOL_VALUE(true);                 \
     };
 
-WX_DECLARE_TYPE_MOVABLE(bool)
-WX_DECLARE_TYPE_MOVABLE(unsigned char)
-WX_DECLARE_TYPE_MOVABLE(signed char)
-WX_DECLARE_TYPE_MOVABLE(unsigned int)
-WX_DECLARE_TYPE_MOVABLE(signed int)
-WX_DECLARE_TYPE_MOVABLE(unsigned short int)
-WX_DECLARE_TYPE_MOVABLE(signed short int)
-WX_DECLARE_TYPE_MOVABLE(signed long int)
-WX_DECLARE_TYPE_MOVABLE(unsigned long int)
-WX_DECLARE_TYPE_MOVABLE(float)
-WX_DECLARE_TYPE_MOVABLE(double)
-WX_DECLARE_TYPE_MOVABLE(long double)
-#if wxWCHAR_T_IS_REAL_TYPE
-WX_DECLARE_TYPE_MOVABLE(wchar_t)
-#endif
-#ifdef wxLongLong_t
-WX_DECLARE_TYPE_MOVABLE(wxLongLong_t)
-WX_DECLARE_TYPE_MOVABLE(wxULongLong_t)
-#endif
-
-// Visual C++ 6.0 can't compile partial template specializations and as this is
-// only an optimization, we can live with pointers not being recognized as
-// movable types under VC6
-#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
-
-// pointers are movable:
-template<typename T>
-struct wxIsMovable<T*>
-{
-    static const bool value = true;
-};
-
-template<typename T>
-struct wxIsMovable<const T*>
-{
-    static const bool value = true;
-};
-
-#endif // !VC++ < 7
-
 // Our implementation of wxString is written in such way that it's safe to move
 // it around (unless position cache is used which unfortunately breaks this).
 // OTOH, we don't know anything about std::string.
 // Our implementation of wxString is written in such way that it's safe to move
 // it around (unless position cache is used which unfortunately breaks this).
 // OTOH, we don't know anything about std::string.
diff --git a/include/wx/meta/pod.h b/include/wx/meta/pod.h
new file mode 100644 (file)
index 0000000..c3426cc
--- /dev/null
@@ -0,0 +1,88 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/meta/pod.h
+// Purpose:     Test if a type is POD
+// Author:      Vaclav Slavik, Jaakko Salli
+// Created:     2010-06-14
+// RCS-ID:      $Id$
+// Copyright:   (c) wxWidgets team
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_META_POD_H_
+#define _WX_META_POD_H_
+
+#include "wx/defs.h"
+
+//
+// TODO: Use TR1 is_pod<> implementation where available. VC9 SP1 has it
+//       in tr1 namespace, VC10 has it in std namespace. GCC 4.2 has it in
+//       <tr1/type_traits>, while GCC 4.3 and later have it in <type_traits>.
+//
+
+// This macro declares something called "value" inside a class declaration.
+//
+// It has to be used because VC6 doesn't handle initialization of the static
+// variables in the class declaration itself while BCC5.82 doesn't understand
+// enums (it compiles the template fine but can't use it later)
+#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7)
+    #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) enum { value = val }
+#else
+    #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val
+#endif
+
+// Helper to decide if an object of type T is POD (Plain Old Data)
+template<typename T>
+struct wxIsPod
+{
+    wxDEFINE_TEMPLATE_BOOL_VALUE(false);
+};
+
+// Macro to add wxIsPod<T> specialization for given type that marks it
+// as Plain Old Data:
+#define WX_DECLARE_TYPE_POD(type)                           \
+    template<> struct wxIsPod<type>                         \
+    {                                                       \
+        wxDEFINE_TEMPLATE_BOOL_VALUE(true);                 \
+    };
+
+WX_DECLARE_TYPE_POD(bool)
+WX_DECLARE_TYPE_POD(unsigned char)
+WX_DECLARE_TYPE_POD(signed char)
+WX_DECLARE_TYPE_POD(unsigned int)
+WX_DECLARE_TYPE_POD(signed int)
+WX_DECLARE_TYPE_POD(unsigned short int)
+WX_DECLARE_TYPE_POD(signed short int)
+WX_DECLARE_TYPE_POD(signed long int)
+WX_DECLARE_TYPE_POD(unsigned long int)
+WX_DECLARE_TYPE_POD(float)
+WX_DECLARE_TYPE_POD(double)
+WX_DECLARE_TYPE_POD(long double)
+#if wxWCHAR_T_IS_REAL_TYPE
+WX_DECLARE_TYPE_POD(wchar_t)
+#endif
+#ifdef wxLongLong_t
+WX_DECLARE_TYPE_POD(wxLongLong_t)
+WX_DECLARE_TYPE_POD(wxULongLong_t)
+#endif
+
+// Visual C++ 6.0 can't compile partial template specializations and as this is
+// only an optimization, we can live with pointers not being recognized as
+// POD types under VC6
+#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
+
+// pointers are Plain Old Data:
+template<typename T>
+struct wxIsPod<T*>
+{
+    static const bool value = true;
+};
+
+template<typename T>
+struct wxIsPod<const T*>
+{
+    static const bool value = true;
+};
+
+#endif // !VC++ < 7
+
+#endif // _WX_META_POD_H_
index 0ecefb86d0e71125f3413b4b9e83f132c43bf68a..b7e1fe07258fcc04f53928aa9ce2573899f1f079 100644 (file)
 
     When compared to wxVariant, there are various internal implementation
     differences as well. For instance, wxAny only allocates separate data
 
     When compared to wxVariant, there are various internal implementation
     differences as well. For instance, wxAny only allocates separate data
-    object in heap for large (ie. size in bytes more than
-    WX_ANY_VALUE_BUFFER_SIZE) or 'non-movable' data types. Pointers, integers,
-    bools etc. are fitted in the wxAny's own buffer without need for any extra
-    allocation. Use following code to declare your own data type as 'movable':
+    object in heap for large (i.e. size in bytes more than
+    WX_ANY_VALUE_BUFFER_SIZE) or non-POD (Plain Old Data) data types.
+    Pointers, integers, bools etc. are fitted in the wxAny's internal buffer
+    without need for any extra allocation. It is possible that wxAny cannot
+    automatically determine if your own data structure is considered a
+    POD or not, so you may need to declare it as such explicitly, using
+    code like this:
 
     @code
 
     @code
-    #include "wx/meta/movable.h"
-    WX_DECLARE_TYPE_MOVABLE(MyClass)
+    #include "wx/meta/pod.h"
+    WX_DECLARE_TYPE_POD(MyPodStruct)
     @endcode
 
     @endcode
 
-    However, you must be aware that 'movable' means such data that can be
-    copied with memcpy() without corrupting program integrity. For instance,
-    movable objects usually cannot contain pointers or references to other
-    data. wxRect, wxPoint, and wxSize are good examples of movable classes.
+    Be extra careful what you declare as Plain Old Data. It must be such data
+    that can be copied with memcpy() without corrupting program integrity. For
+    instance, POD structures usually cannot contain pointers or references to
+    other data. wxRect, wxPoint, and wxSize are good examples of POD
+    classes.
 
 
-    Note that pointers to any and all classes are already automatically
-    declared as movable data.
+    Note that pointers to any and all types are already automatically
+    declared as Plain Old Data.
 
     @library{wxbase}
     @category{data}
 
     @library{wxbase}
     @category{data}
index 90b2855e4a7d18f13cd728c95000997b1575d824..445d2ccb4d8ba856966ae1d956384fa797e9c747 100644 (file)
@@ -86,6 +86,7 @@ TEST_OBJECTS =  \
        test_mbconvtest.o \
        test_dynamiclib.o \
        test_environ.o \
        test_mbconvtest.o \
        test_dynamiclib.o \
        test_environ.o \
+       test_metatest.o \
        test_misctests.o \
        test_module.o \
        test_pathlist.o \
        test_misctests.o \
        test_module.o \
        test_pathlist.o \
@@ -460,6 +461,9 @@ test_dynamiclib.o: $(srcdir)/misc/dynamiclib.cpp $(TEST_ODEP)
 test_environ.o: $(srcdir)/misc/environ.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/environ.cpp
 
 test_environ.o: $(srcdir)/misc/environ.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/environ.cpp
 
+test_metatest.o: $(srcdir)/misc/metatest.cpp $(TEST_ODEP)
+       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/metatest.cpp
+
 test_misctests.o: $(srcdir)/misc/misctests.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/misctests.cpp
 
 test_misctests.o: $(srcdir)/misc/misctests.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/misctests.cpp
 
index e104f20bf9653600acb65ec1a1f96cb85ecd2f9b..32e3bb97ea9ae2affa86eeb251a3627a0d30411d 100644 (file)
@@ -70,6 +70,7 @@ TEST_OBJECTS =  \
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_dynamiclib.obj \\r
        $(OBJS)\test_environ.obj \\r
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_dynamiclib.obj \\r
        $(OBJS)\test_environ.obj \\r
+       $(OBJS)\test_metatest.obj \\r
        $(OBJS)\test_misctests.obj \\r
        $(OBJS)\test_module.obj \\r
        $(OBJS)\test_pathlist.obj \\r
        $(OBJS)\test_misctests.obj \\r
        $(OBJS)\test_module.obj \\r
        $(OBJS)\test_pathlist.obj \\r
@@ -502,6 +503,9 @@ $(OBJS)\test_dynamiclib.obj: .\misc\dynamiclib.cpp
 $(OBJS)\test_environ.obj: .\misc\environ.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\environ.cpp\r
 \r
 $(OBJS)\test_environ.obj: .\misc\environ.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\environ.cpp\r
 \r
+$(OBJS)\test_metatest.obj: .\misc\metatest.cpp\r
+       $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\metatest.cpp\r
+\r
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
index fccd347e5c8f0d26a02cd4251268deb127809023..69c87613f0ea9e0a9a9c5d472a4268f9d4b80477 100644 (file)
@@ -62,6 +62,7 @@ TEST_OBJECTS =  \
        $(OBJS)\test_mbconvtest.o \\r
        $(OBJS)\test_dynamiclib.o \\r
        $(OBJS)\test_environ.o \\r
        $(OBJS)\test_mbconvtest.o \\r
        $(OBJS)\test_dynamiclib.o \\r
        $(OBJS)\test_environ.o \\r
+       $(OBJS)\test_metatest.o \\r
        $(OBJS)\test_misctests.o \\r
        $(OBJS)\test_module.o \\r
        $(OBJS)\test_pathlist.o \\r
        $(OBJS)\test_misctests.o \\r
        $(OBJS)\test_module.o \\r
        $(OBJS)\test_pathlist.o \\r
@@ -483,6 +484,9 @@ $(OBJS)\test_dynamiclib.o: ./misc/dynamiclib.cpp
 $(OBJS)\test_environ.o: ./misc/environ.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
 $(OBJS)\test_environ.o: ./misc/environ.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
+$(OBJS)\test_metatest.o: ./misc/metatest.cpp\r
+       $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
+\r
 $(OBJS)\test_misctests.o: ./misc/misctests.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
 $(OBJS)\test_misctests.o: ./misc/misctests.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
index 4d1592bf04d151a340f4581f8a5ae831b0e4b7b0..fa535a38859442bbefa4865ffb37799e05df1f9a 100644 (file)
@@ -64,6 +64,7 @@ TEST_OBJECTS =  \
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_dynamiclib.obj \\r
        $(OBJS)\test_environ.obj \\r
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_dynamiclib.obj \\r
        $(OBJS)\test_environ.obj \\r
+       $(OBJS)\test_metatest.obj \\r
        $(OBJS)\test_misctests.obj \\r
        $(OBJS)\test_module.obj \\r
        $(OBJS)\test_pathlist.obj \\r
        $(OBJS)\test_misctests.obj \\r
        $(OBJS)\test_module.obj \\r
        $(OBJS)\test_pathlist.obj \\r
@@ -628,6 +629,9 @@ $(OBJS)\test_dynamiclib.obj: .\misc\dynamiclib.cpp
 $(OBJS)\test_environ.obj: .\misc\environ.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\environ.cpp\r
 \r
 $(OBJS)\test_environ.obj: .\misc\environ.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\environ.cpp\r
 \r
+$(OBJS)\test_metatest.obj: .\misc\metatest.cpp\r
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\metatest.cpp\r
+\r
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
index a7585376687e9e5657b27bd8d82cbc40053ce5b3..aac28188faf96a5e4aa8dfb2ca38b6af5b2a21c5 100644 (file)
@@ -300,6 +300,7 @@ TEST_OBJECTS =  &
        $(OBJS)\test_mbconvtest.obj &\r
        $(OBJS)\test_dynamiclib.obj &\r
        $(OBJS)\test_environ.obj &\r
        $(OBJS)\test_mbconvtest.obj &\r
        $(OBJS)\test_dynamiclib.obj &\r
        $(OBJS)\test_environ.obj &\r
+       $(OBJS)\test_metatest.obj &\r
        $(OBJS)\test_misctests.obj &\r
        $(OBJS)\test_module.obj &\r
        $(OBJS)\test_pathlist.obj &\r
        $(OBJS)\test_misctests.obj &\r
        $(OBJS)\test_module.obj &\r
        $(OBJS)\test_pathlist.obj &\r
@@ -540,6 +541,9 @@ $(OBJS)\test_dynamiclib.obj :  .AUTODEPEND .\misc\dynamiclib.cpp
 $(OBJS)\test_environ.obj :  .AUTODEPEND .\misc\environ.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
 $(OBJS)\test_environ.obj :  .AUTODEPEND .\misc\environ.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
+$(OBJS)\test_metatest.obj :  .AUTODEPEND .\misc\metatest.cpp\r
+       $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
+\r
 $(OBJS)\test_misctests.obj :  .AUTODEPEND .\misc\misctests.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
 $(OBJS)\test_misctests.obj :  .AUTODEPEND .\misc\misctests.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
diff --git a/tests/misc/metatest.cpp b/tests/misc/metatest.cpp
new file mode 100644 (file)
index 0000000..1fcefd2
--- /dev/null
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/misc/metatest.cpp
+// Purpose:     Test template meta-programming constructs
+// Author:      Jaakko Salli
+// RCS-ID:      $Id$
+// Copyright:   (c) the wxWidgets team
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+#   pragma hdrstop
+#endif
+
+#include "wx/object.h"
+#include "wx/meta/pod.h"
+#include "wx/meta/movable.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class MetaProgrammingTestCase : public CppUnit::TestCase
+{
+public:
+    MetaProgrammingTestCase() { }
+
+private:
+    CPPUNIT_TEST_SUITE( MetaProgrammingTestCase );
+        CPPUNIT_TEST( IsPod );
+        CPPUNIT_TEST( IsMovable );
+    CPPUNIT_TEST_SUITE_END();
+
+    void IsPod();
+    void IsMovable();
+
+    DECLARE_NO_COPY_CLASS(MetaProgrammingTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( MetaProgrammingTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MetaProgrammingTestCase,
+                                       "MetaProgrammingTestCase" );
+
+
+void MetaProgrammingTestCase::IsPod()
+{
+    CPPUNIT_ASSERT(wxIsPod<bool>::value);
+    CPPUNIT_ASSERT(wxIsPod<signed int>::value);
+    CPPUNIT_ASSERT(wxIsPod<double>::value);
+#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
+    CPPUNIT_ASSERT(wxIsPod<wxObject*>::value);
+#endif
+    CPPUNIT_ASSERT(!wxIsPod<wxObject>::value);
+}
+
+void MetaProgrammingTestCase::IsMovable()
+{
+    CPPUNIT_ASSERT(wxIsMovable<bool>::value);
+    CPPUNIT_ASSERT(wxIsMovable<signed int>::value);
+    CPPUNIT_ASSERT(wxIsMovable<double>::value);
+#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
+    CPPUNIT_ASSERT(wxIsMovable<wxObject*>::value);
+#endif
+    CPPUNIT_ASSERT(!wxIsMovable<wxObject>::value);
+}
index 3a0a5af5f3360046e566fac726b8c15e7e70baf6..bb1d82192c3420b1fd9b13fa1abc16126929ea23 100644 (file)
@@ -61,6 +61,7 @@
             mbconv/mbconvtest.cpp
             misc/dynamiclib.cpp
             misc/environ.cpp
             mbconv/mbconvtest.cpp
             misc/dynamiclib.cpp
             misc/environ.cpp
+            misc/metatest.cpp
             misc/misctests.cpp
             misc/module.cpp
             misc/pathlist.cpp
             misc/misctests.cpp
             misc/module.cpp
             misc/pathlist.cpp
index 976585634a7f02f16e29f5a9493453e3cb0b94b1..83fef0ef6feebd39f91e68fbd98d14c4cc0891c8 100644 (file)
@@ -405,6 +405,10 @@ SOURCE=.\streams\memstream.cpp
 # End Source File\r
 # Begin Source File\r
 \r
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\misc\metatest.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\thread\misc.cpp\r
 # End Source File\r
 # Begin Source File\r
 SOURCE=.\thread\misc.cpp\r
 # End Source File\r
 # Begin Source File\r
index 48f402dfe5708ab31628a25a59b8bd01d42e49bc..b593bc6545ac7dbc11dc9ed40821645dca3f12d2 100644 (file)
                        <File\r
                                RelativePath=".\streams\memstream.cpp">\r
                        </File>\r
                        <File\r
                                RelativePath=".\streams\memstream.cpp">\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\metatest.cpp">\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\misc.cpp">\r
                        </File>\r
                        <File\r
                                RelativePath=".\thread\misc.cpp">\r
                        </File>\r
index ee86d82baa04a703f166631bde4bbd2b42050b0e..d6881f816d19091ce4d479d1355d0bb2df99c9a4 100644 (file)
                                RelativePath=".\streams\memstream.cpp"\r
                                >\r
                        </File>\r
                                RelativePath=".\streams\memstream.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\metatest.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\misc.cpp"\r
                                >\r
                        <File\r
                                RelativePath=".\thread\misc.cpp"\r
                                >\r
index 74ea5490fc766050a8b92429fd6e0f900488ecfb..4f139224530c81bdd5fb059289f7033632506ad5 100644 (file)
                                RelativePath=".\streams\memstream.cpp"\r
                                >\r
                        </File>\r
                                RelativePath=".\streams\memstream.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\metatest.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\misc.cpp"\r
                                >\r
                        <File\r
                                RelativePath=".\thread\misc.cpp"\r
                                >\r
index 724fee3a4f11ef550dabeb1d21694ce84153f926..477b0150ee87e3b990a535ad17e56f244ba0fb3f 100644 (file)
@@ -353,6 +353,7 @@ wx/meta/convertible.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
+wx/meta/pod.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h
index bb516bbf4391ed80351c1610df6cb03b751bcca4..6b03b7b87240899fa4751f9b56b3bc36432abad5 100644 (file)
@@ -258,6 +258,7 @@ wx/meta/convertible.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
+wx/meta/pod.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h
index 46ee82ce44104d41bb50e41f8769f724a267211a..6f73f7d3b4c7a734c2fd6e2126ba34b719c6d743 100644 (file)
@@ -282,6 +282,7 @@ wx/meta/convertible.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
 wx/meta/if.h
 wx/meta/int2type.h
 wx/meta/movable.h
+wx/meta/pod.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h
 wx/fswatcher.h
 wx/generic/fswatcher.h
 wx/unix/app.h