__DIRECTOR__ renamed Swig::Director
SWIG_DIRECTOR_EXCEPTION renamed Swig::DirectorException (similarly for derived classes) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5138 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7ee01311b2
commit
9da574aae9
20 changed files with 507 additions and 496 deletions
|
|
@ -6,64 +6,63 @@
|
|||
*
|
||||
* Author : Scott Michel (scottm@aero.org)
|
||||
*
|
||||
* N.B.: This file was
|
||||
adapted from the python director.swg, written by
|
||||
* This file was adapted from the python director.swg, written by
|
||||
* Mark Rose (mrose@stm.lbl.gov)
|
||||
************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/* director base class */
|
||||
class __DIRECTOR__ {
|
||||
private:
|
||||
/* pointer to java virtual machine */
|
||||
JavaVM *__jvm;
|
||||
namespace Swig {
|
||||
/* director base class */
|
||||
class Director {
|
||||
private:
|
||||
/* pointer to java virtual machine */
|
||||
JavaVM *__jvm;
|
||||
|
||||
protected:
|
||||
/* pointer to the wrapped java object */
|
||||
jobject __self;
|
||||
/* Acquire Java VM environment from Java VM */
|
||||
JNIEnv *__acquire_jenv() const {
|
||||
JNIEnv *env;
|
||||
__jvm->AttachCurrentThread((void **) &env, NULL);
|
||||
return env;
|
||||
}
|
||||
protected:
|
||||
/* pointer to the wrapped java object */
|
||||
jobject __self;
|
||||
/* Acquire Java VM environment from Java VM */
|
||||
JNIEnv *__acquire_jenv() const {
|
||||
JNIEnv *env;
|
||||
__jvm->AttachCurrentThread((void **) &env, NULL);
|
||||
return env;
|
||||
}
|
||||
|
||||
public:
|
||||
__DIRECTOR__(JNIEnv *jenv):
|
||||
__jvm((JavaVM *) NULL),
|
||||
__self(NULL)
|
||||
{
|
||||
/* Acquire the Java VM pointer */
|
||||
jenv->GetJavaVM(&__jvm);
|
||||
}
|
||||
public:
|
||||
Director(JNIEnv *jenv):
|
||||
__jvm((JavaVM *) NULL),
|
||||
__self(NULL) {
|
||||
/* Acquire the Java VM pointer */
|
||||
jenv->GetJavaVM(&__jvm);
|
||||
}
|
||||
|
||||
/* Remove the Java object global lock at destruction */
|
||||
virtual ~__DIRECTOR__()
|
||||
{
|
||||
if (__self) {
|
||||
JNIEnv *jenv;
|
||||
jmethodID disconn_meth;
|
||||
|
||||
jenv = __acquire_jenv();
|
||||
disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(__self), "__director_disconnect", "()V");
|
||||
if (disconn_meth)
|
||||
jenv->CallVoidMethod(__self, disconn_meth);
|
||||
jenv->DeleteGlobalRef(__self);
|
||||
__self = (jobject) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set __self and get Java global reference on object */
|
||||
inline void __set_self(JNIEnv *jenv, jobject jself)
|
||||
{
|
||||
__self = jenv->NewGlobalRef(jself);
|
||||
}
|
||||
/* Remove the Java object global lock at destruction */
|
||||
virtual ~Director() {
|
||||
if (__self) {
|
||||
JNIEnv *jenv;
|
||||
jmethodID disconn_meth;
|
||||
|
||||
/* return a pointer to the wrapped java object */
|
||||
inline jobject __get_self() const
|
||||
{ return __self; }
|
||||
};
|
||||
jenv = __acquire_jenv();
|
||||
disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(__self), "__director_disconnect", "()V");
|
||||
if (disconn_meth)
|
||||
jenv->CallVoidMethod(__self, disconn_meth);
|
||||
jenv->DeleteGlobalRef(__self);
|
||||
__self = (jobject) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set __self and get Java global reference on object */
|
||||
inline void __set_self(JNIEnv *jenv, jobject jself) {
|
||||
__self = jenv->NewGlobalRef(jself);
|
||||
}
|
||||
|
||||
/* return a pointer to the wrapped java object */
|
||||
inline jobject __get_self() const {
|
||||
return __self;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue