2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 17:32:55 +00:00

Fix to allow accessing enums as data members

[SVN r16656]
This commit is contained in:
Dave Abrahams
2002-12-18 21:11:16 +00:00
parent 809535b934
commit 0df5ebf0fa
3 changed files with 42 additions and 14 deletions

View File

@@ -6,6 +6,7 @@
#include <boost/python/enum.hpp>
#include <boost/python/def.hpp>
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
using namespace boost::python;
@@ -13,6 +14,11 @@ enum color { red = 1, green = 2, blue = 4 };
color identity_(color x) { return x; }
struct colorized {
colorized() : x(red) {}
color x;
};
BOOST_PYTHON_MODULE(enum_ext)
{
enum_<color>("color")
@@ -23,6 +29,10 @@ BOOST_PYTHON_MODULE(enum_ext)
;
def("identity", identity_);
class_<colorized>("colorized")
.def_readwrite("x", &colorized::x)
;
}
#include "module_tail.cpp"