Commit 7da8ef13 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

add a few typemaps + fix annoying clang warning

parent f93d8756
...@@ -134,6 +134,10 @@ namespace Namespace { ...@@ -134,6 +134,10 @@ namespace Namespace {
$1 = PyInt_AsLong($input); $1 = PyInt_AsLong($input);
} }
%typemap(in) const qlonglong& {
$1 = PyInt_AsLong($input);
}
%typemap(directorout) qlonglong { %typemap(directorout) qlonglong {
PyObject *o = static_cast<PyObject *>($1); PyObject *o = static_cast<PyObject *>($1);
if (PyInt_Check(o)) { if (PyInt_Check(o)) {
...@@ -148,6 +152,10 @@ namespace Namespace { ...@@ -148,6 +152,10 @@ namespace Namespace {
%typemap(typecheck) const qlonglong& = long long; %typemap(typecheck) const qlonglong& = long long;
%typemap(typecheck) QString = char *; %typemap(typecheck) QString = char *;
%typemap(typecheck) const QString& = char *; %typemap(typecheck) const QString& = char *;
%typemap(typecheck) QString = const char *;
%typemap(typecheck) const QString& = const char *;
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, noblock=1) QStringList { %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, noblock=1) QStringList {
$1 = PyList_Check($input) ? 1 : 0; $1 = PyList_Check($input) ? 1 : 0;
} }
...@@ -195,9 +203,8 @@ namespace Namespace { ...@@ -195,9 +203,8 @@ namespace Namespace {
%typemap(in) QStringList { %typemap(in) QStringList {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
for(i;i!=end; ++i) { for(int i = 0; i!=end; ++i) {
$1 << QString(PyString_AsString(PyList_GET_ITEM($input, i))); $1 << QString(PyString_AsString(PyList_GET_ITEM($input, i)));
} }
} else { } else {
...@@ -207,10 +214,9 @@ namespace Namespace { ...@@ -207,10 +214,9 @@ namespace Namespace {
%typemap(in) const QStringList& { %typemap(in) const QStringList& {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
$1 = new QStringList; $1 = new QStringList;
for(i;i!=end; ++i) { for(int i = 0 ;i!=end; ++i) {
char *t = PyString_AsString(PyList_GET_ITEM($input, i)); char *t = PyString_AsString(PyList_GET_ITEM($input, i));
(*$1) << QString(t); (*$1) << QString(t);
} }
...@@ -228,9 +234,8 @@ namespace Namespace { ...@@ -228,9 +234,8 @@ namespace Namespace {
%typemap(directorout) QStringList { %typemap(directorout) QStringList {
PyObject *list = static_cast<PyObject *>($1); PyObject *list = static_cast<PyObject *>($1);
if (PyList_Check(list)) { if (PyList_Check(list)) {
int i = 0;
int end = PyList_Size(list); int end = PyList_Size(list);
for(i;i<end; ++i) { for(int i = 0; i<end; ++i) {
char *t = PyString_AsString(PyList_GET_ITEM(list, i)); char *t = PyString_AsString(PyList_GET_ITEM(list, i));
$result << QString(t); $result << QString(t);
} }
...@@ -243,9 +248,8 @@ namespace Namespace { ...@@ -243,9 +248,8 @@ namespace Namespace {
%typemap(in) QList<long> { %typemap(in) QList<long> {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
for(i;i!=end; ++i) { for(int i = 0; i!=end; ++i) {
$1 << PyInt_AsLong(PyList_GET_ITEM($input, i)); $1 << PyInt_AsLong(PyList_GET_ITEM($input, i));
} }
} else { } else {
...@@ -255,10 +259,9 @@ namespace Namespace { ...@@ -255,10 +259,9 @@ namespace Namespace {
%typemap(in) const QList<long>& { %typemap(in) const QList<long>& {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
$1 = new QList<long>; $1 = new QList<long>;
for(i;i!=end; ++i) { for(int i = 0; i!=end; ++i) {
($1)->append(PyInt_AsLong(PyList_GET_ITEM($input, i))); ($1)->append(PyInt_AsLong(PyList_GET_ITEM($input, i)));
} }
} else { } else {
...@@ -275,9 +278,8 @@ namespace Namespace { ...@@ -275,9 +278,8 @@ namespace Namespace {
%typemap(directorout) QList<long> { %typemap(directorout) QList<long> {
PyObject *list = static_cast<PyObject *>($1); PyObject *list = static_cast<PyObject *>($1);
if (PyList_Check(list)) { if (PyList_Check(list)) {
int i = 0;
int end = PyList_Size(list); int end = PyList_Size(list);
for(i;i<end; ++i) { for(int i = 0; i<end; ++i) {
PyObject *o = PyList_GET_ITEM(list, i); PyObject *o = PyList_GET_ITEM(list, i);
$result << PyInt_AsLong(o); $result << PyInt_AsLong(o);
} }
...@@ -290,9 +292,8 @@ namespace Namespace { ...@@ -290,9 +292,8 @@ namespace Namespace {
%typemap(in) QList<double> { %typemap(in) QList<double> {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
for(i;i!=end; ++i) { for(int i = 0; i!=end; ++i) {
$1 << PyFloat_AsDouble(PyList_GET_ITEM($input, i)); $1 << PyFloat_AsDouble(PyList_GET_ITEM($input, i));
} }
} else { } else {
...@@ -302,10 +303,9 @@ namespace Namespace { ...@@ -302,10 +303,9 @@ namespace Namespace {
%typemap(in) const QList<double>& { %typemap(in) const QList<double>& {
if (PyList_Check($input)) { if (PyList_Check($input)) {
int i = 0;
int end = PyList_Size($input); int end = PyList_Size($input);
$1 = new QList<double>; $1 = new QList<double>;
for(i;i!=end; ++i) { for(int i = 0; i!=end; ++i) {
($1)->append(PyFloat_AsDouble(PyList_GET_ITEM($input, i))); ($1)->append(PyFloat_AsDouble(PyList_GET_ITEM($input, i)));
} }
} else { } else {
...@@ -322,9 +322,8 @@ namespace Namespace { ...@@ -322,9 +322,8 @@ namespace Namespace {
%typemap(directorout) QList<double> { %typemap(directorout) QList<double> {
PyObject *list = static_cast<PyObject *>($1); PyObject *list = static_cast<PyObject *>($1);
if (PyList_Check(list)) { if (PyList_Check(list)) {
int i = 0;
int end = PyList_Size(list); int end = PyList_Size(list);
for(i;i<end; ++i) { for(int i = 0; i<end; ++i) {
PyObject *o = PyList_GET_ITEM(list, i); PyObject *o = PyList_GET_ITEM(list, i);
$result << PyFloat_AsDouble(o); $result << PyFloat_AsDouble(o);
} }
......
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