Boost logo

Boost :

From: MikeEnsor_at_[hidden]
Date: 2001-11-08 16:53:16

I am pretty sure that the class builder has not run by the time it
gets to this code....I have a series of overridden functions such as
functions that compensate for the "int and double" issue...I have them
in an include file at the top of my module c++ file...What can I do to
manualy convert this into a PyObject*? Is there anything I can do to
get around this?


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> ----- Original Message -----
> From: <MikeEnsor_at_C...>
> > I'm looking for a conversion from my own type to Python. I
created a
> > class called "Instance". I need to return that type back to
> > It is wrapped with boost as a class. The line I use (it isn't
> > working) is:
> > PyObject* GetInstance(MyList& l)
> > {
> > Instance i;
> > l.GetInstance(i); // pass by ref, not my code that does this
> > return boost::python::to_python(i);
> > }
> >
> > I do have Instance wrapped and included into the module, but I can
> > return it back like this. The compiler says that Instance is not
> > of the converted types. I can return the "super" type (Instance
> > derived from InstBase), and that works, but it does not have the
> > specific info I need from Instance. Does this clear things up
> > Thank you very much for helping me out.
> Hmm, I am guessing that the class_builder<Instance> is not declared
yet at
> the point you're trying to wrap the GetInstance function.
> Keep in mind, though, that Boost.Python will try to /copy/ your
> object when you return it this way. As of today, the only way to
return an
> object by reference is to resort to "dangerous" trick as described
> under the heading
"If you
> can't (afford to) copy the referent, or the pointer is non-const"
> HTH,
> Dave

Boost list run by bdawes at, gregod at, cpdaniel at, john at