Question on String merge

Eric Blake ebb9@email.byu.edu
Fri Mar 8 22:01:00 GMT 2002


I'm trying to merge some of my recent changes to String and StringBuffer
from Classpath into gcj.  Now that both String and Character use
gnu.java.lang.CharData in Classpath, I'm trying to figure out how to
represent that in C-style arrays in the native code of gcj.  I don't
want the static data to be defined twice, but I also don't want to
pollute the namespace.

Is this approach all right, or am I missing something obvious?

Index: include/java-chartables.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/java-chartables.h,v
retrieving revision 1.1.1.1.26.1
diff -u -r1.1.1.1.26.1 java-chartables.h
--- java-chartables.h   2002/03/06 19:12:51     1.1.1.1.26.1
+++ java-chartables.h   2002/03/09 05:52:38
...
@@ -73,213 +78,217 @@
  * Each entry has been adjusted so that a modulo 16 sum with the
desired
  * character gives the actual index into <code>data</code>.
  */
+#ifndef CHARTABLES_DEFINE
+extern const jchar blocks[];
+#else
 static const jchar blocks[] = {
-    450, 450, 449, 300, 299, 416, 504, 638, 513, 656,
...
+    3000, 5543, 4038, 448, 433, 2507, 2092, 4741,
   };
+#endif // CHARTABLES_DEFINE
 /** Length of blocks. */
 static const int blocks_length = 2048;

Index: java/lang/natCharacter.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natCharacter.cc,v
retrieving revision 1.5.24.1
diff -u -r1.5.24.1 natCharacter.cc
--- natCharacter.cc     2002/03/06 19:13:00     1.5.24.1
+++ natCharacter.cc     2002/03/09 05:52:38
@@ -41,7 +41,9 @@
 #include <jvm.h>
 #include <java/lang/Character.h>

+#define CHARTABLES_DEFINE 1
 #include <java-chartables.h>
+#undef CHARTABLES_DEFINE

 ^L

Index: java/lang/natString.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natString.cc,v
retrieving revision 1.25
diff -u -r1.25 natString.cc
--- natString.cc        2001/11/15 02:22:52     1.25
+++ natString.cc        2002/03/09 05:56:56
@@ -1,6 +1,6 @@
 // natString.cc - Implementation of java.lang.String native methods.

-/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation

    This file is part of libgcj.

@@ -28,6 +28,7 @@
 #include <gnu/gcj/convert/UnicodeToBytes.h>
 #include <gnu/gcj/convert/BytesToUnicode.h>
 #include <jvm.h>
+#include <java-chartables.h>

 static void unintern (jobject);
 static jstring* strhash = NULL;


-- 
This signature intentionally left boring.

Eric Blake             ebb9@email.byu.edu
  BYU student, free software programmer



More information about the Java mailing list