]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/enum_ext.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)
5 #include <boost/python/enum.hpp>
6 #include <boost/python/def.hpp>
7 #include <boost/python/module.hpp>
8 #include <boost/python/class.hpp>
9 #if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
10 # include <boost/type_traits/is_enum.hpp>
11 # include <boost/mpl/bool.hpp>
13 using namespace boost::python
;
15 enum color
{ red
= 1, green
= 2, blue
= 4, blood
= 1 };
17 #if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
18 namespace boost
// Pro7 has a hard time detecting enums
20 template <> struct is_enum
<color
> : boost::mpl::true_
{};
24 color
identity_(color x
) { return x
; }
27 colorized() : x(red
) {}
31 BOOST_PYTHON_MODULE(enum_ext
)
35 .value("green", green
)
37 .value("blood", blood
)
41 def("identity", identity_
);
43 #if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
44 color
colorized::*px
= &colorized::x
;
45 class_
<colorized
>("colorized")
46 .def_readwrite("x", px
)
49 class_
<colorized
>("colorized")
50 .def_readwrite("x", &colorized::x
)
55 #include "module_tail.cpp"