[C++-sig] V2 enum convertors

David Abrahams david.abrahams at rcn.com
Mon Apr 1 22:01:07 CEST 2002


----- Original Message -----
From: "Peter Bienstman" <pbienst at MIT.EDU>

> OK, I've got V2 to work on a small subset of my project,

Wonderful!

> but now I'm
> wondering if there is already equivalent V2 functionality for
>
>  template class boost::python::enum_as_int_converters<Limit>;
>
> and then inside the module:
>
>   m.add(boost::python::make_ref(Plus), "Plus");
>   m.add(boost::python::make_ref(Min),  "Min");


I'm afraid the answer at the moment is no.

The code is stabilized to the point where I would consider doing it,
now. If you are interested in trying yourself, you can look at
boost/libs/python/src/converter/builtin_converters.cpp and
boost/boost/python/converter/builtin_converters.hpp.

However, I'm not completely sure what the best interface would be. In
particular, should enums really be exposed as Python Ints? Wouldn't it
be better to expose a Python subclass of Int whose str() and repr()
functions return user-friendly names?

I'd like to consider these things (and would love some feedback) before
implementing enum support.

-Dave






More information about the Cplusplus-sig mailing list