Boost logo

Boost :

From: Trevor Perrin (tperrin_at_[hidden])
Date: 2001-07-08 15:04:23


Sorry, that mail was incomplete, I sent it by accident. Anyways, I tried
the below and tweaking it in various ways (ie wrapping/unwrapping the
boostold::shared_ptr in boost::python::type<>) to make from_python() work in
a similar stand-alone way to to_python() but couldn't; I'm using vc6sp4; is
there a simple way to do this? I kind of get the impression from
conversions.hpp I'm out of luck..

Trevor

-----Original Message-----
From: Trevor Perrin [mailto:tperrin_at_[hidden]]
Sent: Sunday, July 08, 2001 12:58 PM
To: 'boost_at_[hidden]'
Subject: RE: [boost] Python & smart pointers

Thanks. What about from_python()? By analogy with
python_extension_class_converters I tried:

template <class T>
boostold::shared_ptr<T>& from_python(PyObject* p, boostold::shared_ptr<T>&)
{
  return
boost::python::python_extension_class_converters<T>::smart_ptr_reference(p,
boost::python::type<boostold::shared_ptr<T> >());
}

-----Original Message-----
From: David Abrahams [mailto:david.abrahams_at_[hidden]]
Sent: Sunday, July 08, 2001 5:39 AM
To: boost_at_[hidden]
Subject: Re: [boost] Python & smart pointers

The formula is simple: just use this technique:
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug
workaround
  template <class T>
  PyObject* to_python(my_smart_ptr<T> p)
  {
      return
boost::python::python_extension_class_converters<T>::ptr_to_python(p);
  }
BOOST_PYTHON_END_CONVERSION_NAMESPACE

-Dave
----- Original Message -----
From: "Trevor Perrin" <tperrin_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, July 07, 2001 11:22 PM
Subject: [boost] Python & smart pointers

>
> An uninformed question by a Boost.Python newbie:
>
> I've previously created a modified boost::smart_ptr for myself, and
> moved
it
> into a 'boostold' namespace. Now I'd like to use at least
> boostold::shared_ptr with Boost.Python. As a first stab I duplicated
> the bottom 4 converter member functions in
> extension_class.hpp/python_extension_class_converters, which refer to
> 'boost::shared_ptr', and changed 'boost::shared_ptr' to
> 'boostold::shared_ptr'.
>
> Which seems to work (I'm using vc6sp4; also I don't care about
> cross-extension-module dependencies right now), but I'm wondering if
there's
> a cleaner way to insert these converters into boost.python than
> modifying its code. I'm also quite confused by the shared_ptr
> converter code within conversions.hpp; what is "wrapped_pointer", for
> example? Is the "MUST_SUPPORT_MSVC" code in the comments an idiom I
> should be using?
>
> Trevor
>
>
> 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/
>
>

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/

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