[cffi-devel] There doesn't seem to be anything in CFFI doc. about wrapping macros

Joeish W joeish80829 at yahoo.com
Sat Nov 2 18:54:47 UTC 2013


well I have to do a glue layer for it any way because the macro  gets an unidentified alien function  error when I try to call it from a defcfun in lisp...I write alot of glue code for unidentified alien function errors but those are for functions not macros. could you help get me started writing a glue layer for this macro i posted so i can call it in a defcfun for c....i have no idea how to type  cast the parameters or how to do a return on them...btw .sorry if i sent  a reply to your mailbox Frank =)





On Saturday, November 2, 2013 9:23 AM, Frank Gönninger <frank.goenninger at consequor.de> wrote:
 
This is a simple code generation C macro, so this is simple to be
>transcripted into Common Lisp. There are several alternatives to do this.
>
>Either you write the code explicitly in every use occasion or you write a
>Common Lisp macro that does the same.
>
>(defmacro cv-seq-elem( seq elem_type index )
>  `( Š 
>
>But why do you what to do this in
 Lisp? I would rather write some glue
>layer in C and have much simpler calls from Lisp to C.
>
>Good luck.
>
>Frank
>
>
>
>Am 02.11.13 16:43 schrieb "Joeish W" unter <joeish80829 at yahoo.com>:
>
>>
>>I'm trying to wrap the GET_SEQ_ELEM  macro below can some one give me
>>clues or example how i would go about this easily
>>
>>with a cffi function like defcfun...If there is no clear way i definately
>>propose an addendum to cffi for wrapping macros
>>
>>
>>#define  CV_SEQ_ELEM( seq, elem_type, index )   
                 \
>>
>>/* assert gives some guarantee that <seq> parameter is valid */  \
>>
>>(   assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) &&      \
>>
>>    (seq)->elem_size == sizeof(elem_type)),                      \
>>
>>    (elem_type*)((seq)->first && (unsigned)index
>> <               \
>>
>>    (unsigned)((seq)->first->count) ?                            \
>>
>>    (seq)->first->data + (index) *
 sizeof(elem_type) :           \
>>
>>    cvGetSeqElem( (CvSeq*)(seq), (index) )))
>>
>>#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq),
>>elem_type, (index) )
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20131102/5e09f0b5/attachment.html>


More information about the cffi-devel mailing list