|
Boost : |
From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-15 19:30:33
David Abrahams wrote:
> 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.
I see. Thanks! I'd never considered something
other that (1). So I guess there is a predefined mapping
from Python types to C++ types?
In the bindings I created, the system didn't handle
methods at all. It just hooked get_attr, which the
user had to implement to call the right C++ function.
That is, I defined an abstract class corresponding
to a PyObjct, with virtual functions that were called from C for
each entry in the Python 'virtual table'. Unfortunately,
that doesn't work too well, since Python checks if the
table entries are null or not: for my abstraction,
they never were. About then, I gave up. :-)
-- John (Max) Skaller, mailto:skaller_at_[hidden] 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk