preprocessor.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef PREPROCESSOR_DWA200247_HPP
  6. # define PREPROCESSOR_DWA200247_HPP
  7. # include <boost/preprocessor/cat.hpp>
  8. # include <boost/preprocessor/comma_if.hpp>
  9. # include <boost/preprocessor/repeat.hpp>
  10. # include <boost/preprocessor/tuple/elem.hpp>
  11. // stuff that should be in the preprocessor library
  12. # define BOOST_PYTHON_APPLY(x) BOOST_PP_CAT(BOOST_PYTHON_APPLY_, x)
  13. # define BOOST_PYTHON_APPLY_BOOST_PYTHON_ITEM(v) v
  14. # define BOOST_PYTHON_APPLY_BOOST_PYTHON_NIL
  15. // cv-qualifiers
  16. # if !defined(__MWERKS__) || __MWERKS__ > 0x2407
  17. # define BOOST_PYTHON_CV_COUNT 4
  18. # else
  19. # define BOOST_PYTHON_CV_COUNT 1
  20. # endif
  21. # ifndef BOOST_PYTHON_MAX_ARITY
  22. # define BOOST_PYTHON_MAX_ARITY 15
  23. # endif
  24. # ifndef BOOST_PYTHON_MAX_BASES
  25. # define BOOST_PYTHON_MAX_BASES 10
  26. # endif
  27. # define BOOST_PYTHON_CV_QUALIFIER(i) \
  28. BOOST_PYTHON_APPLY( \
  29. BOOST_PP_TUPLE_ELEM(4, i, BOOST_PYTHON_CV_QUALIFIER_I) \
  30. )
  31. # define BOOST_PYTHON_CV_QUALIFIER_I \
  32. ( \
  33. BOOST_PYTHON_NIL, \
  34. BOOST_PYTHON_ITEM(const), \
  35. BOOST_PYTHON_ITEM(volatile), \
  36. BOOST_PYTHON_ITEM(const volatile) \
  37. )
  38. // enumerators
  39. # define BOOST_PYTHON_UNARY_ENUM(c, text) BOOST_PP_REPEAT(c, BOOST_PYTHON_UNARY_ENUM_I, text)
  40. # define BOOST_PYTHON_UNARY_ENUM_I(z, n, text) BOOST_PP_COMMA_IF(n) text ## n
  41. # define BOOST_PYTHON_BINARY_ENUM(c, a, b) BOOST_PP_REPEAT(c, BOOST_PYTHON_BINARY_ENUM_I, (a, b))
  42. # define BOOST_PYTHON_BINARY_ENUM_I(z, n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, _), n)
  43. # define BOOST_PYTHON_ENUM_WITH_DEFAULT(c, text, def) BOOST_PP_REPEAT(c, BOOST_PYTHON_ENUM_WITH_DEFAULT_I, (text, def))
  44. # define BOOST_PYTHON_ENUM_WITH_DEFAULT_I(z, n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) = BOOST_PP_TUPLE_ELEM(2, 1, _)
  45. // fixed text (no commas)
  46. # define BOOST_PYTHON_FIXED(z, n, text) text
  47. // flags
  48. # define BOOST_PYTHON_FUNCTION_POINTER 0x0001
  49. # define BOOST_PYTHON_POINTER_TO_MEMBER 0x0002
  50. #endif // PREPROCESSOR_DWA200247_HPP