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...
#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) )
There doesn't seem to be anything in CFFI doc.about Macros
-
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
-
- Posts: 166
- Joined: Sun Nov 28, 2010 4:21 pm
Re: There doesn't seem to be anything in CFFI doc.about Mac
C/C++ preprocessor macros don't exist past compile-time, if you want to use one as a function in lisp you will need to make a stub C file that creates an actual function for it, and then compile a shared library from it and finally create a cffi definition for it. Or you could just try to implement it as a macro on the lisp side.
-
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
Re: There doesn't seem to be anything in CFFI doc.about Mac
I have a glue c and h file which i comile to so all the time so im used to that.....this would be my first macro function.....could you tell me 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....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....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 write this so i would have a basis for learning how to wrap mor c macros
#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....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....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 write this so i would have a basis for learning how to wrap mor c macros