I've made some progress on learning to wrap std::vector. I've got a
__getitem__, but I don't know what to do about __setitem__.
cdef extern from "vector":
pass
cdef extern from "test1.hpp":
ctypedef struct intvec "std::vector<unsigned int>":
void (* push_back)(int elem)
inline int get "operator[]" (int i)
intvec intvec_factory "std::vector<unsigned int>"(int len)
int my_sum "my_sum<std::vector<unsigned int> >"(intvec vec)
cdef intvec v = intvec_factory(2)
v.push_back(2)
#print my_sum (v)
cdef class intvec_wrap:
cdef intvec vec
def __init__(self):
self.vec = intvec_factory (2)
def __getitem__(self, int i):
return self.vec.get (i)
Problem is, operator[] (or at()) returns an int&. I don't have a clue what
to do with this.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev