From 62ac7de80e5c88adcc3113b71557157c33cb9323 Mon Sep 17 00:00:00 2001 From: Mike Jerris Date: Tue, 27 Jun 2017 12:33:38 -0500 Subject: [PATCH] FS-10427: move mod_python to use swig3.0 so we can reswig on debian9 --- src/mod/languages/mod_python/Makefile.am | 2 +- src/mod/languages/mod_python/freeswitch.py | 2 +- .../languages/mod_python/mod_python_wrap.cpp | 56 +++++++++++-------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/mod/languages/mod_python/Makefile.am b/src/mod/languages/mod_python/Makefile.am index f3073c5c53..910c53a846 100644 --- a/src/mod/languages/mod_python/Makefile.am +++ b/src/mod/languages/mod_python/Makefile.am @@ -20,7 +20,7 @@ swigclean: clean rm -f mod_python_wrap.* freeswitch.py mod_python_wrap.cpp: mod_python_extra.c hack.diff - swig2.0 -python -c++ -I../../../../src/include -oh mod_python_wrap.h -o mod_python_wrap.cpp mod_python.i + swig3.0 -python -c++ -I../../../../src/include -oh mod_python_wrap.h -o mod_python_wrap.cpp mod_python.i echo "#include \"mod_python_extra.c\"" >> mod_python_wrap.cpp patch -s -p0 -i hack.diff diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index 4c9e4dd6b4..82a55b8342 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 2.0.12 +# Version 3.0.2 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index f39f9e61ce..b4880a1ef2 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.12 + * Version 3.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -560,14 +560,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *iter = start; do { if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; + size_t l = 0; + size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { - register int compare = strcmp(name, iname); + int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { @@ -611,7 +611,7 @@ SWIG_TypeQueryModule(swig_module_info *start, of the str field (the human readable name) */ swig_module_info *iter = start; do { - register size_t i = 0; + size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; @@ -630,10 +630,10 @@ SWIG_TypeQueryModule(swig_module_info *start, SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register unsigned char uu = *u; + unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } @@ -645,11 +645,11 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; + char d = *(c++); + unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) @@ -1326,7 +1326,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { - register int i; + int i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; @@ -1336,7 +1336,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); + Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); @@ -1346,7 +1346,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { - register int i; + int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } @@ -2461,7 +2461,7 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + 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; @@ -2987,7 +2987,7 @@ static swig_module_info swig_module = {swig_types, 28, 0, 0, 0, 0}; #endif #define SWIG_name "_freeswitch" -#define SWIGVERSION 0x020012 +#define SWIGVERSION 0x030002 #define SWIG_VERSION SWIGVERSION @@ -3166,7 +3166,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03010000 + return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape"); +#else return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); +#endif #else return PyString_FromStringAndSize(carray, static_cast< int >(size)); #endif @@ -3349,7 +3353,8 @@ SWIG_AsCharArray(PyObject * obj, char *val, size_t size) char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); if (SWIG_IsOK(res)) { - if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize; + /* special case of single char conversion when we don't need space for NUL */ + if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize; if (csize <= size) { if (val) { if (csize) memcpy(val, cptr, csize*sizeof(char)); @@ -3478,7 +3483,10 @@ SWIGINTERNINLINE PyObject* SWIGINTERN int SWIG_AsVal_bool (PyObject *obj, bool *val) { - int r = PyObject_IsTrue(obj); + int r; + if (!PyBool_Check(obj)) + return SWIG_ERROR; + r = PyObject_IsTrue(obj); if (r == -1) return SWIG_ERROR; if (val) *val = r ? true : false; @@ -5947,7 +5955,7 @@ SWIGINTERN PyObject *_wrap_EventConsumer_enodes_set(PyObject *SWIGUNUSEDPARM(sel { if (arg2) { size_t ii = 0; - for (; ii < (size_t)SWITCH_EVENT_ALL+1; ++ii) arg1->enodes[ii] = arg2[ii]; + for (; ii < (size_t)SWITCH_EVENT_ALL+1; ++ii) *(switch_event_node_t * *)&arg1->enodes[ii] = *((switch_event_node_t * *)arg2 + ii); } else { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""enodes""' of type '""switch_event_node_t *[SWITCH_EVENT_ALL+1]""'"); } @@ -10525,7 +10533,7 @@ static swig_const_info swig_const_table[] = { * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -10855,7 +10863,7 @@ extern "C" { var = var->next; } if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -10872,7 +10880,7 @@ extern "C" { var = var->next; } if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; }