[Cython] how would I wrap something like this in a .pxd file
Chris Colbert
sccolbert at gmail.com
Wed Jul 1 21:53:59 CEST 2009
Thanks Lisandro,
I may just end up declaring each struct like this with a 'pass'
and then implementing the fields on the python side (this is how ctypes does it)
Cheers!
On Wed, Jul 1, 2009 at 3:01 PM, Lisandro Dalcin<dalcinl at gmail.com> wrote:
> On Wed, Jul 1, 2009 at 3:24 PM, Chris Colbert<sccolbert at gmail.com> wrote:
>> i just saw this line in the docs:
>>
>> 6. If the header file defines a function using a macro, declare it as
>> though it were an ordinary function, with appropriate argument and
>> result types.
>>
>> So i'll start there.
>>
>> Sorry for the bogus post.
>>
>
> IMHO, your post was not bogus... Making Cython use such kind of macros
> (which resembles a C++ template emulation) can be not so easy...
> Perhaps the easiest way would be to define a helper struct (one of
> each node_type) in some C header, and then include it using cdef
> extern from "mydefs.h": ...
>
>
>>
>> On Wed, Jul 1, 2009 at 1:52 PM, Chris Colbert<sccolbert at gmail.com> wrote:
>>> In wrapping a C library, I come across many #define statements that I
>>> need to use elsewhere. When they simply define a constant, I use an
>>> anonymous enum and all is well.
>>>
>>> But how would I wrap something like this that shown up in a header
>>> file that i'm cdef extern'ing from:
>>>
>>> #define CV_TREE_NODE_FIELDS(node_type) \
>>>
>>> int flags; \
>>>
>>> int header_size; \
>>>
>>> struct node_type* h_prev; \
>>>
>>> struct node_type* h_next; \
>>>
>>> struct node_type* v_prev; \
>>>
>>> struct node_type* v_next ;
>>>
>>>
>>> or something like this:
>>>
>>> #define CV_IS_STORAGE(storage) \
>>>
>>> ((storage) != NULL && \
>>>
>>> (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) ==
>>> CV_STORAGE_MAGIC_VAL)
>>>
>>>
>>>
>>>
>>> Thanks and Cheers!
>>>
>>> Chris
>>>
>> _______________________________________________
>> Cython-dev mailing list
>> Cython-dev at codespeak.net
>> http://codespeak.net/mailman/listinfo/cython-dev
>>
>
>
>
> --
> Lisandro Dalcín
> ---------------
> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
> Tel/Fax: +54-(0)342-451.1594
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
>
More information about the Cython-dev
mailing list