Remove non-const char * usage where the Python API now supports it
Python fixed many APIs to use const char * instead of char * at around Python 2.4. As we support 2.7 and later, we can now remove the non-const string usage. Types changed: PyArg_ParseTuple PyArg_ParseTupleAndKeywords PyArg_UnpackTuple PyDict_SetItemString PyMethodDef PyModuleDef SWIG_Python_UnpackTuple SWIG_Python_str_FromChar SWIG_addvarlink swig_const_info
This commit is contained in:
parent
18f433d862
commit
a1f40568d6
6 changed files with 45 additions and 48 deletions
|
|
@ -24,7 +24,7 @@ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
|
|||
PyObject *func;
|
||||
PyObject *parms;
|
||||
|
||||
if (!PyArg_ParseTuple(args,"OO",&func,&parms))
|
||||
if (!PyArg_ParseTuple(args, "OO", &func, &parms))
|
||||
return NULL;
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ extern "C" {
|
|||
/* Constant information structure */
|
||||
typedef struct swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
const char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ swig_varlink_type(void) {
|
|||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
#endif
|
||||
(char *)"swigvarlink", /* tp_name */
|
||||
"swigvarlink", /* tp_name */
|
||||
sizeof(swig_varlinkobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor) swig_varlink_dealloc, /* tp_dealloc */
|
||||
|
|
@ -208,7 +208,7 @@ SWIG_Python_newvarlink(void) {
|
|||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
|
||||
SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
|
||||
swig_varlinkobject *v = (swig_varlinkobject *) p;
|
||||
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
||||
if (gv) {
|
||||
|
|
@ -330,7 +330,7 @@ SWIG_init(void) {
|
|||
#if PY_VERSION_HEX >= 0x03000000
|
||||
static struct PyModuleDef SWIG_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
(char *) SWIG_name,
|
||||
SWIG_name,
|
||||
NULL,
|
||||
-1,
|
||||
SwigMethods,
|
||||
|
|
@ -393,7 +393,7 @@ SWIG_init(void) {
|
|||
#if PY_VERSION_HEX >= 0x03000000
|
||||
m = PyModule_Create(&SWIG_module);
|
||||
#else
|
||||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
m = Py_InitModule(SWIG_name, SwigMethods);
|
||||
#endif
|
||||
|
||||
md = d = PyModule_GetDict(m);
|
||||
|
|
|
|||
|
|
@ -208,7 +208,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 */
|
||||
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj);
|
||||
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char *)"O", obj);
|
||||
|
||||
/*
|
||||
Helper for static pointer initialization for both C and C++ code, for example
|
||||
|
|
@ -582,23 +582,20 @@ SWIGINTERN PyObject*
|
|||
SwigPyObject_own(PyObject *v, PyObject *args)
|
||||
{
|
||||
PyObject *val = 0;
|
||||
if (!PyArg_UnpackTuple(args, "own", 0, 1, &val))
|
||||
{
|
||||
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) {
|
||||
if (PyObject_IsTrue(val)) {
|
||||
SwigPyObject_acquire(v,args);
|
||||
} else {
|
||||
SwigPyObject_disown(v,args);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
static PyMethodDef
|
||||
|
|
@ -805,7 +802,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);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
/* Consttab, needed for callbacks, it should be removed later */
|
||||
|
||||
%typemap(consttab) SWIGTYPE ((*)(ANY))
|
||||
{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
|
||||
{ SWIG_PY_POINTER, "$symname", 0, 0, (void *)($value), &$descriptor }
|
||||
%typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
|
||||
|
||||
%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue