]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/staticmethod.cpp
1 // Copyright David Abrahams 2002.
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/class.hpp>
7 #include <boost/python/module.hpp>
8 #include <boost/python/def.hpp>
9 #include <boost/python/call_method.hpp>
10 #include <boost/ref.hpp>
11 #include <boost/utility.hpp>
12 #define BOOST_ENABLE_ASSERT_HANDLER
13 #include <boost/assert.hpp>
15 using namespace boost::python
;
19 explicit X(int x
) : x(x
), magic(7654321) { ++counter
; }
20 X(X
const& rhs
) : x(rhs
.x
), magic(7654321) { ++counter
; }
21 virtual ~X() { BOOST_ASSERT(magic
== 7654321); magic
= 6666666; x
= 9999; --counter
; }
23 void set(int _x
) { BOOST_ASSERT(magic
== 7654321); this->x
= _x
; }
24 int value() const { BOOST_ASSERT(magic
== 7654321); return x
; }
25 static int count() { return counter
; }
27 void operator=(X
const&);
34 int getXmagic(){return 7654321;}
36 BOOST_PYTHON_MODULE(staticmethod_ext
)
38 class_
<X
>("X", init
<int>())
39 .def("value", &X::value
)
41 .def("count", &X::count
)
42 .staticmethod("count")
43 .def("magic", &getXmagic
)
44 .staticmethod("magic")
48 #include "module_tail.cpp"