- Compliance with ISO/IEC 14882:1998(E) 17.4.3.1.2 -> eg double underscores removed
- Potential member variable and method name clashes remove by preceding with 'swig' - consistent use of C++ booleans for the swig_disown flag across and within the modules that use this it in director code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5139 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9da574aae9
commit
f4fac221fa
5 changed files with 170 additions and 176 deletions
|
|
@ -16,50 +16,46 @@ namespace Swig {
|
||||||
/* director base class */
|
/* director base class */
|
||||||
class Director {
|
class Director {
|
||||||
private:
|
private:
|
||||||
/* pointer to java virtual machine */
|
/* pointer to Java virtual machine */
|
||||||
JavaVM *__jvm;
|
JavaVM *swig_jvm;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* pointer to the wrapped java object */
|
/* pointer to the wrapped Java object */
|
||||||
jobject __self;
|
jobject swig_self;
|
||||||
|
|
||||||
/* Acquire Java VM environment from Java VM */
|
/* Acquire Java VM environment from Java VM */
|
||||||
JNIEnv *__acquire_jenv() const {
|
JNIEnv *swig_acquire_jenv() const {
|
||||||
JNIEnv *env;
|
JNIEnv *env = NULL;
|
||||||
__jvm->AttachCurrentThread((void **) &env, NULL);
|
swig_jvm->AttachCurrentThread((void **) &env, NULL);
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Director(JNIEnv *jenv):
|
Director(JNIEnv *jenv) : swig_jvm((JavaVM *) NULL), swig_self(NULL) {
|
||||||
__jvm((JavaVM *) NULL),
|
|
||||||
__self(NULL) {
|
|
||||||
/* Acquire the Java VM pointer */
|
/* Acquire the Java VM pointer */
|
||||||
jenv->GetJavaVM(&__jvm);
|
jenv->GetJavaVM(&swig_jvm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the Java object global lock at destruction */
|
/* Remove the Java object global lock at destruction */
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
if (__self) {
|
if (swig_self) {
|
||||||
JNIEnv *jenv;
|
JNIEnv *jenv = swig_acquire_jenv();
|
||||||
jmethodID disconn_meth;
|
jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(swig_self), "swig_director_disconnect", "()V");
|
||||||
|
|
||||||
jenv = __acquire_jenv();
|
|
||||||
disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(__self), "__director_disconnect", "()V");
|
|
||||||
if (disconn_meth)
|
if (disconn_meth)
|
||||||
jenv->CallVoidMethod(__self, disconn_meth);
|
jenv->CallVoidMethod(swig_self, disconn_meth);
|
||||||
jenv->DeleteGlobalRef(__self);
|
jenv->DeleteGlobalRef(swig_self);
|
||||||
__self = (jobject) NULL;
|
swig_self = (jobject) NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set __self and get Java global reference on object */
|
/* Set swig_self and get Java global reference on object */
|
||||||
inline void __set_self(JNIEnv *jenv, jobject jself) {
|
void swig_set_self(JNIEnv *jenv, jobject jself) {
|
||||||
__self = jenv->NewGlobalRef(jself);
|
swig_self = jenv->NewGlobalRef(jself);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return a pointer to the wrapped java object */
|
/* return a pointer to the wrapped Java object */
|
||||||
inline jobject __get_self() const {
|
jobject swig_get_self() const {
|
||||||
return __self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,105 +34,105 @@ namespace Swig {
|
||||||
class Director {
|
class Director {
|
||||||
private:
|
private:
|
||||||
/* pointer to the wrapped ocaml object */
|
/* pointer to the wrapped ocaml object */
|
||||||
CAML_VALUE _self;
|
CAML_VALUE swig_self;
|
||||||
/* flag indicating whether the object is owned by ocaml or c++ */
|
/* flag indicating whether the object is owned by ocaml or c++ */
|
||||||
mutable int _disown;
|
mutable bool swig_disown_flag;
|
||||||
/* shared flag for breaking recursive director calls */
|
/* shared flag for breaking recursive director calls */
|
||||||
static int _up;
|
static bool swig_up;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
/* locks for sharing the _up flag in a threaded environment */
|
/* locks for sharing the swig_up flag in a threaded environment */
|
||||||
static pthread_mutex_t _mutex_up;
|
static pthread_mutex_t swig_mutex_up;
|
||||||
static int _mutex_active;
|
static bool swig_mutex_active;
|
||||||
static pthread_t _mutex_thread;
|
static pthread_t swig_mutex_thread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* reset the _up flag once the routing direction has been determined */
|
/* reset the swig_up flag once the routing direction has been determined */
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = 0;
|
Swig::Director::swig_up = false;
|
||||||
Swig::Director::_mutex_active = 0;
|
Swig::Director::swig_mutex_active = false;
|
||||||
pthread_mutex_unlock(&_mutex_up);
|
pthread_mutex_unlock(&swig_mutex_up);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = 0;
|
Swig::Director::swig_up = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* wrap a ocaml object, optionally taking ownership */
|
/* wrap a ocaml object, optionally taking ownership */
|
||||||
Director(CAML_VALUE self, int disown): _self(self), _disown(disown) {
|
Director(CAML_VALUE self, bool disown) : swig_self(self), swig_disown_flag(disown) {
|
||||||
register_global_root(&_self);
|
register_global_root(&swig_self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* discard our reference at destruction */
|
/* discard our reference at destruction */
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
remove_global_root(&_self);
|
remove_global_root(&swig_self);
|
||||||
__disown();
|
swig_disown();
|
||||||
// Disown is safe here because we're just divorcing a reference that
|
// Disown is safe here because we're just divorcing a reference that
|
||||||
// points to us.
|
// points to us.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return a pointer to the wrapped ocaml object */
|
/* return a pointer to the wrapped ocaml object */
|
||||||
CAML_VALUE __get_self() const {
|
CAML_VALUE swig_get_self() const {
|
||||||
return callback(*caml_named_value("caml_director_get_self"),_self);
|
return callback(*caml_named_value("caml_director_get_self"),swig_self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the _up flag to determine if the method call should be routed
|
/* get the swig_up flag to determine if the method call should be routed
|
||||||
* to the c++ base class or through the wrapped ocaml object
|
* to the c++ base class or through the wrapped ocaml object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
int __get_up() const {
|
bool swig_get_up() const {
|
||||||
if (Swig::Director::_mutex_active) {
|
if (Swig::Director::swig_mutex_active) {
|
||||||
if (pthread_equal(Swig::Director::_mutex_thread, pthread_self())) {
|
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
|
||||||
int up = _up;
|
bool up = swig_up;
|
||||||
__clear_up();
|
swig_clear_up();
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int __get_up() const {
|
bool swig_get_up() const {
|
||||||
int up = _up;
|
bool up = swig_up;
|
||||||
_up = 0;
|
swig_up = false;
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set the _up flag if the next method call should be directed to
|
/* set the swig_up flag if the next method call should be directed to
|
||||||
* the c++ base class rather than the wrapped ocaml object
|
* the c++ base class rather than the wrapped ocaml object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
pthread_mutex_lock(&Swig::Director::_mutex_up);
|
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
|
||||||
Swig::Director::_mutex_thread = pthread_self();
|
Swig::Director::swig_mutex_thread = pthread_self();
|
||||||
Swig::Director::_mutex_active = 1;
|
Swig::Director::swig_mutex_active = true;
|
||||||
Swig::Director::_up = 1;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
Swig::Director::_up = 1;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* acquire ownership of the wrapped ocaml object (the sense of "disown"
|
/* acquire ownership of the wrapped ocaml object (the sense of "disown"
|
||||||
* is from ocaml) */
|
* is from ocaml) */
|
||||||
void __disown() const {
|
void swig_disown() const {
|
||||||
if (!_disown) {
|
if (!swig_disown_flag) {
|
||||||
_disown=1;
|
swig_disown_flag=true;
|
||||||
callback(*caml_named_value("caml_obj_disown"),_self);
|
callback(*caml_named_value("caml_obj_disown"),swig_self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int Swig::Director::_up = 0;
|
bool Swig::Director::swig_up = false;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
MUTEX_INIT(Swig::Director::_mutex_up);
|
MUTEX_INIT(Swig::Director::swig_mutex_up);
|
||||||
pthread_t Swig::Director::_mutex_thread;
|
pthread_t Swig::Director::swig_mutex_thread;
|
||||||
int Swig::Director::_mutex_active = 0;
|
bool Swig::Director::swig_mutex_active = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ namespace Swig {
|
||||||
/* base class for director exceptions */
|
/* base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException {
|
||||||
protected:
|
protected:
|
||||||
std::string _msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
DirectorException(const char* msg="") {
|
DirectorException(const char* msg="") {
|
||||||
}
|
}
|
||||||
const char *getMessage() {
|
const char *getMessage() const {
|
||||||
return _msg.c_str();
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
virtual ~DirectorException() {}
|
virtual ~DirectorException() {}
|
||||||
};
|
};
|
||||||
|
|
@ -29,8 +29,8 @@ namespace Swig {
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public Swig::DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(const char* msg="") {
|
DirectorTypeMismatchException(const char* msg="") {
|
||||||
_msg = "Swig director type mismatch: ";
|
swig_msg = "Swig director type mismatch: ";
|
||||||
_msg += msg;
|
swig_msg += msg;
|
||||||
PyErr_SetString(PyExc_TypeError, msg);
|
PyErr_SetString(PyExc_TypeError, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -61,118 +61,117 @@ namespace Swig {
|
||||||
class Director {
|
class Director {
|
||||||
private:
|
private:
|
||||||
/* pointer to the wrapped python object */
|
/* pointer to the wrapped python object */
|
||||||
PyObject* _self;
|
PyObject* swig_self;
|
||||||
/* flag indicating whether the object is owned by python or c++ */
|
/* flag indicating whether the object is owned by python or c++ */
|
||||||
mutable int _disown;
|
mutable bool swig_disown_flag;
|
||||||
/* shared flag for breaking recursive director calls */
|
/* shared flag for breaking recursive director calls */
|
||||||
static int _up;
|
static bool swig_up;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
/* locks for sharing the _up flag in a threaded environment */
|
/* locks for sharing the swig_up flag in a threaded environment */
|
||||||
static pthread_mutex_t _mutex_up;
|
static pthread_mutex_t swig_mutex_up;
|
||||||
static int _mutex_active;
|
static bool swig_mutex_active;
|
||||||
static pthread_t _mutex_thread;
|
static pthread_t swig_mutex_thread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* decrement the reference count of the wrapped python object */
|
/* decrement the reference count of the wrapped python object */
|
||||||
void __decref() const {
|
void swig_decref() const {
|
||||||
if (_disown) {
|
if (swig_disown_flag) {
|
||||||
Py_DECREF(_self);
|
Py_DECREF(swig_self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the _up flag once the routing direction has been determined */
|
/* reset the swig_up flag once the routing direction has been determined */
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = 0;
|
Swig::Director::swig_up = false;
|
||||||
Swig::Director::_mutex_active = 0;
|
Swig::Director::swig_mutex_active = false;
|
||||||
pthread_mutex_unlock(&_mutex_up);
|
pthread_mutex_unlock(&swig_mutex_up);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = 0;
|
Swig::Director::swig_up = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* wrap a python object, optionally taking ownership */
|
/* wrap a python object, optionally taking ownership */
|
||||||
Director(PyObject* self, int disown): _self(self), _disown(disown) {
|
Director(PyObject* self, bool disown) : swig_self(self), swig_disown_flag(disown) {
|
||||||
__incref();
|
swig_incref();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* discard our reference at destruction */
|
/* discard our reference at destruction */
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
__decref();
|
swig_decref();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return a pointer to the wrapped python object */
|
/* return a pointer to the wrapped python object */
|
||||||
PyObject *__get_self() const {
|
PyObject *swig_get_self() const {
|
||||||
return _self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the swig_up flag to determine if the method call should be routed
|
||||||
/* get the _up flag to determine if the method call should be routed
|
|
||||||
* to the c++ base class or through the wrapped python object
|
* to the c++ base class or through the wrapped python object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
int __get_up() const {
|
bool swig_get_up() const {
|
||||||
if (Swig::Director::_mutex_active) {
|
if (Swig::Director::swig_mutex_active) {
|
||||||
if (pthread_equal(Swig::Director::_mutex_thread, pthread_self())) {
|
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
|
||||||
int up = _up;
|
bool up = swig_up;
|
||||||
__clear_up();
|
swig_clear_up();
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int __get_up() const {
|
bool swig_get_up() const {
|
||||||
int up = _up;
|
bool up = swig_up;
|
||||||
_up = 0;
|
swig_up = false;
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set the _up flag if the next method call should be directed to
|
/* set the swig_up flag if the next method call should be directed to
|
||||||
* the c++ base class rather than the wrapped python object
|
* the c++ base class rather than the wrapped python object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
pthread_mutex_lock(&Swig::Director::_mutex_up);
|
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
|
||||||
Swig::Director::_mutex_thread = pthread_self();
|
Swig::Director::swig_mutex_thread = pthread_self();
|
||||||
Swig::Director::_mutex_active = 1;
|
Swig::Director::swig_mutex_active = true;
|
||||||
Swig::Director::_up = 1;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
Swig::Director::_up = 1;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* acquire ownership of the wrapped python object (the sense of "disown"
|
/* acquire ownership of the wrapped python object (the sense of "disown"
|
||||||
* is from python) */
|
* is from python) */
|
||||||
void __disown() const {
|
void swig_disown() const {
|
||||||
if (!_disown) {
|
if (!swig_disown_flag) {
|
||||||
_disown=1;
|
swig_disown_flag=true;
|
||||||
__incref();
|
swig_incref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase the reference count of the wrapped python object */
|
/* increase the reference count of the wrapped python object */
|
||||||
void __incref() const {
|
void swig_incref() const {
|
||||||
if (_disown) {
|
if (swig_disown_flag) {
|
||||||
Py_INCREF(_self);
|
Py_INCREF(swig_self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int Swig::Director::_up = 0;
|
bool Swig::Director::swig_up = false;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
MUTEX_INIT(Swig::Director::_mutex_up);
|
MUTEX_INIT(Swig::Director::swig_mutex_up);
|
||||||
pthread_t Swig::Director::_mutex_thread;
|
pthread_t Swig::Director::swig_mutex_thread;
|
||||||
int Swig::Director::_mutex_active = 0;
|
bool Swig::Director::swig_mutex_active = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,7 @@
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
$input = SWIG_NewPointerObj((void *) $1_name, $1_descriptor, 0);
|
$input = SWIG_NewPointerObj((void *) $1_name, $1_descriptor, 0);
|
||||||
} else {
|
} else {
|
||||||
$input = proxy->__get_self();
|
$input = proxy->swig_get_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@ namespace Swig {
|
||||||
/* Base class for director exceptions */
|
/* Base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException {
|
||||||
protected:
|
protected:
|
||||||
VALUE _error;
|
VALUE swig_error;
|
||||||
protected:
|
protected:
|
||||||
DirectorException(VALUE error=Qnil) : _error(error) {}
|
DirectorException(VALUE error=Qnil) : swig_error(error) {}
|
||||||
public:
|
public:
|
||||||
VALUE getType() const {
|
VALUE getType() const {
|
||||||
return CLASS_OF(_error);
|
return CLASS_OF(swig_error);
|
||||||
}
|
}
|
||||||
VALUE getError() const {
|
VALUE getError() const {
|
||||||
return _error;
|
return swig_error;
|
||||||
}
|
}
|
||||||
virtual ~DirectorException() {}
|
virtual ~DirectorException() {}
|
||||||
};
|
};
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Swig {
|
||||||
DirectorTypeMismatchException(const char *msg="") {
|
DirectorTypeMismatchException(const char *msg="") {
|
||||||
VALUE str = rb_str_new2("Swig director type mismatch: ");
|
VALUE str = rb_str_new2("Swig director type mismatch: ");
|
||||||
rb_str_concat(str, rb_str_new2(msg));
|
rb_str_concat(str, rb_str_new2(msg));
|
||||||
_error = rb_exc_new3(rb_eTypeError, str);
|
swig_error = rb_exc_new3(rb_eTypeError, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -75,35 +75,35 @@ namespace Swig {
|
||||||
class Director {
|
class Director {
|
||||||
private:
|
private:
|
||||||
/* pointer to the wrapped Ruby object */
|
/* pointer to the wrapped Ruby object */
|
||||||
VALUE _self;
|
VALUE swig_self;
|
||||||
/* flag indicating whether the object is owned by Ruby or c++ */
|
/* flag indicating whether the object is owned by Ruby or c++ */
|
||||||
mutable bool _disown;
|
mutable bool swig_disown_flag;
|
||||||
/* shared flag for breaking recursive director calls */
|
/* shared flag for breaking recursive director calls */
|
||||||
static bool _up;
|
static bool swig_up;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
/* locks for sharing the _up flag in a threaded environment */
|
/* locks for sharing the swig_up flag in a threaded environment */
|
||||||
static pthread_mutex_t _mutex_up;
|
static pthread_mutex_t swig_mutex_up;
|
||||||
static bool _mutex_active;
|
static bool swig_mutex_active;
|
||||||
static pthread_t _mutex_thread;
|
static pthread_t swig_mutex_thread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* reset the _up flag once the routing direction has been determined */
|
/* reset the swig_up flag once the routing direction has been determined */
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = false;
|
Swig::Director::swig_up = false;
|
||||||
Swig::Director::_mutex_active = false;
|
Swig::Director::swig_mutex_active = false;
|
||||||
pthread_mutex_unlock(&_mutex_up);
|
pthread_mutex_unlock(&swig_mutex_up);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __clear_up() const {
|
void swig_clear_up() const {
|
||||||
Swig::Director::_up = false;
|
Swig::Director::swig_up = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* wrap a Ruby object, optionally taking ownership */
|
/* wrap a Ruby object, optionally taking ownership */
|
||||||
Director(VALUE self, bool disown) : _self(self), _disown(disown) {
|
Director(VALUE self, bool disown) : swig_self(self), swig_disown_flag(disown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* discard our reference at destruction */
|
/* discard our reference at destruction */
|
||||||
|
|
@ -111,64 +111,63 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return a pointer to the wrapped Ruby object */
|
/* return a pointer to the wrapped Ruby object */
|
||||||
VALUE __get_self() const {
|
VALUE swig_get_self() const {
|
||||||
return _self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the swig_up flag to determine if the method call should be routed
|
||||||
/* get the _up flag to determine if the method call should be routed
|
|
||||||
* to the c++ base class or through the wrapped Ruby object
|
* to the c++ base class or through the wrapped Ruby object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
bool __get_up() const {
|
bool swig_get_up() const {
|
||||||
if (Swig::Director::_mutex_active) {
|
if (Swig::Director::swig_mutex_active) {
|
||||||
if (pthread_equal(Swig::Director::_mutex_thread, pthread_self())) {
|
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
|
||||||
bool up = _up;
|
bool up = swig_up;
|
||||||
__clear_up();
|
swig_clear_up();
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bool __get_up() const {
|
bool swig_get_up() const {
|
||||||
bool up = _up;
|
bool up = swig_up;
|
||||||
_up = false;
|
swig_up = false;
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set the _up flag if the next method call should be directed to
|
/* set the swig_up flag if the next method call should be directed to
|
||||||
* the c++ base class rather than the wrapped Ruby object
|
* the c++ base class rather than the wrapped Ruby object
|
||||||
*/
|
*/
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
pthread_mutex_lock(&Swig::Director::_mutex_up);
|
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
|
||||||
Swig::Director::_mutex_thread = pthread_self();
|
Swig::Director::swig_mutex_thread = pthread_self();
|
||||||
Swig::Director::_mutex_active = true;
|
Swig::Director::swig_mutex_active = true;
|
||||||
Swig::Director::_up = true;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void __set_up() const {
|
void swig_set_up() const {
|
||||||
Swig::Director::_up = true;
|
Swig::Director::swig_up = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* acquire ownership of the wrapped Ruby object (the sense of "disown"
|
/* acquire ownership of the wrapped Ruby object (the sense of "disown"
|
||||||
* is from Ruby) */
|
* is from Ruby) */
|
||||||
void __disown() const {
|
void swig_disown() const {
|
||||||
if (!_disown) {
|
if (!swig_disown_flag) {
|
||||||
_disown = true;
|
swig_disown_flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Swig::Director::_up = false;
|
bool Swig::Director::swig_up = false;
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
MUTEX_INIT(Swig::Director::_mutex_up);
|
MUTEX_INIT(Swig::Director::swig_mutex_up);
|
||||||
pthread_t Swig::Director::_mutex_thread;
|
pthread_t Swig::Director::swig_mutex_thread;
|
||||||
int Swig::Director::_mutex_active = false;
|
bool Swig::Director::swig_mutex_active = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue