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

Initial attempt to fix problems

[SVN r10158]
This commit is contained in:
Dave Abrahams
2001-05-19 23:29:04 +00:00
parent 9261e2a3d9
commit 4d3079293d
26 changed files with 339 additions and 316 deletions

View File

@@ -95,11 +95,11 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
// Convert a MillerIndex object to a Python tuple.
//
PyObject* to_python(const MillerIndex& hkl)
PyObject* to_python(python::semantics, const MillerIndex& hkl)
{
python::tuple result(3);
for (int i = 0; i < 3; i++)
result.set_item(i, python::ref(to_python(hkl.v[i])));
result.set_item(i, hkl.v[i]);
return result.reference().release();
}

View File

@@ -14,16 +14,14 @@ namespace vects {
{
std::vector<double>::iterator v_it = begin();
for (int i = 0; i < tuple.size(); i++)
v_it[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
boost::python::type<double>());
v_it[i] = from_python(tuple[i].get(), boost::python::type<double>());
}
boost::python::tuple as_tuple() const
{
boost::python::tuple t(size());
for (int i = 0; i < size(); i++)
t.set_item(i,
boost::python::ref(BOOST_PYTHON_CONVERSION::to_python((*this)[i])));
t.set_item(i, (*this)[i]);
return t;
}
};

View File

@@ -14,16 +14,14 @@ namespace vects {
{
std::vector<int>::iterator v_it = begin();
for (int i = 0; i < tuple.size(); i++)
v_it[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
boost::python::type<int>());
v_it[i] = from_python(tuple[i].get(), boost::python::type<int>());
}
boost::python::tuple as_tuple() const
{
boost::python::tuple t(size());
for (int i = 0; i < size(); i++)
t.set_item(i,
boost::python::ref(BOOST_PYTHON_CONVERSION::to_python((*this)[i])));
t.set_item(i, (*this)[i]);
return t;
}
};

View File

@@ -45,8 +45,6 @@ namespace { // Avoid cluttering the global namespace.
// Support for pickle.
using BOOST_PYTHON_CONVERSION::from_python;
python::ref world_getinitargs(const world& w) {
python::tuple result(1);
result.set_item(0, w.get_country());

View File

@@ -94,7 +94,6 @@ BOOST_PYTHON_MODULE_INIT(pickle3)
namespace {
using BOOST_PYTHON_CONVERSION::from_python;
using boost::python::type;
using boost::python::ref;
using boost::python::tuple;

View File

@@ -25,8 +25,7 @@ namespace { // Avoid cluttering the global namespace.
{
std::vector<double>::iterator vd = begin();
for (int i = 0; i < tuple.size(); i++)
vd[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
python::type<double>());
vd[i] = from_python(tuple[i].get(), python::type<double>());
}
};
@@ -57,8 +56,8 @@ namespace { // Avoid cluttering the global namespace.
python::tuple as_tuple(const std::vector<double>& vd)
{
python::tuple t(vd.size());
for (int i = 0; i < vd.size(); i++) t.set_item(i,
python::ref(BOOST_PYTHON_CONVERSION::to_python(vd[i])));
for (int i = 0; i < vd.size(); i++)
t.set_item(i, vd[i]);
return t;
}