]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/return_arg.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / python / test / return_arg.cpp
1 // Copyright David Abrahams and Nikolay Mladenov 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)
5
6 #include <boost/python/module.hpp>
7 #include <boost/python/class.hpp>
8 #include <boost/python/def.hpp>
9 #include <boost/python/return_arg.hpp>
10
11 struct Widget
12 {
13 Widget()
14 : sensitive_(true)
15 {}
16
17 bool get_sensitive() const
18 {
19 return sensitive_;
20 }
21
22 void set_sensitive(bool s)
23 {
24 this->sensitive_ = s;
25 }
26
27 private:
28 bool sensitive_;
29 };
30
31 struct Label : Widget
32 {
33 Label() {}
34
35 std::string get_label() const
36 {
37 return label_;
38 }
39
40 void set_label(const std::string &l)
41 {
42 label_ = l;
43 }
44
45 private:
46 std::string label_;
47 };
48
49 void return_arg_f(boost::python::object) {}
50
51 using namespace boost::python;
52 BOOST_PYTHON_MODULE(return_arg_ext)
53 {
54 class_<Widget>("Widget")
55 .def("sensitive", &Widget::get_sensitive)
56 .def("sensitive", &Widget::set_sensitive, return_self<>())
57 ;
58
59 class_<Label, bases<Widget> >("Label")
60 .def("label", &Label::get_label)//,return_arg<0>()) //error(s)
61 .def("label", &Label::set_label, return_self<>())
62 ;
63
64 def("return_arg", return_arg_f, return_arg<1>());
65 }
66
67 #include "module_tail.cpp"