On Monday, November 5, 2012 11:45:47 PM UTC-8, Robert Bradshaw wrote:
> On Mon, Nov 5, 2012 at 10:07 PM, RC <rav...@gmail.com <javascript:>>
> wrote:
> > I am trying to wrap a cpp lib into cython. Here are some details:
> > Handle.h:
> > class Handle {
> > public:
> > // accessors
> > // mutators
> > };
> > class Store {
> > public:
> > Handle* lookup(char* handleName);
> > int update(Handle*);
> > };
> > handle.pyx:
> > cdef extern from "Handle.h" namespace "xxx":
> > cdef cppclass Handle:
> > ....
> > cdef extern from "Handle.h" namespace "xxx":
> > cdef cppclass Store:
> > Handle* lookup(char*)
> > int update(Handle*)
> > cdef class PyHandle:
> > cdef class PyStore:
> > cdef Store* store
> > def __cinit__(self):
> > store = ....
> > def lookup(self, name):
> > handle = self.store.lookup(name)
> > pHandle = PyHandle()
> > pHandle.handle = handle
> > return pHandle
> > def update(self, h):
> > self.store.update(h.handle)
> > the last statement is giving me an error saying "Cannot convert Python
> > object to 'Handle *'". I know i am missing something simple. How do i
> pass
> > the handle* that is embedded in the python object to the call?
> On the vary last line, all it knows is that h is a Python object. You
> probably meant to say
> def update(self, PyHandle h):
> self.store.update(h.handle)
> - Robert