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
|
||||
* 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))
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
return PyInstanceMethod_New(func);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@
|
|||
|
||||
%{
|
||||
#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.");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -700,7 +706,7 @@ namespace swig
|
|||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -711,7 +717,7 @@ namespace swig
|
|||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -722,7 +728,7 @@ namespace swig
|
|||
SWIG_Error(SWIG_TypeError, "Slice object expected.");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,3 +199,10 @@ typedef struct {
|
|||
#if PY_VERSION_HEX < 0x02030000
|
||||
typedef destructor freefunc;
|
||||
#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
|
||||
#endif
|
||||
|
||||
#define SWIG_PYTHON_CAPSULE_NAME (char*) "swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer" SWIG_TYPE_TABLE_NAME
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Pointer declarations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -1480,8 +1478,8 @@ SWIG_Python_GetModule(void) {
|
|||
#ifdef SWIG_LINK_RUNTIME
|
||||
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
|
||||
#else
|
||||
# if PY_VERSION_HEX >= 0x02070000
|
||||
type_pointer = PyCapsule_Import(SWIG_PYTHON_CAPSULE_NAME, 0);
|
||||
# ifdef SWIGPY_USE_CAPSULE
|
||||
type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
|
||||
# else
|
||||
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
|
||||
|
|
@ -1528,10 +1526,10 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
|
|||
#endif
|
||||
|
||||
SWIGRUNTIME void
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
#ifdef SWIGPY_USE_CAPSULE
|
||||
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
|
||||
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 */
|
||||
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIG_PYTHON_CAPSULE_NAME, SWIG_Python_DestroyModule);
|
||||
#ifdef SWIGPY_USE_CAPSULE
|
||||
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
|
||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
||||
#endif
|
||||
if (pointer && module) {
|
||||
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
||||
#endif
|
||||
} else {
|
||||
Py_XDECREF(pointer);
|
||||
}
|
||||
|
|
@ -1586,7 +1586,7 @@ SWIG_Python_TypeQuery(const char *type)
|
|||
PyObject *obj = PyDict_GetItem(cache, key);
|
||||
swig_type_info *descriptor;
|
||||
if (obj) {
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
#ifdef SWIGPY_USE_CAPSULE
|
||||
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
|
||||
#else
|
||||
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();
|
||||
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
||||
if (descriptor) {
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
#ifdef SWIGPY_USE_CAPSULE
|
||||
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
|
||||
#else
|
||||
obj = PyCObject_FromVoidPtr(descriptor, NULL);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,16 @@
|
|||
* 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") {
|
||||
SWIGINTERN int
|
||||
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);
|
||||
if (cptr) {
|
||||
*cptr = %new_array(len + 1, wchar_t);
|
||||
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
|
||||
PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len);
|
||||
(*cptr)[len] = 0;
|
||||
}
|
||||
if (psize) *psize = (size_t) len + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue