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

Add typemap for qlist.

parent 9d172798
...@@ -176,6 +176,37 @@ namespace Namespace { ...@@ -176,6 +176,37 @@ namespace Namespace {
} }
} }
%typemap(in) QList<long> {
if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input);
for(i;i!=end; ++i) {
$1 << PyInt_AsLong(PyList_GET_ITEM($input, i));
}
} else {
qDebug("QList<long> expected");
}
}
%typemap(in) const QList<long>& {
if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input);
$1 = new QList<long>;
for(i;i!=end; ++i) {
($1)->append(PyInt_AsLong(PyList_GET_ITEM($input, i)));
}
} else {
qDebug("QList<long> expected");
}
}
%typemap(freearg) const QList<long>& {
if ($1) {
delete $1;
}
}
// C++ -> Python // C++ -> Python
%typemap(out) qlonglong { %typemap(out) qlonglong {
...@@ -249,6 +280,17 @@ namespace Namespace { ...@@ -249,6 +280,17 @@ namespace Namespace {
} }
} }
%typemap(out) QList<long> {
$result = 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);
}
}
template <class T1, class T2> class QPair template <class T1, class T2> class QPair
{ {
public: public:
......
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