Page 1 of 1

How do i wrap this c struct in cffi?

Posted: Thu Oct 31, 2013 1:49 am
by joeish80829
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.
*/
#define CV_SEQUENCE_FIELDS() \
CV_TREE_NODE_FIELDS(CvSeq); \
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
{
CV_SEQUENCE_FIELDS()
}


the CV_SEQUENCE_FIELDS()
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 =)