target.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. // Copyright David Abrahams 2002.
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. # ifndef TARGET_DWA2002521_HPP
  7. # define TARGET_DWA2002521_HPP
  8. # include <boost/python/detail/preprocessor.hpp>
  9. # include <boost/type.hpp>
  10. # include <boost/preprocessor/comma_if.hpp>
  11. # include <boost/preprocessor/if.hpp>
  12. # include <boost/preprocessor/iterate.hpp>
  13. # include <boost/preprocessor/debug/line.hpp>
  14. # include <boost/preprocessor/enum_params.hpp>
  15. # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  16. namespace boost { namespace python { namespace detail {
  17. # define BOOST_PP_ITERATION_PARAMS_1 \
  18. (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/target.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
  19. # include BOOST_PP_ITERATE()
  20. # define BOOST_PP_ITERATION_PARAMS_1 \
  21. (4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/target.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
  22. # include BOOST_PP_ITERATE()
  23. template <class R, class T>
  24. T& (* target(R (T::*)) )() { return 0; }
  25. }}} // namespace boost::python::detail
  26. # endif // TARGET_DWA2002521_HPP
  27. /* --------------- function pointers --------------- */
  28. // For gcc 4.4 compatability, we must include the
  29. // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
  30. #else // BOOST_PP_IS_ITERATING
  31. #if BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
  32. # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
  33. && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
  34. # line BOOST_PP_LINE(__LINE__, target.hpp(function_pointers))
  35. # endif
  36. # define N BOOST_PP_ITERATION()
  37. template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
  38. BOOST_PP_IF(N, A0, void)(* target(R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))) )()
  39. {
  40. return 0;
  41. }
  42. # undef N
  43. /* --------------- pointers-to-members --------------- */
  44. #elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
  45. // Outer over cv-qualifiers
  46. # define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/target.hpp>))
  47. # include BOOST_PP_ITERATE()
  48. #elif BOOST_PP_ITERATION_DEPTH() == 2
  49. # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
  50. && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
  51. # line BOOST_PP_LINE(__LINE__, target.hpp(pointers-to-members))
  52. # endif
  53. // Inner over arities
  54. # define N BOOST_PP_ITERATION()
  55. # define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
  56. template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
  57. T& (* target(R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q) )()
  58. {
  59. return 0;
  60. }
  61. # undef N
  62. # undef Q
  63. #endif // BOOST_PP_ITERATION_DEPTH()
  64. #endif