try_catch_eval.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
  2. #ifndef BOOST_PHOENIX_STATEMENT_DETAIL_TRY_CATCH_EVAL_HPP
  3. #define BOOST_PHOENIX_STATEMENT_DETAIL_TRY_CATCH_EVAL_HPP
  4. #include <boost/phoenix/support/iterate.hpp>
  5. #include <boost/phoenix/statement/detail/preprocessed/try_catch_eval.hpp>
  6. #endif
  7. #else
  8. #if !BOOST_PHOENIX_IS_ITERATING
  9. #ifndef BOOST_PHOENIX_STATEMENT_DETAIL_TRY_CATCH_EVAL_HPP
  10. #define BOOST_PHOENIX_STATEMENT_DETAIL_TRY_CATCH_EVAL_HPP
  11. #include <boost/phoenix/support/iterate.hpp>
  12. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  13. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/try_catch_eval_" BOOST_PHOENIX_LIMIT_STR ".hpp")
  14. #endif
  15. /*==============================================================================
  16. Copyright (c) 2005-2010 Joel de Guzman
  17. Copyright (c) 2010 Thomas Heller
  18. Distributed under the Boost Software License, Version 1.0. (See accompanying
  19. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  20. ==============================================================================*/
  21. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  22. #pragma wave option(preserve: 1)
  23. #endif
  24. #define BOOST_PHOENIX_TRY_CATCH_EVAL_R(Z, N, DATA) \
  25. catch( \
  26. typename proto::result_of::value< \
  27. typename proto::result_of::child_c< \
  28. BOOST_PP_CAT(A, N) \
  29. , 0 \
  30. >::type \
  31. >::type::type &e \
  32. ) \
  33. { \
  34. eval_catch_body(BOOST_PP_CAT(a, N), e, ctx); \
  35. } \
  36. /**/
  37. #define BOOST_PHOENIX_ITERATION_PARAMS \
  38. (3, (1, BOOST_PHOENIX_CATCH_LIMIT, \
  39. <boost/phoenix/statement/detail/try_catch_eval.hpp>))
  40. #include BOOST_PHOENIX_ITERATE()
  41. #undef BOOST_PHOENIX_TRY_CATCH_EVAL_R
  42. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  43. #pragma wave option(output: null)
  44. #endif
  45. #endif
  46. #else
  47. template <typename Try, BOOST_PHOENIX_typename_A, typename Context>
  48. typename boost::enable_if<
  49. proto::matches<
  50. BOOST_PP_CAT(A, BOOST_PP_DEC(BOOST_PHOENIX_ITERATION))
  51. , rule::catch_
  52. >
  53. , result_type
  54. >::type
  55. operator()(Try const & try_, BOOST_PHOENIX_A_const_ref_a, Context const & ctx
  56. BOOST_PHOENIX_SFINAE_AND_OVERLOADS) const
  57. {
  58. try
  59. {
  60. boost::phoenix::eval(proto::child_c<0>(try_), ctx);
  61. }
  62. BOOST_PP_REPEAT(BOOST_PHOENIX_ITERATION, BOOST_PHOENIX_TRY_CATCH_EVAL_R, _)
  63. }
  64. template <typename Try, BOOST_PHOENIX_typename_A, typename Context>
  65. typename boost::disable_if<
  66. proto::matches<
  67. BOOST_PP_CAT(A, BOOST_PP_DEC(BOOST_PHOENIX_ITERATION))
  68. , rule::catch_
  69. >
  70. , result_type
  71. >::type
  72. operator()(Try const & try_, BOOST_PHOENIX_A_const_ref_a, Context const & ctx) const
  73. {
  74. try
  75. {
  76. boost::phoenix::eval(proto::child_c<0>(try_), ctx);
  77. }
  78. BOOST_PP_REPEAT(
  79. BOOST_PP_DEC(BOOST_PHOENIX_ITERATION)
  80. , BOOST_PHOENIX_TRY_CATCH_EVAL_R, _
  81. )
  82. catch(...)
  83. {
  84. boost::phoenix::eval(
  85. proto::child_c<0>(
  86. BOOST_PP_CAT(a, BOOST_PP_DEC(BOOST_PHOENIX_ITERATION))
  87. )
  88. , ctx);
  89. }
  90. }
  91. #endif
  92. #endif // BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES