1 |
|
|
#ifndef DOXYGEN_BOOST_DOC_HH |
2 |
|
|
#define DOXYGEN_BOOST_DOC_HH |
3 |
|
|
|
4 |
|
|
#ifndef DOXYGEN_DOC_HH |
5 |
|
|
#error "You should have included doxygen.hh first." |
6 |
|
|
#endif // DOXYGEN_DOC_HH |
7 |
|
|
|
8 |
|
|
#include <boost/python.hpp> |
9 |
|
|
|
10 |
|
|
namespace doxygen { |
11 |
|
|
|
12 |
|
|
namespace visitor { |
13 |
|
|
|
14 |
|
|
template <typename function_type, |
15 |
|
|
typename policy_type = boost::python::default_call_policies> |
16 |
|
|
struct member_func_impl : boost::python::def_visitor< |
17 |
|
|
member_func_impl<function_type, policy_type> > { |
18 |
|
815 |
member_func_impl(const char* n, const function_type& f) |
19 |
|
815 |
: name(n), function(f) {} |
20 |
|
|
|
21 |
|
20 |
member_func_impl(const char* n, const function_type& f, policy_type p) |
22 |
|
20 |
: name(n), function(f), policy(p) {} |
23 |
|
|
|
24 |
|
|
template <class classT> |
25 |
|
835 |
inline void visit(classT& c) const { |
26 |
|
|
// Either a boost::python::keyword<N> object or a void_ object |
27 |
✓✗ |
835 |
call(c, member_func_args(function)); |
28 |
|
835 |
} |
29 |
|
|
|
30 |
|
|
template <class classT, std::size_t nkeywords> |
31 |
|
|
inline void call( |
32 |
|
|
classT& c, const boost::python::detail::keywords<nkeywords>& args) const { |
33 |
|
|
c.def(name, function, member_func_doc(function), args, policy); |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
template <class classT> |
37 |
|
835 |
inline void call(classT& c, const void_&) const { |
38 |
✓✗ |
835 |
c.def(name, function, member_func_doc(function), policy); |
39 |
|
835 |
} |
40 |
|
|
|
41 |
|
|
const char* name; |
42 |
|
|
const function_type& function; |
43 |
|
|
policy_type policy; |
44 |
|
|
}; |
45 |
|
|
|
46 |
|
|
// TODO surprisingly, this does not work when defined here but it works when |
47 |
|
|
// defined after the generated files are included. |
48 |
|
|
template <typename function_type> |
49 |
|
815 |
inline member_func_impl<function_type> member_func( |
50 |
|
|
const char* name, const function_type& function) { |
51 |
|
815 |
return member_func_impl<function_type>(name, function); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
template <typename function_type, typename policy_type> |
55 |
|
20 |
inline member_func_impl<function_type, policy_type> member_func( |
56 |
|
|
const char* name, const function_type& function, |
57 |
|
|
const policy_type& policy) { |
58 |
|
20 |
return member_func_impl<function_type, policy_type>(name, function, policy); |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
#define DOXYGEN_DOC_DECLARE_INIT_VISITOR(z, nargs, unused) \ |
62 |
|
|
template <typename Class BOOST_PP_COMMA_IF(nargs) \ |
63 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, class Arg)> \ |
64 |
|
|
struct init_##nargs##_impl \ |
65 |
|
|
: boost::python::def_visitor< \ |
66 |
|
|
init_##nargs##_impl<Class BOOST_PP_COMMA_IF(nargs) \ |
67 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, Arg)> > { \ |
68 |
|
|
typedef constructor_##nargs##_impl<Class BOOST_PP_COMMA_IF(nargs) \ |
69 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, Arg)> \ |
70 |
|
|
constructor; \ |
71 |
|
|
typedef boost::python::init<BOOST_PP_ENUM_PARAMS(nargs, Arg)> init_base; \ |
72 |
|
|
\ |
73 |
|
|
template <class classT> \ |
74 |
|
|
inline void visit(classT& c) const { \ |
75 |
|
|
call(c, constructor::args()); \ |
76 |
|
|
} \ |
77 |
|
|
\ |
78 |
|
|
template <class classT> \ |
79 |
|
|
void call(classT& c, \ |
80 |
|
|
const boost::python::detail::keywords<nargs + 1>& args) const { \ |
81 |
|
|
c.def(init_base(constructor::doc(), args)); \ |
82 |
|
|
} \ |
83 |
|
|
\ |
84 |
|
|
template <class classT> \ |
85 |
|
|
void call(classT& c, const void_&) const { \ |
86 |
|
|
c.def(init_base(constructor::doc())); \ |
87 |
|
|
} \ |
88 |
|
|
}; \ |
89 |
|
|
\ |
90 |
|
|
template <typename Class BOOST_PP_COMMA_IF(nargs) \ |
91 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, class Arg)> \ |
92 |
|
|
inline init_##nargs##_impl<Class BOOST_PP_COMMA_IF(nargs) \ |
93 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, Arg)> \ |
94 |
|
|
init() { \ |
95 |
|
|
return init_##nargs##_impl<Class BOOST_PP_COMMA_IF(nargs) \ |
96 |
|
|
BOOST_PP_ENUM_PARAMS(nargs, Arg)>(); \ |
97 |
|
|
} |
98 |
|
|
|
99 |
✓✓✗ |
2340 |
BOOST_PP_REPEAT(DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR, |
100 |
|
|
DOXYGEN_DOC_DECLARE_INIT_VISITOR, ~) |
101 |
|
|
#undef DOXYGEN_DOC_DECLARE_INIT_VISITOR |
102 |
|
|
|
103 |
|
|
} // namespace visitor |
104 |
|
|
|
105 |
|
|
template <typename Func> |
106 |
|
165 |
void def(const char* name, Func func) { |
107 |
✓✗ |
165 |
boost::python::def(name, func, member_func_doc(func)); |
108 |
|
165 |
} |
109 |
|
|
|
110 |
|
|
} // namespace doxygen |
111 |
|
|
|
112 |
|
|
#endif // DOXYGEN_BOOST_DOC_HH |