I'm used to wrapping functions but I'm trying to wrap the function cvStartWriteSeq and it appears to use a macro - CV_WRITE_SEQ_ELEM - to write elements to a opencv sequence...
here is the code isaw where I discovered that:
CvSeqWriter writer;
cvStartWriteSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage, &writer );
for( i = 0; i < 100; i++ )
{
CvPoint pt; pt.x = rand()%320; pt.y = rand()%240;
CV_WRITE_SEQ_ELEM( pt, writer );
}
CvSeq* seq = cvEndWriteSeq( &writer );
I'm familiar with using defcfun to wrap functions but in the /modules/core/include/opencv2/core/types_c.h I saw the macro and I was curious as how I would accomplish the task. here is the macro definition...
#define CV_WRITE_SEQ_ELEM( elem, writer ) \
{ \
assert( (writer).seq->elem_size == sizeof(elem)); \
if( (writer).ptr >= (writer).block_max ) \
{ \
cvCreateSeqBlock( &writer); \
} \
assert( (writer).ptr <= (writer).block_max - sizeof(elem));\
memcpy((writer).ptr, &(elem), sizeof(elem)); \
(writer).ptr += sizeof(elem); \
}
any guidance on how I would do this would speed up the process of getting a complete Lisp opencv wrapper and be greatly appreciated =)
CFFI has an ASDF extension which I wrote exactly for this case: wrapping C macros. Example: https://github.com/sionescu/iolib/blob/ee8d3e538b6a4f0433b6e53e2d0bd767ba879149/iolib.syscalls.asd https://github.com/sionescu/iolib/blob/ee8d3e538b6a4f0433b6e53e2d0bd767ba879149/syscalls/ffi-wrappers-unix.lisp