- explicitcall feature removed.

- Instead of using the swig_up flag in each director method (Python, Ruby, Ocaml) to indicate
whether the explicit C++ call to the appropriate base class method or a normal
polymorphic C++ call should be made, the new approach makes one of these calls
directly from the wrapper method.
- Java/C# recursive director method calls fixed (no need for explicitcall feature to solve this now)


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9272 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-09-13 20:45:31 +00:00
commit 949e220630
5 changed files with 28 additions and 241 deletions

View file

@ -26,18 +26,10 @@ namespace Swig {
swig_incref();
}
bool Director::swig_up = false;
#ifdef __PTHREAD__
pthread_mutex_t SWIG_MUTEX_INIT(Director::swig_mutex_up);
pthread_mutex_t SWIG_MUTEX_INIT(Director::swig_mutex_own);
pthread_t Director::swig_mutex_thread;
bool Director::swig_mutex_active = false;
#endif
}
#endif /* __cplusplus */

View file

@ -317,7 +317,7 @@ namespace Swig {
{
public:
DirectorPureVirtualException(const char* msg = "")
: DirectorException(PyExc_RuntimeError, "Swig director pure virtal method called", msg)
: DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg)
{
}
@ -376,15 +376,6 @@ namespace Swig {
PyObject* swig_self;
/* flag indicating whether the object is owned by python or c++ */
mutable bool swig_disown_flag;
/* shared flag for breaking recursive director calls */
static bool swig_up;
#ifdef __PTHREAD__
/* locks for sharing the swig_up flag in a threaded environment */
static pthread_mutex_t swig_mutex_up;
static bool swig_mutex_active;
static pthread_t swig_mutex_thread;
#endif
/* decrement the reference count of the wrapped python object */
void swig_decref() const {
@ -395,19 +386,6 @@ namespace Swig {
}
}
/* reset the swig_up flag once the routing direction has been determined */
#ifdef __PTHREAD__
void swig_clear_up() const {
Swig::Director::swig_up = false;
Swig::Director::swig_mutex_active = false;
pthread_mutex_unlock(&swig_mutex_up);
}
#else
void swig_clear_up() const {
Swig::Director::swig_up = false;
}
#endif
public:
/* wrap a python object, optionally taking ownership */
Director(PyObject* self);
@ -420,44 +398,6 @@ namespace Swig {
return swig_self;
}
/* get the swig_up flag to determine if the method call should be routed
* to the c++ base class or through the wrapped python object
*/
#ifdef __PTHREAD__
bool swig_get_up() const {
if (Swig::Director::swig_mutex_active) {
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
bool up = swig_up;
swig_clear_up();
return up;
}
}
return 0;
}
#else
bool swig_get_up() const {
bool up = swig_up;
swig_up = false;
return up;
}
#endif
/* set the swig_up flag if the next method call should be directed to
* the c++ base class rather than the wrapped python object
*/
#ifdef __PTHREAD__
void swig_set_up() const {
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
Swig::Director::swig_mutex_thread = pthread_self();
Swig::Director::swig_mutex_active = true;
Swig::Director::swig_up = true;
}
#else
void swig_set_up() const {
Swig::Director::swig_up = true;
}
#endif
/* acquire ownership of the wrapped python object (the sense of "disown"
* is from python) */
void swig_disown() const {
@ -482,7 +422,7 @@ namespace Swig {
virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
}
/* ownership managing */
/* ownership management */
private:
typedef std::map<void*, GCItem_var> ownership_map;
mutable ownership_map owner;
@ -531,7 +471,6 @@ namespace Swig {
return own;
}
};
}
#endif /* __cplusplus */