invoker.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Copyright Daniel Wallin 2005. Use, modification and distribution is
  2. // subject to the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_PARAMETER_INVOKER_051210_HPP
  5. # define BOOST_PARAMETER_INVOKER_051210_HPP
  6. # include <boost/mpl/begin.hpp>
  7. # include <boost/mpl/next.hpp>
  8. # include <boost/mpl/deref.hpp>
  9. # include <boost/mpl/size.hpp>
  10. # include <boost/parameter/keyword.hpp>
  11. # include <boost/preprocessor/iteration/iterate.hpp>
  12. namespace boost { namespace parameter { namespace python { namespace aux {
  13. template <long Arity, class M, class R, class Args>
  14. struct invoker;
  15. template <class M, class R>
  16. struct make_invoker
  17. {
  18. template <class Args>
  19. struct apply
  20. {
  21. typedef invoker<
  22. mpl::size<Args>::value, M, R, Args
  23. > type;
  24. };
  25. };
  26. template <long Arity, class M, class R, class T, class Args>
  27. struct member_invoker;
  28. template <class M, class R, class T>
  29. struct make_member_invoker
  30. {
  31. template <class Args>
  32. struct apply
  33. {
  34. typedef member_invoker<
  35. mpl::size<Args>::value, M, R, T, Args
  36. > type;
  37. };
  38. };
  39. template <long Arity, class T, class R, class Args>
  40. struct call_invoker;
  41. template <class T, class R>
  42. struct make_call_invoker
  43. {
  44. template <class Args>
  45. struct apply
  46. {
  47. typedef call_invoker<
  48. mpl::size<Args>::value, T, R, Args
  49. > type;
  50. };
  51. };
  52. template <long Arity, class T, class Args>
  53. struct init_invoker;
  54. template <class T>
  55. struct make_init_invoker
  56. {
  57. template <class Args>
  58. struct apply
  59. {
  60. typedef init_invoker<
  61. mpl::size<Args>::value, T, Args
  62. > type;
  63. };
  64. };
  65. template <class M, class R, class Args>
  66. struct invoker<0, M, R, Args>
  67. {
  68. static R execute()
  69. {
  70. return M()(boost::type<R>());
  71. }
  72. };
  73. template <class M, class R, class T, class Args>
  74. struct member_invoker<0, M, R, T, Args>
  75. {
  76. static R execute(T& self)
  77. {
  78. return M()(boost::type<R>(), self);
  79. }
  80. };
  81. template <class T, class R, class Args>
  82. struct call_invoker<0, T, R, Args>
  83. {
  84. static R execute(T& self)
  85. {
  86. return self();
  87. }
  88. };
  89. template <class T, class Args>
  90. struct init_invoker<0, T, Args>
  91. {
  92. static T* execute(T& self)
  93. {
  94. return new T;
  95. }
  96. };
  97. # define BOOST_PP_ITERATION_PARAMS_1 (4, \
  98. (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 1))
  99. # include BOOST_PP_ITERATE()
  100. # define BOOST_PP_ITERATION_PARAMS_1 (4, \
  101. (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 2))
  102. # include BOOST_PP_ITERATE()
  103. # define BOOST_PP_ITERATION_PARAMS_1 (4, \
  104. (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 3))
  105. # include BOOST_PP_ITERATE()
  106. # define BOOST_PP_ITERATION_PARAMS_1 (4, \
  107. (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 4))
  108. # include BOOST_PP_ITERATE()
  109. }}}} // namespace boost::parameter::python::aux
  110. #endif // BOOST_PARAMETER_INVOKER_051210_HPP