[kaffe] CVS kaffe (robilad): Resynced with gnu classpath: iconv build fixes
Kaffe CVS
cvs-commits at kaffe.org
Sat May 14 16:50:19 PDT 2005
PatchSet 6469
Date: 2005/05/14 23:46:09
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with gnu classpath: iconv build fixes
2005-05-15 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
2005-04-25 Mark Wielaard <mark at klomp.org>
* native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c:
Include config.h and jcl.h, use if defined(HAVE_ICONV), add new
static variables infid and outfid, add char_union.
(Java_gnu_java_nio_charset_iconv_IconvDecoder_openIconv):
Guard with if defined(HAVE_ICONV), use JCL_jstring_to_cstring,
JCL_free_cstring and JCL_ThrowException, cache inremaining and
outremaining fieldIDs.
(Java_gnu_java_nio_charset_iconv_IconvDecoder_decode):
Guard with if defined(HAVE_ICONV), use ICONV_CONST for iconv
argument, used cached fieldIDs, use char_union.
(Java_gnu_java_nio_charset_iconv_IconvDecoder_closeIconv):
Guard with if defined(HAVE_ICONV).
* native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c:
Include config.h and jcl.h, use if defined(HAVE_ICONV), add new
static variables infid and outfid, add char_union.
(Java_gnu_java_nio_charset_iconv_IconvEncoder_openIconv):
Guard with if defined(HAVE_ICONV), use JCL_jstring_to_cstring,
JCL_free_cstring and JCL_ThrowException, cache inremaining and
outremaining fieldIDs.
(Java_gnu_java_nio_charset_iconv_IconvEncoder_encode):
Guard with if defined(HAVE_ICONV), use ICONV_CONST for iconv
argument, used cached fieldIDs, use char_union.
(Java_gnu_java_nio_charset_iconv_IconvEncoder_closeIconv):
Guard with if defined(HAVE_ICONV).
* gnu/java/nio/charset/iconv/IconvDecoder.java (dispose): Renamed.
(finalize): Renamed from dispose.
Members:
ChangeLog:1.3996->1.3997
libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.2->1.3
libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.2->1.3
libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java:1.1->1.2
libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java:1.1->1.2
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3996 kaffe/ChangeLog:1.3997
--- kaffe/ChangeLog:1.3996 Sat May 14 23:36:37 2005
+++ kaffe/ChangeLog Sat May 14 23:46:09 2005
@@ -2,6 +2,41 @@
Resynced with GNU Classpath.
+ 2005-04-25 Mark Wielaard <mark at klomp.org>
+
+ * native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c:
+ Include config.h and jcl.h, use if defined(HAVE_ICONV), add new
+ static variables infid and outfid, add char_union.
+ (Java_gnu_java_nio_charset_iconv_IconvDecoder_openIconv):
+ Guard with if defined(HAVE_ICONV), use JCL_jstring_to_cstring,
+ JCL_free_cstring and JCL_ThrowException, cache inremaining and
+ outremaining fieldIDs.
+ (Java_gnu_java_nio_charset_iconv_IconvDecoder_decode):
+ Guard with if defined(HAVE_ICONV), use ICONV_CONST for iconv
+ argument, used cached fieldIDs, use char_union.
+ (Java_gnu_java_nio_charset_iconv_IconvDecoder_closeIconv):
+ Guard with if defined(HAVE_ICONV).
+ * native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c:
+ Include config.h and jcl.h, use if defined(HAVE_ICONV), add new
+ static variables infid and outfid, add char_union.
+ (Java_gnu_java_nio_charset_iconv_IconvEncoder_openIconv):
+ Guard with if defined(HAVE_ICONV), use JCL_jstring_to_cstring,
+ JCL_free_cstring and JCL_ThrowException, cache inremaining and
+ outremaining fieldIDs.
+ (Java_gnu_java_nio_charset_iconv_IconvEncoder_encode):
+ Guard with if defined(HAVE_ICONV), use ICONV_CONST for iconv
+ argument, used cached fieldIDs, use char_union.
+ (Java_gnu_java_nio_charset_iconv_IconvEncoder_closeIconv):
+ Guard with if defined(HAVE_ICONV).
+ * gnu/java/nio/charset/iconv/IconvDecoder.java (dispose): Renamed.
+ (finalize): Renamed from dispose.
+ * gnu/java/nio/charset/iconv/IconvEncoder.java (dispose): Renamed.
+ (finalize): Renamed from dispose.
+
+2005-05-15 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath.
+
2005-04-25 Tom Tromey <tromey at redhat.com>
* java/awt/AWTKeyStroke.java (vktable): Now package-private.
Index: kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.2 kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.3
--- kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.2 Sat May 14 23:32:07 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c Sat May 14 23:46:09 2005
@@ -35,24 +35,55 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <config.h>
+#include <jcl.h>
+
#include <stdio.h>
#include <assert.h>
#include <errno.h>
+
+#if defined(HAVE_ICONV)
#include <iconv.h>
+#endif
+
#include "gnu_java_nio_charset_iconv_IconvDecoder.h"
static void createRawData (JNIEnv * env, jobject obj, void *ptr);
static void *getData (JNIEnv * env, jobject obj);
+static jfieldID infid = NULL;
+static jfieldID outfid = NULL;
+
+/* Union used for type punning. */
+union char_union
+{
+ jbyte **jb;
+ jchar **jc;
+ char **c;
+};
+
JNIEXPORT void JNICALL
Java_gnu_java_nio_charset_iconv_IconvDecoder_openIconv (JNIEnv * env,
jobject obj,
jstring jname)
{
- jclass exception;
+#if defined(HAVE_ICONV)
iconv_t iconv_object;
+ jclass cls;
- const char *name = (*env)->GetStringUTFChars (env, jname, 0);
+ const char *name = JCL_jstring_to_cstring (env, jname);
+ if (name == NULL)
+ return;
+
+ /* Cache fieldIDs for use in decode function. */
+ if (infid == NULL || outfid == NULL)
+ {
+ cls = (*env)->GetObjectClass (env, obj);
+ infid = (*env)->GetFieldID (env, cls, "inremaining", "I");
+ assert (infid != 0);
+ outfid = (*env)->GetFieldID (env, cls, "outremaining", "I");
+ assert (outfid != 0);
+ }
/* to java from "name", native java format depends on endianness */
#ifdef WORDS_BIGENDIAN
@@ -61,19 +92,18 @@
iconv_object = iconv_open ("UTF-16LE", name);
#endif
- (*env)->ReleaseStringUTFChars (env, jname, name);
+ JCL_free_cstring (env, jname, name);
if ((long) iconv_object == -1L)
{
- /* Throw an exception if charset not available */
- (*env)->ExceptionDescribe (env);
- (*env)->ExceptionClear (env);
- exception =
- (*env)->FindClass (env, "java/lang/IllegalArgumentException");
- assert (exception != 0);
- (*env)->ThrowNew (env, exception, "Charset not available.");
+ JCL_ThrowException (env, "java/lang/IllegalArgumentException",
+ "Charset not available");
return;
}
createRawData (env, obj, (void *) iconv_object);
+#else
+ JCL_ThrowException (env, "java/lang/IllegalArgumentException",
+ "iconv not available");
+#endif
}
JNIEXPORT jint JNICALL
@@ -84,11 +114,10 @@
jint posIn, jint remIn,
jint posOut, jint remOut)
{
+#if defined(HAVE_ICONV)
iconv_t iconv_object = getData (env, obj);
- jclass cls;
- jfieldID fid;
size_t retval;
- char **in, **out;
+ union char_union in, out;
jbyte *input, *inputcopy;
jchar *output, *outputcopy;
size_t lenIn = (size_t) remIn;
@@ -100,9 +129,10 @@
input += posIn;
output += posOut;
- in = (char **) &input;
- out = (char **) &output;
- retval = iconv (iconv_object, in, &lenIn, out, &lenOut);
+ in.jb = &input;
+ out.jc = &output;
+ retval = iconv (iconv_object, (ICONV_CONST char **) in.c, &lenIn,
+ out.c, &lenOut);
/* XXX: Do we need to relase the input array? It's not modified. */
(*env)->ReleaseByteArrayElements (env, inArr, inputcopy, 0);
@@ -118,24 +148,24 @@
else
retval = 0;
- cls = (*env)->GetObjectClass (env, obj);
- fid = (*env)->GetFieldID (env, cls, "inremaining", "I");
- assert (fid != 0);
- (*env)->SetIntField (env, obj, fid, (jint) lenIn);
- fid = (*env)->GetFieldID (env, cls, "outremaining", "I");
- assert (fid != 0);
- (*env)->SetIntField (env, obj, fid, (jint) (lenOut >> 1));
+ (*env)->SetIntField (env, obj, infid, (jint) lenIn);
+ (*env)->SetIntField (env, obj, outfid, (jint) (lenOut >> 1));
return (jint) retval;
+#else
+ return -1;
+#endif
}
JNIEXPORT void JNICALL
Java_gnu_java_nio_charset_iconv_IconvDecoder_closeIconv (JNIEnv * env,
jobject obj)
{
+#if defined(HAVE_ICONV)
iconv_t iconv_object;
iconv_object = getData (env, obj);
iconv_close (iconv_object);
+#endif
}
Index: kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.2 kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.3
--- kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.2 Sat May 14 23:32:07 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c Sat May 14 23:46:09 2005
@@ -35,24 +35,55 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <config.h>
+#include <jcl.h>
+
#include <stdio.h>
#include <assert.h>
#include <errno.h>
+
+#if defined(HAVE_ICONV)
#include <iconv.h>
+#endif
+
#include "gnu_java_nio_charset_iconv_IconvEncoder.h"
static void createRawData (JNIEnv * env, jobject obj, void *ptr);
static void *getData (JNIEnv * env, jobject obj);
+static jfieldID infid = NULL;
+static jfieldID outfid = NULL;
+
+/* Union used for type punning. */
+union char_union
+{
+ jbyte **jb;
+ jchar **jc;
+ char **c;
+};
+
JNIEXPORT void JNICALL
Java_gnu_java_nio_charset_iconv_IconvEncoder_openIconv (JNIEnv * env,
jobject obj,
jstring jname)
{
- jclass exception;
+#if defined(HAVE_ICONV)
iconv_t iconv_object;
+ jclass cls;
- const char *name = (*env)->GetStringUTFChars (env, jname, 0);
+ const char *name = JCL_jstring_to_cstring (env, jname);
+ if (name == NULL)
+ return;
+
+ /* Cache fieldIDs for use in encode function. */
+ if (infid == NULL || outfid == NULL)
+ {
+ cls = (*env)->GetObjectClass (env, obj);
+ infid = (*env)->GetFieldID (env, cls, "inremaining", "I");
+ assert (infid != 0);
+ outfid = (*env)->GetFieldID (env, cls, "outremaining", "I");
+ assert (outfid != 0);
+ }
/* to "name" from java, native java format depends on endianness */
#ifdef WORDS_BIGENDIAN
@@ -61,19 +92,18 @@
iconv_object = iconv_open (name, "UTF-16LE");
#endif
- (*env)->ReleaseStringUTFChars (env, jname, name);
+ JCL_free_cstring (env, jname, name);
if ((long) iconv_object == -1L)
{
- /* Throw an exception if charset not available */
- (*env)->ExceptionDescribe (env);
- (*env)->ExceptionClear (env);
- exception =
- (*env)->FindClass (env, "java/lang/IllegalArgumentException");
- assert (exception != 0);
- (*env)->ThrowNew (env, exception, "Charset not available.");
+ JCL_ThrowException (env, "java/lang/IllegalArgumentException",
+ "Charset not available");
return;
}
createRawData (env, obj, (void *) iconv_object);
+#else
+ JCL_ThrowException (env, "java/lang/IllegalArgumentException",
+ "iconv not available");
+#endif
}
JNIEXPORT jint JNICALL
@@ -84,11 +114,10 @@
jint posIn, jint remIn,
jint posOut, jint remOut)
{
+#if defined(HAVE_ICONV)
iconv_t iconv_object = getData (env, obj);
- jclass cls;
- jfieldID fid;
size_t retval;
- char **in, **out;
+ union char_union in, out;
jchar *input, *inputcopy;
jbyte *output, *outputcopy;
size_t lenIn = (size_t) remIn * 2;
@@ -100,9 +129,10 @@
input += posIn;
output += posOut;
- in = (char **) &input;
- out = (char **) &output;
- retval = iconv (iconv_object, in, &lenIn, out, &lenOut);
+ in.jc = &input;
+ out.jb = &output;
+ retval = iconv (iconv_object, (ICONV_CONST char **) in.c, &lenIn,
+ out.c, &lenOut);
/* XXX: Do we need to relase the input array? It's not modified. */
(*env)->ReleaseCharArrayElements (env, inArr, inputcopy, 0);
@@ -118,24 +148,24 @@
else
retval = 0;
- cls = (*env)->GetObjectClass (env, obj);
- fid = (*env)->GetFieldID (env, cls, "inremaining", "I");
- assert (fid != 0);
- (*env)->SetIntField (env, obj, fid, (jint) (lenIn >> 1));
- fid = (*env)->GetFieldID (env, cls, "outremaining", "I");
- assert (fid != 0);
- (*env)->SetIntField (env, obj, fid, (jint) lenOut);
+ (*env)->SetIntField (env, obj, infid, (jint) (lenIn >> 1));
+ (*env)->SetIntField (env, obj, outfid, (jint) lenOut);
return (jint) retval;
+#else
+ return -1;
+#endif
}
JNIEXPORT void JNICALL
Java_gnu_java_nio_charset_iconv_IconvEncoder_closeIconv (JNIEnv * env,
jobject obj)
{
+#if defined(HAVE_ICONV)
iconv_t iconv_object;
iconv_object = getData (env, obj);
iconv_close (iconv_object);
+#endif
}
Index: kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java
diff -u kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java:1.1 kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java:1.2
--- kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java:1.1 Sat Apr 23 09:54:27 2005
+++ kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvDecoder.java Sat May 14 23:46:10 2005
@@ -104,7 +104,7 @@
return CoderResult.OVERFLOW;
}
- public void dispose()
+ protected void finalize()
{
closeIconv();
}
Index: kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java
diff -u kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java:1.1 kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java:1.2
--- kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java:1.1 Sat Apr 23 09:54:27 2005
+++ kaffe/libraries/javalib/gnu/java/nio/charset/iconv/IconvEncoder.java Sat May 14 23:46:10 2005
@@ -104,7 +104,7 @@
return CoderResult.OVERFLOW;
}
- public void dispose()
+ protected void finalize()
{
closeIconv();
}
More information about the kaffe
mailing list