Skip to content
Permalink
Browse files

Python bindings: add compatibility with SWIG 4.0 (based on patch by @…

  • Loading branch information...
rouault committed Jul 8, 2019
1 parent aa9ed57 commit 5ec508c7aced408147e898c945ffbe9075056d2a
@@ -913,12 +913,18 @@ retStringAndCPLFree* GetArrayFilename(PyArrayObject *psArray)
}

/* Keep a reference to the VirtualMem object */
%#if SWIGVERSION >= 0x040000
%#define obj0 swig_obj[0]
%#endif
%#if NPY_API_VERSION >= 0x00000007
PyArray_SetBaseObject(ar, obj0);
%#else
PyArray_BASE(ar) = obj0;
%#endif
Py_INCREF(obj0);
%#if SWIGVERSION >= 0x040000
%#undef obj0
%#endif
Py_DECREF($result);
$result = (PyObject*) ar;
}
@@ -2066,7 +2066,14 @@ DecomposeSequenceOf4DCoordinates( PyObject *seq, int nCount, double *x, double *
%#if PY_VERSION_HEX >= 0x02070000
/* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
if (PyBuffer_FillInfo(buf, obj0, *($1), *($2), *($4), PyBUF_ND)) {

if (PyBuffer_FillInfo(buf,
%#if SWIGVERSION >= 0x040000
swig_obj[0],
%#else
obj0,
%#endif
*($1), *($2), *($4), PyBUF_ND)) {
// error, handle
}
if( *($3) == GDT_Byte )
@@ -4544,7 +4544,14 @@ SWIGINTERN PyObject *_wrap_VirtualMem_GetAddr(PyObject *SWIGUNUSEDPARM(self), Py
#if PY_VERSION_HEX >= 0x02070000
/* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
if (PyBuffer_FillInfo(buf, obj0, *(arg2), *(arg3), *(arg5), PyBUF_ND)) {

if (PyBuffer_FillInfo(buf,
#if SWIGVERSION >= 0x040000
swig_obj[0],
#else
obj0,
#endif
*(arg2), *(arg3), *(arg5), PyBUF_ND)) {
// error, handle
}
if( *(arg4) == GDT_Byte )
@@ -5554,12 +5561,18 @@ SWIGINTERN PyObject *_wrap_VirtualMemGetArray(PyObject *SWIGUNUSEDPARM(self), Py
}

/* Keep a reference to the VirtualMem object */
#if SWIGVERSION >= 0x040000
#define obj0 swig_obj[0]
#endif
#if NPY_API_VERSION >= 0x00000007
PyArray_SetBaseObject(ar, obj0);
#else
PyArray_BASE(ar) = obj0;
#endif
Py_INCREF(obj0);
#if SWIGVERSION >= 0x040000
#undef obj0
#endif
Py_DECREF(resultobj);
resultobj = (PyObject*) ar;
}
@@ -15357,7 +15357,14 @@ SWIGINTERN PyObject *_wrap_VirtualMem_GetAddr(PyObject *SWIGUNUSEDPARM(self), Py
#if PY_VERSION_HEX >= 0x02070000
/* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
if (PyBuffer_FillInfo(buf, obj0, *(arg2), *(arg3), *(arg5), PyBUF_ND)) {

if (PyBuffer_FillInfo(buf,
#if SWIGVERSION >= 0x040000
swig_obj[0],
#else
obj0,
#endif
*(arg2), *(arg3), *(arg5), PyBUF_ND)) {
// error, handle
}
if( *(arg4) == GDT_Byte )

0 comments on commit 5ec508c

Please sign in to comment.
You can’t perform that action at this time.