Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51416 - in sandbox/mirror: boost/mirror boost/mirror/detail boost/mirror/intrinsic libs/mirror/test
From: chochlik_at_[hidden]
Date: 2009-02-23 13:37:42


Author: matus.chochlik
Date: 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
New Revision: 51416
URL: http://svn.boost.org/trac/boost/changeset/51416

Log:
[mirror 0.3.x]
- update of the internal compile time counter facility
- update of the internal global_list
- added registration of nested namespaces of a namspace
- added a compile time meta-object-sequence of namespace members
- update of some of the intrinsic meta-functions

Added:
   sandbox/mirror/boost/mirror/detail/counter.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/detail/global_list.hpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/other_rt_01.cpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/other_rt_02.cpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/intrinsic/at.hpp | 16 ++++
   sandbox/mirror/boost/mirror/intrinsic/empty.hpp | 20 +++++-
   sandbox/mirror/boost/mirror/intrinsic/get_type_list.hpp | 4
   sandbox/mirror/boost/mirror/intrinsic/size.hpp | 19 +++++-
   sandbox/mirror/boost/mirror/meta_namespace.hpp | 120 +++++++++++++++++++++++++++-------------
   sandbox/mirror/libs/mirror/test/Jamfile.v2 | 3 +
   6 files changed, 132 insertions(+), 50 deletions(-)

Added: sandbox/mirror/boost/mirror/detail/counter.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/counter.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -0,0 +1,123 @@
+/**
+ * \file boost/mirror/detail/counter.hpp
+ *
+ * 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_META_DETAIL_COUNTER_HPP
+#define BOOST_MIRROR_META_DETAIL_COUNTER_HPP
+
+#include <boost/preprocessor/facilities/empty.hpp>
+
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/next_prior.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/identity.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#ifndef BOOST_MIRROR_COUNTER_LUID
+#ifdef __COUNTER__
+#define BOOST_MIRROR_COUNTER_LUID __COUNTER__
+#else
+#define BOOST_MIRROR_COUNTER_LUID __LINE__
+#define BOOST_MIRROR_COUNTER_UNRELIABLE
+#endif
+#endif
+
+namespace boost {
+namespace mirror {
+namespace counter {
+
+// local null-type
+typedef ::boost::mpl::int_<-1> null_;
+// the initial value of the counter
+typedef ::boost::mpl::int_<0> initial;
+
+// a fallback version of the get_next function
+template <class Selector>
+null_ get_next(Selector*, ...);
+
+// the get_next overload for the first incrementation
+template <class Selector>
+::boost::mpl::int_<1> get_next(Selector*, initial);
+
+template <class Selector, class Value, int InstId>
+struct current
+{
+ enum {instantiation_id = InstId};
+
+ typedef BOOST_TYPEOF(get_next((Selector*)0, Value())) next;
+
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::is_same<next, null_>,
+ ::boost::mpl::identity<Value>,
+ current<Selector, next, InstId>
+ >::type type;
+};
+
+template <class T> struct selector;
+
+} // namespace counter
+} // namespace mirror
+} // namespace boost
+
+/** This macro registers a selector for the given fully qualified
+ * type. This macro should be used inside of the ::boost::mirror
+ * namespace.
+ */
+#define BOOST_MIRROR_REGISTER_COUNTER_SELECTOR(FULLY_QUALIFIED_TYPE) \
+namespace counter { \
+template <> struct selector < FULLY_QUALIFIED_TYPE > { }; \
+} /** namespace counter */
+
+
+#define BOOST_MIRROR_COUNTER_CURRENT_COUNT(SELECTOR, LUID) \
+ ::boost::mirror::counter::current< \
+ ::boost::mirror::counter::selector< SELECTOR >, \
+ ::boost::mirror::counter::initial, LUID \
+ >::type
+
+#define BOOST_MIRROR_COUNTER_PREVIOUS_COUNT_BASE(SELECTOR, LUID, TYPENAME_KW) \
+ TYPENAME_KW ::boost::mpl::prior< \
+ TYPENAME_KW ::boost::mirror::counter::current< \
+ ::boost::mirror::counter::selector< SELECTOR >, \
+ ::boost::mirror::counter::initial, LUID \
+ >::type \
+ >:: type
+
+#define BOOST_MIRROR_COUNTER_PREVIOUS_COUNT(SELECTOR, LUID) \
+ BOOST_MIRROR_COUNTER_PREVIOUS_COUNT_BASE(SELECTOR, LUID, BOOST_PP_EMPTY())
+
+
+#define BOOST_MIRROR_COUNTER_INCREMENT_COUNTER(SELECTOR, LUID) \
+ ::boost::mpl::next< \
+ current< \
+ selector< SELECTOR>, \
+ initial, \
+ LUID \
+ >::type \
+ >::type get_next( \
+ selector< SELECTOR>*, \
+ current< selector< SELECTOR>, initial, LUID >::type \
+ );
+
+#define BOOST_MIRROR_COUNTER_CURRENT(SELECTOR) \
+ BOOST_MIRROR_COUNTER_CURRENT_COUNT( \
+ SELECTOR, \
+ BOOST_MIRROR_COUNTER_LUID \
+ )
+#define BOOST_MIRROR_COUNTER_PREVIOUS(SELECTOR) \
+ BOOST_MIRROR_COUNTER_PREVIOUS_COUNT(SELECTOR, BOOST_MIRROR_COUNTER_LUID)
+#define BOOST_MIRROR_COUNTER_INCREMENT(SELECTOR) \
+ BOOST_MIRROR_COUNTER_INCREMENT_COUNTER(SELECTOR, BOOST_MIRROR_COUNTER_LUID)
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/detail/global_list.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/global_list.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -0,0 +1,103 @@
+/**
+ * \file boost/mirror/detail/global_list.hpp
+ *
+ * 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_META_DETAIL_GLOBAL_LIST_HPP
+#define BOOST_MIRROR_META_DETAIL_GLOBAL_LIST_HPP
+
+#include <boost/mirror/detail/counter.hpp>
+
+
+namespace boost {
+namespace mirror {
+namespace counter {
+
+template <class Selector, class Counter>
+struct global_list;
+
+template <class Selector>
+struct global_list<Selector, initial>
+{
+ typedef ::boost::mpl::vector0<> type;
+};
+
+} // namespace counter
+
+#define BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(FULLY_QUALIFIED_TYPE) \
+ BOOST_MIRROR_REGISTER_COUNTER_SELECTOR(FULLY_QUALIFIED_TYPE)
+
+
+#define BOOST_MIRROR_GET_GLOBAL_LIST_BASE_WRAPPER(SELECTOR, LUID, TYPENAME_KW) \
+ TYPENAME_KW ::boost::mirror::counter::global_list< \
+ ::boost::mirror::counter::selector< SELECTOR>, \
+ BOOST_MIRROR_COUNTER_PREVIOUS_COUNT_BASE( \
+ SELECTOR, \
+ LUID, \
+ TYPENAME_KW \
+ ) \
+ >
+
+#define BOOST_MIRROR_GET_GLOBAL_LIST_BASE(SELECTOR, LUID, TYPENAME_KW) \
+ BOOST_MIRROR_GET_GLOBAL_LIST_BASE_WRAPPER( \
+ SELECTOR, \
+ LUID, \
+ TYPENAME_KW \
+ )::type
+
+#define BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(SELECTOR, ITEM, LUID) \
+namespace counter { \
+template <> \
+struct global_list< \
+ ::boost::mirror::counter::selector< SELECTOR>, \
+ BOOST_MIRROR_COUNTER_CURRENT_COUNT(SELECTOR, LUID) \
+> \
+{ \
+ typedef ::boost::mpl::push_back< \
+ BOOST_MIRROR_GET_GLOBAL_LIST_BASE( \
+ SELECTOR, \
+ LUID, \
+ BOOST_PP_EMPTY() \
+ ), \
+ ITEM \
+ >::type type; \
+}; \
+BOOST_MIRROR_COUNTER_INCREMENT_COUNTER(SELECTOR, LUID) \
+}
+
+
+#define BOOST_MIRROR_GET_GLOBAL_LIST(SELECTOR) \
+ BOOST_MIRROR_GET_GLOBAL_LIST_BASE( \
+ SELECTOR, \
+ BOOST_MIRROR_COUNTER_LUID, \
+ BOOST_PP_EMPTY() \
+ )
+
+#ifndef BOOST_MIRROR_COUNTER_UNRELIABLE
+
+#define BOOST_MIRROR_ADD_TO_GLOBAL_LIST(SELECTOR, ITEM) \
+ BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE( \
+ SELECTOR, \
+ ITEM, \
+ BOOST_MIRROR_COUNTER_LUID \
+ )
+
+#else // BOOST_MIRROR_COUNTER_UNRELIABLE
+
+// if we don't have a reliable counter adding to
+// global lists is disabled
+#define BOOST_MIRROR_ADD_TO_GLOBAL_LIST(SELECTOR, ITEM)
+
+#define BOOST_MIRROR_NO_GLOBAL_LISTS
+
+#endif // BOOST_MIRROR_COUNTER_UNRELIABLE
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/intrinsic/at.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/intrinsic/at.hpp (original)
+++ sandbox/mirror/boost/mirror/intrinsic/at.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -12,6 +12,8 @@
 
 #include <boost/mirror/intrinsic/detail/attribute_at.hpp>
 #include <boost/mirror/intrinsic/detail/base_class_at.hpp>
+#include <boost/mirror/detail/global_list.hpp>
+#include <boost/mpl/at.hpp>
 
 namespace boost {
 namespace mirror {
@@ -34,7 +36,7 @@
                 Position
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of at_impl<MetaObjectSequence>
          * for meta_class_all_attributes<>
          */
         template <class Class, class VariantTag, class Position>
@@ -45,7 +47,7 @@
                 Position
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of at_impl<MetaObjectSequence>
          * for meta_base_classes<>
          */
         template <class Class, class VariantTag, class Position>
@@ -55,6 +57,16 @@
                 Position
>{ };
 
+ /** Specialization of at_impl<MetaObjectSequence>
+ * for global_list<>
+ */
+ template <class Selector, class Counter, class Position>
+ struct at_impl<counter::global_list<Selector, Counter>, Position >
+ : mpl::at<
+ typename counter::global_list<Selector, Counter>::type,
+ Position
+ >{ };
+
 } // namespace detail
 
 template <

Modified: sandbox/mirror/boost/mirror/intrinsic/empty.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/intrinsic/empty.hpp (original)
+++ sandbox/mirror/boost/mirror/intrinsic/empty.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -19,13 +19,13 @@
 namespace mirror {
 namespace detail {
 
- /** Declaration of the default at_impl
+ /** Declaration of the default empty_impl
          * helper template.
          */
         template <class MetaObjectSequence>
         struct empty_impl { };
 
- /** Specialization of at_impl<MetaObjectSequence>
+ /** Specialization of empty_impl<MetaObjectSequence>
          * for meta_class_attributes<>
          */
         template <class Class, class VariantTag>
@@ -37,7 +37,7 @@
>::type_list
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of empty_impl<MetaObjectSequence>
          * for meta_class_all_attributes<>
          */
         template <class Class, class VariantTag>
@@ -49,7 +49,7 @@
>::type_list
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of empty_impl<MetaObjectSequence>
          * for meta_base_classes<>
          */
         template <class Class, class VariantTag>
@@ -61,6 +61,18 @@
>::list
>{ };
 
+ /** Specialization of empty_impl<MetaObjectSequence>
+ * for global_list<>
+ */
+ template <class Selector, class Counter>
+ struct empty_impl<counter::global_list<Selector, Counter> >
+ : mpl::empty<
+ typename counter::global_list<
+ Selector,
+ Counter
+ >::type_list
+ >{ };
+
 } // namespace detail
 
 template <class MetaObjectSequence>

Modified: sandbox/mirror/boost/mirror/intrinsic/get_type_list.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/intrinsic/get_type_list.hpp (original)
+++ sandbox/mirror/boost/mirror/intrinsic/get_type_list.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -36,7 +36,7 @@
>::type_list type;
         };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of get_type_list_impl<MetaObjectSequence>
          * for meta_class_all_attributes<>
          */
         template <class Class, class VariantTag>
@@ -48,7 +48,7 @@
>::type_list type;
         };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of get_type_list_impl<MetaObjectSequence>
          * for meta_base_classes<>
          */
         template <class MetaInheritance>

Modified: sandbox/mirror/boost/mirror/intrinsic/size.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/intrinsic/size.hpp (original)
+++ sandbox/mirror/boost/mirror/intrinsic/size.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -14,6 +14,7 @@
 
 #include <boost/mirror/meta_attributes.hpp>
 #include <boost/mirror/meta_inheritance.hpp>
+#include <boost/mirror/detail/global_list.hpp>
 
 namespace boost {
 namespace mirror {
@@ -25,7 +26,7 @@
         template <class MetaObjectSequence>
         struct size_impl { };
 
- /** Specialization of at_impl<MetaObjectSequence>
+ /** Specialization of size_impl<MetaObjectSequence>
          * for meta_class_attributes<>
          */
         template <class Class, class VariantTag>
@@ -37,7 +38,7 @@
>::type_list
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of size_impl<MetaObjectSequence>
          * for meta_class_all_attributes<>
          */
         template <class Class, class VariantTag>
@@ -49,7 +50,7 @@
>::type_list
>{ };
 
- /** Specialization of for_each_impl<MetaObjectSequence>
+ /** Specialization of size_impl<MetaObjectSequence>
          * for meta_base_classes<>
          */
         template <class Class, class VariantTag>
@@ -61,6 +62,18 @@
>::list
>{ };
 
+ /** Specialization of size_impl<MetaObjectSequence>
+ * for counter::global_list
+ */
+ template <class Selector, class Counter>
+ struct size_impl<counter::global_list<Selector, Counter> >
+ : mpl::size<
+ typename counter::global_list<
+ Selector,
+ Counter
+ >::type
+ >{ };
+
 } // namespace detail
 
 template <class MetaObjectSequence>

Modified: sandbox/mirror/boost/mirror/meta_namespace.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_namespace.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_namespace.hpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -33,6 +33,10 @@
 // full name builder
 #include <boost/mirror/detail/full_name_builder.hpp>
 
+// global lists
+#include <boost/mirror/detail/global_list.hpp>
+
+
 
 namespace boost {
 namespace mirror {
@@ -73,11 +77,18 @@
                 typename NamespacePlaceholder::parent_placeholder
> scope;
 
- //
+ // the list of ancestors of this namespace
         typedef typename ::boost::mpl::push_back<
                 typename scope::ancestors,
                 scope
>::type ancestors;
+
+ // a meta object sequence of members of this namespace
+ typedef BOOST_MIRROR_GET_GLOBAL_LIST_BASE_WRAPPER(
+ NamespacePlaceholder,
+ BOOST_MIRROR_COUNTER_LUID,
+ typename
+ ) members;
 };
 
 /** The declaration of the namespace placeholder for the
@@ -136,7 +147,7 @@
         typedef meta_namespace< namespace_ :: _ > scope;
         typedef mpl::vector0<> ancestors;
 };
-
+BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR( ::boost::mirror::namespace_::_)
 
 // helper macro expanded multiple times during the namespace registration
 #define BOOST_MIRROR_REG_NAMESPACE_PROLOGUE_HELPER(R, DATA, NAMESPACE_NAME) \
@@ -175,7 +186,14 @@
  * } // namespace bar
  * } // namespace foo
  * } // namespace test
- * } // -9-
+ * } // namespace namespace_ -9-
+ * BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(
+ * ::boost::mirror::namespace_::test::foo::bar::baz::_
+ * ) -10-
+ * BOOST_MIRROR_ADD_TO_GLOBAL_LIST(
+ * ::boost::mirror::namespace_::test::foo::bar::_
+ * ::boost::mirror::namespace_::test::foo::bar::baz::_
+ * ) -11-
  */
 #define BOOST_MIRROR_REG_NAMESPACE(NAME_SEQUENCE) \
         namespace namespace_ { /* -1- */ \
@@ -184,45 +202,69 @@
                 _, \
                 NAME_SEQUENCE \
         ) /* -2- */ \
- struct _ /* -3- */ \
+ struct _ /* -3- */ \
+ { \
+ typedef ::boost::mirror::namespace_ \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_MIRROR_REG_NAMESPACE_ENUM_HELPER, \
+ _, \
+ BOOST_PP_SEQ_POP_BACK(NAME_SEQUENCE) \
+ ) :: _ parent_placeholder; /* -4- */ \
+ static inline const ::std::string& get_name( \
+ mpl::false_, \
+ ::std::char_traits<char> \
+ ) \
                 { \
- typedef ::boost::mirror::namespace_ \
- BOOST_PP_SEQ_FOR_EACH( \
- BOOST_MIRROR_REG_NAMESPACE_ENUM_HELPER, \
- _, \
- BOOST_PP_SEQ_POP_BACK(NAME_SEQUENCE) \
- ) :: _ parent_placeholder; /* -4- */ \
- static inline const ::std::string& get_name( \
- mpl::false_, \
- ::std::char_traits<char> \
- ) \
- { \
- static ::std::string s_name(BOOST_PP_STRINGIZE( \
- BOOST_PP_SEQ_HEAD( \
- BOOST_PP_SEQ_REVERSE(NAME_SEQUENCE) \
- ) \
- )); \
- return s_name; \
- } \
- static inline const ::std::wstring& get_name( \
- mpl::false_, \
- ::std::char_traits<wchar_t> \
- ) \
- { \
- static ::std::wstring s_name(BOOST_PP_WSTRINGIZE( \
- BOOST_PP_SEQ_HEAD( \
- BOOST_PP_SEQ_REVERSE(NAME_SEQUENCE) \
- ) \
- )); \
- return s_name; \
- } /* -5- */ \
- }; \
+ static ::std::string s_name(BOOST_PP_STRINGIZE( \
+ BOOST_PP_SEQ_HEAD( \
+ BOOST_PP_SEQ_REVERSE(NAME_SEQUENCE) \
+ ) \
+ )); \
+ return s_name; \
                 } \
+ static inline const ::std::wstring& get_name( \
+ mpl::false_, \
+ ::std::char_traits<wchar_t> \
+ ) \
+ { \
+ static ::std::wstring s_name(BOOST_PP_WSTRINGIZE( \
+ BOOST_PP_SEQ_HEAD( \
+ BOOST_PP_SEQ_REVERSE(NAME_SEQUENCE) \
+ ) \
+ )); \
+ return s_name; \
+ } /* -5- */ \
+ }; \
+ } \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_MIRROR_REG_NAMESPACE_EPILOGUE_HELPER, \
+ _, \
+ NAME_SEQUENCE \
+ ) /* -9- */ \
+ BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR( \
+ ::boost::mirror::namespace_ \
                 BOOST_PP_SEQ_FOR_EACH( \
- BOOST_MIRROR_REG_NAMESPACE_EPILOGUE_HELPER, \
- _, \
- NAME_SEQUENCE \
- ) /* -9- */
+ BOOST_MIRROR_REG_NAMESPACE_ENUM_HELPER, \
+ _, \
+ NAME_SEQUENCE \
+ ) :: _ \
+ ) /* -10- */ \
+ BOOST_MIRROR_ADD_TO_GLOBAL_LIST( \
+ ::boost::mirror::namespace_ \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_MIRROR_REG_NAMESPACE_ENUM_HELPER, \
+ _, \
+ BOOST_PP_SEQ_POP_BACK(NAME_SEQUENCE) \
+ ) :: _, \
+ BOOST_MIRRORED_NAMESPACE( \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_MIRROR_REG_NAMESPACE_ENUM_HELPER, \
+ _, \
+ NAME_SEQUENCE \
+ ) \
+ ) \
+ ) /* -11- */
+
 
 
 /** Register some of the common namespaces

Modified: sandbox/mirror/libs/mirror/test/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/test/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/test/Jamfile.v2 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -19,6 +19,7 @@
          [ compile namespaces_ct_02.cpp ]
          [ compile namespaces_ct_03.cpp ]
          [ compile namespaces_ct_04.cpp ]
+ [ compile namespaces_ct_05.cpp ]
          [ compile-fail namespaces_cf_01.cpp ]
          [ compile types_ct_01.cpp ]
          [ compile types_ct_02.cpp ]
@@ -46,5 +47,7 @@
          [ compile concepts_ct_01.cpp ]
          [ compile concepts_ct_02.cpp ]
          [ compile concepts_ct_03.cpp ]
+ [ run other_rt_01.cpp ]
+ [ run other_rt_02.cpp ]
     ;
 

Added: sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/namespaces_ct_05.cpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -0,0 +1,120 @@
+/**
+ * \file test/namespaces_ct_05.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing namespaces registration and reflection.
+ *
+ * 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>
+// assert
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/equal.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/and.hpp>
+// namespace registering
+#include <boost/mirror/meta_namespace.hpp>
+// intrinsic meta-functions
+#include <boost/mirror/intrinsic/size.hpp>
+#include <boost/mirror/intrinsic/at.hpp>
+#include <boost/mirror/intrinsic/empty.hpp>
+//
+#include "./test.hpp"
+
+namespace test {
+
+namespace a { }
+namespace b { }
+namespace c { }
+namespace d { }
+namespace e { }
+namespace f { }
+namespace g { }
+namespace h { }
+
+} // namespace test
+
+namespace boost{
+namespace mirror {
+
+BOOST_MIRROR_REG_NAMESPACE((test))
+BOOST_MIRROR_REG_NAMESPACE((test)(a))
+BOOST_MIRROR_REG_NAMESPACE((test)(b))
+BOOST_MIRROR_REG_NAMESPACE((test)(c))
+BOOST_MIRROR_REG_NAMESPACE((test)(d))
+BOOST_MIRROR_REG_NAMESPACE((test)(e))
+BOOST_MIRROR_REG_NAMESPACE((test)(f))
+BOOST_MIRROR_REG_NAMESPACE((test)(g))
+BOOST_MIRROR_REG_NAMESPACE((test)(h))
+
+} // namespace mirror
+} // namespace boost
+
+void test_main()
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ // define an alternative name for the global scope meta-data
+ typedef BOOST_MIRRORED_NAMESPACE(::test) meta_test;
+ //
+#ifdef BOOST_MIRROR_NO_GLOBAL_LISTS
+ BOOST_MPL_ASSERT( empty< meta_test::members > );
+ BOOST_MPL_ASSERT_RELATION( size< meta_test::members >::value, ==, 0);
+#else
+ typedef mpl::vector<
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::a), mpl::int_<0> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::b), mpl::int_<1> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::c), mpl::int_<2> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::d), mpl::int_<3> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::e), mpl::int_<4> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::f), mpl::int_<5> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::g), mpl::int_<6> >,
+ mpl::vector2<BOOST_MIRRORED_NAMESPACE(::test::h), mpl::int_<7> >
+ > meta_namespaces_and_indices;
+
+ typedef mpl::accumulate<
+ meta_namespaces_and_indices,
+ mpl::vector0<>,
+ mpl::push_back<
+ mpl::_1,
+ mpl::front<mpl::_2>
+ >
+ >::type meta_namespaces;
+
+ BOOST_MPL_ASSERT_NOT( empty< meta_test::members > );
+ BOOST_MPL_ASSERT_RELATION( size< meta_test::members >::value, ==, 8);
+ // NOTE: this is just a internal implementation detail test
+ BOOST_MPL_ASSERT(( mpl::equal< meta_test::members::type, meta_namespaces >));
+ BOOST_MPL_ASSERT((
+ mpl::accumulate<
+ meta_namespaces_and_indices,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ is_same<
+ at<meta_test::members, mpl::back<mpl::_2> >,
+ mpl::front<mpl::_2>
+ >
+ >
+ >
+ ));
+#endif
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: namespaces compile test 05");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/other_rt_01.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/other_rt_01.cpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -0,0 +1,103 @@
+/**
+ * \file test/other_rt_01.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Tests the internal counter facility
+
+ *
+ * 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/mirror/detail/counter.hpp>
+//
+#include "./test.hpp"
+
+namespace boost {
+namespace mirror {
+namespace counter {
+
+struct test_selector_1 { };
+struct test_selector_2 { };
+
+#define BOOST_MIRROR_TEST_COUNTERS_WITH_SELECTOR(SELECTOR, VALUE) \
+int test_value( \
+ SELECTOR*, \
+ BOOST_MIRROR_COUNTER_CURRENT_COUNT(SELECTOR, __LINE__) \
+) \
+{ \
+ return VALUE;\
+} \
+BOOST_MIRROR_COUNTER_INCREMENT_COUNTER(SELECTOR, __LINE__)
+
+#define BOOST_MIRROR_TEST_COUNTERS(VALUE) \
+BOOST_MIRROR_TEST_COUNTERS_WITH_SELECTOR(test_selector_1, VALUE) \
+BOOST_MIRROR_TEST_COUNTERS_WITH_SELECTOR(test_selector_2, VALUE)
+
+BOOST_MIRROR_TEST_COUNTERS(1)
+BOOST_MIRROR_TEST_COUNTERS(2)
+BOOST_MIRROR_TEST_COUNTERS(3)
+BOOST_MIRROR_TEST_COUNTERS(4)
+BOOST_MIRROR_TEST_COUNTERS(5)
+BOOST_MIRROR_TEST_COUNTERS(6)
+BOOST_MIRROR_TEST_COUNTERS(7)
+BOOST_MIRROR_TEST_COUNTERS(8)
+BOOST_MIRROR_TEST_COUNTERS(9)
+
+} // namespace counter
+} // namespace mirror
+} // namespace boost
+
+template <class Number>
+void test_value(Number number)
+{
+ BOOST_CHECK(
+ Number::value ==
+ ::boost::mirror::counter::test_value(
+ (::boost::mirror::counter::test_selector_1*)0,
+ number
+ )
+ );
+ BOOST_CHECK(
+ Number::value ==
+ ::boost::mirror::counter::test_value(
+ (::boost::mirror::counter::test_selector_2*)0,
+ number
+ )
+ );
+ BOOST_CHECK(
+ ::boost::mirror::counter::test_value(
+ (::boost::mirror::counter::test_selector_1*)0,
+ number
+ ) ==
+ ::boost::mirror::counter::test_value(
+ (::boost::mirror::counter::test_selector_2*)0,
+ number
+ )
+ );
+}
+
+void test_main()
+{
+ test_value(::boost::mpl::int_<1>());
+ test_value(::boost::mpl::int_<2>());
+ test_value(::boost::mpl::int_<3>());
+ test_value(::boost::mpl::int_<4>());
+ test_value(::boost::mpl::int_<5>());
+ test_value(::boost::mpl::int_<6>());
+ test_value(::boost::mpl::int_<7>());
+ test_value(::boost::mpl::int_<8>());
+ test_value(::boost::mpl::int_<9>());
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: other run-time test 01");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+

Added: sandbox/mirror/libs/mirror/test/other_rt_02.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/other_rt_02.cpp 2009-02-23 13:37:40 EST (Mon, 23 Feb 2009)
@@ -0,0 +1,139 @@
+/**
+ * \file test/other_rt_02.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Tests the internal global_list facility
+
+ *
+ * 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/mirror/detail/global_list.hpp>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/at.hpp>
+
+//
+#include "./test.hpp"
+
+namespace boost {
+namespace mirror {
+
+
+struct selector_1 { };
+struct selector_2 { };
+struct selector_3 { };
+struct selector_4 { };
+
+struct item_1_1 { };
+struct item_1_2 { };
+struct item_1_3 { };
+
+struct item_2_1 { };
+struct item_2_2 { };
+struct item_2_3 { };
+struct item_2_4 { };
+
+struct item_3_1 { };
+struct item_3_2 { };
+struct item_3_3 { };
+struct item_3_4 { };
+struct item_3_5 { };
+
+struct item_4_1 { };
+struct item_4_2 { };
+struct item_4_3 { };
+struct item_4_4 { };
+struct item_4_5 { };
+struct item_4_6 { };
+
+
+BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(selector_1)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_1, item_1_1, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_1, item_1_2, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_1, item_1_3, __LINE__)
+
+BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(selector_2)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_2, item_2_1, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_2, item_2_2, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_2, item_2_3, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_2, item_2_4, __LINE__)
+
+BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(selector_3)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_3, item_3_1, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_3, item_3_2, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_3, item_3_3, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_3, item_3_4, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_3, item_3_5, __LINE__)
+
+BOOST_MIRROR_REGISTER_GLOBAL_LIST_SELECTOR(selector_4)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_3_1, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_4_2, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_4_3, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_4_4, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_4_5, __LINE__)
+BOOST_MIRROR_ADD_TO_GLOBAL_LIST_BASE(selector_4, item_4_6, __LINE__)
+
+} // namespace mirror
+} // namespace boost
+
+template <class Selector>
+struct get_list_by_selector
+{
+ typedef BOOST_MIRROR_GET_GLOBAL_LIST_BASE(
+ Selector,
+ __LINE__,
+ typename
+ ) type;
+};
+
+void test_main()
+{
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ using namespace ::boost::mirror::counter;
+
+ typedef mpl::vector<
+ mpl::vector2<selector_1, mpl::int_<3> >,
+ mpl::vector2<selector_2, mpl::int_<4> >,
+ mpl::vector2<selector_3, mpl::int_<5> >,
+ mpl::vector2<selector_4, mpl::int_<6> >
+ > selectors_and_sizes;
+
+ BOOST_MPL_ASSERT((
+ mpl::accumulate<
+ selectors_and_sizes,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ mpl::equal_to<
+ mpl::size<
+ get_list_by_selector<
+ mpl::front< mpl::_2>
+ >
+ >,
+ mpl::at< mpl::_2, mpl::int_<1> >
+ >
+ >
+ >::type
+ ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: other run-time test 02");
+ 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