Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-06-15 15:02:30


----- Original Message -----
From: "John Max Skaller" <skaller_at_[hidden]>
>
> I did. I gather that the system allows
> building Python modules and classes in C++. But I can't
> see at first glance, how, for example, Python objects
> are made visble to C++ ones. I'm just looking
> for a short summary of the model.

C++ functions which are exposed to Python get an argument conversion layer
which is based on the argument types (using template type deduction). So, if
there is a conversion from the passed Python type to the C++ argument type,
the function call succeeds with that conversion. If you want your C++
function to see a "raw" python type, there are several options:

1. Use a PyObject* argument. Its type conversion is the identity
2. Use a boost::python::ref, which does the reference-counting part for you
3. Use a specific python type wrapper (e.g. boost::python::tuple) from
boost/python/objects.hpp.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk