annotate DEPENDENCIES/generic/include/boost/python/converter/implicit.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright David Abrahams 2002.
Chris@16 2 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 3 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 4 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5 #ifndef IMPLICIT_DWA2002326_HPP
Chris@16 6 # define IMPLICIT_DWA2002326_HPP
Chris@16 7
Chris@16 8 # include <boost/python/converter/rvalue_from_python_data.hpp>
Chris@16 9 # include <boost/python/converter/registrations.hpp>
Chris@16 10 # include <boost/python/converter/registered.hpp>
Chris@16 11
Chris@16 12 # include <boost/python/extract.hpp>
Chris@16 13
Chris@16 14 namespace boost { namespace python { namespace converter {
Chris@16 15
Chris@16 16 template <class Source, class Target>
Chris@16 17 struct implicit
Chris@16 18 {
Chris@16 19 static void* convertible(PyObject* obj)
Chris@16 20 {
Chris@16 21 // Find a converter which can produce a Source instance from
Chris@16 22 // obj. The user has told us that Source can be converted to
Chris@16 23 // Target, and instantiating construct() below, ensures that
Chris@16 24 // at compile-time.
Chris@16 25 return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters)
Chris@16 26 ? obj : 0;
Chris@16 27 }
Chris@16 28
Chris@16 29 static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
Chris@16 30 {
Chris@16 31 void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
Chris@16 32
Chris@16 33 arg_from_python<Source> get_source(obj);
Chris@16 34 bool convertible = get_source.convertible();
Chris@16 35 BOOST_VERIFY(convertible);
Chris@16 36
Chris@16 37 new (storage) Target(get_source());
Chris@16 38
Chris@16 39 // record successful construction
Chris@16 40 data->convertible = storage;
Chris@16 41 }
Chris@16 42 };
Chris@16 43
Chris@16 44 }}} // namespace boost::python::converter
Chris@16 45
Chris@16 46 #endif // IMPLICIT_DWA2002326_HPP