[C++-sig] Raw constructor (i.e. combination of make_constructor and raw_function)

Hans Meine meine at kogs1.informatik.uni-hamburg.de
Mon Aug 22 15:33:51 CEST 2005


Hi again!

On Monday 22 August 2005 02:47, David Abrahams wrote:
> > I am trying to do something like
> >
> >     python::class_<MyVector>("PythonVector", python::no_init)
> >         .def("__init__", python::raw_function(&createVector, 1));
> >
> > 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?

-- 
Ciao, /  /
     /--/
    /  / ANS



More information about the Cplusplus-sig mailing list