Use safe Py_None in Windows or when using -DSWIG_PYTHON_SAFE_NONE
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8021 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f787718a53
commit
c09006dbdd
2 changed files with 18 additions and 10 deletions
|
|
@ -78,6 +78,15 @@ extern "C" {
|
||||||
|
|
||||||
/* Safe Py_None and Py_Void accessors */
|
/* Safe Py_None and Py_Void accessors */
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
|
# ifndef SWIG_PYTHON_NO_SAFE_NONE
|
||||||
|
# ifndef SWIG_PYTHON_SAFE_NONE
|
||||||
|
# define SWIG_PYTHON_SAFE_NONE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SWIG_PYTHON_SAFE_NONE
|
||||||
SWIGRUNTIME PyObject *
|
SWIGRUNTIME PyObject *
|
||||||
_SWIG_Py_None(void)
|
_SWIG_Py_None(void)
|
||||||
{
|
{
|
||||||
|
|
@ -88,23 +97,22 @@ _SWIG_Py_None(void)
|
||||||
}
|
}
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIMEINLINE PyObject *
|
SWIGRUNTIMEINLINE PyObject *
|
||||||
SWIG_Py_None(void)
|
SWIG_Py_None(void)
|
||||||
{
|
{
|
||||||
static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
|
static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
# ifdef Py_None
|
||||||
#ifdef Py_None
|
# undef Py_None
|
||||||
# undef Py_None
|
# define Py_None SWIG_Py_None()
|
||||||
# define Py_None SWIG_Py_None()
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SWIGRUNTIMEINLINE PyObject *
|
SWIGRUNTIMEINLINE PyObject *
|
||||||
SWIG_Py_Void(void)
|
SWIG_Py_Void(void)
|
||||||
{
|
{
|
||||||
PyObject *none = SWIG_Py_None();
|
PyObject *none = Py_None;
|
||||||
Py_INCREF(none);
|
Py_INCREF(none);
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +123,7 @@ SWIGINTERN PyObject*
|
||||||
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
|
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = obj;
|
result = obj;
|
||||||
} else if (result == SWIG_Py_None()) {
|
} else if (result == Py_None) {
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
result = obj;
|
result = obj;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -867,7 +875,7 @@ SWIG_Python_AcquirePtr(PyObject *obj, int own) {
|
||||||
SWIGRUNTIME int
|
SWIGRUNTIME int
|
||||||
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
|
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
|
||||||
if (!obj) return SWIG_ERROR;
|
if (!obj) return SWIG_ERROR;
|
||||||
if (obj == SWIG_Py_None()) {
|
if (obj == Py_None) {
|
||||||
if (ptr) *ptr = 0;
|
if (ptr) *ptr = 0;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set comparison with none for ConstructorToFunction */
|
/* Set comparison with none for ConstructorToFunction */
|
||||||
setSubclassInstanceCheck(NewString("$arg != SWIG_Py_None()"));
|
setSubclassInstanceCheck(NewString("$arg != Py_None"));
|
||||||
|
|
||||||
/* Initialize all of the output files */
|
/* Initialize all of the output files */
|
||||||
String *outfile = Getattr(n,"outfile");
|
String *outfile = Getattr(n,"outfile");
|
||||||
|
|
@ -1725,7 +1725,7 @@ public:
|
||||||
/*
|
/*
|
||||||
if (constructor && (Getattr(n, "wrap:self") != 0)) {
|
if (constructor && (Getattr(n, "wrap:self") != 0)) {
|
||||||
Wrapper_add_local(f, "subclassed", "int subclassed = 0");
|
Wrapper_add_local(f, "subclassed", "int subclassed = 0");
|
||||||
Printf(f->code, "subclassed = (arg1 != SWIG_Py_None());\n");
|
Printf(f->code, "subclassed = (arg1 != Py_None);\n");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue