Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72969 - in branches/pplib/v2: boost/preprocessor boost/preprocessor/debug boost/preprocessor/facilities libs/preprocessor/test
From: eldiener_at_[hidden]
Date: 2011-07-08 10:21:45


Author: eldiener
Date: 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
New Revision: 72969
URL: http://svn.boost.org/trac/boost/changeset/72969

Log:
Added ASSERT_IS_LIST and REMOVE_PARENS along with some tests.
Added:
   branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp (contents, props changed)
   branches/pplib/v2/boost/preprocessor/facilities/remove_parens.hpp (contents, props changed)
Text files modified:
   branches/pplib/v2/boost/preprocessor/debug.hpp | 3 ++-
   branches/pplib/v2/boost/preprocessor/facilities.hpp | 1 +
   branches/pplib/v2/boost/preprocessor/facilities/is_tuple_begin.hpp | 2 +-
   branches/pplib/v2/libs/preprocessor/test/Jamfile.v2 | 34 +++++++++++++++++-----------------
   branches/pplib/v2/libs/preprocessor/test/facilities.cxx | 5 +++++
   5 files changed, 26 insertions(+), 19 deletions(-)

Modified: branches/pplib/v2/boost/preprocessor/debug.hpp
==============================================================================
--- branches/pplib/v2/boost/preprocessor/debug.hpp (original)
+++ branches/pplib/v2/boost/preprocessor/debug.hpp 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -13,8 +13,9 @@
 # define BOOST_PREPROCESSOR_DEBUG_HPP
 #
 # include <boost/preprocessor/debug/assert.hpp>
-# include <boost/preprocessor/debug/assert_is_tuple.hpp>
 # include <boost/preprocessor/debug/assert_is_array.hpp>
+# include <boost/preprocessor/debug/assert_is_list.hpp>
+# include <boost/preprocessor/debug/assert_is_tuple.hpp>
 # include <boost/preprocessor/debug/line.hpp>
 #
 # endif

Added: branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp
==============================================================================
--- (empty file)
+++ branches/pplib/v2/boost/preprocessor/debug/assert_is_list.hpp 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -0,0 +1,106 @@
+# /* **************************************************************************
+# * *
+# * (C) Copyright Edward Diener 2011. *
+# * 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) *
+# * *
+# ************************************************************************** */
+#
+# /* See http://www.boost.org for most recent version. */
+#
+# ifndef BOOST_PREPROCESSOR_DEBUG_ASSERT_IS_LIST_HPP
+# define BOOST_PREPROCESSOR_DEBUG_ASSERT_IS_LIST_HPP
+#
+# include <boost/preprocessor/config/config.hpp>
+# include <boost/preprocessor/comparison/equal.hpp>
+# include <boost/preprocessor/control/iif.hpp>
+# include <boost/preprocessor/debug/assert.hpp>
+# include <boost/preprocessor/debug/assert_is_tuple.hpp>
+# include <boost/preprocessor/facilities/is_tuple_begin.hpp>
+# include <boost/preprocessor/tuple/elem.hpp>
+# include <boost/preprocessor/tuple/size.hpp>
+#
+# /* BOOST_PP_ASSERT_IS_LIST */
+#
+# if BOOST_PP_VARIADICS
+# 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_IIF \
+ ( \
+ BOOST_PP_IS_TUPLE_BEGIN(x), \
+ BOOST_PP_IS_LIST_DETAIL_TWO_ELEMENT_TUPLE, \
+ BOOST_PP_IS_LIST_DETAIL_BOOST_PP_NIL \
+ ) \
+ (x) \
+ ) \
+/**/
+#
+
+/*
+
+ Check if we have a two element tuple
+
+*/
+
+# define BOOST_PP_IS_LIST_DETAIL_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 \
+ ) \
+ (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 \
+ ( \
+ BOOST_PP_IS_TUPLE_BEGIN(BOOST_PP_TUPLE_ELEM(0,x)), \
+ BOOST_PP_IS_LIST_DETAIL_GEN_ZERO, \
+ BOOST_PP_IS_LIST_DETAIL_SECOND \
+ ) \
+ (x) \
+/**/
+#
+
+/*
+
+ 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)) \
+ 1 \
+/**/
+#
+# define BOOST_PP_IS_LIST_DETAIL_GEN_ZERO(x) \
+ 0 \
+/**/
+#
+# 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 */
+# endif /* BOOST_PP_VARIADICS */
+# endif /* BOOST_PREPROCESSOR_DEBUG_ASSERT_IS_LIST_HPP */

Modified: branches/pplib/v2/boost/preprocessor/facilities.hpp
==============================================================================
--- branches/pplib/v2/boost/preprocessor/facilities.hpp (original)
+++ branches/pplib/v2/boost/preprocessor/facilities.hpp 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -20,5 +20,6 @@
 # include <boost/preprocessor/facilities/intercept.hpp>
 # include <boost/preprocessor/facilities/is_tuple_begin.hpp>
 # include <boost/preprocessor/facilities/overload.hpp>
+# include <boost/preprocessor/facilities/remove_parens.hpp>
 #
 # endif

Modified: branches/pplib/v2/boost/preprocessor/facilities/is_tuple_begin.hpp
==============================================================================
--- branches/pplib/v2/boost/preprocessor/facilities/is_tuple_begin.hpp (original)
+++ branches/pplib/v2/boost/preprocessor/facilities/is_tuple_begin.hpp 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -16,7 +16,7 @@
 # include <boost/preprocessor/arithmetic/dec.hpp>
 # include <boost/preprocessor/variadic/size.hpp>
 #
-# /* BOOST_PP_IS_TUPLE */
+# /* BOOST_PP_IS_TUPLE_BEGIN */
 #
 # if BOOST_PP_VARIADICS
 # define BOOST_PP_IS_TUPLE_BEGIN(x) \

Added: branches/pplib/v2/boost/preprocessor/facilities/remove_parens.hpp
==============================================================================
--- (empty file)
+++ branches/pplib/v2/boost/preprocessor/facilities/remove_parens.hpp 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -0,0 +1,38 @@
+# /* **************************************************************************
+# * *
+# * (C) Copyright Edward Diener 2011. *
+# * 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) *
+# * *
+# ************************************************************************** */
+#
+# /* See http://www.boost.org for most recent version. */
+#
+# ifndef BOOST_PREPROCESSOR_FACILITIES_REMOVE_PARENS_HPP
+# define BOOST_PREPROCESSOR_FACILITIES_REMOVE_PARENS_HPP
+#
+# include <boost/preprocessor/config/config.hpp>
+# include <boost/preprocessor/control/iif.hpp>
+# include <boost/preprocessor/facilities/is_tuple_begin.hpp>
+# include <boost/preprocessor/tuple/enum.hpp>
+#
+# /* BOOST_PP_REMOVE_PARENS */
+#
+# if BOOST_PP_VARIADICS
+# define BOOST_PP_REMOVE_PARENS(x) \
+ BOOST_PP_IIF \
+ ( \
+ BOOST_PP_IS_TUPLE_BEGIN(x), \
+ BOOST_PP_REMOVE_PARENS_DETAIL, \
+ BOOST_PP_IDENTITY \
+ ) \
+ (x)() \
+/**/
+#
+# define BOOST_PP_REMOVE_PARENS_DETAIL(x) \
+ BOOST_PP_IDENTITY(BOOST_PP_TUPLE_ENUM(x)) \
+/**/
+#
+# endif /* BOOST_PP_VARIADICS */
+# endif /* BOOST_PREPROCESSOR_FACILITIES_REMOVE_PARENS_HPP */

Modified: branches/pplib/v2/libs/preprocessor/test/Jamfile.v2
==============================================================================
--- branches/pplib/v2/libs/preprocessor/test/Jamfile.v2 (original)
+++ branches/pplib/v2/libs/preprocessor/test/Jamfile.v2 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -124,14 +124,14 @@
         [ compile tuple.cpp : <define>BOOST_PP_VARIADICS=0 : tuple_nvm ]
    ;
 
-test-suite preprocessor_dbg
- :
- [ compile-fail debug_fail.cpp
- : <variant>debug
- <define>BOOST_PP_VARIADICS=1
- <toolset>gcc:<cflags>-std=c++0x
- ]
- ;
+# test-suite preprocessor_dbg
+# :
+# [ compile-fail debug_fail.cpp
+# : <variant>debug
+# <define>BOOST_PP_VARIADICS=1
+# <toolset>gcc:<cflags>-std=c++0x
+# ]
+# ;
 
 test-suite preprocessor_c
    :
@@ -253,12 +253,12 @@
         ]
    ;
 
-test-suite preprocessor_c_dbg
- :
- [ compile-fail debug_fail.c
- : <variant>debug
- <define>BOOST_PP_VARIADICS=1
- <toolset>gcc:<cflags>-std=c99
- : debug_fail_c
- ]
- ;
+# test-suite preprocessor_c_dbg
+# :
+# [ compile-fail debug_fail.c
+# : <variant>debug
+# <define>BOOST_PP_VARIADICS=1
+# <toolset>gcc:<cflags>-std=c99
+# : debug_fail_c
+# ]
+# ;

Modified: branches/pplib/v2/libs/preprocessor/test/facilities.cxx
==============================================================================
--- branches/pplib/v2/libs/preprocessor/test/facilities.cxx (original)
+++ branches/pplib/v2/libs/preprocessor/test/facilities.cxx 2011-07-08 10:21:44 EDT (Fri, 08 Jul 2011)
@@ -48,4 +48,9 @@
 BEGIN BOOST_PP_IS_TUPLE_BEGIN((4,8,ty,2)yz) == 1 END
 BEGIN BOOST_PP_IS_TUPLE_BEGIN(A green test(3.x.t)) == 0 END
 
+BEGIN BOOST_PP_REMOVE_PARENS((5)) == 5 END
+BEGIN BOOST_PP_REMOVE_PARENS(6) == 6 END
+BEGIN BOOST_PP_REMOVE_PARENS((5) + 2) == 7 END
+BEGIN BOOST_PP_REMOVE_PARENS(6 - 2) == 4 END
+
 #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