summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9276815)
raw | patch | inline | side by side (parent: 9276815)
author | ishmal <ishmal@users.sourceforge.net> | |
Wed, 12 Mar 2008 19:55:00 +0000 (19:55 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Wed, 12 Mar 2008 19:55:00 +0000 (19:55 +0000) |
src/bind/dobinding.cpp | patch | blob | history | |
src/bind/javabind-private.h | patch | blob | history | |
src/bind/javabind.cpp | patch | blob | history |
diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp
index 29d61b722d0810af3aa2bebfee0e2c949c7c2944..e2157de0b3f69b584e9b6c2640496e1ac95c3a9a 100644 (file)
--- a/src/bind/dobinding.cpp
+++ b/src/bind/dobinding.cpp
static jlong getPointer(JNIEnv *env, jobject obj)
{
jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "_pointer", "J");
+ if (!id)
+ {
+ err("getPointer: %s", getException(env).c_str());
+ return 0;
+ }
jlong val = env->GetLongField(obj, id);
return val;
}
static void setPointer(JNIEnv *env, jobject obj, jlong val)
{
jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "_pointer", "J");
+ if (!id)
+ {
+ err("setPointer: %s", getException(env).c_str());
+ return;
+ }
env->SetLongField(obj, id, val);
}
+static void JNICALL BaseObject_construct
+ (JNIEnv *env, jobject obj)
+{
+ setPointer(env, obj, 0L);
+}
+
+static void JNICALL BaseObject_destruct
+ (JNIEnv *env, jobject obj)
+{
+ NodePtr *ptr = (NodePtr *)getPointer(env, obj);
+ if (ptr)
+ {
+ delete ptr;
+ }
+ setPointer(env, obj, 0L);
+}
+
+
+static JNINativeMethod nm_BaseObject[] =
+{
+{ (char *)"construct", (char *)"()V", (void *)BaseObject_construct },
+{ (char *)"destruct", (char *)"()V", (void *)BaseObject_destruct },
+{ NULL, NULL, NULL }
+};
+
+static NativeClass nc_BaseObject =
+{
+ "org/inkscape/cmn/BaseObject",
+ nm_BaseObject
+};
+
+//########################################################################
+//# BASE OBJECT
+//########################################################################
+
static void JNICALL DOMBase_construct
(JNIEnv *env, jobject obj)
{
"org/inkscape/dom/DOMBase",
nm_DOMBase
};
+
+
//########################################################################
//# DOMImplementation
//########################################################################
*/
static NativeClass *allClasses[] =
{
+ &nc_BaseObject,
&nc_DOMBase,
&nc_DOMImplementation,
NULL
index 5a810480ba6dfcf51eaf7f07b61fbe4ebc0a9fbd..c4dbd5e9a8530aee1a0a6d4f64a3aa807980117b 100644 (file)
//# UTILITY
//########################################################################
+String normalizePath(const String &str);
+
+String getExceptionString(JNIEnv *env);
+
+String getException(JNIEnv *env)
+ { return getExceptionString(env); }
+
jint getInt(JNIEnv *env, jobject obj, const char *name);
void setInt(JNIEnv *env, jobject obj, const char *name, jint val);
diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp
index b03d562ceea3da7807669a1b4805e2f2e6144b12..1424a527b457cc60ce67519c42c95b071d6b5018 100644 (file)
--- a/src/bind/javabind.cpp
+++ b/src/bind/javabind.cpp
return buf;
}
+String getExceptionString(JNIEnv *env)
+{
+ String buf;
+ jthrowable exc = env->ExceptionOccurred();
+ if (!exc)
+ return buf;
+ jclass cls = env->GetObjectClass(exc);
+ jmethodID mid = env->GetMethodID(cls, "toString", "()Ljava/lang/String;");
+ jstring jstr = (jstring) env->CallObjectMethod(exc, mid);
+ const char *str = env->GetStringUTFChars(jstr, JNI_FALSE);
+ buf.append(str);
+ env->ReleaseStringUTFChars(jstr, str);
+ env->ExceptionClear();
+ return buf;
+}
jint getInt(JNIEnv *env, jobject obj, const char *name)
{
+
/**
* Fetch the last exception from the JVM, if any. Clear it to
* continue processing
*/
String JavaBinderyImpl::getException()
{
- String buf;
- jthrowable exc = env->ExceptionOccurred();
- if (!exc)
- return buf;
- jclass cls = env->GetObjectClass(exc);
- jmethodID mid = env->GetMethodID(cls, "toString", "()Ljava/lang/String;");
- jstring jstr = (jstring) env->CallObjectMethod(exc, mid);
- const char *str = env->GetStringUTFChars(jstr, JNI_FALSE);
- buf.append(str);
- env->ReleaseStringUTFChars(jstr, str);
- env->ExceptionClear();
- return buf;
+ return getExceptionString(env);
}