[kaffe] CVS kaffe (guilhem): JNI splitting (continued)

Kaffe CVS cvs-commits at kaffe.org
Fri Jun 25 09:10:52 PDT 2004


PatchSet 4868 
Date: 2004/06/25 16:04:33
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
JNI splitting (continued)

       * kaffe/kaffevm/jni/jni.c, kaffe/kaffevm/jni/jni_funcs.h:
        Moved out functions concerning Field handling to jni-fields.c.
        Moved out functions concerning arrays handling to jni-arrays.c.

        * kaffe/kaffevm/jni/jni-arrays.c,
        kaffe/kaffevm/jni/jni-fields.c: New files.

        * kaffe/kaffevm/jni/Makefile.am: Added jni-arrays.c and jni-field.c.

        * kaffe/kaffevm/jni/Makefile.in: Regenerated.

Members: 
	ChangeLog:1.2434->1.2435 
	kaffe/kaffevm/jni/Makefile.am:1.2->1.3 
	kaffe/kaffevm/jni/Makefile.in:1.3->1.4 
	kaffe/kaffevm/jni/jni-arrays.c:INITIAL->1.1 
	kaffe/kaffevm/jni/jni-fields.c:INITIAL->1.1 
	kaffe/kaffevm/jni/jni.c:1.2->1.3 
	kaffe/kaffevm/jni/jni_funcs.h:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2434 kaffe/ChangeLog:1.2435
--- kaffe/ChangeLog:1.2434	Fri Jun 25 15:21:33 2004
+++ kaffe/ChangeLog	Fri Jun 25 16:04:33 2004
@@ -1,4 +1,18 @@
+2004-06-52  Guilhem Lavaux <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/jni/jni.c, kaffe/kaffevm/jni/jni_funcs.h:
+	Moved out functions concerning Field handling to jni-fields.c.
+	Moved out functions concerning arrays handling to jni-arrays.c.
+
+	* kaffe/kaffevm/jni/jni-arrays.c,
+	kaffe/kaffevm/jni/jni-fields.c: New files.
+
+	* kaffe/kaffevm/jni/Makefile.am: Added jni-arrays.c and jni-field.c.
+
+	* kaffe/kaffevm/jni/Makefile.in: Regenerated.
+
 2004-06-25  Rob Gonzalez <rob at kaffe.org>
+
 	* verify2.c
 	Some minor fixes to keep gcc from complaining
 
Index: kaffe/kaffe/kaffevm/jni/Makefile.am
diff -u kaffe/kaffe/kaffevm/jni/Makefile.am:1.2 kaffe/kaffe/kaffevm/jni/Makefile.am:1.3
--- kaffe/kaffe/kaffevm/jni/Makefile.am:1.2	Tue Jun 22 17:10:16 2004
+++ kaffe/kaffe/kaffevm/jni/Makefile.am	Fri Jun 25 16:04:35 2004
@@ -27,7 +27,9 @@
 libkaffejni_la_SOURCES = \
 	jni.c \
 	jni-base.c \
-	jni-callmethod.c
+	jni-callmethod.c \
+	jni-fields.c \
+	jni-arrays.c
 
 noinst_HEADERS= \
 	jni_i.h \
Index: kaffe/kaffe/kaffevm/jni/Makefile.in
diff -u kaffe/kaffe/kaffevm/jni/Makefile.in:1.3 kaffe/kaffe/kaffevm/jni/Makefile.in:1.4
--- kaffe/kaffe/kaffevm/jni/Makefile.in:1.3	Wed Jun 23 15:36:45 2004
+++ kaffe/kaffe/kaffevm/jni/Makefile.in	Fri Jun 25 16:04:35 2004
@@ -74,13 +74,16 @@
 CONFIG_CLEAN_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libkaffejni_la_LIBADD =
-am_libkaffejni_la_OBJECTS = jni.lo jni-base.lo jni-callmethod.lo
+am_libkaffejni_la_OBJECTS = jni.lo jni-base.lo jni-callmethod.lo \
+	jni-fields.lo jni-arrays.lo
 libkaffejni_la_OBJECTS = $(am_libkaffejni_la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/config -I$(top_builddir)/include/kaffe
 depcomp = $(SHELL) $(top_srcdir)/scripts/depcomp
 am__depfiles_maybe = depfiles
- at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/jni-base.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/jni-callmethod.Plo ./$(DEPDIR)/jni.Plo
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/jni-arrays.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/jni-base.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/jni-callmethod.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/jni-fields.Plo ./$(DEPDIR)/jni.Plo
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
@@ -357,7 +360,9 @@
 libkaffejni_la_SOURCES = \
 	jni.c \
 	jni-base.c \
-	jni-callmethod.c
+	jni-callmethod.c \
+	jni-fields.c \
+	jni-arrays.c
 
 noinst_HEADERS = \
 	jni_i.h \
@@ -415,8 +420,10 @@
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jni-arrays.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jni-base.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jni-callmethod.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jni-fields.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jni.Plo at am__quote@
 
 .c.o:
===================================================================
Checking out kaffe/kaffe/kaffevm/jni/jni-arrays.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/jni/jni-arrays.c,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jni/jni-arrays.c	Fri Jun 25 16:10:51 2004
@@ -0,0 +1,700 @@
+/*
+ * jni-arrays.c
+ * Java Native Interface - Array handling JNI functions.
+ *
+ * Copyright (c) 1996, 1997, 2004
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2004
+ *      The Kaffe.org's developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#include "config.h"
+#include "jtypes.h"
+#include "jni_i.h"
+#include "jni.h"
+#include "jni_funcs.h"
+#include "Arrays.h"
+#include "jnirefs.h"
+#include "exception.h"
+
+jobject
+KaffeJNI_GetObjectArrayElement(JNIEnv* env UNUSED, jobjectArray arr, jsize elem)
+{
+	jobject obj;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (elem >= obj_length((HArrayOfObject*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	obj = unhand_array((HArrayOfObject*)arr)->body[elem];
+
+	ADD_REF(obj);
+	END_EXCEPTION_HANDLING();
+	return (obj);
+}
+
+void
+KaffeJNI_SetObjectArrayElement(JNIEnv* env UNUSED, jobjectArray arr, jsize elem, jobject val)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elem >= obj_length((HArrayOfObject*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	unhand_array((HArrayOfObject*)arr)->body[elem] = (Hjava_lang_Object*)val;
+
+	END_EXCEPTION_HANDLING();
+}
+
+jobjectArray
+KaffeJNI_NewObjectArray(JNIEnv* env UNUSED, jsize len, jclass cls, jobject init)
+{
+	HArrayOfObject* obj;
+	int i;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	obj = (HArrayOfObject*)newArray((Hjava_lang_Class*)cls, len);
+
+	/* I assume this is what init is for */
+	for (i = 0; i < len; i++) {
+		unhand_array(obj)->body[i] = (Hjava_lang_Object*)init;
+	}
+
+	ADD_REF(obj);
+	END_EXCEPTION_HANDLING();
+	return (obj);
+}
+
+jbooleanArray
+KaffeJNI_NewBooleanArray(JNIEnv* env UNUSED, jsize len)
+{
+	jbooleanArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(booleanClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jbyteArray
+KaffeJNI_NewByteArray(JNIEnv* env UNUSED, jsize len)
+{
+	jbyteArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(byteClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jcharArray
+KaffeJNI_NewCharArray(JNIEnv* env UNUSED, jsize len)
+{
+	jcharArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(charClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jshortArray
+KaffeJNI_NewShortArray(JNIEnv* env UNUSED, jsize len)
+{
+	jshortArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(shortClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jintArray
+KaffeJNI_NewIntArray(JNIEnv* env UNUSED, jsize len)
+{
+	jintArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(intClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jlongArray
+KaffeJNI_NewLongArray(JNIEnv* env UNUSED, jsize len)
+{
+	jlongArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(longClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jfloatArray
+KaffeJNI_NewFloatArray(JNIEnv* env UNUSED, jsize len)
+{
+	jfloatArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(floatClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jdoubleArray
+KaffeJNI_NewDoubleArray(JNIEnv* env UNUSED, jsize len)
+{
+	jdoubleArray arr;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	arr = newArray(doubleClass, len);
+
+	ADD_REF(arr);
+	END_EXCEPTION_HANDLING();
+	return (arr);
+}
+
+jboolean*
+KaffeJNI_GetBooleanArrayElements(JNIEnv* env UNUSED, jbooleanArray arr, jbool* iscopy)
+{
+	jboolean* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfBoolean*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jbyte*
+KaffeJNI_GetByteArrayElements(JNIEnv* env UNUSED, jbyteArray arr, jbool* iscopy)
+{
+	jbyte* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfByte*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+void*
+KaffeJNI_GetPrimitiveArrayCritical(JNIEnv* env, jarray arr, jbool* iscopy)
+{
+  return (KaffeJNI_GetByteArrayElements(env, (jbyteArray)arr, iscopy));
+}
+
+jchar*
+KaffeJNI_GetCharArrayElements(JNIEnv* env UNUSED, jcharArray arr, jbool* iscopy)
+{
+	jchar* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfChar*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jshort*
+KaffeJNI_GetShortArrayElements(JNIEnv* env UNUSED, jshortArray arr, jbool* iscopy)
+{
+	jshort* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfShort*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jint*
+KaffeJNI_GetIntArrayElements(JNIEnv* env UNUSED, jintArray arr, jbool* iscopy)
+{
+	jint* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfInt*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jlong*
+KaffeJNI_GetLongArrayElements(JNIEnv* env UNUSED, jlongArray arr, jbool* iscopy)
+{
+	jlong* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfLong*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jfloat*
+KaffeJNI_GetFloatArrayElements(JNIEnv* env UNUSED, jfloatArray arr, jbool* iscopy)
+{
+	jfloat* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfFloat*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+jdouble*
+KaffeJNI_GetDoubleArrayElements(JNIEnv* env UNUSED, jdoubleArray arr, jbool* iscopy)
+{
+	jdouble* array;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	if (iscopy != NULL) {
+		*iscopy = JNI_FALSE;
+	}
+	array = unhand_array((HArrayOfDouble*)arr)->body;
+
+	END_EXCEPTION_HANDLING();
+	return (array);
+}
+
+void
+KaffeJNI_ReleaseBooleanArrayElements(JNIEnv* env UNUSED, jbooleanArray arr, jbool* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfBoolean*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfBoolean*)arr)->body, elems, obj_length((HArrayOfBoolean*)arr) * sizeof(jboolean));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfBoolean*)arr)->body, elems, obj_length((HArrayOfBoolean*)arr) * sizeof(jboolean));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseByteArrayElements(JNIEnv* env UNUSED, jbyteArray arr, jbyte* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfByte*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfByte*)arr)->body, elems, obj_length((HArrayOfByte*)arr) * sizeof(jbyte));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfByte*)arr)->body, elems, obj_length((HArrayOfByte*)arr) * sizeof(jbyte));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleasePrimitiveArrayCritical(JNIEnv* env, jbyteArray arr, void* elems, jint mode)
+{
+  KaffeJNI_ReleaseByteArrayElements(env, (jbyteArray)arr, (jbyte*)elems, mode);
+}
+
+void
+KaffeJNI_ReleaseCharArrayElements(JNIEnv* env UNUSED, jcharArray arr, jchar* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfChar*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfChar*)arr)->body, elems, obj_length((HArrayOfChar*)arr) * sizeof(jchar));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfChar*)arr)->body, elems, obj_length((HArrayOfChar*)arr) * sizeof(jchar));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseShortArrayElements(JNIEnv* env UNUSED, jshortArray arr, jshort* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfShort*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfShort*)arr)->body, elems, obj_length((HArrayOfShort*)arr) * sizeof(jshort));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfShort*)arr)->body, elems, obj_length((HArrayOfShort*)arr) * sizeof(jshort));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseIntArrayElements(JNIEnv* env UNUSED, jintArray arr, jint* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfInt*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfInt*)arr)->body, elems, obj_length((HArrayOfInt*)arr) * sizeof(jint));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfInt*)arr)->body, elems, obj_length((HArrayOfInt*)arr) * sizeof(jint));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseLongArrayElements(JNIEnv* env UNUSED, jlongArray arr, jlong* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfLong*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfLong*)arr)->body, elems, obj_length((HArrayOfLong*)arr) * sizeof(jlong));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfLong*)arr)->body, elems, obj_length((HArrayOfLong*)arr) * sizeof(jlong));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseFloatArrayElements(JNIEnv* env UNUSED, jfloatArray arr, jfloat* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfFloat*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfFloat*)arr)->body, elems, obj_length((HArrayOfFloat*)arr) * sizeof(jfloat));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfFloat*)arr)->body, elems, obj_length((HArrayOfFloat*)arr) * sizeof(jfloat));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_ReleaseDoubleArrayElements(JNIEnv* env UNUSED, jdoubleArray arr, jdouble* elems, jint mode)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (elems != unhand_array((HArrayOfDouble*)arr)->body) {
+		switch (mode) {
+		case JNI_COMMIT:
+			memcpy(unhand_array((HArrayOfDouble*)arr)->body, elems, obj_length((HArrayOfDouble*)arr) * sizeof(jdouble));
+			break;
+		case 0:
+			memcpy(unhand_array((HArrayOfDouble*)arr)->body, elems, obj_length((HArrayOfDouble*)arr) * sizeof(jdouble));
+			KFREE(elems);
+			break;
+		case JNI_ABORT:
+			KFREE(elems);
+			break;
+		}
+	}
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetBooleanArrayRegion(JNIEnv* env UNUSED, jbooleanArray arr, jsize start, jsize len, jbool* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfBoolean*)arr) || start + len > obj_length((HArrayOfBoolean*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfBoolean*)arr)->body[start], len * sizeof(jboolean));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetByteArrayRegion(JNIEnv* env UNUSED, jbyteArray arr, jsize start, jsize len, jbyte* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfByte*)arr) || start + len > obj_length((HArrayOfByte*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfByte*)arr)->body[start], len * sizeof(jbyte));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetCharArrayRegion(JNIEnv* env UNUSED, jcharArray arr, jsize start, jsize len, jchar* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfChar*)arr) || start + len > obj_length((HArrayOfChar*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfChar*)arr)->body[start], len * sizeof(jchar));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetShortArrayRegion(JNIEnv* env UNUSED, jshortArray arr, jsize start, jsize len, jshort* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfShort*)arr) || start + len > obj_length((HArrayOfShort*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfShort*)arr)->body[start], len * sizeof(jshort));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetIntArrayRegion(JNIEnv* env UNUSED, jintArray arr, jsize start, jsize len, jint* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfInt*)arr) || start + len > obj_length((HArrayOfInt*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfInt*)arr)->body[start], len * sizeof(jint));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetLongArrayRegion(JNIEnv* env UNUSED, jlongArray arr, jsize start, jsize len, jlong* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfLong*)arr) || start + len > obj_length((HArrayOfLong*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfLong*)arr)->body[start], len * sizeof(jlong));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetFloatArrayRegion(JNIEnv* env UNUSED, jfloatArray arr, jsize start, jsize len, jfloat* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfFloat*)arr) || start + len > obj_length((HArrayOfFloat*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfFloat*)arr)->body[start], len * sizeof(jfloat));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_GetDoubleArrayRegion(JNIEnv* env UNUSED, jdoubleArray arr, jsize start, jsize len, jdouble* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfDouble*)arr) || start + len > obj_length((HArrayOfDouble*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(data, &unhand_array((HArrayOfDouble*)arr)->body[start], len * sizeof(jdouble));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetBooleanArrayRegion(JNIEnv* env UNUSED, jbooleanArray arr, jsize start, jsize len, jbool* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfBoolean*)arr) || start+len > obj_length((HArrayOfBoolean*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfBoolean*)arr)->body[start], data, len * sizeof(jboolean));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetByteArrayRegion(JNIEnv* env UNUSED, jbyteArray arr, jsize start, jsize len, jbyte* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfByte*)arr) || start+len > obj_length((HArrayOfByte*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfByte*)arr)->body[start], data, len * sizeof(jbyte));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetCharArrayRegion(JNIEnv* env UNUSED, jcharArray arr, jsize start, jsize len, jchar* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfChar*)arr) || start+len > obj_length((HArrayOfChar*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfChar*)arr)->body[start], data, len * sizeof(jchar));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetShortArrayRegion(JNIEnv* env UNUSED, jshortArray arr, jsize start, jsize len, jshort* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfShort*)arr) || start+len > obj_length((HArrayOfShort*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfShort*)arr)->body[start], data, len * sizeof(jshort));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetIntArrayRegion(JNIEnv* env UNUSED, jintArray arr, jsize start, jsize len, jint* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfInt*)arr) || start+len > obj_length((HArrayOfInt*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfInt*)arr)->body[start], data, len * sizeof(jint));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetLongArrayRegion(JNIEnv* env UNUSED, jlongArray arr, jsize start, jsize len, jlong* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfLong*)arr) || start+len > obj_length((HArrayOfLong*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfLong*)arr)->body[start], data, len * sizeof(jlong));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetFloatArrayRegion(JNIEnv* env UNUSED, jfloatArray arr, jsize start, jsize len, jfloat* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfFloat*)arr) || start+len > obj_length((HArrayOfFloat*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfFloat*)arr)->body[start], data, len * sizeof(jfloat));
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetDoubleArrayRegion(JNIEnv* env UNUSED, jdoubleArray arr, jsize start, jsize len, jdouble* data)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	if (start >= obj_length((HArrayOfDouble*)arr) || start+len > obj_length((HArrayOfDouble*)arr)) {
+		throwException(ArrayIndexOutOfBoundsException);
+	}
+	memcpy(&unhand_array((HArrayOfDouble*)arr)->body[start], data, len * sizeof(jdouble));
+
+	END_EXCEPTION_HANDLING();
+}
===================================================================
Checking out kaffe/kaffe/kaffevm/jni/jni-fields.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/jni/jni-fields.c,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jni/jni-fields.c	Fri Jun 25 16:10:51 2004
@@ -0,0 +1,450 @@
+/*
+ * jni-fields.c
+ * Java Native Interface - Get/SetXField JNI functions.
+ *
+ * Copyright (c) 1996, 1997, 2004
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2004
+ *      The Kaffe.org's developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+/*
+ * Get and set fields.
+ */
+#include "config.h"
+#include "jtypes.h"
+#include "jni_i.h"
+#include "jni.h"
+#include "classMethod.h"
+#include "jni_funcs.h"
+
+#define	GET_FIELD(T,O,F)	*(T*)((char*)(O) + FIELD_BOFFSET((Field*)(F)))
+#define	SET_FIELD(T,O,F,V)	*(T*)((char*)(O) + FIELD_BOFFSET((Field*)(F))) = (V)
+#define	GET_STATIC_FIELD(T,F)	*(T*)FIELD_ADDRESS((Field*)F)
+#define	SET_STATIC_FIELD(T,F,V)	*(T*)FIELD_ADDRESS((Field*)F) = (V)
+
+/* ------------------------------------------------------------------------------
+ * GetField functions
+ * ------------------------------------------------------------------------------
+ */
+
+jobject
+KaffeJNI_GetObjectField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jobject nobj;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	nobj = GET_FIELD(jobject, obj, fld);
+
+	ADD_REF(nobj);
+	END_EXCEPTION_HANDLING();
+	return (nobj);
+}
+
+jboolean
+KaffeJNI_GetBooleanField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jboolean r;
+
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jboolean, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jbyte
+KaffeJNI_GetByteField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jbyte r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jbyte, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jchar
+KaffeJNI_GetCharField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jchar r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jchar, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jshort
+KaffeJNI_GetShortField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jshort r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jshort, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jint
+KaffeJNI_GetIntField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jint r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jint, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jlong
+KaffeJNI_GetLongField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jlong r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jlong, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jfloat
+KaffeJNI_GetFloatField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jfloat r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jfloat, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+jdouble
+KaffeJNI_GetDoubleField(JNIEnv* env UNUSED, jobject obj, jfieldID fld)
+{
+	jdouble r;
+	BEGIN_EXCEPTION_HANDLING(0);
+
+	r = GET_FIELD(jdouble, obj, fld);
+
+	END_EXCEPTION_HANDLING();
+	return (r);
+}
+
+/* ------------------------------------------------------------------------------
+ * SetField functions
+ * ------------------------------------------------------------------------------
+ */
+
+void
+KaffeJNI_SetObjectField(JNIEnv* env UNUSED, jobject obj, jfieldID fld, jobject val)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	SET_FIELD(jobject, obj, fld, val);
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetBooleanField(JNIEnv* env UNUSED, jobject obj, jfieldID fld, jbool val)
+{
+	BEGIN_EXCEPTION_HANDLING_VOID();
+
+	SET_FIELD(jboolean, obj, fld, val);
+
+	END_EXCEPTION_HANDLING();
+}
+
+void
+KaffeJNI_SetByteField(JNIEnv* env UNUSED, jobject obj, jfieldID fld, jbyte val)

*** Patch too long, truncated ***




More information about the kaffe mailing list