]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/injected.cpp
1 // Copyright David Abrahams 2003.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/python/module.hpp>
7 #include <boost/python/class.hpp>
8 #include "test_class.hpp"
10 #include <boost/shared_ptr.hpp>
11 #include <boost/python/make_constructor.hpp>
12 #include <boost/python/args.hpp>
14 using namespace boost::python
;
16 typedef test_class
<> X
;
18 X
* empty() { return new X(1000); }
20 std::auto_ptr
<X
> sum(int a
, int b
) { return std::auto_ptr
<X
>(new X(a
+b
)); }
22 boost::shared_ptr
<X
> product(int a
, int b
, int c
)
24 return boost::shared_ptr
<X
>(new X(a
*b
*c
));
27 BOOST_PYTHON_MODULE(injected_ext
)
29 class_
<X
>("X", init
<int>())
30 .def("__init__", make_constructor(empty
))
31 .def("__init__", make_constructor(sum
))
32 .def("__init__", make_constructor(product
33 , default_call_policies()
34 , ( arg_("a"), arg_("b"), arg_("c"))
36 "this is product's docstring")
37 .def("value", &X::value
)