]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/test/enum_ext.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / test / enum_ext.cpp
CommitLineData
7c673cae
FG
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>
12#endif
13using namespace boost::python;
14
15enum color { red = 1, green = 2, blue = 4, blood = 1 };
16
17#if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
18namespace boost // Pro7 has a hard time detecting enums
19{
20 template <> struct is_enum<color> : boost::mpl::true_ {};
21}
22#endif
23
24color identity_(color x) { return x; }
25
26struct colorized {
27 colorized() : x(red) {}
28 color x;
29};
30
31BOOST_PYTHON_MODULE(enum_ext)
32{
33 enum_<color>("color")
34 .value("red", red)
35 .value("green", green)
36 .value("blue", blue)
37 .value("blood", blood)
38 .export_values()
39 ;
40
41 def("identity", identity_);
42
43#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
44 color colorized::*px = &colorized::x;
45 class_<colorized>("colorized")
46 .def_readwrite("x", px)
47 ;
48#else
49 class_<colorized>("colorized")
50 .def_readwrite("x", &colorized::x)
51 ;
52#endif
53}
54
55#include "module_tail.cpp"