]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/python/detail/signature.hpp
Manually merged pull request #222
[casparcg] / dependencies / boost / boost / python / detail / signature.hpp
1 #if !defined(BOOST_PP_IS_ITERATING)
2
3 // Copyright David Abrahams 2002.
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 SIGNATURE_DWA20021121_HPP
9 #  define SIGNATURE_DWA20021121_HPP
10
11 #  include <boost/python/type_id.hpp>
12
13 #  include <boost/python/detail/preprocessor.hpp>
14 #  include <boost/python/detail/indirect_traits.hpp>
15 #  include <boost/python/converter/pytype_function.hpp>
16
17 #  include <boost/preprocessor/iterate.hpp>
18 #  include <boost/preprocessor/iteration/local.hpp>
19
20 #  include <boost/mpl/at.hpp>
21 #  include <boost/mpl/size.hpp>
22
23 namespace boost { namespace python { namespace detail { 
24
25 struct signature_element
26 {
27     char const* basename;
28     converter::pytype_function pytype_f;
29     bool lvalue;
30 };
31
32 struct py_func_sig_info
33 {
34     signature_element const *signature;
35     signature_element const *ret;
36 };
37
38 template <unsigned> struct signature_arity;
39
40 #  define BOOST_PP_ITERATION_PARAMS_1                                            \
41         (3, (0, BOOST_PYTHON_MAX_ARITY + 1, <boost/python/detail/signature.hpp>))
42 #  include BOOST_PP_ITERATE()
43
44 // A metafunction returning the base class used for
45 //
46 //   signature<class F, class CallPolicies, class Sig>.
47 //
48 template <class Sig>
49 struct signature_base_select
50 {
51     enum { arity = mpl::size<Sig>::value - 1 };
52     typedef typename signature_arity<arity>::template impl<Sig> type;
53 };
54
55 template <class Sig>
56 struct signature
57     : signature_base_select<Sig>::type
58 {
59 };
60
61 }}} // namespace boost::python::detail
62
63 # endif // SIGNATURE_DWA20021121_HPP
64
65 #else
66
67 # define N BOOST_PP_ITERATION()
68
69 template <>
70 struct signature_arity<N>
71 {
72     template <class Sig>
73     struct impl
74     {
75         static signature_element const* elements()
76         {
77             static signature_element const result[N+2] = {
78                 
79 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
80 # define BOOST_PP_LOCAL_MACRO(i)                                                            \
81                 {                                                                           \
82                   type_id<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>().name()           \
83                   , &converter::expected_pytype_for_arg<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>::get_pytype   \
84                   , indirect_traits::is_reference_to_non_const<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>::value \
85                 },
86 #else
87 # define BOOST_PP_LOCAL_MACRO(i)                                                            \
88                 {                                                                           \
89                   type_id<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>().name()           \
90                   , 0 \
91                   , indirect_traits::is_reference_to_non_const<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>::value \
92                 },
93 #endif
94                 
95 # define BOOST_PP_LOCAL_LIMITS (0, N)
96 # include BOOST_PP_LOCAL_ITERATE()
97                 {0,0,0}
98             };
99             return result;
100         }
101     };
102 };
103
104 #endif // BOOST_PP_IS_ITERATING 
105
106