[Pyrex] ANN: pyrexembed - Pyrex C++ wrapping kit

Lenard Lindstrom len-l at telus.net
Tue Nov 8 20:15:27 CET 2005


Pyrex already handles many aspects of C++. Here is the web site 
example written in pure Pyrex:

cdef extern from "MyClass.h":
    ctypedef struct myclass "MyClass":
        int dosomething(float arg)
    myclass *myclassfactory "new MyClass" (int arg)

cdef class MyClass:
    cdef myclass *thisptr

    def __init__(self, arg):
        self.thisptr = myclassfactory(arg)

    def dosomething(self, arg):
        return self.thisptr.dosomething(arg)


Of course 'pyrexembed' could simplify things when C++ exception traps 
must be written. I'm still not sure how best to do this.

Lenard Lindstrom
<len-l at telus.net>

On 8 Nov 2005 at 18:36, David McNab wrote:

> Hi all,
> 
> Since Greg's commitments don't allow for him to implement C++ support in
> Pyrex any time soon, I've created an interim solution.
> 
> It's called 'pyrexembed', a mechanism that allows you to embed C++ code
> directly into your Pyrex files, and end up with extensions that compile
> and work as expected.
> 
> All is revealed on the website and in the tarball:
> 
>    http://www.freenet.org.nz/python/pyrexembed
> 
> Have fun with it.
> 
> Patches, bug reports, feature requests, n-figure donations etc - all
> welcome, you've got my email.




More information about the Pyrex mailing list