Fix for bug #3057804: migrate PyCObject to PyCapsule.
Other misc. fixes for python3.2, mostly dealing with changed interfaces to python functions. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12620 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7a0726c8b6
commit
17af467132
5 changed files with 46 additions and 20 deletions
|
|
@ -32,14 +32,17 @@ typedef struct swig_const_info {
|
||||||
* Wrapper of PyInstanceMethod_New() used in Python 3
|
* Wrapper of PyInstanceMethod_New() used in Python 3
|
||||||
* It is exported to the generated module, used for -fastproxy
|
* It is exported to the generated module, used for -fastproxy
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)
|
||||||
|
{
|
||||||
|
return PyInstanceMethod_New(func);
|
||||||
|
}
|
||||||
|
#else
|
||||||
SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
|
SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
|
||||||
{
|
{
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
|
||||||
return PyInstanceMethod_New(func);
|
|
||||||
#else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX >= 0x03020000
|
||||||
|
# define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj))
|
||||||
|
#else
|
||||||
|
# define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj))
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -689,7 +695,7 @@ namespace swig
|
||||||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
|
PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
|
||||||
return swig::getslice(self, i, j);
|
return swig::getslice(self, i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -700,7 +706,7 @@ namespace swig
|
||||||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
|
PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
|
||||||
swig::setslice(self, i, j, v);
|
swig::setslice(self, i, j, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -711,7 +717,7 @@ namespace swig
|
||||||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
|
PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
|
||||||
swig::delslice(self, i,j);
|
swig::delslice(self, i,j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -722,7 +728,7 @@ namespace swig
|
||||||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
|
PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
|
||||||
swig::delslice(self, i,j);
|
swig::delslice(self, i,j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,3 +199,10 @@ typedef struct {
|
||||||
#if PY_VERSION_HEX < 0x02030000
|
#if PY_VERSION_HEX < 0x02030000
|
||||||
typedef destructor freefunc;
|
typedef destructor freefunc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
|
||||||
|
(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
|
||||||
|
(PY_MAJOR_VERSION > 3))
|
||||||
|
# define SWIGPY_USE_CAPSULE
|
||||||
|
# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -216,8 +216,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
|
||||||
#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
|
#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SWIG_PYTHON_CAPSULE_NAME (char*) "swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer" SWIG_TYPE_TABLE_NAME
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Pointer declarations
|
* Pointer declarations
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -1480,8 +1478,8 @@ SWIG_Python_GetModule(void) {
|
||||||
#ifdef SWIG_LINK_RUNTIME
|
#ifdef SWIG_LINK_RUNTIME
|
||||||
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
|
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
|
||||||
#else
|
#else
|
||||||
# if PY_VERSION_HEX >= 0x02070000
|
# ifdef SWIGPY_USE_CAPSULE
|
||||||
type_pointer = PyCapsule_Import(SWIG_PYTHON_CAPSULE_NAME, 0);
|
type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
|
||||||
# else
|
# else
|
||||||
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||||
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
|
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
|
||||||
|
|
@ -1528,10 +1526,10 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SWIGRUNTIME void
|
SWIGRUNTIME void
|
||||||
#if PY_VERSION_HEX >= 0x02070000
|
#ifdef SWIGPY_USE_CAPSULE
|
||||||
SWIG_Python_DestroyModule(PyObject *obj)
|
SWIG_Python_DestroyModule(PyObject *obj)
|
||||||
{
|
{
|
||||||
swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIG_PYTHON_CAPSULE_NAME);
|
swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
|
||||||
#else
|
#else
|
||||||
SWIG_Python_DestroyModule(void *vptr)
|
SWIG_Python_DestroyModule(void *vptr)
|
||||||
{
|
{
|
||||||
|
|
@ -1559,13 +1557,15 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
|
||||||
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
|
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
|
||||||
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
|
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
|
||||||
#endif
|
#endif
|
||||||
#if PY_VERSION_HEX >= 0x02070000
|
#ifdef SWIGPY_USE_CAPSULE
|
||||||
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIG_PYTHON_CAPSULE_NAME, SWIG_Python_DestroyModule);
|
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
|
||||||
|
if (pointer && module) {
|
||||||
|
PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
|
||||||
#else
|
#else
|
||||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
||||||
#endif
|
|
||||||
if (pointer && module) {
|
if (pointer && module) {
|
||||||
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
Py_XDECREF(pointer);
|
Py_XDECREF(pointer);
|
||||||
}
|
}
|
||||||
|
|
@ -1586,7 +1586,7 @@ SWIG_Python_TypeQuery(const char *type)
|
||||||
PyObject *obj = PyDict_GetItem(cache, key);
|
PyObject *obj = PyDict_GetItem(cache, key);
|
||||||
swig_type_info *descriptor;
|
swig_type_info *descriptor;
|
||||||
if (obj) {
|
if (obj) {
|
||||||
#if PY_VERSION_HEX >= 0x02070000
|
#ifdef SWIGPY_USE_CAPSULE
|
||||||
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
|
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
|
||||||
#else
|
#else
|
||||||
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
|
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
|
||||||
|
|
@ -1595,7 +1595,7 @@ SWIG_Python_TypeQuery(const char *type)
|
||||||
swig_module_info *swig_module = SWIG_Python_GetModule();
|
swig_module_info *swig_module = SWIG_Python_GetModule();
|
||||||
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
#if PY_VERSION_HEX >= 0x02070000
|
#ifdef SWIGPY_USE_CAPSULE
|
||||||
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
|
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
|
||||||
#else
|
#else
|
||||||
obj = PyCObject_FromVoidPtr(descriptor, NULL);
|
obj = PyCObject_FromVoidPtr(descriptor, NULL);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,16 @@
|
||||||
* utility methods for wchar_t strings
|
* utility methods for wchar_t strings
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX >= 0x03020000
|
||||||
|
# define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
|
||||||
|
#else
|
||||||
|
# define SWIGPY_UNICODE_ARG(obj) ((PyUnicodeObject*) (obj))
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
|
%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
||||||
|
|
@ -20,7 +30,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
||||||
Py_ssize_t len = PyUnicode_GetSize(obj);
|
Py_ssize_t len = PyUnicode_GetSize(obj);
|
||||||
if (cptr) {
|
if (cptr) {
|
||||||
*cptr = %new_array(len + 1, wchar_t);
|
*cptr = %new_array(len + 1, wchar_t);
|
||||||
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
|
PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len);
|
||||||
(*cptr)[len] = 0;
|
(*cptr)[len] = 0;
|
||||||
}
|
}
|
||||||
if (psize) *psize = (size_t) len + 1;
|
if (psize) *psize = (size_t) len + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue