os/ossrv/ossrv_pub/boost_apis/boost/python/signature.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/signature.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,179 @@
     1.4 +///////////////////////////////////////////////////////////////////////////////
     1.5 +//
     1.6 +// Copyright David Abrahams 2002, Joel de Guzman, 2002.
     1.7 +// Distributed under the Boost Software License, Version 1.0. (See
     1.8 +// accompanying file LICENSE_1_0.txt or copy at
     1.9 +// http://www.boost.org/LICENSE_1_0.txt)
    1.10 +//
    1.11 +///////////////////////////////////////////////////////////////////////////////
    1.12 +#if !defined(BOOST_PP_IS_ITERATING)
    1.13 +
    1.14 +# ifndef SIGNATURE_JDG20020813_HPP
    1.15 +#  define SIGNATURE_JDG20020813_HPP
    1.16 +
    1.17 +# include <boost/python/detail/prefix.hpp>
    1.18 +
    1.19 +# include <boost/mpl/if.hpp>
    1.20 +# include <boost/type_traits/is_convertible.hpp>
    1.21 +
    1.22 +#  include <boost/python/detail/preprocessor.hpp>
    1.23 +#  include <boost/preprocessor/repeat.hpp>
    1.24 +#  include <boost/preprocessor/enum.hpp>
    1.25 +#  include <boost/preprocessor/enum_params.hpp>
    1.26 +#  include <boost/preprocessor/empty.hpp>
    1.27 +#  include <boost/preprocessor/arithmetic/sub.hpp>
    1.28 +#  include <boost/preprocessor/iterate.hpp>
    1.29 +#  include <boost/python/detail/type_list.hpp>
    1.30 +
    1.31 +#  include <boost/preprocessor/debug/line.hpp>
    1.32 +#  include <boost/preprocessor/arithmetic/sub.hpp>
    1.33 +#  include <boost/preprocessor/arithmetic/inc.hpp>
    1.34 +#  include <boost/preprocessor/repetition/enum_trailing_params.hpp>
    1.35 +
    1.36 +# define BOOST_PYTHON_LIST_INC(n)        \
    1.37 +   BOOST_PP_CAT(mpl::vector, BOOST_PP_INC(n))
    1.38 +
    1.39 +///////////////////////////////////////////////////////////////////////////////
    1.40 +namespace boost { namespace python { namespace detail {
    1.41 +
    1.42 +// A metafunction returning C1 if C1 is derived from C2, and C2
    1.43 +// otherwise
    1.44 +template <class C1, class C2>
    1.45 +struct most_derived
    1.46 +{
    1.47 +    typedef typename mpl::if_<
    1.48 +        is_convertible<C1*,C2*>
    1.49 +      , C1
    1.50 +      , C2
    1.51 +    >::type type;
    1.52 +};
    1.53 +
    1.54 +//  The following macros generate expansions for::
    1.55 +//
    1.56 +//      template <class RT, class T0... class TN>
    1.57 +//      inline mpl::vector<RT, T0...TN>
    1.58 +//      get_signature(RT(*)(T0...TN), void* = 0)
    1.59 +//      {
    1.60 +//          return mpl::list<RT, T0...TN>();
    1.61 +//      }
    1.62 +//
    1.63 +//   And, for an appropriate assortment of cv-qualifications::
    1.64 +//
    1.65 +//      template <class RT, class ClassT, class T0... class TN>
    1.66 +//      inline mpl::vector<RT, ClassT&, T0...TN>
    1.67 +//      get_signature(RT(ClassT::*)(T0...TN) cv))
    1.68 +//      {
    1.69 +//          return mpl::list<RT, ClassT&, T0...TN>();
    1.70 +//      }
    1.71 +//
    1.72 +//      template <class Target, class RT, class ClassT, class T0... class TN>
    1.73 +//      inline mpl::vector<
    1.74 +//          RT
    1.75 +//        , typename most_derived<Target, ClassT>::type&
    1.76 +//        , T0...TN
    1.77 +//      >
    1.78 +//      get_signature(RT(ClassT::*)(T0...TN) cv), Target*)
    1.79 +//      {
    1.80 +//          return mpl::list<RT, ClassT&, T0...TN>();
    1.81 +//      }
    1.82 +//
    1.83 +//  There are two forms for invoking get_signature::
    1.84 +//
    1.85 +//      get_signature(f)
    1.86 +//
    1.87 +//  and ::
    1.88 +//
    1.89 +//      get_signature(f,(Target*)0)
    1.90 +//
    1.91 +//  These functions extract the return type, class (for member
    1.92 +//  functions) and arguments of the input signature and stuff them in
    1.93 +//  an mpl type sequence.  Note that cv-qualification is dropped from
    1.94 +//  the "hidden this" argument of member functions; that is a
    1.95 +//  necessary sacrifice to ensure that an lvalue from_python converter
    1.96 +//  is used.  A pointer is not used so that None will be rejected for
    1.97 +//  overload resolution.
    1.98 +//
    1.99 +//  The second form of get_signature essentially downcasts the "hidden
   1.100 +//  this" argument of member functions to Target, because the function
   1.101 +//  may actually be a member of a base class which is not wrapped, and
   1.102 +//  in that case conversion from python would fail.
   1.103 +//
   1.104 +// @group {
   1.105 +
   1.106 +#  define BOOST_PP_ITERATION_PARAMS_1                                   \
   1.107 +    (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
   1.108 +
   1.109 +#  include BOOST_PP_ITERATE()
   1.110 +#  undef BOOST_PYTHON_LIST_INC
   1.111 +
   1.112 +// }
   1.113 +
   1.114 +}}} // namespace boost::python::detail
   1.115 +
   1.116 +
   1.117 +# endif // SIGNATURE_JDG20020813_HPP
   1.118 +
   1.119 +#elif BOOST_PP_ITERATION_DEPTH() == 1 // defined(BOOST_PP_IS_ITERATING)
   1.120 +
   1.121 +# define N BOOST_PP_ITERATION()
   1.122 +
   1.123 +template <
   1.124 +    class RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
   1.125 +inline BOOST_PYTHON_LIST_INC(N)<
   1.126 +    RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)>
   1.127 +get_signature(RT(*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* = 0)
   1.128 +{
   1.129 +    return BOOST_PYTHON_LIST_INC(N)<
   1.130 +            RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
   1.131 +        >();
   1.132 +}
   1.133 +
   1.134 +# undef N
   1.135 +
   1.136 +# define BOOST_PP_ITERATION_PARAMS_2 \
   1.137 +    (3, (0, 3, <boost/python/signature.hpp>))
   1.138 +# include BOOST_PP_ITERATE()
   1.139 +
   1.140 +#else
   1.141 +
   1.142 +# define N BOOST_PP_RELATIVE_ITERATION(1)
   1.143 +# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_ITERATION())
   1.144 +
   1.145 +template <
   1.146 +    class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
   1.147 +inline BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
   1.148 +    RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)>
   1.149 +get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q)
   1.150 +{
   1.151 +    return BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
   1.152 +            RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
   1.153 +        >();
   1.154 +}
   1.155 +
   1.156 +template <
   1.157 +    class Target
   1.158 +  , class RT
   1.159 +  , class ClassT
   1.160 +    BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)
   1.161 +>
   1.162 +inline BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
   1.163 +    RT
   1.164 +  , typename most_derived<Target, ClassT>::type&
   1.165 +    BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
   1.166 +>
   1.167 +get_signature(
   1.168 +    RT(ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q
   1.169 +  , Target*
   1.170 +)
   1.171 +{
   1.172 +    return BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
   1.173 +        RT
   1.174 +      , BOOST_DEDUCED_TYPENAME most_derived<Target, ClassT>::type&
   1.175 +        BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
   1.176 +    >();
   1.177 +}
   1.178 +
   1.179 +# undef Q
   1.180 +# undef N
   1.181 +
   1.182 +#endif // !defined(BOOST_PP_IS_ITERATING)