how to wrap a nested struct in cffi?

Discussion of Common Lisp

how to wrap a nested struct in cffi?

Postby joeish80829 » Thu Oct 31, 2013 1:52 am

here is the way CvMemStorage is defined in OpenCV


typedef struct CvMemStorage
{
int signature;
CvMemBlock* bottom; /* First allocated block.
*/
CvMemBlock* top; /* Current memory block - top of the stack.
*/
struct CvMemStorage* parent; /* We get new blocks from parent as needed.
*/
int block_size; /* Block size.
*/
int free_space; /* Remaining free space in current block.
*/
}
CvMemStorage;


bu i get


unknown CFFI type: (:STRUCT CV-MEM-STORAGE).
[Condition of type SIMPLE-ERROR]


when i wrap like this....i know lisp is known for recursion how do i bypass this

(defcstruct cv-mem-storage
(signature :int)
(bottom (:pointer (:struct cv-mem-block)))
(top (:pointer (:struct cv-mem-block)))
(parent (:pointer (:struct cv-mem-storage)))
(block-size :int)
(free-space :int))
joeish80829
 
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am

Re: how to wrap a nested struct in cffi?

Postby Goheeca » Fri Nov 01, 2013 12:55 am

CFFI doesn't support cyclic definitions. Just leave the parent pointer unspecified, it should work.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version).
User avatar
Goheeca
 
Posts: 198
Joined: Thu May 10, 2012 12:54 pm

Re: how to wrap a nested struct in cffi?

Postby joeish80829 » Fri Nov 01, 2013 7:48 am

thanks for your help ....you were right it did
joeish80829
 
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest