Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit d89aecea authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Add typemap director in and out for QList<long>.

parent 3b3a19a5
......@@ -137,7 +137,7 @@ namespace Namespace {
if (PyString_Check($input)) {
$1 = QString(PyString_AsString($input));
} else {
qDebug("QString expected");
qDebug("String is expected as input. Empty QString is returned.");
}
}
......@@ -146,7 +146,7 @@ namespace Namespace {
char *t = PyString_AsString($input);
$1 = new QString(t);
} else {
qDebug("QString expected");
qDebug("String is expected as input. Empty QString is returned.");
}
}
......@@ -158,7 +158,7 @@ namespace Namespace {
$1 << QString(PyString_AsString(PyList_GET_ITEM($input, i)));
}
} else {
qDebug("QStringList expected");
qDebug("PyList of strings is expected as input. Empty QStringList is returned.");
}
}
......@@ -172,7 +172,13 @@ namespace Namespace {
(*$1) << QString(t);
}
} else {
qDebug("QStringList expected");
qDebug("PyList of strings is expected as input. Empty QStringList is returned.");
}
}
%typemap(freearg) const QStringList& {
if ($1) {
delete $1;
}
}
......@@ -184,7 +190,7 @@ namespace Namespace {
$1 << PyInt_AsLong(PyList_GET_ITEM($input, i));
}
} else {
qDebug("QList<long> expected");
qDebug("PyList of integers is expected as input. Empty QList<long> is returned.");
}
}
......@@ -197,7 +203,7 @@ namespace Namespace {
($1)->append(PyInt_AsLong(PyList_GET_ITEM($input, i)));
}
} else {
qDebug("QList<long> expected");
qDebug("PyList of integers is expected as input. Empty QList<long> is returned.");
}
}
......@@ -207,6 +213,20 @@ namespace Namespace {
}
}
%typemap(directorout) QList<long> {
PyObject *list = static_cast<PyObject *>($1);
if (PyList_Check(list)) {
int i = 0;
int end = PyList_Size(list);
for(i;i<end; ++i) {
PyObject *o = PyList_GET_ITEM(list, i);
$result << PyInt_AsLong(o);
}
} else {
qDebug("PyList of integers is expected as input. Empty QList<long> is returned.");
}
}
// C++ -> Python
%typemap(out) qlonglong {
......@@ -283,12 +303,24 @@ namespace Namespace {
%typemap(out) QList<long> {
$result = PyList_New($1.size());
int i = 0;
QList<long>::iterator it = $1.begin();
QList<long>::iterator it = $1.begin();
QList<long>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* v = PyInt_FromLong(*it);
PyList_SET_ITEM($result, i, v);
}
}
%typemap(directorin) QList<long> {
PyObject *list = PyList_New($1.size());
int i = 0;
QList<long>::iterator it = $1.begin();
QList<long>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* l = PyInt_FromLong(*it);
PyList_SET_ITEM($result, i, l);
PyObject* v = PyInt_FromLong(*it);
PyList_SET_ITEM(list, i, v);
}
$input = list;
}
template <class T1, class T2> class QPair
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment