Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/enum.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.3 KB
Line 
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 };
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        .export_values()
38        ;
39   
40    def("identity", identity_);
41
42#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
43    color colorized::*px = &colorized::x;
44    class_<colorized>("colorized")
45        .def_readwrite("x", px)
46        ;
47#else
48    class_<colorized>("colorized")
49        .def_readwrite("x", &colorized::x)
50        ;
51#endif
52}
53
54#include "module_tail.cpp"
Note: See TracBrowser for help on using the repository browser.