[C++-sig] What's wrong here? (BPL V2)

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Jun 13 17:41:26 CEST 2002


--- Dominic Sacré <bugcreator at gmx.de> wrote:
> If I have a PyObject*, and I know that it points to a wrapped C++ class,
> how can I get a pointer to the C++ object?
> 
> With v1 I used
> from_python (p, boost::python::type<Foo *>())
> but I can't find the v2 equivalent.
> Probably I'm missing something obvious again...

David is currently working on the user-level from_python equivalent.
Until then, here is what I use as a place-holder (haven't tried it
to extract pointers, though):

#include <boost/python/converter/return_from_python.hpp>

  template <typename U>
  struct extractor
  {
    static
    U
    get(PyObject* obj)
    {
      Py_INCREF(obj);
      return converter::return_from_python<U>()(obj);
    }
  };

Ralf


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Cplusplus-sig mailing list