2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00
Files
python/src/converter/from_python.cpp
Dave Abrahams ac34e0e108 implicit conversions
[SVN r13277]
2002-03-26 06:38:41 +00:00

58 lines
1.5 KiB
C++

// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#include <boost/python/converter/find_from_python.hpp>
#include <boost/python/converter/registrations.hpp>
#include <boost/python/converter/from_python_data.hpp>
namespace boost { namespace python { namespace converter {
BOOST_PYTHON_DECL rvalue_stage1_data find(
PyObject* source
, rvalue_from_python_registration const* chain)
{
rvalue_stage1_data data;
data.convertible = 0;
for (;chain != 0; chain = chain->next)
{
void* r = chain->convertible(source);
if (r != 0)
{
data.convertible = r;
data.construct = chain->construct;
break;
}
}
return data;
}
BOOST_PYTHON_DECL rvalue_from_python_registration const* find_chain(
PyObject* source
, rvalue_from_python_registration const* chain)
{
for (;chain != 0; chain = chain->next)
{
if (chain->convertible(source))
break;
}
return chain;
}
BOOST_PYTHON_DECL void* find(
PyObject* source
, lvalue_from_python_registration const* chain)
{
for (;chain != 0; chain = chain->next)
{
void* r = chain->convert(source);
if (r != 0)
return r;
}
return 0;
}
}}} // namespace boost::python::converter