[C++-sig] current spelling of from_python<>?
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Tue Jun 11 23:12:09 CEST 2002
--- David Abrahams <david.abrahams at rcn.com> wrote:
> From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
>
>
> > Until about a week ago the code below worked as a placeholder
> > for a user-level from_python<> converter:
> >
> > template <typename U>
> > struct extractor
> > {
> > static
> > U
> > get(PyObject* obj)
> > {
> > Py_INCREF(obj);
> > return converter::callback_from_python<U>()(obj);
> > }
> > };
> >
> > converter::callback_from_python<> is defined in the obsolete file
> > converter/callback.hpp. What should I be using instead?
>
> converter::return_from_python<> in converter/return_from_python.hpp
Using return_from_python<>, extractor<T> works fine. Thanks!
Is it expected that extractor<T const&> does not work for
converting the elements of a Python tuple of Python float or int?
I also need this convertible() test:
static void* convertible(PyObject* obj)
{
using namespace boost::python;
tuple t = list_or_tuple_as_tuple(obj);
if (!ContainerAdaptor::check_size(
type<ContainerType>(), t.size())) return 0;
for(std::size_t i=0;i<t.size();i++) {
arg_from_python<container_element_type const&> from_py(t[i].get());
if (!from_py.convertible()) return 0;
}
return obj;
}
Observations:
The code as shown works with Linux/gcc304, but VC6 reports
"indirect_traits.hpp(308) : error C2057: expected constant expression."
arg_from_python<container_element_type> also works with Linux/gcc304, but VC6
reports "fatal error C1001: INTERNAL COMPILER ERROR."
Should/could I use a different approach for testing convertibility that VC6
might not choke on?
Thanks,
Ralf
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
More information about the Cplusplus-sig
mailing list