]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/raw_ctor.cpp
1 // Copyright David Abrahams 2004. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include <boost/python/class.hpp>
6 #include <boost/python/raw_function.hpp>
7 #include <boost/python/make_constructor.hpp>
8 #include <boost/python/dict.hpp>
9 #include <boost/python/tuple.hpp>
10 #include <boost/python/module.hpp>
12 using namespace boost::python
;
17 Foo(tuple args
, dict kw
)
18 : args(args
), kw(kw
) {}
24 object
init_foo(tuple args
, dict kw
)
26 tuple
rest(args
.slice(1,_
));
27 return args
[0].attr("__init__")(rest
, kw
);
30 BOOST_PYTHON_MODULE(raw_ctor_ext
)
32 // using no_init postpones defining __init__ function until after
33 // raw_function for proper overload resolution order, since later
34 // defs get higher priority.
35 class_
<Foo
>("Foo", no_init
)
36 .def("__init__", raw_function(&init_foo
))
37 .def(init
<tuple
, dict
>())
38 .def_readwrite("args", &Foo::args
)
39 .def_readwrite("kw", &Foo::kw
)
43 #include "module_tail.cpp"