[C++-sig] Raw constructor (i.e. combination of make_constructor and raw_function)
Hans Meine
hans_meine at gmx.net
Mon Aug 22 18:05:20 CEST 2005
On Monday 22 August 2005 15:33, Hans Meine wrote:
> > > But this gives the vector as first element of the args tuple to
> > > createVector().
> >
> > What's wrong with that?
>
> I tried some more ways (e.g. returning None), and found out that it's
>
> MyVector &result((python::extract<MyVector &>(args[0])()));
>
> which is not working. Your question indicates that it should be possible
> to initialize the object given as first parameter. If so, how should I do
> that? I need access to the contained C++ object, or do I have to export
> internal functions to python in order to set the state of the
> "self"-object?
Actually, I don't understand what kind of object I get in args[0]. Obviously,
this corresponds to the "self"-argument of python __init__ functions.
Naively, I would expect that it carries some kind of default-constructed C++
object (which I would like to prevent in the first place, but anyhow).
But I fail to either extract<>() something useful from it, or manipulate the
object through a TypeWrapper - e.g. I exported the vector's resize() function
to python and do
python::object result(args[0]);
result.attr("resize")(size);
However, I always get the same error messages - that I cannot do with a
"PythonVector" what I am trying to do (extraction/call methods) because a
"vigra::PythonVector<float>" is expected, which is exactly the class wrapped
with class_ as "PythonVector":
| ArgumentError: Python argument types in
| PythonVector.resize(PythonVector, int)
| did not match C++ signature:
| resize(vigra::PythonVector<float> {lvalue}, unsigned)
Maybe the "self"-object passed to the constructor is incomplete in some way?
Ciao, / /
/--/
/ / ANS
More information about the Cplusplus-sig
mailing list