Re: [ctypes-users] Using ctypes to to build a pointer(pointer(struct))
Brought to you by:
theller
From: Nathan H. <iwa...@go...> - 2008-06-10 22:04:15
|
Hi all, I m currently trying to wrap some "wtf" c code with ctypes and have the current problem: one of the methods takes a POINTER(POINTER(Model)) as an argument and I currently have want to pass a list of models to this function, which are defined like this: models = [ Model(), Model() ] so i convert l to a ctypes list using: m = ( Model * len(models))( *models ) which unfortunately doesnt work (obviously). sim.foo(m) Is there an easy way that I can convert an list of models into POINTER(POINTER(Model) using Python, or would it be best to write a wrapper function in C to accomplish this (which doesnt appeal to me at all) as I have access to the C code. Many Thanks in advance Nathan PS. I don't know why the original author used POINTER(POINTER(Model)) when POINTER(Model) would have sufficed. |