more threads cleaning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7944 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
31466e0085
commit
5aada71816
5 changed files with 27 additions and 41 deletions
|
|
@ -273,9 +273,7 @@ namespace swig
|
||||||
{
|
{
|
||||||
%ignore stop_iteration;
|
%ignore stop_iteration;
|
||||||
%typemap(throws) stop_iteration {
|
%typemap(throws) stop_iteration {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
|
||||||
PyErr_SetObject(PyExc_StopIteration, SWIG_Py_Void());
|
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
||||||
SWIG_fail;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -494,7 +492,6 @@ namespace swig
|
||||||
try {
|
try {
|
||||||
return swig::as<T>(item, true);
|
return swig::as<T>(item, true);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
|
snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
|
|
@ -502,7 +499,6 @@ namespace swig
|
||||||
}
|
}
|
||||||
SWIG_Python_AddErrorMsg(msg);
|
SWIG_Python_AddErrorMsg(msg);
|
||||||
SWIG_Python_AddErrorMsg(e.what());
|
SWIG_Python_AddErrorMsg(e.what());
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -913,11 +909,9 @@ namespace swig
|
||||||
}
|
}
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
if (seq) {
|
if (seq) {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_TypeError, e.what());
|
PyErr_SetString(PyExc_TypeError, e.what());
|
||||||
}
|
}
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -955,10 +949,8 @@ namespace swig
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
} else {
|
} else {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"sequence size not valid in python");
|
"sequence size not valid in python");
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,36 +61,36 @@ swig_varlink_dealloc(swig_varlinkobject *v) {
|
||||||
|
|
||||||
SWIGINTERN PyObject *
|
SWIGINTERN PyObject *
|
||||||
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
|
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
PyObject *res = NULL;
|
||||||
swig_globalvar *var = v->vars;
|
swig_globalvar *var = v->vars;
|
||||||
while (var) {
|
while (var) {
|
||||||
if (strcmp(var->name,n) == 0) {
|
if (strcmp(var->name,n) == 0) {
|
||||||
PyObject *obj = (*var->get_attr)();
|
res = (*var->get_attr)();
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
break;
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
var = var->next;
|
var = var->next;
|
||||||
}
|
}
|
||||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
if (res == NULL && !PyErr_Occurred()) {
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||||
return NULL;
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
|
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
int res = 1;
|
||||||
swig_globalvar *var = v->vars;
|
swig_globalvar *var = v->vars;
|
||||||
while (var) {
|
while (var) {
|
||||||
if (strcmp(var->name,n) == 0) {
|
if (strcmp(var->name,n) == 0) {
|
||||||
int res = (*var->set_attr)(p);
|
res = (*var->set_attr)(p);
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
break;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
var = var->next;
|
var = var->next;
|
||||||
}
|
}
|
||||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
if (res == 1 && !PyErr_Occurred()) {
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||||
return 1;
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERN PyTypeObject*
|
SWIGINTERN PyTypeObject*
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@
|
||||||
|
|
||||||
#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
|
#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
|
||||||
#define SWIG_Error(code, msg) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(SWIG_Python_ErrorType(code), msg); SWIG_PYTHON_THREAD_END_BLOCK; }
|
#define SWIG_Error(code, msg) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(SWIG_Python_ErrorType(code), msg); SWIG_PYTHON_THREAD_END_BLOCK; }
|
||||||
|
#define SWIG_SetErrorObj(type, obj) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(type, obj); SWIG_PYTHON_THREAD_END_BLOCK; }
|
||||||
|
#define SWIG_SetErrorMsg(type, msg) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(type, msg); SWIG_PYTHON_THREAD_END_BLOCK; }
|
||||||
|
|
||||||
|
|
||||||
#define SWIG_fail goto fail
|
#define SWIG_fail goto fail
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,24 @@
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
|
# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
|
||||||
# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
|
# ifndef SWIG_PYTHON_INITIALIZE_THREADS
|
||||||
|
# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
|
||||||
|
# endif
|
||||||
# ifdef __cplusplus /* C++ code */
|
# ifdef __cplusplus /* C++ code */
|
||||||
class SWIG_Python_Thread_Block {
|
class SWIG_Python_Thread_Block {
|
||||||
bool status;
|
bool status;
|
||||||
PyGILState_STATE state;
|
PyGILState_STATE state;
|
||||||
void begin() { if (!status) { state = PyGILState_Ensure(); status = true;} }
|
|
||||||
public:
|
public:
|
||||||
void end() { if (status) { PyGILState_Release(state); status = false;} }
|
void end() { if (status) { PyGILState_Release(state); status = false;} }
|
||||||
SWIG_Python_Thread_Block() : status(false) { begin(); }
|
SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
|
||||||
~SWIG_Python_Thread_Block() { end(); }
|
~SWIG_Python_Thread_Block() { end(); }
|
||||||
};
|
};
|
||||||
class SWIG_Python_Thread_Allow {
|
class SWIG_Python_Thread_Allow {
|
||||||
bool status;
|
bool status;
|
||||||
PyThreadState *save;
|
PyThreadState *save;
|
||||||
void begin() { if (!status) { status = true; save = PyEval_SaveThread(); } }
|
|
||||||
public:
|
public:
|
||||||
void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
|
void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
|
||||||
SWIG_Python_Thread_Allow() : status(false) { begin(); }
|
SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
|
||||||
~SWIG_Python_Thread_Allow() { end(); }
|
~SWIG_Python_Thread_Allow() { end(); }
|
||||||
};
|
};
|
||||||
# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
|
# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,7 @@ public:
|
||||||
"if ( $comparison ) { /* subclassed */\n",
|
"if ( $comparison ) { /* subclassed */\n",
|
||||||
" $director_new \n",
|
" $director_new \n",
|
||||||
"} else {\n",
|
"} else {\n",
|
||||||
" SWIG_PYTHON_THREAD_BEGIN_BLOCK;\n",
|
" SWIG_SetErrorMsg(PyExc_RuntimeError,\"accessing abstract class or protected constructor\"); \n",
|
||||||
" PyErr_SetString(PyExc_RuntimeError,",
|
|
||||||
" \"accessing abstract class or protected constructor\"); \n",
|
|
||||||
" SWIG_PYTHON_THREAD_END_BLOCK;\n",
|
|
||||||
" SWIG_fail;\n",
|
" SWIG_fail;\n",
|
||||||
"}\n", NIL);
|
"}\n", NIL);
|
||||||
director_multiple_inheritance = 1;
|
director_multiple_inheritance = 1;
|
||||||
|
|
@ -1214,9 +1211,7 @@ public:
|
||||||
Printf(f->code,"Py_INCREF(Py_NotImplemented);\n");
|
Printf(f->code,"Py_INCREF(Py_NotImplemented);\n");
|
||||||
Printf(f->code,"return Py_NotImplemented;\n");
|
Printf(f->code,"return Py_NotImplemented;\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(f->code,"SWIG_PYTHON_THREAD_BEGIN_BLOCK;\n");
|
Printf(f->code,"SWIG_SetErrorMsg(PyExc_NotImplementedError,\"No matching function for overloaded '%s'\");\n", symname);
|
||||||
Printf(f->code,"PyErr_SetString(PyExc_NotImplementedError,\"No matching function for overloaded '%s'\");\n", symname);
|
|
||||||
Printf(f->code,"SWIG_PYTHON_THREAD_END_BLOCK;\n");
|
|
||||||
Printf(f->code,"return NULL;\n");
|
Printf(f->code,"return NULL;\n");
|
||||||
}
|
}
|
||||||
Printv(f->code,"}\n",NIL);
|
Printv(f->code,"}\n",NIL);
|
||||||
|
|
@ -1517,9 +1512,7 @@ public:
|
||||||
Printf(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n");
|
Printf(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n");
|
||||||
if (dirprot_mode() && !is_public(n)) {
|
if (dirprot_mode() && !is_public(n)) {
|
||||||
Printf(f->code, "if (!director || !(director->swig_get_inner(\"%s\"))) {\n", name);
|
Printf(f->code, "if (!director || !(director->swig_get_inner(\"%s\"))) {\n", name);
|
||||||
Printf(f->code,"SWIG_PYTHON_THREAD_BEGIN_BLOCK;\n");
|
Printf(f->code, "SWIG_SetErrorMsg(PyExc_RuntimeError,\"accessing protected member %s\");\n", name);
|
||||||
Printf(f->code, "PyErr_SetString(PyExc_RuntimeError,\"accessing protected member %s\");\n", name);
|
|
||||||
Printf(f->code,"SWIG_PYTHON_THREAD_END_BLOCK;\n");
|
|
||||||
Printf(f->code, "SWIG_fail;\n");
|
Printf(f->code, "SWIG_fail;\n");
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
}
|
}
|
||||||
|
|
@ -1541,7 +1534,6 @@ public:
|
||||||
|
|
||||||
/* Emit the function call */
|
/* Emit the function call */
|
||||||
if (director_method) {
|
if (director_method) {
|
||||||
if (allow_thread) thread_end_block(n, f);
|
|
||||||
Printf(f->code, "try {\n");
|
Printf(f->code, "try {\n");
|
||||||
Printf(f->code, " Swig::UnknownExceptionHandler dh;\n");
|
Printf(f->code, " Swig::UnknownExceptionHandler dh;\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1563,8 +1555,6 @@ public:
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This part below still needs cleanup */
|
/* This part below still needs cleanup */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue