ok i do appreciate you help so far but 1 more thing....i get everything else you said
what do i cast the return value to for CV_GET_SEQ_ELEM because the
documentation for it says...."The macro checks first whether the desired
element belongs to the first block of the sequence and returns it if it
does; otherwise the macro calls the main function GetSeqElem" tthe
documentation for cvGetSeqElem says "Returns a pointer to a sequence
element according to its index." so the macro seems to have ability to
return 2 separate values but the function cvGetseqElem does
not....cvGetSeqElems return is usually cast to other types when its
used though....I was hoping you could help me figure out how to cast its return and how to get by the parameters not being declared here i/e to int or double etc
#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )
I
know what these variables are i/e elem_type is an int and sq is a CvSeq*, index is an int....but i have
alot glue code to write for macros like this....so if i didnt know what
the variables should be declared as ....what do i do.....this will help me master this part of writing my library(gloe code for macros) if you could answer this for me
On Saturday, November 2, 2013 1:14 PM, Frank Gönninger <frank.goenninger(a)consequor.de> wrote:
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(a)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(a)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(a)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(a)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) )
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>