2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00
Files
python/test/enum.cpp
Ralf W. Grosse-Kunstleve e80224b1ad boost/python, libs/python: all changes from trunk merged into branches/release (without any manual modifications)
Commands used:
  svn merge https://svn.boost.org/svn/boost/branches/release/boost/python https://svn.boost.org/svn/boost/trunk/boost/python /net/chevy/raid1/rwgk/boost_release/merge_attempt/boost/boost/python

  svn merge https://svn.boost.org/svn/boost/branches/release/libs/python https://svn.boost.org/svn/boost/trunk/libs/python /net/chevy/raid1/rwgk/boost_release/merge_attempt/boost/libs/python

  svn, version 1.6.4 (r38063)
     compiled Aug 17 2009, 13:31:03


[SVN r55629]
2009-08-17 21:01:18 +00:00

56 lines
1.3 KiB
C++

// Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python/enum.hpp>
#include <boost/python/def.hpp>
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
# include <boost/type_traits/is_enum.hpp>
# include <boost/mpl/bool.hpp>
#endif
using namespace boost::python;
enum color { red = 1, green = 2, blue = 4, blood = 1 };
#if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
namespace boost // Pro7 has a hard time detecting enums
{
template <> struct is_enum<color> : boost::mpl::true_ {};
}
#endif
color identity_(color x) { return x; }
struct colorized {
colorized() : x(red) {}
color x;
};
BOOST_PYTHON_MODULE(enum_ext)
{
enum_<color>("color")
.value("red", red)
.value("green", green)
.value("blue", blue)
.value("blood", blood)
.export_values()
;
def("identity", identity_);
#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
color colorized::*px = &colorized::x;
class_<colorized>("colorized")
.def_readwrite("x", px)
;
#else
class_<colorized>("colorized")
.def_readwrite("x", &colorized::x)
;
#endif
}
#include "module_tail.cpp"