Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72983 - in branches/pplib/v2: boost/preprocessor/debug libs/preprocessor/test
From: eldiener_at_[hidden]
Date: 2011-07-09 10:10:43


Author: eldiener
Date: 2011-07-09 10:10:42 EDT (Sat, 09 Jul 2011)
New Revision: 72983
URL: http://svn.boost.org/trac/boost/changeset/72983

Log:
Updated ASSERT_IS_LIST and tests.
Text files modified:
   branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp | 115 +++++++++++++++++++++++----------------
   branches/pplib/v2/libs/preprocessor/test/debug.cxx | 1
   branches/pplib/v2/libs/preprocessor/test/debug_fail.cxx | 1
   3 files changed, 70 insertions(+), 47 deletions(-)

Modified: branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp
==============================================================================
--- branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp (original)
+++ branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp 2011-07-09 10:10:42 EDT (Sat, 09 Jul 2011)
@@ -15,9 +15,12 @@
 # include <boost/preprocessor/config/config.hpp>
 # include <boost/preprocessor/comparison/equal.hpp>
 # include <boost/preprocessor/control/iif.hpp>
+# include <boost/preprocessor/control/while.hpp>
 # include <boost/preprocessor/debug/assert.hpp>
 # include <boost/preprocessor/debug/assert_is_tuple.hpp>
+# include <boost/preprocessor/facilities/is_empty.hpp>
 # include <boost/preprocessor/facilities/is_tuple_begin.hpp>
+# include <boost/preprocessor/logical/not.hpp>
 # include <boost/preprocessor/tuple/elem.hpp>
 # include <boost/preprocessor/tuple/size.hpp>
 #
@@ -27,78 +30,96 @@
 # if defined(NDEBUG)
 # define BOOST_PP_ASSERT_IS_LIST(x) \
 /**/
+#
 # else
-
-/*
-
- Check if the list starts with a tuple or is BOOST_PP_NIL
-
-*/
+#
 # define BOOST_PP_ASSERT_IS_LIST(x) \
- BOOST_PP_ASSERT \
+ BOOST_PP_IS_LIST_DETAIL_GEN_EMPTY \
       ( \
- BOOST_PP_IIF \
+ BOOST_PP_WHILE \
         ( \
- BOOST_PP_IS_TUPLE_BEGIN(x), \
- BOOST_PP_IS_LIST_DETAIL_TWO_ELEMENT_TUPLE, \
- BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL \
+ BOOST_PP_IS_LIST_DETAIL_PRED, \
+ BOOST_PP_IS_LIST_DETAIL_OP, \
+ x \
         ) \
- (x) \
       ) \
 /**/
 #
-
-/*
-
- Check if we have a two element tuple
-
-*/
-
-# define BOOST_PP_IS_LIST_DETAIL_TWO_ELEMENT_TUPLE(x) \
+# define BOOST_PP_IS_LIST_DETAIL_GEN_EMPTY(x) \
+ BOOST_PP_IS_LIST_DETAIL_GEN_EMPTY_I(x) \
+/**/
+#
+# define BOOST_PP_IS_LIST_DETAIL_GEN_EMPTY_I(x)
+#
+#define BOOST_PP_IS_LIST_DETAIL_PRED(d,state) \
+ BOOST_PP_IIF \
+ ( \
+ BOOST_PP_IS_TUPLE_BEGIN(state), \
+ BOOST_PP_IS_LIST_DETAIL_GEN_ONE, \
+ BOOST_PP_IS_LIST_DETAIL_NOT_BOOST_PP_NIL \
+ ) \
+ (state) \
+/**/
+#
+#define BOOST_PP_IS_LIST_DETAIL_OP(d,state) \
+ BOOST_PP_IIF \
+ ( \
+ BOOST_PP_IS_TUPLE_BEGIN(state), \
+ BOOST_PP_IS_LIST_DETAIL_PROCESS_TWO_ELEMENT_TUPLE, \
+ BOOST_PP_IS_LIST_DETAIL_PROCESS_IF_BOOST_PP_NIL \
+ ) \
+ (state) \
+/**/
+#
+# define BOOST_PP_IS_LIST_DETAIL_PROCESS_TWO_ELEMENT_TUPLE(x) \
     BOOST_PP_ASSERT_IS_TUPLE(x) \
     BOOST_PP_IIF \
       ( \
       BOOST_PP_EQUAL(2,BOOST_PP_TUPLE_SIZE(x)), \
- BOOST_PP_IS_LIST_DETAIL_CHECK_LIST_FORM, \
- BOOST_PP_IS_LIST_DETAIL_GEN_ZERO \
+ BOOST_PP_IS_LIST_DETAIL_RETURN_SECOND, \
+ BOOST_PP_IS_LIST_DETAIL_ASSERT \
       ) \
     (x) \
 /**/
 #
-
-/*
-
- Check if the first element does not begin as a tuple
-
-*/
-
-# define BOOST_PP_IS_LIST_DETAIL_CHECK_LIST_FORM(x) \
- BOOST_PP_IIF \
+# define BOOST_PP_IS_LIST_DETAIL_RETURN_SECOND(x) \
+ BOOST_PP_TUPLE_ELEM(1,x) \
+/**/
+#
+#define BOOST_PP_IS_LIST_DETAIL_PROCESS_IF_BOOST_PP_NIL(x) \
+ BOOST_PP_ASSERT \
       ( \
- BOOST_PP_IS_TUPLE_BEGIN(BOOST_PP_TUPLE_ELEM(0,x)), \
- BOOST_PP_IS_LIST_DETAIL_GEN_ZERO, \
- BOOST_PP_IS_LIST_DETAIL_SECOND \
+ BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL(x) \
       ) \
- (x) \
+ BOOST_PP_NIL \
+/**/
+#
+# define BOOST_PP_IS_LIST_DETAIL_ASSERT(x) \
+ BOOST_PP_ASSERT(0) \
 /**/
 #
-
-/*
-
- Finally check if the second element is a list
-
-*/
-
-# define BOOST_PP_IS_LIST_DETAIL_SECOND(x) \
- BOOST_PP_ASSERT_IS_LIST(BOOST_PP_TUPLE_ELEM(1,x)) \
+# define BOOST_PP_IS_LIST_DETAIL_GEN_ONE(x) \
     1 \
 /**/
 #
-# define BOOST_PP_IS_LIST_DETAIL_GEN_ZERO(x) \
- 0 \
+# define BOOST_PP_IS_LIST_DETAIL_NOT_BOOST_PP_NIL(x) \
+ BOOST_PP_NOT \
+ ( \
+ BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL(x) \
+ ) \
+/**/
+#
+# define BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL(x) \
+ BOOST_PP_IS_EMPTY \
+ ( \
+ BOOST_PP_CAT \
+ ( \
+ BOOST_PP_IS_LIST_DETAIL_NIL_HELPER_, \
+ x \
+ ) \
+ ) \
 /**/
 #
-# define BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL(x) BOOST_PP_IS_EMPTY(BOOST_PP_CAT(BOOST_PP_IS_LIST_DETAIL_NIL_HELPER_, x))
 # define BOOST_PP_IS_LIST_DETAIL_NIL_HELPER_BOOST_PP_NIL
 #
 # endif /* NDEBUG */

Modified: branches/pplib/v2/libs/preprocessor/test/debug.cxx
==============================================================================
--- branches/pplib/v2/libs/preprocessor/test/debug.cxx (original)
+++ branches/pplib/v2/libs/preprocessor/test/debug.cxx 2011-07-09 10:10:42 EDT (Sat, 09 Jul 2011)
@@ -26,5 +26,6 @@
 
 BOOST_PP_ASSERT_IS_TUPLE((x,3,e,2))
 BOOST_PP_ASSERT_IS_ARRAY((4,(x,3,e,2)))
+BOOST_PP_ASSERT_IS_LIST((4,(x,BOOST_PP_NIL)))
 
 # endif
\ No newline at end of file

Modified: branches/pplib/v2/libs/preprocessor/test/debug_fail.cxx
==============================================================================
--- branches/pplib/v2/libs/preprocessor/test/debug_fail.cxx (original)
+++ branches/pplib/v2/libs/preprocessor/test/debug_fail.cxx 2011-07-09 10:10:42 EDT (Sat, 09 Jul 2011)
@@ -16,5 +16,6 @@
 
 BOOST_PP_ASSERT_IS_TUPLE((x,3,e,2)ty)
 BOOST_PP_ASSERT_IS_ARRAY((y,(x,3,e,2)))
+BOOST_PP_ASSERT_IS_LIST((4,(x)))
 
 # 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