Chris@16: // Copyright David Abrahams 2002. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: #ifndef IMPLICIT_DWA2002326_HPP Chris@16: # define IMPLICIT_DWA2002326_HPP Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: Chris@16: namespace boost { namespace python { namespace converter { Chris@16: Chris@16: template Chris@16: struct implicit Chris@16: { Chris@16: static void* convertible(PyObject* obj) Chris@16: { Chris@16: // Find a converter which can produce a Source instance from Chris@16: // obj. The user has told us that Source can be converted to Chris@16: // Target, and instantiating construct() below, ensures that Chris@16: // at compile-time. Chris@16: return implicit_rvalue_convertible_from_python(obj, registered::converters) Chris@16: ? obj : 0; Chris@16: } Chris@16: Chris@16: static void construct(PyObject* obj, rvalue_from_python_stage1_data* data) Chris@16: { Chris@16: void* storage = ((rvalue_from_python_storage*)data)->storage.bytes; Chris@16: Chris@16: arg_from_python get_source(obj); Chris@16: bool convertible = get_source.convertible(); Chris@16: BOOST_VERIFY(convertible); Chris@16: Chris@16: new (storage) Target(get_source()); Chris@16: Chris@16: // record successful construction Chris@16: data->convertible = storage; Chris@16: } Chris@16: }; Chris@16: Chris@16: }}} // namespace boost::python::converter Chris@16: Chris@16: #endif // IMPLICIT_DWA2002326_HPP