$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
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?
thanks,
Mike
--- 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 
Python.
> > 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 
not
> > return it back like this.  The compiler says that Instance is not 
one
> > of the converted types.  I can return the "super" type (Instance 
is
> > derived from InstBase), and that works, but it does not have the
> > specific info I need from Instance.  Does this clear things up 
more?
> > 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 
Instance
> 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 
at
> http://www.boost.org/libs/python/doc/pointers.html under the heading 
"If you
> can't (afford to) copy the referent, or the pointer is non-const"
> 
> HTH,
> Dave