Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:39

0001 #if !defined(BOOST_PP_IS_ITERATING)
0002 
0003 // Copyright David Abrahams 2001.
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 # ifndef MAKE_HOLDER_DWA20011215_HPP
0009 #  define MAKE_HOLDER_DWA20011215_HPP
0010 
0011 #  include <boost/python/detail/prefix.hpp>
0012 
0013 #  include <boost/python/object/instance.hpp>
0014 #  include <boost/python/converter/registry.hpp>
0015 #if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
0016 #  include <boost/python/detail/python_type.hpp>
0017 #endif
0018 
0019 #  include <boost/python/object/forward.hpp>
0020 #  include <boost/python/detail/preprocessor.hpp>
0021 
0022 #  include <boost/mpl/next.hpp>
0023 #  include <boost/mpl/begin_end.hpp>
0024 #  include <boost/mpl/deref.hpp>
0025 
0026 #  include <boost/preprocessor/iterate.hpp>
0027 #  include <boost/preprocessor/iteration/local.hpp>
0028 #  include <boost/preprocessor/repeat.hpp>
0029 #  include <boost/preprocessor/debug/line.hpp>
0030 #  include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
0031 
0032 #  include <cstddef>
0033 
0034 namespace boost { namespace python { namespace objects {
0035 
0036 template <int nargs> struct make_holder;
0037 
0038 #  define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index)
0039 
0040 // specializations...
0041 #  define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/make_holder.hpp>))
0042 #  include BOOST_PP_ITERATE()
0043 
0044 #  undef BOOST_PYTHON_DO_FORWARD_ARG
0045 
0046 }}} // namespace boost::python::objects
0047 
0048 # endif // MAKE_HOLDER_DWA20011215_HPP
0049 
0050 // For gcc 4.4 compatability, we must include the
0051 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
0052 #else // BOOST_PP_IS_ITERATING
0053 #if BOOST_PP_ITERATION_DEPTH() == 1
0054 # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100)                      \
0055         && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
0056 #  line BOOST_PP_LINE(__LINE__, make_holder.hpp)
0057 # endif 
0058 
0059 # define N BOOST_PP_ITERATION()
0060 
0061 template <>
0062 struct make_holder<N>
0063 {
0064     template <class Holder, class ArgList>
0065     struct apply
0066     {
0067 # if N
0068         // Unrolled iteration through each argument type in ArgList,
0069         // choosing the type that will be forwarded on to the holder's
0070         // templated constructor.
0071         typedef typename mpl::begin<ArgList>::type iter0;
0072         
0073 #  define BOOST_PP_LOCAL_MACRO(n)               \
0074     typedef typename mpl::deref<iter##n>::type t##n;        \
0075     typedef typename forward<t##n>::type f##n;  \
0076     typedef typename mpl::next<iter##n>::type   \
0077         BOOST_PP_CAT(iter,BOOST_PP_INC(n)); // Next iterator type
0078         
0079 #  define BOOST_PP_LOCAL_LIMITS (0, N-1)
0080 #  include BOOST_PP_LOCAL_ITERATE()
0081 # endif 
0082         
0083         static void execute(
0084 #if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
0085             boost::python::detail::python_class<BOOST_DEDUCED_TYPENAME Holder::value_type> *p
0086 #else
0087             PyObject *p
0088 #endif
0089             BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a))
0090         {
0091             typedef instance<Holder> instance_t;
0092 
0093             void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder),
0094                                             boost::python::detail::alignment_of<Holder>::value);
0095             try {
0096                 (new (memory) Holder(
0097                     p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
0098             }
0099             catch(...) {
0100                 Holder::deallocate(p, memory);
0101                 throw;
0102             }
0103         }
0104     };
0105 };
0106 
0107 # undef N
0108 
0109 #endif // BOOST_PP_ITERATION_DEPTH()
0110 #endif