bitwise.hpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef PHOENIX_OPERATOR_BITWISE_HPP
  7. #define PHOENIX_OPERATOR_BITWISE_HPP
  8. #include <boost/spirit/home/phoenix/core/composite.hpp>
  9. #include <boost/spirit/home/phoenix/core/compose.hpp>
  10. #include <boost/spirit/home/phoenix/detail/type_deduction.hpp>
  11. #include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp>
  12. #include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp>
  13. #include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp>
  14. #include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp>
  15. #ifdef BOOST_MSVC
  16. # pragma warning(push)
  17. # pragma warning(disable : 4800)
  18. #endif
  19. namespace boost { namespace phoenix
  20. {
  21. struct invert_eval;
  22. struct and_assign_eval;
  23. struct or_assign_eval;
  24. struct xor_assign_eval;
  25. struct shift_left_assign_eval;
  26. struct shift_right_assign_eval;
  27. struct and_eval;
  28. struct or_eval;
  29. struct xor_eval;
  30. struct shift_left_eval;
  31. struct shift_right_eval;
  32. BOOST_UNARY_RESULT_OF(~x, result_of_invert)
  33. BOOST_BINARY_RESULT_OF(x &= y, result_of_and_assign)
  34. BOOST_BINARY_RESULT_OF(x |= y, result_of_or_assign)
  35. BOOST_BINARY_RESULT_OF(x ^= y, result_of_xor_assign)
  36. BOOST_BINARY_RESULT_OF(x <<= y, result_of_shift_left_assign)
  37. BOOST_BINARY_RESULT_OF(x >>= y, result_of_shift_right_assign)
  38. BOOST_BINARY_RESULT_OF(x & y, result_of_and)
  39. BOOST_BINARY_RESULT_OF(x | y, result_of_or)
  40. BOOST_BINARY_RESULT_OF(x ^ y, result_of_xor)
  41. BOOST_BINARY_RESULT_OF(x << y, result_of_shift_left)
  42. BOOST_BINARY_RESULT_OF(x >> y, result_of_shift_right)
  43. #define x a0.eval(env)
  44. #define y a1.eval(env)
  45. PHOENIX_UNARY_EVAL(invert_eval, result_of_invert, ~x)
  46. PHOENIX_UNARY_COMPOSE(invert_eval, ~)
  47. PHOENIX_BINARY_EVAL(and_assign_eval, result_of_and_assign, x &= y)
  48. PHOENIX_BINARY_EVAL(or_assign_eval, result_of_or_assign, x |= y)
  49. PHOENIX_BINARY_EVAL(xor_assign_eval, result_of_xor_assign, x ^= y)
  50. PHOENIX_BINARY_EVAL(shift_left_assign_eval, result_of_shift_left_assign, x <<= y)
  51. PHOENIX_BINARY_EVAL(shift_right_assign_eval, result_of_shift_right_assign, x >>= y)
  52. PHOENIX_BINARY_EVAL(and_eval, result_of_and, x & y)
  53. PHOENIX_BINARY_EVAL(or_eval, result_of_or, x | y)
  54. PHOENIX_BINARY_EVAL(xor_eval, result_of_xor, x ^ y)
  55. PHOENIX_BINARY_EVAL(shift_left_eval, result_of_shift_left, x << y)
  56. PHOENIX_BINARY_EVAL(shift_right_eval, result_of_shift_right, x >> y)
  57. PHOENIX_BINARY_COMPOSE(and_assign_eval, &=)
  58. PHOENIX_BINARY_COMPOSE(or_assign_eval, |=)
  59. PHOENIX_BINARY_COMPOSE(xor_assign_eval, ^=)
  60. PHOENIX_BINARY_COMPOSE(shift_left_assign_eval, <<=)
  61. PHOENIX_BINARY_COMPOSE(shift_right_assign_eval, >>=)
  62. PHOENIX_BINARY_COMPOSE(and_eval, &)
  63. PHOENIX_BINARY_COMPOSE(or_eval, |)
  64. PHOENIX_BINARY_COMPOSE(xor_eval, ^)
  65. PHOENIX_BINARY_COMPOSE(shift_left_eval, <<)
  66. PHOENIX_BINARY_COMPOSE(shift_right_eval, >>)
  67. #undef x
  68. #undef y
  69. }}
  70. #if defined(BOOST_MSVC)
  71. # pragma warning(pop)
  72. #endif
  73. #endif