2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00

enum export

[SVN r16604]
This commit is contained in:
Dave Abrahams
2002-12-13 20:04:34 +00:00
parent eab084c9a2
commit 4a5817d8ba
7 changed files with 39 additions and 1 deletions

View File

@@ -12,6 +12,8 @@
#include <boost/python/dict.hpp>
#include <boost/python/str.hpp>
#include <boost/python/extract.hpp>
#include <boost/python/object_protocol.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <structmember.h>
#include <cstdio>
@@ -194,6 +196,18 @@ void enum_base::add_value(char const* name_, long value)
p->name = incref(name.ptr());
}
void enum_base::export_values()
{
dict d = extract<dict>(this->attr("values"))();
list values = d.values();
scope current;
for (unsigned i = 0, max = len(values); i < max; ++i)
{
api::setattr(current, object(values[i].attr("name")), values[i]);
}
}
PyObject* enum_base::to_python(PyTypeObject* type_, long x)
{
object type((type_handle(borrowed(type_))));