Make Python API more pythonic

This commit is contained in:
wmayer
2013-10-09 21:16:04 +02:00
parent 564f3d14e3
commit a3b4524cca
3 changed files with 13 additions and 13 deletions

View File

@@ -662,24 +662,24 @@ void MatrixPy::setA44(Py::Float arg)
(*this->getMatrixPtr())[3][3] = (double)arg;
}
Py::List MatrixPy::getA(void) const
Py::Sequence MatrixPy::getA(void) const
{
double mat[16];
this->getMatrixPtr()->getMatrix(mat);
Py::List list(16);
Py::Tuple tuple(16);
for (int i=0; i<16; i++) {
list[i] = Py::Float(mat[i]);
tuple[i] = Py::Float(mat[i]);
}
return list;
return tuple;
}
void MatrixPy::setA(Py::List arg)
void MatrixPy::setA(Py::Sequence arg)
{
double mat[16];
this->getMatrixPtr()->getMatrix(mat);
int index=0;
for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
for (Py::Sequence::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
mat[index++] = (double)Py::Float(*it);
}