fix various missing INCREF/DECREF and other to run clean with fpectl
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7989 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
dfca3b285f
commit
24f109f8ca
3 changed files with 8 additions and 10 deletions
|
|
@ -161,7 +161,7 @@ typedef struct {
|
|||
PyObject *newraw;
|
||||
PyObject *newargs;
|
||||
PyObject *destroy;
|
||||
PyObject *delargs;
|
||||
int delargs;
|
||||
} PySwigClientData;
|
||||
|
||||
SWIGRUNTIME PySwigClientData *
|
||||
|
|
@ -184,6 +184,7 @@ PySwigClientData_New(PyObject* obj)
|
|||
Py_INCREF(data->newraw);
|
||||
data->newargs = PyTuple_New(1);
|
||||
PyTuple_SetItem(data->newargs, 0, obj);
|
||||
Py_INCREF(data->newargs);
|
||||
}
|
||||
/* the destroy method, aka as the C++ delete method */
|
||||
data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
|
||||
|
|
@ -194,7 +195,7 @@ PySwigClientData_New(PyObject* obj)
|
|||
if (data->destroy) {
|
||||
Py_INCREF(data->destroy);
|
||||
int flags = PyCFunction_GET_FLAGS(data->destroy);
|
||||
data->delargs = (flags & (METH_VARARGS)) ? PyTuple_New(1) : 0;
|
||||
data->delargs = (flags & (METH_VARARGS));
|
||||
} else {
|
||||
data->delargs = 0;
|
||||
}
|
||||
|
|
@ -209,7 +210,6 @@ PySwigClientData_Del(PySwigClientData* data)
|
|||
Py_XDECREF(data->newraw);
|
||||
Py_XDECREF(data->newargs);
|
||||
Py_XDECREF(data->destroy);
|
||||
Py_XDECREF(data->delargs);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
|
@ -334,13 +334,13 @@ PySwigObject_dealloc(PyObject *v)
|
|||
PyObject *res;
|
||||
PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
|
||||
PyObject *mself = PyCFunction_GET_SELF(destroy);
|
||||
PyObject *args = data->delargs;
|
||||
if (args) {
|
||||
if (data->delargs) {
|
||||
/* we need to create a temporal object to carry the destroy operation */
|
||||
PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
|
||||
PyObject *args = PyTuple_New(1);
|
||||
PyTuple_SetItem(args,0,tmp);
|
||||
res = ((*meth)(mself, args));
|
||||
PyTuple_SetItem(args,0,SWIG_Py_Void());
|
||||
Py_DECREF(args);
|
||||
} else {
|
||||
res = ((*meth)(mself, v));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,10 +138,10 @@
|
|||
%define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...)
|
||||
%typemap(typecheck,precedence=check,fragment=frag)
|
||||
Type *
|
||||
"$1 = asptr_meth($input, (Type**)(0));";
|
||||
"$1 = asptr_meth($input, (Type**)(0)) != 0;";
|
||||
%typemap(typecheck,precedence=check,fragment=frag)
|
||||
Type, const Type&
|
||||
"Type *ptr; $1 = asptr_meth($input, &ptr) && ptr;";
|
||||
"$1 = asptr_meth($input, (Type**)(0)) != 0;";
|
||||
%enddef
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2216,7 +2216,6 @@ public:
|
|||
}
|
||||
|
||||
Printf(f_directors_h,"\n\n");
|
||||
Printf(f_directors_h,"public:\n");
|
||||
Printf(f_directors_h,"#if defined(SWIG_DIRECTOR_VTABLE)\n");
|
||||
Printf(f_directors_h,"/* VTable implementation */\n");
|
||||
Printf(f_directors_h," PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n");
|
||||
|
|
@ -2229,7 +2228,6 @@ public:
|
|||
Printf(f_directors_h," msg += method_name;\n");
|
||||
Printf(f_directors_h," Swig::DirectorMethodException::raise(msg.c_str());\n");
|
||||
Printf(f_directors_h," }\n");
|
||||
Printf(f_directors_h," Py_DECREF(swig_get_self());\n");
|
||||
Printf(f_directors_h," vtable[method_index] = method;\n");
|
||||
Printf(f_directors_h," };\n");
|
||||
Printf(f_directors_h," return method;\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue