|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-30 22:28:41
Mike,
First of all, you'll need to pick a different interface for "function" (or
wrap a different function and have it call your function), because
Boost.Python can only convert a single Python object into a single function
parameter.
Probably the easiest thing you can do is to write a function taking a
boost::python::ref (which is kind of a smart pointer to a PyObject), and
just use the regular Python 'C' API to extract the buffer data.
If you want to get fancier, you could create a type which corresponds to a
Python buffer (perhaps struct my_buffer { void* data; int size; };) and
write a family of from_python(PyObject*, type<buffer>) functions which check
the argument type and convert Python buffers into your buffer type. You can
look at boost/python/conversions.hpp for some examples. That would allow you
to automatically wrap functions which accept my_buffer arguments.
HTH,
Dave
===================================================
David Abrahams, C++ library designer for hire
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================
----- Original Message -----
From: "Mike Ensor" <MikeEnsor_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, September 29, 2001 7:47 PM
Subject: [boost] Boost::Python
> I am using Boost.Python to build c++ to python wrappers. I am
> trying to make binary data available to python and visa versa. I have
tried
> many different approaches. The functions in C++ look similar to this:
>
> void function(const void* buffer, int size);
>
> and in python I can create a "buffer" of information. When I check
> the type of the "buffer" it is a "buffer".
>
> When I compile the c++ it won't let me because "none of the 425
> overloads can convert prameter 2 from type 'struct
boost::python::type<void
> const*>'"
>
> How do I make the const void * be seen in Python and how do I send
> in binary data into this function from python?
>
> Thank you for your help,
> Mike Ensor
> mikeensor_at_[hidden]
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk