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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user