Hello Cython Developers, I just opened PR https://github.com/cython/cython/pull/3640, which adds support for C++ scoped enumerations.
Feedback on the high-level approach used here is greatly welcome and appreciated. In general, I used the advice in https://groups.google.com/forum/#!topic/cython-users/OdvjbZ1_YKU as a starting point. One problem I haven't been to solve is coercing Python objects to and from the enum class correctly. Currently the following utility function does the conversion from C++->Python (CppConvert.pyx): #################### enum.to_py #################### cdef extern from "<type_traits>" namespace "std": cdef cppclass underlying_type_t[T]: pass @cname("{{cname}}") cdef object {{cname}}(const {{TYPE}}& x): return <int><underlying_type_t[{{TYPE}}]>(x) As you can see, the conversion goes C++->underlying_type_t->int->Python, where ideally I'd like to eliminate the conversion to `int` before obtaining a Python object. Any ideas for how to solve this? If you prefer that this discussion happen more broadly on GitHub, I'm happy to move it there. Best, Ashwin
_______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel