Always use PyCapsule
It is supported by all the Python versions we now support.
This commit is contained in:
parent
a82c1b943b
commit
2ea976f1d8
2 changed files with 2 additions and 34 deletions
|
|
@ -75,12 +75,10 @@ SWIG_Python_str_FromChar(const char *c)
|
||||||
# define PyObject_DEL PyObject_Del
|
# define PyObject_DEL PyObject_Del
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
|
// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user
|
||||||
(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
|
// interface files check for it.
|
||||||
(PY_MAJOR_VERSION > 3))
|
|
||||||
# define SWIGPY_USE_CAPSULE
|
# define SWIGPY_USE_CAPSULE
|
||||||
# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
|
# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PY_VERSION_HEX < 0x03020000
|
#if PY_VERSION_HEX < 0x03020000
|
||||||
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
|
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
|
||||||
|
|
|
||||||
|
|
@ -1386,12 +1386,7 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||||
#ifdef SWIG_LINK_RUNTIME
|
#ifdef SWIG_LINK_RUNTIME
|
||||||
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
|
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
|
||||||
#else
|
#else
|
||||||
# ifdef SWIGPY_USE_CAPSULE
|
|
||||||
type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
|
type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
|
||||||
# else
|
|
||||||
type_pointer = PyCObject_Import("swig_runtime_data" SWIG_RUNTIME_VERSION,
|
|
||||||
"type_pointer" SWIG_TYPE_TABLE_NAME);
|
|
||||||
# endif
|
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
type_pointer = (void *)0;
|
type_pointer = (void *)0;
|
||||||
|
|
@ -1402,17 +1397,9 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIME void
|
SWIGRUNTIME void
|
||||||
#ifdef SWIGPY_USE_CAPSULE
|
|
||||||
SWIG_Python_DestroyModule(PyObject *obj)
|
SWIG_Python_DestroyModule(PyObject *obj)
|
||||||
#else
|
|
||||||
SWIG_Python_DestroyModule(void *vptr)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#ifdef SWIGPY_USE_CAPSULE
|
|
||||||
swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
|
swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
|
||||||
#else
|
|
||||||
swig_module_info *swig_module = (swig_module_info *) vptr;
|
|
||||||
#endif
|
|
||||||
swig_type_info **types = swig_module->types;
|
swig_type_info **types = swig_module->types;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i =0; i < swig_module->size; ++i) {
|
for (i =0; i < swig_module->size; ++i) {
|
||||||
|
|
@ -1435,21 +1422,12 @@ 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("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
|
PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SWIGPY_USE_CAPSULE
|
|
||||||
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
|
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
|
||||||
if (pointer && module) {
|
if (pointer && module) {
|
||||||
PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
|
PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
|
||||||
} else {
|
} else {
|
||||||
Py_XDECREF(pointer);
|
Py_XDECREF(pointer);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
|
||||||
if (pointer && module) {
|
|
||||||
PyModule_AddObject(module, "type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
|
||||||
} else {
|
|
||||||
Py_XDECREF(pointer);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The python cached type query */
|
/* The python cached type query */
|
||||||
|
|
@ -1467,20 +1445,12 @@ 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) {
|
||||||
#ifdef SWIGPY_USE_CAPSULE
|
|
||||||
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
|
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
|
||||||
#else
|
|
||||||
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
swig_module_info *swig_module = SWIG_GetModule(0);
|
swig_module_info *swig_module = SWIG_GetModule(0);
|
||||||
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
#ifdef SWIGPY_USE_CAPSULE
|
|
||||||
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
|
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
|
||||||
#else
|
|
||||||
obj = PyCObject_FromVoidPtr(descriptor, NULL);
|
|
||||||
#endif
|
|
||||||
PyDict_SetItem(cache, key, obj);
|
PyDict_SetItem(cache, key, obj);
|
||||||
Py_DECREF(obj);
|
Py_DECREF(obj);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue