File indexing completed on 2025-01-18 09:41:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
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
0068