[857] | 1 | #if !defined(BOOST_PP_IS_ITERATING)
|
---|
| 2 |
|
---|
| 3 | // Copyright David Abrahams 2001.
|
---|
| 4 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
| 5 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
| 6 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 7 |
|
---|
| 8 | # ifndef MAKE_HOLDER_DWA20011215_HPP
|
---|
| 9 | # define MAKE_HOLDER_DWA20011215_HPP
|
---|
| 10 |
|
---|
| 11 | # include <boost/python/detail/prefix.hpp>
|
---|
| 12 |
|
---|
| 13 | # include <boost/python/object/instance.hpp>
|
---|
| 14 |
|
---|
| 15 | # include <boost/python/object/forward.hpp>
|
---|
| 16 | # include <boost/python/detail/preprocessor.hpp>
|
---|
| 17 |
|
---|
| 18 | # include <boost/mpl/next.hpp>
|
---|
| 19 | # include <boost/mpl/begin_end.hpp>
|
---|
| 20 | # include <boost/mpl/deref.hpp>
|
---|
| 21 |
|
---|
| 22 | # include <boost/preprocessor/iterate.hpp>
|
---|
| 23 | # include <boost/preprocessor/iteration/local.hpp>
|
---|
| 24 | # include <boost/preprocessor/repeat.hpp>
|
---|
| 25 | # include <boost/preprocessor/debug/line.hpp>
|
---|
| 26 | # include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
|
---|
| 27 |
|
---|
| 28 | # include <cstddef>
|
---|
| 29 |
|
---|
| 30 | namespace boost { namespace python { namespace objects {
|
---|
| 31 |
|
---|
| 32 | template <int nargs> struct make_holder;
|
---|
| 33 |
|
---|
| 34 | # define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index)
|
---|
| 35 |
|
---|
| 36 | // specializations...
|
---|
| 37 | # define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/make_holder.hpp>))
|
---|
| 38 | # include BOOST_PP_ITERATE()
|
---|
| 39 |
|
---|
| 40 | # undef BOOST_PYTHON_DO_FORWARD_ARG
|
---|
| 41 |
|
---|
| 42 | }}} // namespace boost::python::objects
|
---|
| 43 |
|
---|
| 44 | # endif // MAKE_HOLDER_DWA20011215_HPP
|
---|
| 45 |
|
---|
| 46 | #elif BOOST_PP_ITERATION_DEPTH() == 1
|
---|
| 47 | # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
---|
| 48 | && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
---|
| 49 | # line BOOST_PP_LINE(__LINE__, make_holder.hpp)
|
---|
| 50 | # endif
|
---|
| 51 |
|
---|
| 52 | # define N BOOST_PP_ITERATION()
|
---|
| 53 |
|
---|
| 54 | template <>
|
---|
| 55 | struct make_holder<N>
|
---|
| 56 | {
|
---|
| 57 | template <class Holder, class ArgList>
|
---|
| 58 | struct apply
|
---|
| 59 | {
|
---|
| 60 | # if N
|
---|
| 61 | // Unrolled iteration through each argument type in ArgList,
|
---|
| 62 | // choosing the type that will be forwarded on to the holder's
|
---|
| 63 | // templated constructor.
|
---|
| 64 | typedef typename mpl::begin<ArgList>::type iter0;
|
---|
| 65 |
|
---|
| 66 | # define BOOST_PP_LOCAL_MACRO(n) \
|
---|
| 67 | typedef typename mpl::deref<iter##n>::type t##n; \
|
---|
| 68 | typedef typename forward<t##n>::type f##n; \
|
---|
| 69 | typedef typename mpl::next<iter##n>::type \
|
---|
| 70 | BOOST_PP_CAT(iter,BOOST_PP_INC(n)); // Next iterator type
|
---|
| 71 |
|
---|
| 72 | # define BOOST_PP_LOCAL_LIMITS (0, N-1)
|
---|
| 73 | # include BOOST_PP_LOCAL_ITERATE()
|
---|
| 74 | # endif
|
---|
| 75 |
|
---|
| 76 | static void execute(
|
---|
| 77 | PyObject* p
|
---|
| 78 | BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a))
|
---|
| 79 | {
|
---|
| 80 | typedef instance<Holder> instance_t;
|
---|
| 81 |
|
---|
| 82 | void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder));
|
---|
| 83 | try {
|
---|
| 84 | (new (memory) Holder(
|
---|
| 85 | p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
|
---|
| 86 | }
|
---|
| 87 | catch(...) {
|
---|
| 88 | Holder::deallocate(p, memory);
|
---|
| 89 | throw;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | };
|
---|
| 93 | };
|
---|
| 94 |
|
---|
| 95 | # undef N
|
---|
| 96 |
|
---|
| 97 | #endif
|
---|