don't use Py_None directly nor &PyType_Type

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7925 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-04 08:50:00 +00:00
commit 922d58ac19
9 changed files with 67 additions and 46 deletions

View file

@ -4,6 +4,9 @@
#ifdef __cplusplus
extern "C" {
#if 0
} /* cc-mode */
#endif
#endif
/* -----------------------------------------------------------------------------
@ -16,16 +19,40 @@ extern "C" {
/* Constant information structure */
typedef struct swig_const_info {
int type;
char *name;
long lvalue;
double dvalue;
void *pvalue;
swig_type_info **ptype;
int type;
char *name;
long lvalue;
double dvalue;
void *pvalue;
swig_type_info **ptype;
} swig_const_info;
/* -----------------------------------------------------------------------------
* Safe Py_None and Py_Void accessors
* ----------------------------------------------------------------------------- */
SWIGRUNTIME PyObject *
SWIG_Py_None(void)
{
static PyObject *none = 0;
if (!none) {
none = Py_BuildValue("");
Py_DECREF(none);
}
return none;
}
SWIGRUNTIMEINLINE PyObject *
SWIG_Py_Void(void)
{
PyObject *none = SWIG_Py_None();
Py_INCREF(none);
return none;
}
/* -----------------------------------------------------------------------------
* Append a value to the result obj
* ----------------------------------------------------------------------------- */
@ -33,7 +60,7 @@ SWIGINTERN PyObject*
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
if (!result) {
result = obj;
} else if (result == Py_None) {
} else if (result == SWIG_Py_None()) {
Py_DECREF(result);
result = obj;
} else {
@ -49,6 +76,9 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
}
#ifdef __cplusplus
#if 0
{ /* cc-mode */
#endif
}
#endif

View file

@ -262,8 +262,7 @@ namespace swig
{
%ignore stop_iteration;
%typemap(throws) stop_iteration {
Py_INCREF(Py_None);
PyErr_SetObject(PyExc_StopIteration, Py_None);
PyErr_SetObject(PyExc_StopIteration, SWIG_Py_Void());
}
}

View file

@ -96,7 +96,7 @@ swig_varlink_type(void) {
const PyTypeObject tmp
#endif
= {
PyObject_HEAD_INIT(&PyType_Type)
PyObject_HEAD_INIT(NULL)
0, /* Number of items in variable part (ob_size) */
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
@ -137,6 +137,7 @@ swig_varlink_type(void) {
type_init = 1;
}
#endif
varlink_type.ob_type = &PyType_Type;
return &varlink_type;
}

View file

@ -262,24 +262,24 @@ SWIGRUNTIME PyObject*
PySwigObject_append(PyObject* v, PyObject* next)
{
PySwigObject *sobj = (PySwigObject *) v;
if (!PySwigObject_Check(next))
if (!PySwigObject_Check(next)) {
return NULL;
}
sobj->next = next;
Py_INCREF(next);
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
SWIGRUNTIME PyObject*
PySwigObject_next(PyObject* v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *obj = sobj->next ? sobj->next : Py_None;
Py_INCREF(obj);
return obj;
if (sobj->next) {
Py_INCREF(sobj->next);
return sobj->next;
} else {
return SWIG_Py_Void();
}
}
SWIGINTERN PyObject*
@ -287,8 +287,7 @@ PySwigObject_disown(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *)v;
sobj->own = 0;
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
@ -296,8 +295,7 @@ PySwigObject_acquire(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *)v;
sobj->own = SWIG_POINTER_OWN;
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
@ -373,7 +371,7 @@ PySwigObject_type(void) {
const PyTypeObject tmp
#endif
= {
PyObject_HEAD_INIT(&PyType_Type)
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
(char *)"PySwigObject", /* tp_name */
sizeof(PySwigObject), /* tp_basicsize */
@ -433,6 +431,7 @@ PySwigObject_type(void) {
type_init = 1;
}
#endif
pyswigobject_type.ob_type = &PyType_Type;
return &pyswigobject_type;
}
@ -702,8 +701,8 @@ SWIG_Python_AcquirePtr(PyObject *obj, int own) {
SWIGRUNTIME int
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
if (!obj) return SWIG_ERROR;
if (obj == Py_None) {
*ptr = 0;
if (obj == SWIG_Py_None()) {
if (ptr) *ptr = 0;
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
@ -713,7 +712,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
swig_type_info *to = sobj->ty;
if (to == ty) {
/* no type cast needed */
*ptr = vptr;
if (ptr) *ptr = vptr;
break;
} else {
swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
@ -725,7 +724,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
} else {
*ptr = vptr;
if (ptr) *ptr = vptr;
break;
}
}
@ -834,8 +833,7 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
SWIGRUNTIME PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
if (!ptr) {
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
} else if (!type) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "Swig: null type passed to NewPointerObj");
@ -862,10 +860,8 @@ SWIGRUNTIME PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
PyObject *robj = 0;
if (!ptr) {
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
robj = PySwigPacked_New((void *) ptr, sz, type);
return robj;
}

View file

@ -66,8 +66,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
}
} else {
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
}
}

View file

@ -39,7 +39,7 @@
/* Python types */
#define SWIG_Object PyObject *
#define VOID_Object (Py_INCREF(Py_None) ? Py_None : 0)
#define VOID_Object SWIG_Py_Void()
/* Overload of the output/constant/exception/dirout handling */

View file

@ -51,8 +51,7 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
}
} else {
Py_INCREF(Py_None);
return Py_None;
return SWIG_Py_Void();
}
}
}