MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

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

Add typemaps director for qstringlist, qlist<double>, qstring and qlonglong.

parent ecbfad0e
......@@ -126,6 +126,16 @@ namespace Namespace {
$1 = PyInt_AsLong($input);
}
%typemap(directorout) qlonglong {
PyObject *o = static_cast<PyObject *>($1);
if (PyInt_Check(o)) {
$result = PyInt_AsLong(o);
} else {
qDebug("Long int is expected as input. Zero integer is returned.");
$result = 0;
}
}
%typemap(typecheck) qlonglong = long long;
%typemap(typecheck) const qlonglong& = long long;
%typemap(typecheck) QString = char *;
......@@ -150,6 +160,15 @@ namespace Namespace {
}
}
%typemap(directorout) QString {
PyObject *ps = static_cast<PyObject *>($1);
if (PyString_Check(ps)) {
$result = QString(PyString_AsString(ps));
} else {
qDebug("String is expected as input. Empty QString is returned.");
}
}
%typemap(in) QStringList {
if (PyList_Check($input)) {
int i = 0;
......@@ -182,6 +201,20 @@ namespace Namespace {
}
}
%typemap(directorout) QStringList {
PyObject *list = static_cast<PyObject *>($1);
if (PyList_Check(list)) {
int i = 0;
int end = PyList_Size(list);
for(i;i<end; ++i) {
char *t = PyString_AsString(PyList_GET_ITEM(list, i));
$result << QString(t);
}
} else {
qDebug("PyList of integers is expected as input. Empty QList<long> is returned.");
}
}
%typemap(in) QList<long> {
if (PyList_Check($input)) {
int i = 0;
......@@ -211,7 +244,7 @@ namespace Namespace {
if ($1) {
delete $1;
}
}
}
%typemap(directorout) QList<long> {
PyObject *list = static_cast<PyObject *>($1);
......@@ -227,6 +260,51 @@ namespace Namespace {
}
}
%typemap(in) QList<double> {
if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input);
for(i;i!=end; ++i) {
$1 << PyFloat_AsDouble(PyList_GET_ITEM($input, i));
}
} else {
qDebug("PyList of double is expected as input. Empty QList<double> is returned.");
}
}
%typemap(in) const QList<double>& {
if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input);
$1 = new QList<double>;
for(i;i!=end; ++i) {
($1)->append(PyFloat_AsDouble(PyList_GET_ITEM($input, i)));
}
} else {
qDebug("PyList of double floats is expected as input. Empty QList<double> is returned.");
}
}
%typemap(freearg) const QList<double>& {
if ($1) {
delete $1;
}
}
%typemap(directorout) QList<double> {
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 << PyFloat_AsDouble(o);
}
} else {
qDebug("PyList of double floats is expected as input. Empty QList<double> is returned.");
}
}
// C++ -> Python
%typemap(out) qlonglong {
......@@ -237,6 +315,14 @@ namespace Namespace {
$result = PyInt_FromLong($1);
}
%typemap(directorin) qlonglong {
$input = PyInt_FromLong($1);
}
%typemap(directorin) const qlonglong& {
$input = PyInt_FromLong($1);
}
%typemap(out) QString {
$result = PyString_FromString($1.toUtf8().constData());
}
......@@ -245,19 +331,37 @@ namespace Namespace {
$result = PyString_FromString($1.toUtf8().constData());
}
%typemap(directorin) QString {
$input = PyString_FromString($1.toUtf8().constData());
}
%typemap(directorin) const QString& {
$input = PyString_FromString($1.toUtf8().constData());
}
%define %QList_typemapsPtr(DATA_TYPE)
%typemap(out) QList<DATA_TYPE> {
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0 ; it != end; ++it, ++i) {
PyObject* obj = SWIG_NewPointerObj((*it), $descriptor(DATA_TYPE), 0|0);
PyList_SET_ITEM($result, i, obj);
}
}
%typemap(directorin) QList<DATA_TYPE> {
PyObject *list = PyList_New($1.size());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0 ; it != end; ++it, ++i) {
PyObject* obj = SWIG_NewPointerObj((*it), $descriptor(DATA_TYPE), 0|0);
PyList_SET_ITEM(list, i, obj);
}
$input = list;
}
%enddef // %QList_typemapsPtr()
%QList_typemapsPtr(dtkCorePlugin *)
......@@ -266,67 +370,94 @@ namespace Namespace {
%typemap(out) QList<DATA_TYPE> {
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0 ; it != end; ++it, ++i) {
DATA_TYPE *newItem = new DATA_TYPE(*it);
PyObject* obj = SWIG_NewPointerObj(newItem, $descriptor(DATA_TYPE*), 0|0);
PyList_SET_ITEM($result, i, obj);
}
}
%typemap(directorin) QList<DATA_TYPE> {
PyObject *list = PyList_New($1.size());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0 ; it != end; ++it, ++i) {
DATA_TYPE *newItem = new DATA_TYPE(*it);
PyObject* obj = SWIG_NewPointerObj(newItem, $descriptor(DATA_TYPE*), 0|0);
PyList_SET_ITEM(list, i, obj);
}
$input = list;
}
%enddef // %QList_typemaps()
%typemap(out) QStringList {
$result = PyList_New($1.size());
int i = 0;
QStringList::iterator it = $1.begin();
QStringList::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* st = PyString_FromString((*it).toUtf8().constData());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject *st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM($result, i, st);
}
}
%typemap(directorin) QStringList {
PyObject *list = PyList_New($1.size());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject *st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM(list, i, st);
}
$input = list;
}
%typemap(out) QList<QString> {
$result = PyList_New($1.size());
int i = 0;
QStringList::iterator it = $1.begin();
QStringList::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* st = PyString_FromString((*it).toUtf8().constData());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject *st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM($result, i, st);
}
}
%typemap(directorin) QList<QString> {
PyObject *list = PyList_New($1.size());
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject *st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM(list, i, st);
}
$input = list;
}
%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) {
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject* v = PyInt_FromLong(*it);
PyList_SET_ITEM($result, i, v);
}
}
%typemap(directorin) const QString& {
$input = PyString_FromString($1.toUtf8().constData());
}
%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) {
auto it = $1.cbegin();
auto end = $1.cend();
for(int i = 0; it != end; ++it, ++i) {
PyObject* v = PyInt_FromLong(*it);
PyList_SET_ITEM(list, i, v);
}
$input = list;
}
// QPair
template <class T1, class T2> class QPair
{
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