[Pyrex] really wanting C++ support

David McNab david at rebirthing.co.nz
Wed May 7 05:55:41 CEST 2003


On Wed, 2003-05-07 at 15:47, Greg Ewing wrote:
> People interested in this could help by suggesting
> what sort of C++ support features they would like to
> see.

For a start, a '--cplusplus' or '-C' argument to pyrexc, which would
cause a C++ file to get generated, with all exported functions (python
entry points and user-declared public funcs) declared as 'extern C'.

Getting Pyrex to generate such C++ source files, which clean-compile,
would be a major milestone, due to the increased strictness of C++
compilers - a lot of things which generate warnings in C produce errors
in C++.

Then, some limited support for C++ objects, whereby object and object
pointer variables can be accessed, as well as their methods and
attributes via the existing '.' syntax.

I guess this would require extension to the 'cdef extern from blah.h'
blocks, to allow for class defs. Also, extensions to casting, etc.

Hopefully the existing parsing infrastructure - which so intelligently
handles '.' syntax with structs - can be extended for C++ object
variables without too much pain. There might be some simple kludges to
thus extend on structs/typedefs.

This is only a very basic subset of C++, but it would be a total
God-send, and make all the difference, because it would allow direct
calls to C++ funcs and access to C++ objects, and would also allow for
creation of C++ callback funcs callable from the C++ library being
wrapped.

Cheers
David






More information about the Pyrex mailing list