2019-11-06 21:44:40 +01:00
|
|
|
From 8f52960e1c6f2fde21fbc3cfe8064af84f90a09d Mon Sep 17 00:00:00 2001
|
2019-09-06 08:26:49 +02:00
|
|
|
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
2019-11-06 21:44:40 +01:00
|
|
|
Date: Thu, 5 Sep 2019 20:05:53 +0200
|
|
|
|
Git-id: 8328ae3077aea7e54537d76a9a8193775ddc8b09
|
2019-09-06 08:26:49 +02:00
|
|
|
Subject: [PATCH] Replace SWIG Python obj0/swig_obj[0] with version agnostic
|
|
|
|
$self
|
|
|
|
|
|
|
|
"obj0" was only meant as a porting helper and should not be used, even
|
|
|
|
with swig 3.0, see swig/swig@cd8fc0a.
|
|
|
|
Use the correct "$self" notation, which is expanded to the correct
|
|
|
|
code regardless of swig version and options.
|
2019-11-06 21:44:40 +01:00
|
|
|
|
|
|
|
Acked-by: Libor Pechacek <lpechacek@gmx.com>
|
2019-09-06 08:26:49 +02:00
|
|
|
---
|
2019-11-06 21:44:40 +01:00
|
|
|
swig/include/gdal_array.i | 12 +++---------
|
|
|
|
swig/include/python/typemaps_python.i | 8 +-------
|
|
|
|
2 files changed, 4 insertions(+), 16 deletions(-)
|
2019-09-06 08:26:49 +02:00
|
|
|
|
|
|
|
diff --git a/swig/include/gdal_array.i b/swig/include/gdal_array.i
|
2019-11-06 21:44:40 +01:00
|
|
|
index d86491d1d45e..6ee34b9abd99 100644
|
2019-09-06 08:26:49 +02:00
|
|
|
--- a/swig/include/gdal_array.i
|
|
|
|
+++ b/swig/include/gdal_array.i
|
2019-11-06 21:44:40 +01:00
|
|
|
@@ -913,18 +913,12 @@ retStringAndCPLFree* GetArrayFilename(PyArrayObject *psArray)
|
|
|
|
}
|
2019-09-06 08:26:49 +02:00
|
|
|
|
|
|
|
/* Keep a reference to the VirtualMem object */
|
2019-11-06 21:44:40 +01:00
|
|
|
-%#if SWIGVERSION >= 0x040000
|
|
|
|
-%#define obj0 swig_obj[0]
|
|
|
|
-%#endif
|
2019-09-06 08:26:49 +02:00
|
|
|
%#if NPY_API_VERSION >= 0x00000007
|
|
|
|
- PyArray_SetBaseObject(ar, obj0);
|
|
|
|
+ PyArray_SetBaseObject(ar, $self);
|
|
|
|
%#else
|
|
|
|
- PyArray_BASE(ar) = obj0;
|
2019-11-06 21:44:40 +01:00
|
|
|
-%#endif
|
|
|
|
- Py_INCREF(obj0);
|
|
|
|
-%#if SWIGVERSION >= 0x040000
|
|
|
|
-%#undef obj0
|
2019-09-06 08:26:49 +02:00
|
|
|
+ PyArray_BASE(ar) = $self;
|
|
|
|
%#endif
|
|
|
|
+ Py_INCREF($self);
|
|
|
|
Py_DECREF($result);
|
|
|
|
$result = (PyObject*) ar;
|
|
|
|
}
|
|
|
|
diff --git a/swig/include/python/typemaps_python.i b/swig/include/python/typemaps_python.i
|
2019-11-06 21:44:40 +01:00
|
|
|
index 85a25b5a3099..2af8b51c6368 100644
|
2019-09-06 08:26:49 +02:00
|
|
|
--- a/swig/include/python/typemaps_python.i
|
|
|
|
+++ b/swig/include/python/typemaps_python.i
|
2019-11-06 21:44:40 +01:00
|
|
|
@@ -2067,13 +2067,7 @@ DecomposeSequenceOf4DCoordinates( PyObject *seq, int nCount, double *x, double *
|
2019-09-06 08:26:49 +02:00
|
|
|
/* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
|
|
|
|
Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
|
2019-11-06 21:44:40 +01:00
|
|
|
|
|
|
|
- if (PyBuffer_FillInfo(buf,
|
|
|
|
-%#if SWIGVERSION >= 0x040000
|
|
|
|
- swig_obj[0],
|
|
|
|
-%#else
|
|
|
|
- obj0,
|
|
|
|
-%#endif
|
|
|
|
- *($1), *($2), *($4), PyBUF_ND)) {
|
2019-09-06 08:26:49 +02:00
|
|
|
+ if (PyBuffer_FillInfo(buf, $self, *($1), *($2), *($4), PyBUF_ND)) {
|
|
|
|
// error, handle
|
|
|
|
}
|
|
|
|
if( *($3) == GDT_Byte )
|
|
|
|
--
|
|
|
|
2.23.0
|
|
|
|
|