PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp

http://pythonocc.googlecode.com/
C++ Header | 101 lines | 75 code | 19 blank | 7 comment | 2 complexity | a770bb06c6f6bd4c7a90fa6aa73e9e24 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2005-2007 Dan Marsden
  3    Copyright (c) 2005-2007 Joel de Guzman
  4
  5    Distributed under the Boost Software License, Version 1.0. (See accompanying 
  6    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7==============================================================================*/
  8#ifndef BOOST_PP_IS_ITERATING
  9#ifndef PHOENIX_STATEMENT_DETAIL_CATCH_ALL_EVAL_HPP
 10#define PHOENIX_STATEMENT_DETAIL_CATCH_ALL_EVAL_HPP
 11
 12#include <boost/spirit/home/phoenix/core/limits.hpp>
 13#include <boost/preprocessor/iteration/iterate.hpp>
 14#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
 15#include <boost/preprocessor/repetition/enum_params_with_defaults.hpp>
 16#include <boost/preprocessor/repetition/enum_params.hpp>
 17#include <boost/preprocessor/repetition/enum_binary_params.hpp>
 18#include <boost/preprocessor/repetition/repeat.hpp>
 19#include <boost/preprocessor/dec.hpp>
 20#include <boost/preprocessor/cat.hpp>
 21#include <boost/mpl/void.hpp>
 22
 23namespace boost { namespace phoenix {
 24    class catch_all_eval
 25    {
 26    public:
 27        template<typename Env, typename TryBody, 
 28                 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(PHOENIX_CATCH_LIMIT, typename CatchBody, mpl::void_),
 29                 typename CatchAllBody = mpl::void_>
 30        struct result
 31        {
 32            typedef void type;
 33        };
 34
 35        template<typename Rt, typename Env, typename TryBody,
 36                 typename CatchAllBody>
 37        static void eval(
 38            const Env& env, TryBody& tryBody, CatchAllBody& catchAllBody)
 39        {
 40            try
 41            {
 42                tryBody.eval(env);
 43            }
 44            catch(...)
 45            {
 46                catchAllBody.eval(env);
 47            }
 48        }
 49
 50#define BOOST_PP_ITERATION_PARAMS_1                                                        \
 51        (3, (1, PHOENIX_CATCH_LIMIT, "boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp"))
 52
 53#include BOOST_PP_ITERATE()
 54
 55    };
 56}}
 57
 58#endif
 59
 60#elif BOOST_PP_ITERATION_DEPTH() == 1
 61
 62#define PHOENIX_ITERATION BOOST_PP_ITERATION()
 63
 64        template<typename Rt, typename Env, typename TryBody,
 65                 BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename CatchBody),
 66                 typename CatchAllBody>
 67        static void eval(
 68            const Env& env, TryBody& tryBody,
 69            BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, CatchBody, catchBody),
 70            CatchAllBody& catchAllBody)
 71        {
 72            try
 73            {
 74                tryBody.eval(env);
 75            }
 76
 77#define BOOST_PP_ITERATION_PARAMS_2                                                                             \
 78        (3, (0, BOOST_PP_DEC(PHOENIX_ITERATION), "boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp"))
 79
 80#include BOOST_PP_ITERATE()
 81
 82            catch(...)
 83            {
 84                catchAllBody.eval(env);
 85            }
 86        }
 87
 88#undef PHOENIX_ITERATION
 89
 90#elif BOOST_PP_ITERATION_DEPTH() == 2
 91
 92#define PHOENIX_ITERATION BOOST_PP_ITERATION()
 93
 94        catch(typename BOOST_PP_CAT(CatchBody, PHOENIX_ITERATION)::exception_type&)
 95        {
 96            BOOST_PP_CAT(catchBody, PHOENIX_ITERATION).eval(env);
 97        }
 98
 99#undef PHOENIX_ITERATION
100
101#endif