try_catch_eval.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 & \
  32. ) \
  33. { \
  34. boost::phoenix::eval(proto::child_c<1>(BOOST_PP_CAT(a, N)), 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) const
  56. {
  57. try
  58. {
  59. boost::phoenix::eval(proto::child_c<0>(try_), ctx);
  60. }
  61. BOOST_PP_REPEAT(BOOST_PHOENIX_ITERATION, BOOST_PHOENIX_TRY_CATCH_EVAL_R, _)
  62. }
  63. template <typename Try, BOOST_PHOENIX_typename_A, typename Context>
  64. typename boost::disable_if<
  65. proto::matches<
  66. BOOST_PP_CAT(A, BOOST_PP_DEC(BOOST_PHOENIX_ITERATION))
  67. , rule::catch_
  68. >
  69. , result_type
  70. >::type
  71. operator()(Try const & try_, BOOST_PHOENIX_A_const_ref_a, Context const & ctx) const
  72. {
  73. try
  74. {
  75. boost::phoenix::eval(proto::child_c<0>(try_), ctx);
  76. }
  77. BOOST_PP_REPEAT(
  78. BOOST_PP_DEC(BOOST_PHOENIX_ITERATION)
  79. , BOOST_PHOENIX_TRY_CATCH_EVAL_R, _
  80. )
  81. catch(...)
  82. {
  83. boost::phoenix::eval(
  84. proto::child_c<0>(
  85. BOOST_PP_CAT(a, BOOST_PP_DEC(BOOST_PHOENIX_ITERATION))
  86. )
  87. , ctx);
  88. }
  89. }
  90. #endif
  91. #endif // BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES