aboutsummaryrefslogtreecommitdiff
path: root/Lib/python/pyrun.swg
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/python/pyrun.swg')
-rw-r--r--Lib/python/pyrun.swg448
1 files changed, 97 insertions, 351 deletions
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index ab1237f62..445a1e324 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -7,6 +7,14 @@
*
* ----------------------------------------------------------------------------- */
+#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */
+# error "This version of SWIG only supports Python >= 2.7"
+#endif
+
+#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000
+# error "This version of SWIG only supports Python 3 >= 3.2"
+#endif
+
/* Common SWIG API */
/* for raw pointers */
@@ -90,11 +98,7 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
SWIGINTERN void
SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
-#if PY_VERSION_HEX < 0x02030000
- PyDict_SetItemString(d, (char *)name, obj);
-#else
PyDict_SetItemString(d, name, obj);
-#endif
Py_DECREF(obj);
if (public_interface)
SwigPyBuiltin_AddPublicSymbol(public_interface, name);
@@ -104,11 +108,7 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam
SWIGINTERN void
SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
-#if PY_VERSION_HEX < 0x02030000
- PyDict_SetItemString(d, (char *)name, obj);
-#else
PyDict_SetItemString(d, name, obj);
-#endif
Py_DECREF(obj);
}
@@ -118,7 +118,6 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
SWIGINTERN PyObject*
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
if (!result) {
result = obj;
} else if (result == Py_None) {
@@ -134,29 +133,6 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
Py_DECREF(obj);
}
return result;
-#else
- PyObject* o2;
- PyObject* o3;
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyTuple_Check(result)) {
- o2 = result;
- result = PyTuple_New(1);
- PyTuple_SET_ITEM(result, 0, o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SET_ITEM(o3, 0, obj);
- o2 = result;
- result = PySequence_Concat(o2, o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
- }
- return result;
-#endif
}
/* Unpack the argument tuple */
@@ -208,11 +184,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
}
/* A functor is a function object with one single object argument */
-#if PY_VERSION_HEX >= 0x02020000
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
-#else
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
-#endif
/*
Helper for static pointer initialization for both C and C++ code, for example
@@ -241,35 +213,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
extern "C" {
#endif
-/* How to access Py_None */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef SWIG_PYTHON_NO_BUILD_NONE
-# ifndef SWIG_PYTHON_BUILD_NONE
-# define SWIG_PYTHON_BUILD_NONE
-# endif
-# endif
-#endif
-
-#ifdef SWIG_PYTHON_BUILD_NONE
-# ifdef Py_None
-# undef Py_None
-# define Py_None SWIG_Py_None()
-# endif
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_Py_None(void)
-{
- PyObject *none = Py_BuildValue((char*)"");
- Py_DECREF(none);
- return none;
-}
-SWIGRUNTIME PyObject *
-SWIG_Py_None(void)
-{
- static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
- return none;
-}
-#endif
-
/* The python void return value */
SWIGRUNTIMEINLINE PyObject *
@@ -296,7 +239,10 @@ SWIGRUNTIMEINLINE int
SWIG_Python_CheckImplicit(swig_type_info *ty)
{
SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
- return data ? data->implicitconv : 0;
+ int fail = data ? data->implicitconv : 0;
+ if (fail)
+ PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors.");
+ return fail;
}
SWIGRUNTIMEINLINE PyObject *
@@ -323,11 +269,7 @@ SwigPyClientData_New(PyObject* obj)
data->newargs = obj;
Py_INCREF(obj);
} else {
-#if (PY_VERSION_HEX < 0x02020000)
- data->newraw = 0;
-#else
- data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
-#endif
+ data->newraw = PyObject_GetAttrString(data->klass, "__new__");
if (data->newraw) {
Py_INCREF(data->newraw);
data->newargs = PyTuple_New(1);
@@ -338,7 +280,7 @@ SwigPyClientData_New(PyObject* obj)
Py_INCREF(data->newargs);
}
/* the destroy method, aka as the C++ delete method */
- data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+ data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
if (PyErr_Occurred()) {
PyErr_Clear();
data->destroy = 0;
@@ -347,11 +289,7 @@ SwigPyClientData_New(PyObject* obj)
int flags;
Py_INCREF(data->destroy);
flags = PyCFunction_GET_FLAGS(data->destroy);
-#ifdef METH_O
data->delargs = !(flags & (METH_O));
-#else
- data->delargs = 0;
-#endif
} else {
data->delargs = 0;
}
@@ -439,20 +377,12 @@ SwigPyObject_hex(SwigPyObject *v)
}
SWIGRUNTIME PyObject *
-#ifdef METH_NOARGS
SwigPyObject_repr(SwigPyObject *v)
-#else
-SwigPyObject_repr(SwigPyObject *v, PyObject *args)
-#endif
{
const char *name = SWIG_TypePrettyName(v->ty);
PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
if (v->next) {
-# ifdef METH_NOARGS
PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
-# else
- PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
-# endif
# if PY_VERSION_HEX >= 0x03000000
PyObject *joined = PyUnicode_Concat(repr, nrep);
Py_DecRef(repr);
@@ -465,6 +395,14 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
return repr;
}
+/* We need a version taking two PyObject* parameters so it's a valid
+ * PyCFunction to use in swigobject_methods[]. */
+SWIGRUNTIME PyObject *
+SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
+{
+ return SwigPyObject_repr((SwigPyObject*)v);
+}
+
SWIGRUNTIME int
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
{
@@ -538,14 +476,14 @@ SwigPyObject_dealloc(PyObject *v)
PyObject *res;
/* PyObject_CallFunction() has the potential to silently drop
- the active active exception. In cases of unnamed temporary
+ the active exception. In cases of unnamed temporary
variable or where we just finished iterating over a generator
StopIteration will be active right now, and this needs to
remain true upon return from SwigPyObject_dealloc. So save
and restore. */
- PyObject *val = NULL, *type = NULL, *tb = NULL;
- PyErr_Fetch(&val, &type, &tb);
+ PyObject *type = NULL, *value = NULL, *traceback = NULL;
+ PyErr_Fetch(&type, &value, &traceback);
if (data->delargs) {
/* we need to create a temporary object to carry the destroy operation */
@@ -560,7 +498,7 @@ SwigPyObject_dealloc(PyObject *v)
if (!res)
PyErr_WriteUnraisable(destroy);
- PyErr_Restore(val, type, tb);
+ PyErr_Restore(type, value, traceback);
Py_XDECREF(res);
}
@@ -579,11 +517,6 @@ SWIGRUNTIME PyObject*
SwigPyObject_append(PyObject* v, PyObject* next)
{
SwigPyObject *sobj = (SwigPyObject *) v;
-#ifndef METH_O
- PyObject *tmp = 0;
- if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
- next = tmp;
-#endif
if (!SwigPyObject_Check(next)) {
PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
return NULL;
@@ -594,11 +527,7 @@ SwigPyObject_append(PyObject* v, PyObject* next)
}
SWIGRUNTIME PyObject*
-#ifdef METH_NOARGS
-SwigPyObject_next(PyObject* v)
-#else
SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
{
SwigPyObject *sobj = (SwigPyObject *) v;
if (sobj->next) {
@@ -610,11 +539,7 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
}
SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-SwigPyObject_disown(PyObject *v)
-#else
SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
{
SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = 0;
@@ -622,11 +547,7 @@ SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
}
SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-SwigPyObject_acquire(PyObject *v)
-#else
SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
{
SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = SWIG_POINTER_OWN;
@@ -637,70 +558,32 @@ SWIGINTERN PyObject*
SwigPyObject_own(PyObject *v, PyObject *args)
{
PyObject *val = 0;
-#if (PY_VERSION_HEX < 0x02020000)
- if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#elif (PY_VERSION_HEX < 0x02050000)
- if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
-#else
- if (!PyArg_UnpackTuple(args, "own", 0, 1, &val))
-#endif
- {
- return NULL;
+ if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) {
+ return NULL;
+ } else {
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+ if (PyObject_IsTrue(val)) {
+ SwigPyObject_acquire(v,args);
+ } else {
+ SwigPyObject_disown(v,args);
+ }
}
- else
- {
- SwigPyObject *sobj = (SwigPyObject *)v;
- PyObject *obj = PyBool_FromLong(sobj->own);
- if (val) {
-#ifdef METH_NOARGS
- if (PyObject_IsTrue(val)) {
- SwigPyObject_acquire(v);
- } else {
- SwigPyObject_disown(v);
- }
-#else
- if (PyObject_IsTrue(val)) {
- SwigPyObject_acquire(v,args);
- } else {
- SwigPyObject_disown(v,args);
- }
-#endif
- }
- return obj;
- }
+ return obj;
+ }
}
-#ifdef METH_O
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#else
static PyMethodDef
swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"},
+ {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"},
+ {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"},
+ {"append", SwigPyObject_append, METH_O, "appends another 'this' object"},
+ {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"},
+ {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"},
{0, 0, 0, 0}
};
-#endif
-
-#if PY_VERSION_HEX < 0x02020000
-SWIGINTERN PyObject *
-SwigPyObject_getattr(SwigPyObject *sobj,char *name)
-{
- return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
-}
-#endif
SWIGRUNTIME PyTypeObject*
SwigPyObject_TypeOnce(void) {
@@ -745,12 +628,8 @@ SwigPyObject_TypeOnce(void) {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
-#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+#else
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
- 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
#endif
};
@@ -764,16 +643,12 @@ SwigPyObject_TypeOnce(void) {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
#endif
- (char *)"SwigPyObject", /* tp_name */
+ "SwigPyObject", /* tp_name */
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
0, /* tp_print */
-#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
-#else
(getattrfunc)0, /* tp_getattr */
-#endif
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03000000
0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
@@ -796,7 +671,6 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_clear */
(richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
0, /* tp_iternext */
swigobject_methods, /* tp_methods */
@@ -817,13 +691,8 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
0, /* tp_del */
-#endif
-#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
-#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
@@ -831,20 +700,14 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
-#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
-#endif
0 /* tp_next */
#endif
};
swigpyobject_type = tmp;
type_init = 1;
-#if PY_VERSION_HEX < 0x02020000
- swigpyobject_type.ob_type = &PyType_Type;
-#else
if (PyType_Ready(&swigpyobject_type) < 0)
return NULL;
-#endif
}
return &swigpyobject_type;
}
@@ -873,20 +736,6 @@ typedef struct {
size_t size;
} SwigPyPacked;
-SWIGRUNTIME int
-SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
- char result[SWIG_BUFFER_SIZE];
- fputs("<Swig Packed ", fp);
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- fputs("at ", fp);
- fputs(result, fp);
- }
- fputs(v->ty->name,fp);
- fputs(">", fp);
- return 0;
-}
-
SWIGRUNTIME PyObject *
SwigPyPacked_repr(SwigPyPacked *v)
{
@@ -915,7 +764,7 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
size_t i = v->size;
size_t j = w->size;
int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
- return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+ return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size);
}
SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
@@ -955,11 +804,11 @@ SwigPyPacked_TypeOnce(void) {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
#endif
- (char *)"SwigPyPacked", /* tp_name */
+ "SwigPyPacked", /* tp_name */
sizeof(SwigPyPacked), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyPacked_dealloc, /* tp_dealloc */
- (printfunc)SwigPyPacked_print, /* tp_print */
+ 0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX>=0x03000000
@@ -983,7 +832,6 @@ SwigPyPacked_TypeOnce(void) {
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
@@ -1004,13 +852,8 @@ SwigPyPacked_TypeOnce(void) {
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
0, /* tp_del */
-#endif
-#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
-#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
@@ -1018,20 +861,14 @@ SwigPyPacked_TypeOnce(void) {
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
-#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
-#endif
0 /* tp_next */
#endif
};
swigpypacked_type = tmp;
type_init = 1;
-#if PY_VERSION_HEX < 0x02020000
- swigpypacked_type.ob_type = &PyType_Type;
-#else
if (PyType_Ready(&swigpypacked_type) < 0)
return NULL;
-#endif
}
return &swigpypacked_type;
}
@@ -1072,20 +909,14 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_This(void)
-{
- return SWIG_Python_str_FromChar("this");
-}
-
-static PyObject *swig_this = NULL;
+static PyObject *Swig_This_global = NULL;
SWIGRUNTIME PyObject *
SWIG_This(void)
{
- if (swig_this == NULL)
- swig_this = _SWIG_This();
- return swig_this;
+ if (Swig_This_global == NULL)
+ Swig_This_global = SWIG_Python_str_FromChar("this");
+ return Swig_This_global;
}
/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
@@ -1117,7 +948,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
obj = 0;
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
if (PyInstance_Check(pyobj)) {
obj = _PyInstance_Lookup(pyobj, SWIG_This());
} else {
@@ -1187,7 +1018,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (obj == Py_None && !implicit_conv) {
if (ptr)
*ptr = 0;
- return SWIG_OK;
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
res = SWIG_ERROR;
@@ -1267,13 +1098,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
}
- }
- if (!SWIG_IsOK(res) && obj == Py_None) {
- if (ptr)
- *ptr = 0;
- if (PyErr_Occurred())
- PyErr_Clear();
- res = SWIG_OK;
+ if (!SWIG_IsOK(res) && obj == Py_None) {
+ if (ptr)
+ *ptr = 0;
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ res = SWIG_OK;
+ }
}
}
return res;
@@ -1287,31 +1118,28 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
return SWIG_ConvertPtr(obj, ptr, ty, 0);
} else {
void *vptr = 0;
-
+ swig_cast_info *tc;
+
/* here we get the method pointer for callbacks */
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
if (desc)
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
- if (!desc)
+ if (!desc)
return SWIG_ERROR;
- if (ty) {
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (tc) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- assert(!newmemory); /* newmemory handling not yet implemented */
- } else {
- return SWIG_ERROR;
- }
+ tc = SWIG_TypeCheck(desc,ty);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
} else {
- *ptr = vptr;
+ return SWIG_ERROR;
}
return SWIG_OK;
}
}
-/* Convert a packed value value */
+/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
@@ -1339,7 +1167,6 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
SWIGRUNTIME PyObject*
SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
{
-#if (PY_VERSION_HEX >= 0x02020000)
PyObject *inst = 0;
PyObject *newraw = data->newraw;
if (newraw) {
@@ -1362,10 +1189,18 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
}
} else {
#if PY_VERSION_HEX >= 0x03000000
- inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
- if (inst) {
- PyObject_SetAttr(inst, SWIG_This(), swig_this);
- Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+ PyObject *empty_args = PyTuple_New(0);
+ if (empty_args) {
+ PyObject *empty_kwargs = PyDict_New();
+ if (empty_kwargs) {
+ inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs);
+ Py_DECREF(empty_kwargs);
+ if (inst) {
+ PyObject_SetAttr(inst, SWIG_This(), swig_this);
+ Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+ }
+ }
+ Py_DECREF(empty_args);
}
#else
PyObject *dict = PyDict_New();
@@ -1377,45 +1212,13 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
#endif
}
return inst;
-#else
-#if (PY_VERSION_HEX >= 0x02010000)
- PyObject *inst = 0;
- PyObject *dict = PyDict_New();
- if (dict) {
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- }
- return (PyObject *) inst;
-#else
- PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
- if (inst == NULL) {
- return NULL;
- }
- inst->in_class = (PyClassObject *)data->newargs;
- Py_INCREF(inst->in_class);
- inst->in_dict = PyDict_New();
- if (inst->in_dict == NULL) {
- Py_DECREF(inst);
- return NULL;
- }
-#ifdef Py_TPFLAGS_HAVE_WEAKREFS
- inst->in_weakreflist = NULL;
-#endif
-#ifdef Py_TPFLAGS_GC
- PyObject_GC_Init(inst);
-#endif
- PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
- return (PyObject *) inst;
-#endif
-#endif
}
SWIGRUNTIME void
SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
{
PyObject *dict;
-#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
PyObject **dictptr = _PyObject_GetDictPtr(inst);
if (dictptr != NULL) {
dict = *dictptr;
@@ -1427,7 +1230,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
return;
}
#endif
- dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ dict = PyObject_GetAttrString(inst, "__dict__");
PyDict_SetItem(dict, SWIG_This(), swig_this);
Py_DECREF(dict);
}
@@ -1526,12 +1329,7 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
#ifdef SWIG_LINK_RUNTIME
type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
#else
-# 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);
-# endif
if (PyErr_Occurred()) {
PyErr_Clear();
type_pointer = (void *)0;
@@ -1541,48 +1339,10 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
return (swig_module_info *) type_pointer;
}
-#if PY_MAJOR_VERSION < 2
-/* PyModule_AddObject function was introduced in Python 2.0. The following function
- is copied out of Python/modsupport.c in python version 2.3.4 */
-SWIGINTERN int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m)) {
- PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg");
- return SWIG_ERROR;
- }
- if (!o) {
- PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
- return SWIG_ERROR;
- }
-
- dict = PyModule_GetDict(m);
- if (dict == NULL) {
- /* Internal error -- modules must have a dict! */
- PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
- return SWIG_ERROR;
- }
- if (PyDict_SetItemString(dict, name, o))
- return SWIG_ERROR;
- Py_DECREF(o);
- return SWIG_OK;
-}
-#endif
-
SWIGRUNTIME void
-#ifdef SWIGPY_USE_CAPSULE
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);
-#else
- swig_module_info *swig_module = (swig_module_info *) vptr;
-#endif
swig_type_info **types = swig_module->types;
size_t i;
for (i =0; i < swig_module->size; ++i) {
@@ -1593,33 +1353,24 @@ SWIG_Python_DestroyModule(void *vptr)
}
}
Py_DECREF(SWIG_This());
- swig_this = NULL;
+ Swig_This_global = NULL;
}
SWIGRUNTIME void
SWIG_Python_SetModule(swig_module_info *swig_module) {
#if PY_VERSION_HEX >= 0x03000000
/* Add a dummy module object into sys.modules */
- PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
+ PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION);
#else
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("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
#endif
-#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);
+ PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
} else {
Py_XDECREF(pointer);
}
-#else
- PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
- if (pointer && module) {
- PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
- } else {
- Py_XDECREF(pointer);
- }
-#endif
}
/* The python cached type query */
@@ -1637,20 +1388,12 @@ SWIG_Python_TypeQuery(const char *type)
PyObject *obj = PyDict_GetItem(cache, key);
swig_type_info *descriptor;
if (obj) {
-#ifdef SWIGPY_USE_CAPSULE
descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
-#else
- descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
-#endif
} else {
swig_module_info *swig_module = SWIG_GetModule(0);
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
if (descriptor) {
-#ifdef SWIGPY_USE_CAPSULE
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
-#else
- obj = PyCObject_FromVoidPtr(descriptor, NULL);
-#endif
PyDict_SetItem(cache, key, obj);
Py_DECREF(obj);
}
@@ -1675,14 +1418,15 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront)
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
- char *tmp;
PyObject *old_str = PyObject_Str(value);
+ const char *tmp = SWIG_Python_str_AsChar(old_str);
+ const char *errmesg = tmp ? tmp : "Invalid error message";
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
- PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
+ PyErr_Format(type, "%s %s", mesg, errmesg);
} else {
- PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ PyErr_Format(type, "%s %s", errmesg, mesg);
}
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
@@ -1808,6 +1552,8 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
Py_INCREF(name);
} else {
encoded_name = PyUnicode_AsUTF8String(name);
+ if (!encoded_name)
+ return -1;
}
PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
Py_DECREF(encoded_name);