[Pyrex] Generating a header?
Lenard Lindstrom
len-l at telus.net
Thu Dec 28 02:03:06 UTC 2006
Andreas Fredriksson wrote:
> On 12/27/06, Lenard Lindstrom <len-l at telus.net> wrote:
>
>> I am a unclear as to why you need separate C files. Is it to allow
>> machine specific implementations? Pyrex allows C level coding.
>
> Yes, I'm writing code for Windows, Mac and Linux. Also, these
> extension modules are going to be pretty big, so I'd rather keep them
> in C and compile them separately. I'm also looking for some separation
> of concerns, keeping Python adaptations in their own file and
> implementation code elsewhere.
>
> // Andreas
>
>
Well, at present Greg Ewing is the creator and sole maintainer of Pyrex,
so he is the one to convince about a new language feature. Pyrex does do
the opposite of what you asked for, that is it will generate a C header
containing exported C functions. So maybe that part of the compiler code
can be co-opted to implement an 'into' keyword. I ran the pyrexc.py
compiler on some test public declarations to see what would happen:
---------------- Pyrex input file -----------------
cdef public double foo(int x):
return x * 2.5
cdef public char bar(char *s):
return s[0]
---------------- Generated .h file ----------------
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
__PYX_EXTERN_C DL_IMPORT(double) (foo(int ));
__PYX_EXTERN_C DL_IMPORT(char) (bar(char (*)));
PyMODINIT_FUNC inittst(void);
---------------- Generated .pyi file --------------
cdef extern double (foo(int ))
cdef extern char (bar(char (*)))
It may not be exactly what you want, but it is close.
--
Lenard Lindstrom
<len-l at telus.net>
More information about the Pyrex
mailing list