How do i wrap this c struct in cffi?

Discussion of Common Lisp

How do i wrap this c struct in cffi?

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

it is the CvSeq struct from opencv and it is defined a wee bit different than
the others

here it is as defined

#define CV_TREE_NODE_FIELDS(node_type) \
int flags; /* Miscellaneous flags. */ \
int header_size; /* Size of sequence header. */ \
struct node_type* h_prev; /* Previous sequence. */ \
struct node_type* h_next; /* Next sequence. */ \
struct node_type* v_prev; /* 2nd previous sequence. */ \
struct node_type* v_next /* 2nd next sequence. */

Read/Write sequence.
Elements can be dynamically inserted to or deleted from the sequence.
int total; /* Total number of elements. */ \
int elem_size; /* Size of sequence element in bytes. */ \
schar* block_max; /* Maximal bound of the last block. */ \
schar* ptr; /* Current write pointer. */ \
int delta_elems; /* Grow seq this many at a time. */ \
CvMemStorage* storage; /* Where the seq is stored. */ \
CvSeqBlock* free_blocks; /* Free blocks list. */ \
CvSeqBlock* first; /* Pointer to the first sequence block. */

typedef struct CvSeq

part of the typedef struct CvSeq threw me
I dont really know what to do with can someone just show me how to write

it so I can then wrap all other structs like this....I could show things i
tried but t
hat would take up so much space it would be exhausting to look at...below is

the swig wrapped struct i'm working with but it hasn't been working right so if

you can show me how to edit it i would be very grateful =)

(defcstruct cv-seq
(flags :int)
(header-size :int)
(h-prev :pointer)
(h-next :pointer)
(v-prev :pointer)
(v-next :pointer)
(total :int)
(elem-size :int)
(block-max :pointer)
(ptr :pointer)
(delta-elems :int)
(storage :pointer)
(free-blocks :pointer)
(first :pointer))

note normally when i add members like this CvSeqBlock* first; i do it like
this (first (:pointer (:struct cv-block))) the new cffi style so if you can
show me the new way on this that would be perfect =)
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 11 guests