1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef BOOST_MSM_BACK_ARGS_H
- #define BOOST_MSM_BACK_ARGS_H
- #include <boost/preprocessor/repetition/enum_params.hpp>
- #include <boost/preprocessor/arithmetic/sub.hpp>
- #include <boost/preprocessor/punctuation/comma_if.hpp>
- #include <boost/preprocessor/control/expr_if.hpp>
- #include <boost/preprocessor/punctuation/comma.hpp>
- #include <boost/preprocessor/arithmetic/add.hpp>
- #include <boost/preprocessor/cat.hpp>
- #include <boost/preprocessor/comparison/less.hpp>
- #include <boost/preprocessor/arithmetic/dec.hpp>
- #include <boost/function.hpp>
- #ifndef BOOST_MSM_VISITOR_ARG_SIZE
- #define BOOST_MSM_VISITOR_ARG_SIZE 2
- #endif
- namespace boost { namespace msm { namespace back
- {
- struct no_args {};
- #define MSM_ARGS_TYPEDEF_SUB(z, n, unused) typedef ARG ## n argument ## n ;
- #define MSM_ARGS_PRINT(z, n, data) data
- #define MSM_ARGS_NONE_PRINT(z, n, data) class data ## n = no_args \
- BOOST_PP_COMMA_IF( BOOST_PP_LESS(n, BOOST_PP_DEC(BOOST_MSM_VISITOR_ARG_SIZE) ) )
- #define MSM_VISITOR_MAIN_ARGS(n) \
- template <class RES, \
- BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_ARGS_NONE_PRINT, ARG)> \
- struct args \
- { \
- typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \
- enum {args_number=n}; \
- BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \
- };
- #define MSM_VISITOR_ARGS(z, n, unused) \
- template <class RES BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class ARG)> \
- struct args<RES, \
- BOOST_PP_ENUM_PARAMS(n,ARG) \
- BOOST_PP_COMMA_IF(n) \
- BOOST_PP_ENUM(BOOST_PP_SUB(BOOST_MSM_VISITOR_ARG_SIZE,n), MSM_ARGS_PRINT, no_args) \
- > \
- { \
- typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \
- enum {args_number=n}; \
- BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \
- };
- MSM_VISITOR_MAIN_ARGS(BOOST_MSM_VISITOR_ARG_SIZE)
- BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_VISITOR_ARGS, ~)
- #undef MSM_VISITOR_ARGS
- #undef MSM_ARGS_PRINT
- }}}
- #endif
|