Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:57

0001 // Copyright 2008 Christophe Henry
0002 // henry UNDERSCORE christophe AT hotmail DOT com
0003 // This is an extended version of the state machine available in the boost::mpl library
0004 // Distributed under the same license as the original.
0005 // Copyright for the original version:
0006 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
0007 // under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_MSM_BACK_ARGS_H
0012 #define BOOST_MSM_BACK_ARGS_H
0013 
0014 #include <boost/preprocessor/repetition/enum_params.hpp>
0015 #include <boost/preprocessor/arithmetic/sub.hpp>
0016 #include <boost/preprocessor/punctuation/comma_if.hpp>
0017 #include <boost/preprocessor/control/expr_if.hpp> 
0018 #include <boost/preprocessor/punctuation/comma.hpp>
0019 #include <boost/preprocessor/arithmetic/add.hpp>
0020 #include <boost/preprocessor/cat.hpp>
0021 #include <boost/preprocessor/comparison/less.hpp>
0022 #include <boost/preprocessor/arithmetic/dec.hpp>
0023 #include <boost/function.hpp>
0024 
0025 #ifndef BOOST_MSM_VISITOR_ARG_SIZE
0026 #define BOOST_MSM_VISITOR_ARG_SIZE 2 // default max number of arguments
0027 #endif
0028 
0029 namespace boost { namespace msm { namespace back
0030 {
0031 struct no_args {};
0032 #define MSM_ARGS_TYPEDEF_SUB(z, n, unused) typedef ARG ## n argument ## n ;
0033 #define MSM_ARGS_PRINT(z, n, data) data
0034 #define MSM_ARGS_NONE_PRINT(z, n, data) class data ## n = no_args                          \
0035     BOOST_PP_COMMA_IF( BOOST_PP_LESS(n, BOOST_PP_DEC(BOOST_MSM_VISITOR_ARG_SIZE) ) )                  
0036 
0037 #define MSM_VISITOR_MAIN_ARGS(n)                                                        \
0038     template <class RES,                                                                \
0039               BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_ARGS_NONE_PRINT, ARG)>    \
0040     struct args                                                                         \
0041     {                                                                                   \
0042         typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type;              \
0043         enum {args_number=n};                                                           \
0044         BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ )                                    \
0045     };
0046 
0047 #define MSM_VISITOR_ARGS(z, n, unused)                                                              \
0048     template <class RES BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class ARG)>                    \
0049     struct args<RES,                                                                                \
0050                 BOOST_PP_ENUM_PARAMS(n,ARG)                                                         \
0051                 BOOST_PP_COMMA_IF(n)                                                                \
0052                 BOOST_PP_ENUM(BOOST_PP_SUB(BOOST_MSM_VISITOR_ARG_SIZE,n), MSM_ARGS_PRINT, no_args)     \
0053                 >                                                                                   \
0054     {                                                                                               \
0055         typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type;                          \
0056         enum {args_number=n};                                                                       \
0057         BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ )                                                \
0058     };
0059 MSM_VISITOR_MAIN_ARGS(BOOST_MSM_VISITOR_ARG_SIZE)
0060 BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_VISITOR_ARGS, ~)
0061 
0062 #undef MSM_VISITOR_ARGS
0063 #undef MSM_ARGS_PRINT
0064 
0065 }}}
0066 
0067 #endif //BOOST_MSM_BACK_ARGS_H
0068