[C++-sig] to_python part two

David Abrahams david.abrahams at rcn.com
Wed Feb 27 20:41:46 CET 2002


----- Original Message -----
From: "Robert Andre" <randre at pppl.gov>
To: <c++-sig at python.org>
Sent: Wednesday, February 27, 2002 11:53 AM
Subject: [C++-sig] to_python part two


>
> Lets see if this makes more sense.  I am including only the
> relevant parts of the code below.
>

<snip>
OK so far...

> -------------- uarray_helper.cc ------------------
> # include <boost/python/detail/config.hpp>
> # include <boost/python/detail/wrap_python.hpp>
> # include <boost/python/detail/none.hpp>
> # include <boost/python/detail/signatures.hpp>
> # include <boost/python/detail/extension_class.hpp>
> # include <boost/smart_ptr.hpp>
> # include <boost/python/errors.hpp>
>
> PyObject* uarray_getitem(const uarray& u, PyObject* p) {
>
>   PyObject* result = 0 ;
>   ... code ...
>
>   uarray uslice = u[k] ;       // find slice, int k extracted from p
>   result = to_python(uslice) ; // <-- COMPILER COMPLAINS -- convert uarray
to PyObject*


Right, it's like I said: the class_builder<uarray> instantiation needs to be
visible before you try this. So, add

namespace boost { namespace python {
  template class class_builder<uarray>; // explicitly instantiate
}} // namespace boost::python

at the top of this source file.

-Dave






More information about the Cplusplus-sig mailing list