[Pyrex] enums in C++ classes
Ravi Lanka
ravi_lanka at acusim.com
Wed Jan 10 01:04:58 UTC 2007
Hi,
I am using pyrex to write a wrapper to a C++ library. class A given
here is a representative class of one of the classes I have in the C++
library. It has an enum declared inside the class and one of the
methods takes this enum as an argument. I am not exactly sure how to
wrap this enum and use it from the python module.
I have included the code below that works fine and now I want to wrap
the "set" method.
please advise.
Ravi
=====================================================
code from a.h and a.cpp:
class A {
public:
A(): { value = 0;}
typedef enum some_enum { zero, one, two, three };
void get() { return value;}
void set( some_enum eval, int i ) { value = i*eval ; }
private:
int value;
};
demo.pyx:
cdef extern from "a.h":
ctypedef struct A "A":
int (*get) ()
#void (*set)(some_enum val, int i)
A* AFactory "new A"()
void deleteA "delete " (void *o)
cdef class AWrapper:
def __new__( self ):
cdef A *first
cdef int i
first = AFactory()
print first.get()
=======================================================================
More information about the Pyrex
mailing list