Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-08-15 13:37:45


Author: matus.chochlik
Date: 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
New Revision: 48163
URL: http://svn.boost.org/trac/boost/changeset/48163

Log:
[mirror 0.2.x]
- test suite update
Added:
   sandbox/mirror/libs/mirror/test/classes.hpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/classes_ct_01.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/classes_ct_02.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/classes_ct_03.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/classes_ct_04.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/types_ct_05.cpp (contents, props changed)
Text files modified:
   sandbox/mirror/libs/mirror/test/Jamfile.v2 | 5 +++++
   1 files changed, 5 insertions(+), 0 deletions(-)

Modified: sandbox/mirror/libs/mirror/test/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/test/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/test/Jamfile.v2 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -24,7 +24,12 @@
          [ compile types_ct_02.cpp ]
          [ compile types_ct_03.cpp ]
          [ compile types_ct_04.cpp ]
+ [ compile types_ct_05.cpp ]
          [ run types_rt_01.cpp ]
          [ run types_rt_02.cpp ]
+ [ compile classes_ct_01.cpp ]
+ [ compile classes_ct_02.cpp ]
+ [ compile classes_ct_03.cpp ]
+ [ compile classes_ct_04.cpp ]
     ;
 

Added: sandbox/mirror/libs/mirror/test/classes.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/classes.hpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,272 @@
+/**
+ * \file test/classes.hpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Several test classes
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef BOOST_MIRROR_LIBS_MIRROR_TEST_CLASSES_HPP
+#define BOOST_MIRROR_LIBS_MIRROR_TEST_CLASSES_HPP
+
+#include "./namespaces.hpp"
+
+namespace test {
+
+ struct A
+ {
+ long a1;
+ long a2;
+ long a3;
+ A(void): a1(1L), a2(2L), a3(3L){ }
+ };
+
+ struct B : virtual A
+ {
+ static int b1;
+ int b2;
+ B(void):b2(4){ }
+ };
+ int B::b1 = 0;
+
+ struct C : virtual A
+ {
+ mutable double c1;
+ double c2;
+ C(void):c1(5.0),c2(6.0){ }
+ };
+
+ struct D : virtual A
+ {
+ const short d1;
+ volatile short d2;
+ D(void):d1(7), d2(8){ }
+ };
+
+ struct E : B, C, D
+ {
+ static const float e;
+ };
+ const float E::e = 1.0f;
+
+ struct F : virtual E
+ {
+ bool f1;
+ bool f2;
+ F(void):f1(true),f2(false){ }
+ };
+
+ struct G : virtual E
+ {
+ char g1;
+ char g2;
+ char g3;
+ G(void):g1('a'),g2('b'),g3('c'){ }
+ };
+
+ struct H : F, G
+ {
+ wchar_t h1;
+ wchar_t h2;
+ wchar_t h3;
+ H(void):h1(L'a'),h2(L'b'),h3(L'c'){ }
+ };
+
+ class I
+ {
+ public:
+ const ::std::string& get_i(void) const
+ {
+ return i;
+ }
+
+ void set_i(const ::std::string& _i)
+ {
+ i = _i;
+ }
+ private:
+ ::std::string i;
+ };
+
+ class J
+ {
+ public:
+ const ::std::wstring& get_j(void) const
+ {
+ return j;
+ }
+
+ void set_j(const ::std::wstring& _j)
+ {
+ j = _j;
+ }
+ private:
+ ::std::wstring j;
+ };
+
+ class K : public I, public J
+ {
+ public:
+ // 'generated', read only attribute without
+ // any actual storage
+ int get_k_ro(void) const
+ {
+ return 1;
+ }
+ // 'consumed', write only attribute without
+ // any actual storage
+ void set_k_wo(int _k)
+ {
+ }
+ };
+
+} // namespace test
+
+
+namespace boost {
+namespace mirror {
+
+/** class ::test::A */
+BOOST_MIRROR_REG_TYPE(::test, A)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::A)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a2)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a3)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::B */
+BOOST_MIRROR_REG_TYPE(::test, B)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::B)
+ BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::A)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::B)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(static, int, b1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, int, b2)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::C */
+BOOST_MIRROR_REG_TYPE(::test, C)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::C)
+ BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::A)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::C)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(mutable, double, c1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, double, c2)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::D */
+BOOST_MIRROR_REG_TYPE(::test, D)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::D)
+ BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::A)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::D)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ _, const short, d1,
+ {return instance.d1;},
+ {dest = DestType(instance.d1);},
+ { } // no setting
+ )
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, volatile short, d2)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::E */
+BOOST_MIRROR_REG_TYPE(::test, E)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::E)
+ BOOST_MIRROR_REG_BASE_CLASS(0, public, ::test::B)
+ BOOST_MIRROR_REG_BASE_CLASS(1, public, ::test::C)
+ BOOST_MIRROR_REG_BASE_CLASS(2, public, ::test::D)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::E)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ static, const float, e,
+ {return instance.e;},
+ {dest = DestType(instance.e);},
+ { } // no setting
+ )
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::F */
+BOOST_MIRROR_REG_TYPE(::test, F)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::F)
+ BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::E)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::F)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, bool, f1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, bool, f2)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::G */
+BOOST_MIRROR_REG_TYPE(::test, G)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::G)
+ BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::E)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::G)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g2)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g3)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::H */
+BOOST_MIRROR_REG_TYPE(::test, H)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::H)
+ BOOST_MIRROR_REG_BASE_CLASS(0, public, ::test::F)
+ BOOST_MIRROR_REG_BASE_CLASS(1, public, ::test::G)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::H)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, wchar_t, h1)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, wchar_t, h2)
+ BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, wchar_t, h3)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::I */
+BOOST_MIRROR_REG_TYPE(::test, I)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::I)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ _, ::std::string, i,
+ {return instance.get_i();},
+ {dest = DestType(instance.get_i());},
+ {instance.set_i(value);}
+ )
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::J */
+BOOST_MIRROR_REG_TYPE(::test, J)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::J)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ _, ::std::wstring, j,
+ {return instance.get_j();},
+ {dest = DestType(instance.get_j());},
+ {instance.set_j(value);}
+ )
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+/** class ::test::K */
+BOOST_MIRROR_REG_TYPE(::test, K)
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::K)
+ BOOST_MIRROR_REG_BASE_CLASS(0, public, ::test::I)
+ BOOST_MIRROR_REG_BASE_CLASS(1, public, ::test::J)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::K)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ _, int, k_ro,
+ {return instance.get_k_ro();},
+ {dest = DestType(instance.get_k_ro());},
+ { } // no setting
+ )
+ BOOST_MIRROR_REG_CLASS_ATTRIB(
+ _, int, k_wo,
+ {return 0;}, // dummy default
+ {dest = DestType(0);},
+ {instance.set_k_wo(value);}
+ )
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif // include guard
+

Added: sandbox/mirror/libs/mirror/test/classes_ct_01.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/classes_ct_01.cpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,140 @@
+/**
+ * \file test/classes_ct_01.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing class registration and reflection.
+ *
+ * this test focuses (indirectly) on the registering,
+ * inheritance of meta_class from meta_type, traits
+ * and cooperation with MPL
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+// MPL
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+//
+#include <boost/type_traits/is_same.hpp>
+//
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/traits/reflects_global_scope.hpp>
+#include <boost/mirror/traits/reflects_namespace.hpp>
+#include <boost/mirror/traits/reflects_class.hpp>
+//
+#include "./namespaces.hpp"
+#include "./classes.hpp"
+#include "./test.hpp"
+
+template <typename MetaObject>
+struct get_scope
+{
+ typedef typename MetaObject::scope type;
+};
+
+template <typename MetaType>
+struct get_reflected_type
+{
+ typedef typename MetaType::reflected_type type;
+};
+
+
+void test_main()
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ typedef mpl::vector<
+ ::test::A,
+ ::test::B,
+ ::test::C,
+ ::test::D,
+ ::test::E,
+ ::test::F,
+ ::test::G,
+ ::test::H,
+ ::test::I,
+ ::test::J,
+ ::test::K
+ > some_classes;
+
+ // none of the classes is defined in the global scope
+ BOOST_MPL_ASSERT_NOT(( mpl::accumulate<
+ some_classes,
+ mpl::false_,
+ mpl::or_<
+ mpl::_1,
+ mirror::reflects_global_scope<
+ get_scope<
+ BOOST_MIRRORED_CLASS(mpl::_2)
+ >
+ >
+ >
+ >::type ));
+
+ // all off the classes are defined in a namespace defined
+ // (directly) under the global scope
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mirror::reflects_namespace<
+ get_scope<
+ BOOST_MIRRORED_CLASS(mpl::_2)
+ >
+ >
+ >
+ >::type ));
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mirror::reflects_global_scope<
+ get_scope<get_scope<
+ BOOST_MIRRORED_CLASS(mpl::_2)
+ > >
+ >
+ >
+ >::type ));
+
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mirror::reflects_class<
+ BOOST_MIRRORED_CLASS(mpl::_2)
+ >
+ >
+ >::type ));
+
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ is_same<
+ get_reflected_type<BOOST_MIRRORED_CLASS(mpl::_2)>,
+ mpl::_2
+ >
+ >
+ >::type ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: classes compile test 01");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/classes_ct_02.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/classes_ct_02.cpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,110 @@
+/**
+ * \file test/classes_ct_02.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing class registration and reflection.
+ *
+ * this test focuses (indirectly) on the registering,
+ * on the count of member attributes, the size algorithm
+ * and cooperation with MPL.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+// MPL
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/equal_to.hpp>
+//
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/algorithm/size.hpp>
+//
+#include "./namespaces.hpp"
+#include "./classes.hpp"
+#include "./test.hpp"
+
+template <typename MetaClass>
+struct get_own_attribs
+{
+ typedef typename MetaClass::attributes type;
+};
+
+template <typename MetaClass>
+struct get_all_attribs
+{
+ typedef typename MetaClass::all_attributes type;
+};
+
+
+void test_main()
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ typedef mpl::vector<
+ // < class, own_attrib_count, all_attrib_count >
+ mpl::vector< ::test::A, mpl::int_<3> , mpl::int_< 3> >,
+ mpl::vector< ::test::B, mpl::int_<2> , mpl::int_< 5> >,
+ mpl::vector< ::test::C, mpl::int_<2> , mpl::int_< 5> >,
+ mpl::vector< ::test::D, mpl::int_<2> , mpl::int_< 5> >,
+ mpl::vector< ::test::E, mpl::int_<1> , mpl::int_<10> >,
+ mpl::vector< ::test::F, mpl::int_<2> , mpl::int_<12> >,
+ mpl::vector< ::test::G, mpl::int_<3> , mpl::int_<13> >,
+ mpl::vector< ::test::H, mpl::int_<3> , mpl::int_<18> >,
+ mpl::vector< ::test::I, mpl::int_<1> , mpl::int_< 1> >,
+ mpl::vector< ::test::J, mpl::int_<1> , mpl::int_< 1> >,
+ mpl::vector< ::test::K, mpl::int_<2> , mpl::int_< 4> >
+ > some_classes;
+
+ // check the counts of own attributes
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mpl::equal_to<
+ mirror::size< get_own_attribs<
+ BOOST_MIRRORED_CLASS(
+ mpl::front<mpl::_2>
+ )
+ > >,
+ mpl::at<mpl::_2, mpl::int_<1> >
+ >
+ >
+ >::type ));
+
+ // check the counts of all attributes
+ BOOST_MPL_ASSERT(( mpl::accumulate<
+ some_classes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mpl::equal_to<
+ mirror::size< get_all_attribs<
+ BOOST_MIRRORED_CLASS(
+ mpl::front<mpl::_2>
+ )
+ > >,
+ mpl::at<mpl::_2, mpl::int_<2> >
+ >
+ >
+ >::type ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: classes compile test 02");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/classes_ct_03.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/classes_ct_03.cpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,120 @@
+/**
+ * \file test/classes_ct_03.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing class registration and reflection.
+ *
+ * this test focuses (indirectly) on the registering,
+ * on the count of member attributes, the size algorithm
+ * and cooperation with MPL.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+// MPL_ASSERT
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+//
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/algorithm/at.hpp>
+//
+#include "./namespaces.hpp"
+#include "./classes.hpp"
+#include "./test.hpp"
+
+
+void test_main()
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ ::test::H h;
+ typedef BOOST_MIRRORED_CLASS(::test::H) meta_H;
+ //
+ //
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<0> >::type::type *,
+ BOOST_TYPEOF(&h.a1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<1> >::type::type *,
+ BOOST_TYPEOF(&h.a2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<2> >::type::type *,
+ BOOST_TYPEOF(&h.a3)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<3> >::type::type *,
+ BOOST_TYPEOF(&h.b1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<4> >::type::type *,
+ BOOST_TYPEOF(&h.b2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<5> >::type::type *,
+ BOOST_TYPEOF(&h.c1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<6> >::type::type *,
+ BOOST_TYPEOF(&h.c2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<7> >::type::type *,
+ BOOST_TYPEOF(&h.d1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<8> >::type::type *,
+ BOOST_TYPEOF(&h.d2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<9> >::type::type *,
+ BOOST_TYPEOF(&h.e)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<10> >::type::type *,
+ BOOST_TYPEOF(&h.f1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<11> >::type::type *,
+ BOOST_TYPEOF(&h.f2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<12> >::type::type *,
+ BOOST_TYPEOF(&h.g1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<13> >::type::type *,
+ BOOST_TYPEOF(&h.g2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<14> >::type::type *,
+ BOOST_TYPEOF(&h.g3)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<15> >::type::type *,
+ BOOST_TYPEOF(&h.h1)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<16> >::type::type *,
+ BOOST_TYPEOF(&h.h2)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ at<meta_H::all_attributes, mpl::int_<17> >::type::type *,
+ BOOST_TYPEOF(&h.h3)
+ > ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: classes compile test 03");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/classes_ct_04.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/classes_ct_04.cpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,102 @@
+/**
+ * \file test/classes_ct_04.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing class registration and reflection.
+ *
+ * Tests the accumulate algorithm on meta_class attributes
+ * and checks the attribute types.
+ *
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+// MPL_ASSERT
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/equal.hpp>
+#include <boost/mpl/transform_view.hpp>
+//
+#include <boost/type_traits/add_pointer.hpp>
+//
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/algorithm/accumulate.hpp>
+//
+#include "./namespaces.hpp"
+#include "./classes.hpp"
+#include "./test.hpp"
+
+template <typename MetaAttribute>
+struct get_attrib_type
+{
+ typedef typename MetaAttribute::type type;
+};
+
+void test_main()
+{
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ ::test::H h;
+ typedef BOOST_MIRRORED_CLASS(::test::H) meta_H;
+ // define a forward op
+ typedef mpl::lambda<mpl::push_back<
+ mpl::_1,
+ add_pointer<
+ get_attrib_type<mpl::_2>
+ >
+ > >::type accumulate_op;
+ //
+ // use the accumulate algorithm to get the typelist
+ typedef accumulate<
+ meta_H::all_attributes,
+ mpl::vector0<>,
+ accumulate_op
+ >::type attrib_types_1;
+ //
+ // use the typelist from the meta_attribs
+ typedef mpl::transform_view<
+ meta_H::all_attributes::type_list,
+ ::boost::add_pointer<mpl::_1>
+ >::type attrib_types_2;
+ //
+ // make a 'hand-made' list
+ typedef mpl::vector<
+ BOOST_TYPEOF(&h.a1),
+ BOOST_TYPEOF(&h.a2),
+ BOOST_TYPEOF(&h.a3),
+ BOOST_TYPEOF(&h.b1),
+ BOOST_TYPEOF(&h.b2),
+ BOOST_TYPEOF(&h.c1),
+ BOOST_TYPEOF(&h.c2),
+ BOOST_TYPEOF(&h.d1),
+ BOOST_TYPEOF(&h.d2),
+ BOOST_TYPEOF(&h.e),
+ BOOST_TYPEOF(&h.f1),
+ BOOST_TYPEOF(&h.f2),
+ BOOST_TYPEOF(&h.g1),
+ BOOST_TYPEOF(&h.g2),
+ BOOST_TYPEOF(&h.g3),
+ BOOST_TYPEOF(&h.h1),
+ BOOST_TYPEOF(&h.h2),
+ BOOST_TYPEOF(&h.h3)
+ > attrib_types_3;
+ //
+ // and compare them
+ BOOST_MPL_ASSERT(( mpl::equal<attrib_types_1, attrib_types_2> ));
+ BOOST_MPL_ASSERT(( mpl::equal<attrib_types_2, attrib_types_3> ));
+ BOOST_MPL_ASSERT(( mpl::equal<attrib_types_1, attrib_types_3> ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: classes compile test 03");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/types_ct_05.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/types_ct_05.cpp 2008-08-15 13:37:44 EDT (Fri, 15 Aug 2008)
@@ -0,0 +1,93 @@
+/**
+ * \file test/types_ct_05.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing cooperation with BOOST_TYPEOF
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/typeof/typeof.hpp>
+//
+#include <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/meta_type.hpp>
+//
+#include "./namespaces.hpp"
+#include "./types.hpp"
+#include "./test.hpp"
+
+int foo(short, long);
+
+void test_main()
+{
+ using namespace ::boost;
+ //
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(false || true)::reflected_type,
+ bool
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF('c')::reflected_type,
+ char
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(L'w')::reflected_type,
+ wchar_t
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF("a+b")::reflected_type,
+ const char [4]
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(L"v+w")::reflected_type,
+ const wchar_t [4]
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(1+2)::reflected_type,
+ int
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(3L + 4L)::reflected_type,
+ long
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(5.0f + 6.0f)::reflected_type,
+ float
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(7.0 + 8.0)::reflected_type,
+ double
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(::std::string("x+y"))::reflected_type,
+ ::std::string
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(::std::wstring(L"x+y"))::reflected_type,
+ ::std::wstring
+ > ));
+ //
+ const int i = 10;
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(&i)::reflected_type,
+ const int *
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEOF(&foo)::reflected_type,
+ int (*)(short, long)
+ > ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: types compile test 05");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk