doxygen-boost.hh
Go to the documentation of this file.
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  member_func_impl(const char* n, const function_type& f)
19  : name(n), function(f) {}
20 
21  member_func_impl(const char* n, const function_type& f, policy_type p)
22  : name(n), function(f), policy(p) {}
23 
24  template <class classT>
25  inline void visit(classT& c) const {
26  // Either a boost::python::keyword<N> object or a void_ object
27  call(c, member_func_args(function));
28  }
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  inline void call(classT& c, const void_&) const {
38  c.def(name, function, member_func_doc(function), policy);
39  }
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>
50  const char* name, const function_type& function) {
51  return member_func_impl<function_type>(name, function);
52 }
53 
54 template <typename function_type, typename policy_type>
56  const char* name, const function_type& function,
57  const policy_type& 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 
101 #undef DOXYGEN_DOC_DECLARE_INIT_VISITOR
102 
103 } // namespace visitor
104 
105 template <typename Func>
106 void def(const char* name, Func func) {
107  boost::python::def(name, func, member_func_doc(func));
108 }
109 
110 } // namespace doxygen
111 
112 #endif // DOXYGEN_BOOST_DOC_HH
#define DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR
Definition: doxygen.hh:10
const char * member_func_doc(FuncPtr)
Definition: doxygen.hh:33
const function_type & function
void def(const char *name, Func func)
BOOST_PP_REPEAT(DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR, DOXYGEN_DOC_DECLARE_CONSTRUCTOR, ~) template< typename Class > struct destructor_doc_impl
Definition: doxygen.hh:57
member_func_impl(const char *n, const function_type &f)
member_func_impl(const char *n, const function_type &f, policy_type p)
boost::mpl::void_ void_
Definition: doxygen.hh:14
void call(classT &c, const void_ &) const
void call(classT &c, const boost::python::detail::keywords< nkeywords > &args) const
#define DOXYGEN_DOC_DECLARE_INIT_VISITOR(z, nargs, unused)
member_func_impl< function_type > member_func(const char *name, const function_type &function)
void_ member_func_args(FuncPtr)
Definition: doxygen.hh:38


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:01