A C macro is merely a text replacement, not a function
definition/declaration. So you can not "call" it - neither from C nor from
Lisp.
In every place in C code where CV_SEQ_ELEM() appears the C preprocessor
replaces this *text* with what the macro generates.
Not knowing what this macro really does it will replace
CV_SEQ_ELEM(myseq,int,1)
with
( assert(sizeof((mytype)->first[0]) == sizeof(CvSeqBlock) &&
(mytype)->elem_size == sizeof(int)), (int*)((mytype)->first &&
(unsigned)1 < (unsigned)((mytype)->first->count) ? (mytype)->first->data +
(1) * sizeof(int) : cvGetSeqElem( (CvSeq*)(mytype), (1) )))
You see, a simple text replacement.
So - all you need to do is to write a C layer that has a function around
this. If you want to do this in
Lisp, then you need to manually translate
this into Lisp. You need to have a solid understanding of C and a solid
understanding of Lisp to do that.
Cheers
Frank
--
C o n s e q u o r C o n s u l t i n g A G
Frank Gönninger
Mobil: +49 175 43 21 058
E-Mail:
frank.goenninger@consequor.de Telefon: +49 711 781181 10
Fax: +49 711 781181 11
Consequor Consulting AG
Liebknechtstr. 33
D-70565 Stuttgart, Germany
Vorstand: Frank Gönninger
Aufsichtsratsvorsitzender: Dipl.-Kfm. Matthias Filbinger
Sitz der Gesellschaft: 70565 Stuttgart, Deutschland
Registergericht Amtsgericht Stuttgart HRB 727446
Am 02.11.13 19:54 schrieb "Joeish W" unter <
joeish80829@yahoo.com>:
>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@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@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) )
>
>
>
>
>
>
>
>
>
>
>
>