source: NonGTP/Boost/boost/python/detail/signature.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
Line 
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
16#  include <boost/preprocessor/iterate.hpp>
17#  include <boost/preprocessor/iteration/local.hpp>
18
19#  include <boost/mpl/at.hpp>
20#  include <boost/mpl/size.hpp>
21
22namespace boost { namespace python { namespace detail {
23
24struct signature_element
25{
26    char const* basename;
27    bool lvalue;
28};
29
30template <unsigned> struct signature_arity;
31
32#  define BOOST_PP_ITERATION_PARAMS_1                                            \
33        (3, (0, BOOST_PYTHON_MAX_ARITY + 1, <boost/python/detail/signature.hpp>))
34#  include BOOST_PP_ITERATE()
35
36// A metafunction returning the base class used for
37//
38//   signature<class F, class CallPolicies, class Sig>.
39//
40template <class Sig>
41struct signature_base_select
42{
43    enum { arity = mpl::size<Sig>::value - 1 };
44    typedef typename signature_arity<arity>::template impl<Sig> type;
45};
46
47template <class Sig>
48struct signature
49    : signature_base_select<Sig>::type
50{
51};
52
53}}} // namespace boost::python::detail
54
55# endif // SIGNATURE_DWA20021121_HPP
56
57#else
58
59# define N BOOST_PP_ITERATION()
60
61template <>
62struct signature_arity<N>
63{
64    template <class Sig>
65    struct impl
66    {
67        static signature_element const* elements()
68        {
69            static signature_element const result[N+2] = {
70               
71# define BOOST_PP_LOCAL_MACRO(i)                                                            \
72     {                                                                                      \
73         type_id<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>().name()                    \
74         , indirect_traits::is_reference_to_non_const<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>::value \
75     },
76               
77# define BOOST_PP_LOCAL_LIMITS (0, N)
78# include BOOST_PP_LOCAL_ITERATE()
79                {0,0}
80            };
81            return result;
82        }
83    };
84};
85
86#endif // BOOST_PP_IS_ITERATING
87
88
Note: See TracBrowser for help on using the repository browser.