#include
#include
#include
#include
#include "simple.h"
namespace simple {
JNIEnv *getEnv();
static bool debug_j4cpp = false;
namespace java {
namespace lang {
Object::Object() {
jthis = NULL;
};
Object::Object(const Object &objref) {
jobject _jthis = objref.jthis;
if (_jthis != NULL) {
jthis = getEnv()->NewGlobalRef(_jthis);
}
};
Object::Object(jobject _jthis, bool copy) {
// std::cout NewGlobalRef(_newjthis);
}
if (NULL != oldjthis) {
if(debug_j4cpp) DebugPrintJObject(__FILE__,__LINE__,"Object::operator= called for oldjthis=",oldjthis);
env->DeleteGlobalRef(oldjthis);
oldjthis = NULL;
}
jthis=newjthis;
releaseEnv(env);
return *this;
}
Object::~Object() {
if (NULL != jthis) {
if(debug_j4cpp) DebugPrintJObject(__FILE__,__LINE__,"Destructor called for ",jthis);
getEnv()->DeleteGlobalRef(jthis);
jthis = NULL;
}
};
jstring Object::toString() {
if (jthis == NULL) {
std::cerr GetObjectClass(jthis);
jstring retVal = NULL;
if (cls != NULL) {
jmethodID mid = env->GetMethodID(cls, "toString", "()Ljava/lang/String;");
if (NULL == mid) {
std::cerr NewGlobalRef(_jthis);
if(GetDebugJ4Cpp()) DebugPrintJObject(__FILE__,__LINE__,"Copy Constructor for class Simple jthis=",jthis);
}
}
Simple Simple::cast(const java::lang::Object &objref) {
JNIEnv *env =getEnv();
static jclass cls = getSimpleClass();
jclass objcls = env->GetObjectClass(objref.jthis);
if(!env->IsAssignableFrom(objcls,cls)) {
throw objcls;
}
Simple retVal(objref.jthis,true);
return retVal;
}
Simple::Simple() : java::lang::Object((jobject)NULL,false) {
JNIEnv *env =getEnv();
static jclass cls = getSimpleClass();
if (cls != NULL) {
static jmethodID mid = env->GetMethodID(cls, "", "()V");
if (NULL == mid) {
std::cerr ExceptionOccurred();
if(t != NULL) {
if(GetDebugJ4Cpp()) {
DebugPrintJObject(__FILE__,__LINE__," Simple::%METHOD_NAME% jthis=",t);
env->ExceptionDescribe();
}
throw t;
}
if(jthis == NULL) {
std::cerr NewGlobalRef(jthis);
}
}
}
releaseEnv(env);
}
Simple::Simple(jint int_0) : java::lang::Object((jobject)NULL,false) {
JNIEnv *env =getEnv();
static jclass cls = getSimpleClass();
if (cls != NULL) {
static jmethodID mid = env->GetMethodID(cls, "", "(I)V");
if (NULL == mid) {
std::cerr ExceptionOccurred();
if(t != NULL) {
if(GetDebugJ4Cpp()) {
DebugPrintJObject(__FILE__,__LINE__," Simple::%METHOD_NAME% jthis=",t);
env->ExceptionDescribe();
}
throw t;
}
if(jthis == NULL) {
std::cerr NewGlobalRef(jthis);
}
}
}
releaseEnv(env);
}
// Destructor for Simple
Simple::~Simple() {
// Place-holder for later extensibility.
}
jint Simple::getValue() {
if(jthis == NULL) {
std::cerr