2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00

attempt to improve the error message when a particular 'to_python()' function is not found

[SVN r8005]
This commit is contained in:
Ullrich Köthe
2000-10-19 14:32:34 +00:00
parent 8e74a5902a
commit e325a815a4

View File

@@ -151,6 +151,21 @@ class PyExtensionClassConverters
{ return py::Type<U>(); }
#endif
friend inline PyExtensionClassConverters const & converter(py::Type<T>)
{
static PyExtensionClassConverters conv;
return conv;
}
PyObject* to_python(const T& x) const
{
py::PyPtr<py::ExtensionInstance> result(create_instance(false));
result->add_implementation(
std::auto_ptr<py::InstanceHolderBase>(
new py::InstanceValueHolder<T,U>(result.get(), x)));
return result.release();
}
PyExtensionClassConverters() {}
// Convert to T*
@@ -267,6 +282,8 @@ py_copy_to_new_value_holder(py::ExtensionInstance* p, const T& x, py::Type<U>)
return new py::InstanceValueHolder<T,U>(p, x);
}
#if 0
template <class T>
PyObject* to_python(const T& x)
{
@@ -277,6 +294,14 @@ PyObject* to_python(const T& x)
py_copy_to_new_value_holder(result.get(), x, py_holder_type(x))));
return result.release();
}
#endif /* #if 0 */
template <class T>
PyObject* to_python(const T& x)
{
return converter(py::Type<T>()).to_python(x);
}
#endif
#ifdef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // back from global namespace for this GCC bug