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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user