Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51424 - in sandbox/mirror: boost/mirror/intrinsic/detail boost/mirror/iterator/detail libs/mirror/test
From: chochlik_at_[hidden]
Date: 2009-02-24 05:15:49


Author: matus.chochlik
Date: 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
New Revision: 51424
URL: http://svn.boost.org/trac/boost/changeset/51424

Log:
[mirror 0.3.x]
- minor updates to the iterator/intrinsic meta-function implementation
- added suport for iteration through global_list items
- update of the testsuite

Added:
   sandbox/mirror/boost/mirror/iterator/detail/global_list_iterator.hpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/intrinsic/detail/positional.hpp | 58 +------------------------------------
   sandbox/mirror/boost/mirror/iterator/detail/base_class_iterator.hpp | 1
   sandbox/mirror/boost/mirror/iterator/detail/iterator.hpp | 1
   sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp | 61 ++++++++++++++++++++++++++++++++++++++-
   4 files changed, 63 insertions(+), 58 deletions(-)

Modified: sandbox/mirror/boost/mirror/intrinsic/detail/positional.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/intrinsic/detail/positional.hpp (original)
+++ sandbox/mirror/boost/mirror/intrinsic/detail/positional.hpp 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
@@ -27,62 +27,8 @@
                 class Arg1,
                 template <class, class> class Implementation
>
- struct position_getter_impl_1 { };
-
- /** Specialization of position_getter_impl_1<MetaObjectSequence>
- * for meta_class_attributes<>
- */
- template <
- class Class,
- class VariantTag,
- class Arg1,
- template <class, class> class Implementation
- >
- struct position_getter_impl_1<
- meta_class_attributes<Class, VariantTag>,
- Arg1,
- Implementation
- >
- : Implementation<
- meta_class_attributes<Class, VariantTag>,
- Arg1
- >{ };
-
- /** Specialization of for_each_impl_1<MetaObjectSequence>
- * for meta_class_all_attributes<>
- */
- template <
- class Class,
- class VariantTag,
- class Arg1,
- template <class, class> class Implementation
- >
- struct position_getter_impl_1<
- meta_class_all_attributes<Class, VariantTag>,
- Arg1,
- Implementation
- >
- : Implementation<
- meta_class_all_attributes<Class, VariantTag>,
- Arg1
- >{ };
-
- /** Specialization of position_getter_impl_1<MetaObjectSequence>
- * for meta_base_classes<>
- */
- template <
- class Class,
- class VariantTag,
- class Arg1,
- template <class, class> class Implementation
- >
- struct position_getter_impl_1<
- meta_base_classes<Class, VariantTag>,
- Arg1,
- Implementation
- >
- : Implementation<
- meta_base_classes<Class, VariantTag>,
+ struct position_getter_impl_1 : Implementation<
+ MetaObjectSequence,
                 Arg1
>{ };
 

Modified: sandbox/mirror/boost/mirror/iterator/detail/base_class_iterator.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/iterator/detail/base_class_iterator.hpp (original)
+++ sandbox/mirror/boost/mirror/iterator/detail/base_class_iterator.hpp 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/mirror/iterator/detail/common_iterator.hpp>
 #include <boost/mirror/meta_inheritance.hpp>
+#include <boost/mirror/intrinsic/at.hpp>
 
 
 namespace boost {

Added: sandbox/mirror/boost/mirror/iterator/detail/global_list_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/iterator/detail/global_list_iterator.hpp 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
@@ -0,0 +1,53 @@
+/**
+ * \file boost/mirror/iterator/detail/global_list_iterator.hpp
+ * Iterators for iterating through meta-object sequences
+ *
+ * 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_ITERATOR_DETAIL_GLOBAL_LIST_ITERATOR_HPP
+#define BOOST_MIRROR_ITERATOR_DETAIL_GLOBAL_LIST_ITERATOR_HPP
+
+#include <boost/mirror/iterator/detail/common_iterator.hpp>
+#include <boost/mirror/detail/global_list.hpp>
+#include <boost/mirror/intrinsic/at.hpp>
+
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+ /** Iterator for iterating through the items
+ * in a global_list
+ */
+ template <
+ class Selector,
+ class Counter
+ >
+ struct iterator_pointee_selector<
+ counter::global_list<Selector, Counter>
+ >
+ {
+ template <
+ class GlobalList,
+ class ItemPos,
+ class UnaryPredicate
+ >
+ struct apply
+ {
+ typedef typename at<
+ GlobalList,
+ ItemPos
+ >::type type;
+ };
+ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/iterator/detail/iterator.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/iterator/detail/iterator.hpp (original)
+++ sandbox/mirror/boost/mirror/iterator/detail/iterator.hpp 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/mirror/iterator/detail/attribute_iterator.hpp>
 #include <boost/mirror/iterator/detail/base_class_iterator.hpp>
+#include <boost/mirror/iterator/detail/global_list_iterator.hpp>
 
 namespace boost {
 namespace mirror {

Modified: sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp (original)
+++ sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp 2009-02-24 05:15:48 EST (Tue, 24 Feb 2009)
@@ -19,12 +19,20 @@
 #include <boost/mpl/front.hpp>
 #include <boost/mpl/back.hpp>
 #include <boost/mpl/and.hpp>
+#include <boost/mpl/lambda.hpp>
 // namespace registering
 #include <boost/mirror/meta_namespace.hpp>
-// intrinsic meta-functions
+// intrinsic meta-functions, iterators and algorithms
 #include <boost/mirror/intrinsic/size.hpp>
 #include <boost/mirror/intrinsic/at.hpp>
 #include <boost/mirror/intrinsic/empty.hpp>
+#include <boost/mirror/intrinsic/begin.hpp>
+#include <boost/mirror/intrinsic/end.hpp>
+#include <boost/mirror/iterators.hpp>
+#include <boost/mirror/algorithm/find_if.hpp>
+//
+#include <boost/mirror/traits/reflects_global_scope.hpp>
+#include <boost/mirror/traits/reflects_namespace.hpp>
 //
 #include "./test.hpp"
 
@@ -57,9 +65,9 @@
 } // namespace mirror
 } // namespace boost
 
+
 void test_main()
 {
- using namespace ::std;
         using namespace ::boost;
         using namespace ::boost::mirror;
         //
@@ -67,8 +75,33 @@
         typedef BOOST_MIRRORED_NAMESPACE(::test) meta_test;
         //
 #ifdef BOOST_MIRROR_NO_GLOBAL_LISTS
+ // if the global lists are not available, then mirror does not
+ // reflect namespace members
+ //
         BOOST_MPL_ASSERT( empty< meta_test::members > );
         BOOST_MPL_ASSERT_RELATION( size< meta_test::members >::value, ==, 0);
+ BOOST_MPL_ASSERT((iterator_equal<
+ begin<meta_test::members>::type,
+ end<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT_NOT((iterator_not_equal<
+ begin<meta_test::members>::type,
+ end<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT((iterator_equal<
+ find_if<
+ meta_test::members,
+ mpl::lambda<reflects_namespace<mpl::_1> >::type
+ >::type,
+ end<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT((iterator_equal<
+ find_if<
+ meta_test::members,
+ mpl::lambda<reflects_global_scope<mpl::_1> >::type
+ >::type,
+ end<meta_test::members>::type
+ >));
 #else
         typedef mpl::vector<
                 mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::a), mpl::int_<0> >,
@@ -107,6 +140,30 @@
>
>
         ));
+ //
+ BOOST_MPL_ASSERT((iterator_not_equal<
+ begin<meta_test::members>::type,
+ end<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT_NOT((iterator_equal<
+ begin<meta_test::members>::type,
+ end<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT((iterator_equal<
+ find_if<
+ meta_test::members,
+ mpl::lambda<reflects_namespace<mpl::_1> >::type
+ >::type,
+ begin<meta_test::members>::type
+ >));
+ BOOST_MPL_ASSERT((iterator_equal<
+ find_if<
+ meta_test::members,
+ mpl::lambda<reflects_global_scope<mpl::_1> >::type
+ >::type,
+ end<meta_test::members>::type
+ >));
+
 #endif
 }
 


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