]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/python_test.cpp
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/python.hpp>
7 #include <boost/parameter/preprocessor.hpp>
8 #include <boost/parameter/keyword.hpp>
9 #include <boost/parameter/python.hpp>
10 #include <boost/utility/enable_if.hpp>
14 BOOST_PARAMETER_KEYWORD(tags
, x
)
15 BOOST_PARAMETER_KEYWORD(tags
, y
)
16 BOOST_PARAMETER_KEYWORD(tags
, z
)
20 // We need the disable_if part for VC7.1/8.0.
24 , typename
boost::disable_if
<
25 boost::is_base_and_derived
<Xbase
, Args
>
28 : value(std::string(args
[x
| "foo"]) + args
[y
| "bar"])
36 BOOST_PARAMETER_CONSTRUCTOR(X
, (Xbase
), tags
,
43 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f
, tags
,
53 return args
[x
] + args
[y
] + args
[z
| 0];
56 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((std::string
), g
, tags
,
63 return std::string(args
[x
| "foo"]) + args
[y
| "bar"];
66 BOOST_PARAMETER_MEMBER_FUNCTION((X
&), h
, tags
,
67 (optional (x
, *, "") (y
, *, ""))
74 X
& operator()(A0
const& a0
)
84 template <class R
, class T
, class A0
, class A1
, class A2
>
85 R
operator()(boost::type
<R
>, T
& self
, A0
const& a0
, A1
const& a1
, A2
const& a2
)
87 return self
.f(a0
,a1
,a2
);
93 template <class R
, class T
, class A0
, class A1
>
94 R
operator()(boost::type
<R
>, T
& self
, A0
const& a0
, A1
const& a1
)
102 template <class R
, class T
>
103 R
operator()(boost::type
<R
>, T
& self
)
108 template <class R
, class T
, class A0
>
109 R
operator()(boost::type
<R
>, T
& self
, A0
const& a0
)
114 template <class R
, class T
, class A0
, class A1
>
115 R
operator()(boost::type
<R
>, T
& self
, A0
const& a0
, A1
const& a1
)
117 return self
.h(a0
,a1
);
121 BOOST_PYTHON_MODULE(python_test_ext
)
123 namespace mpl
= boost::mpl
;
124 using namespace test
;
125 using namespace boost::python
;
129 boost::parameter::python::init
<
131 tags::x
*(std::string
), tags::y
*(std::string
)
137 , boost::parameter::python::function
<
140 int, tags::x(int), tags::y(int), tags::z
*(int)
146 , boost::parameter::python::function
<
149 std::string
, tags::x
*(std::string
), tags::y
*(std::string
)
155 , boost::parameter::python::function
<
158 X
&, tags::x
**(std::string
), tags::y
**(std::string
)
164 boost::parameter::python::call
<
168 >() [ return_arg
<>() ]
170 .def_readonly("value", &X::value
);