call_operator_iterate.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (c) 2004 Daniel Wallin and Arvid Norberg
  2. // Permission is hereby granted, free of charge, to any person obtaining a
  3. // copy of this software and associated documentation files (the "Software"),
  4. // to deal in the Software without restriction, including without limitation
  5. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  6. // and/or sell copies of the Software, and to permit persons to whom the
  7. // Software is furnished to do so, subject to the following conditions:
  8. // The above copyright notice and this permission notice shall be included
  9. // in all copies or substantial portions of the Software.
  10. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
  11. // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  12. // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  13. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
  14. // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
  15. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  16. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  18. // OR OTHER DEALINGS IN THE SOFTWARE.
  19. #define N BOOST_PP_ITERATION()
  20. #define LUABIND_UNWRAP_PARAMETER(z, n, _) \
  21. typename detail::unwrap_parameter_type<T, BOOST_PP_CAT(A, n)>::type \
  22. BOOST_PP_CAT(_, n)
  23. template<class Self BOOST_PP_ENUM_TRAILING_PARAMS(N, class A)>
  24. struct BOOST_PP_CAT(call_operator, N)
  25. : detail::operator_<
  26. BOOST_PP_CAT(call_operator, N)<
  27. Self BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
  28. >
  29. >
  30. {
  31. BOOST_PP_CAT(call_operator, N)(int) {}
  32. template<class T, class Policies>
  33. struct apply
  34. {
  35. static void execute(
  36. lua_State* L
  37. , typename detail::unwrap_parameter_type<T, Self>::type self
  38. BOOST_PP_ENUM_TRAILING(N, LUABIND_UNWRAP_PARAMETER, _)
  39. )
  40. {
  41. using namespace detail;
  42. operator_result(
  43. L
  44. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  45. , self(BOOST_PP_ENUM_PARAMS(N, _))
  46. #else
  47. , (self(BOOST_PP_ENUM_PARAMS(N, _)), detail::operator_void_return())
  48. #endif
  49. , (Policies*)0
  50. );
  51. }
  52. };
  53. static char const* name() { return "__call"; }
  54. };
  55. #undef LUABIND_UNWRAP_PARAMETER
  56. #undef N