[Pyrex] Generating a header?

Lenard Lindstrom len-l at telus.net
Wed Dec 27 22:25:46 UTC 2006


Andreas Fredriksson wrote:
> Hi folks,
>
> I've just started playing with Pyrex and I'm wondering if it would be
> feasible to generate a header from a cdef block.
>
> I'm designing a little application where I'm writing a bunch of native
> modules to be used to construct the application in Python. I don't
> have anything to wrap since I'm starting a fresh project, so it would
> make sense for me to
>
> 1) Write a pyx specification for some module,
> 2) Have the header file generated,
> 3) Implement the functions declared in said header file in C.
>
> Maybe a slight syntax adaptation could work:
>
> cdef extern into "foo.h":
>      ctypedef struct my_opaque_t:
>               pass
>      my_opaque_t *opaque_create()
>      void opaque_destroy(my_opaque_t *self)
>
> "into" would behave as "from", except that it would also capture the
> declarations and store them away so that they can be emitted to a
> header file later on.
>
> I realize that some declarations wouldn't work, but it's better than
> repeating myself in two places. The rest of the pyx file could then
> concern itself with presenting these functions to the Python world
> (probably using classes) where the C files could include "foo.h" and
> implement the functions.
>
> Do you think something like this might work?
>
> // Andreas
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
>
>
>   
I am a unclear as to why you need separate C files. Is it to allow 
machine specific implementations? Pyrex allows C level coding.

-- 
Lenard Lindstrom
<len-l at telus.net>




More information about the Pyrex mailing list