2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

Major rearchitecture of from_python mechanism

[SVN r12924]
This commit is contained in:
Dave Abrahams
2002-02-24 05:24:48 +00:00
parent a04cbd111c
commit e11b457b79
36 changed files with 929 additions and 1218 deletions

View File

@@ -4,23 +4,40 @@
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#include <boost/python/converter/from_python.hpp>
#include <boost/python/converter/registry.hpp>
#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 {
from_python_converter_base::from_python_converter_base(
type_id_t type
, from_python_check checker
)
: body(type)
, m_convertible(checker)
BOOST_PYTHON_DECL void* find(
PyObject* source
, rvalue_from_python_registration const* chain
, rvalue_stage1_data& data)
{
// Insert this in the converter chain.
from_python_converter_base*& head = registry::from_python_chain(type);
m_next = head;
head = this;
for (;chain != 0; chain = chain->next)
{
void* r = chain->convertible(source);
if (r != 0)
{
data.construct = chain->construct;
return data.convertible = r;
}
}
return data.convertible = 0;
}
BOOST_PYTHON_DECL void* find(
PyObject* const 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