I would like to wrap the following code in cython:
enum Status {GOOD, BAD};
typedef enum Status STATUS;
// note that the typedef means people dont
// have to write `enum Status` everywhere
// just returns `GOOD`
STATUS hello();
I wrote the following cython code in c_library.pxd
:
cdef extern from "library.h":
cpdef enum Status:
GOOD,
BAD
ctypedef Status STATUS
cpdef STATUS hello()
The module c_library
now contains c_library.GOOD
, c_library.BAD
,
and c_library.Status
, which behaves like an enum. However, the
return value of a call to function hello
returns a plain int:
>>> c_library.hello()
0
>>> type(c_library.hello())
<class 'int'>
I would like the result to be wrapped in an enum of the same type as well. I can change the cython file, but not the underlying C code. Is that possible?