Commit 60701c05 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Merge branch 'release/1.6.5'

parents aa8c6de0 ffdd726f
# ChangeLog
## version 1.6.5 - 2018-11-20
- Swig: set bool conversion prior to int in order to recover boolean and not integers
## version 1.6.4 - 2018-11-09
- fix for QVariant wrapper mapping
## version 1.6.3 - 2018-11-08
......
......@@ -24,7 +24,7 @@ project(dtk)
set(dtk_VERSION_MAJOR 1)
set(dtk_VERSION_MINOR 6)
set(dtk_VERSION_PATCH 4)
set(dtk_VERSION_PATCH 5)
set(dtk_VERSION
${dtk_VERSION_MAJOR}.${dtk_VERSION_MINOR}.${dtk_VERSION_PATCH})
......
......@@ -419,13 +419,13 @@ namespace Namespace {
long k = PyInt_AS_LONG(key);
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
......@@ -446,13 +446,13 @@ namespace Namespace {
long k = PyInt_AS_LONG(key);
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
......@@ -479,13 +479,13 @@ namespace Namespace {
long k = PyInt_AS_LONG(key);
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
......@@ -507,13 +507,13 @@ namespace Namespace {
long k = PyInt_AS_LONG(key);
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
......@@ -535,20 +535,162 @@ namespace Namespace {
long k = PyInt_AS_LONG(key);
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$result->insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<long, QVariant> is returned.");
}
}
%typemap(in) QMap<QString, QVariant> {
if (PyDict_Check($input)) {
PyObect *key, *value;
Py_ssize_t pos = 0;
QVariant v;
while (PyDict_Next($input, &pos, &key, &value)) {
QString k = QString(PyString_AsString(key));
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$1.insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<QString, QVariant> is returned.");
}
}
%typemap(in) const QMap<QString, QVariant>& {
if (PyDict_Check($input)) {
$1 = new QMap<QString, QVariant>;
PyObject *key, *value;
Py_ssize_t pos = 0;
QVariant v;
while (PyDict_Next($input, &pos, &key, &value)) {
QString k = QString(PyString_AsString(key));
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$1->insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<QString, QVariant> is returned.");
}
}
%typemap(freearg) const QMap<QString, QVariant>& {
if ($1) {
delete $1;
}
}
%typemap(directorout) QMap<QString, QVariant> {
PyObject *dict = static_cast<PyObject *>($1);
if (PyDict_Check(dict)) {
PyObject *key, *value;
Py_ssize_t pos = 0;
QVariant v;
while (PyDict_Next(dict, &pos, &key, &value)) {
QString k = QString(PyString_AsString(key));
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$result.insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<QString, QVariant> is returned.");
}
}
%typemap(directorout) const QMap<QString, QVariant>& {
PyObject *dict = static_cast<PyObject *>($1);
if (PyDict_Check(dict)) {
$result = new QMap<QString, QVariant>();
PyObject *key, *value;
Py_ssize_t pos = 0;
QVariant v;
while (PyDict_Next(dict, &pos, &key, &value)) {
QString k = QString(PyString_AsString(key));
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$result->insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<QString, QVariant> is returned.");
}
}
%typemap(directorout) QMap<QString, QVariant>& {
PyObject *dict = static_cast<PyObject *>($1);
if (PyDict_Check(dict)) {
$result = new QMap<QString, QVariant>();
PyObject *key, *value;
Py_ssize_t pos = 0;
QVariant v;
while (PyDict_Next(dict, &pos, &key, &value)) {
QString k = QString(PyString_AsString(key));
if (PyString_Check(value)) {
v = QVariant::fromValue(QString(PyString_AsString(value)));
} else if (PyBool_Check(value)) {
bool b = (value == Py_True);
v = QVariant::fromValue(b);
} else if (PyInt_Check(value) || PyLong_Check(value)) {
v = QVariant::fromValue(PyInt_AsLong(value));
} else if (PyFloat_Check(value)) {
v = QVariant::fromValue(PyFloat_AsDouble(value));
} else {
qDebug("Value type is not handled. Empty QVariant is set.");
}
$result->insert(k, v);
}
} else {
qDebug("PyDict is expected as input. Empty QMap<long, QVariant> is returned.");
qDebug("PyDict is expected as input. Empty QMap<QString, QVariant> is returned.");
}
}
......
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