Simple question: How to pass a C++ class reference to a callback?

David Abrahams dave at boost-consulting.com
Wed Sep 3 09:22:36 EDT 2003


Harri Pesonen <fuerte at sci.fi> writes:

> David Abrahams wrote:
>> "T. Panbru" <panbru at comcast.net> writes:
>> 
>>>Try encapsulating your C++ class reference in a CObject, using:
>>>
>>>     PyObject* PyCObject_FromVoidPtr( void* cobj, void (*destr)(void *))
>>>     void* PyCObject_AsVoidPtr( PyObject* self)
>>>
>>>and so forth, to go back and forth between the C++ and Python realms.
>>>
>>>Check out the Python docs at:
>>>
>>>     http://www.python.org/doc/2.3/api/cObjects.html
>>>
>> Or use one of the high-level wrapping tools such as Boost.Python
>> (http://www.boost.org/libs/python) which make this stuff much easier
>> and safer.
>
> Boost.Python is not 2.3 compatible yet, but it seems very good.

The CVS version is 2.3 compatible; you can download a snapshot from
http://www.boost-consulting.com/boost.tar.bz2 or you can access our
anonymous CVS or a mirror (about a day behind).

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Python-list mailing list