1 /* src/vmcore/utf8.h - utf8 string functions
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: utf8.h 8367 2007-08-20 20:26:16Z twisti $
33 /* forward typedefs ***********************************************************/
35 typedef struct utf utf;
43 #include "vm/global.h"
46 /* data structure for utf8 symbols ********************************************/
49 utf *hashlink; /* link for external hash chain */
50 s4 blength; /* text length in bytes */
51 char *text; /* pointer to text */
54 /* to determine the end of utf strings */
56 #define UTF_END(u) ((char *) u->text + u->blength)
59 /* utf-symbols for pointer comparison of frequently used strings **************/
61 extern utf *utf_java_lang_Object;
63 extern utf *utf_java_lang_Class;
64 extern utf *utf_java_lang_ClassLoader;
65 extern utf *utf_java_lang_Cloneable;
66 extern utf *utf_java_lang_SecurityManager;
67 extern utf *utf_java_lang_String;
68 extern utf *utf_java_lang_System;
69 extern utf *utf_java_lang_ThreadGroup;
70 extern utf *utf_java_lang_ref_SoftReference;
71 extern utf *utf_java_lang_ref_WeakReference;
72 extern utf *utf_java_lang_ref_PhantomReference;
73 extern utf *utf_java_io_Serializable;
75 extern utf *utf_java_lang_Throwable;
76 extern utf *utf_java_lang_Error;
78 extern utf *utf_java_lang_AbstractMethodError;
79 extern utf *utf_java_lang_ClassCircularityError;
80 extern utf *utf_java_lang_ClassFormatError;
81 extern utf *utf_java_lang_ExceptionInInitializerError;
82 extern utf *utf_java_lang_IncompatibleClassChangeError;
83 extern utf *utf_java_lang_InstantiationError;
84 extern utf *utf_java_lang_InternalError;
85 extern utf *utf_java_lang_LinkageError;
86 extern utf *utf_java_lang_NoClassDefFoundError;
87 extern utf *utf_java_lang_NoSuchFieldError;
88 extern utf *utf_java_lang_NoSuchMethodError;
89 extern utf *utf_java_lang_OutOfMemoryError;
90 extern utf *utf_java_lang_UnsatisfiedLinkError;
91 extern utf *utf_java_lang_UnsupportedClassVersionError;
92 extern utf *utf_java_lang_VerifyError;
93 extern utf *utf_java_lang_VirtualMachineError;
95 #if defined(WITH_CLASSPATH_GNU)
96 extern utf *utf_java_lang_VMThrowable;
99 extern utf *utf_java_lang_Exception;
101 extern utf *utf_java_lang_ArithmeticException;
102 extern utf *utf_java_lang_ArrayIndexOutOfBoundsException;
103 extern utf *utf_java_lang_ArrayStoreException;
104 extern utf *utf_java_lang_ClassCastException;
105 extern utf *utf_java_lang_ClassNotFoundException;
106 extern utf *utf_java_lang_CloneNotSupportedException;
107 extern utf *utf_java_lang_IllegalAccessException;
108 extern utf *utf_java_lang_IllegalArgumentException;
109 extern utf *utf_java_lang_IllegalMonitorStateException;
110 extern utf *utf_java_lang_InstantiationException;
111 extern utf *utf_java_lang_InterruptedException;
112 extern utf *utf_java_lang_NegativeArraySizeException;
113 extern utf *utf_java_lang_NullPointerException;
114 extern utf *utf_java_lang_StringIndexOutOfBoundsException;
116 extern utf *utf_java_lang_reflect_InvocationTargetException;
118 extern utf *utf_java_security_PrivilegedActionException;
120 #if defined(ENABLE_JAVASE)
121 extern utf* utf_java_lang_Void;
124 extern utf* utf_java_lang_Boolean;
125 extern utf* utf_java_lang_Byte;
126 extern utf* utf_java_lang_Character;
127 extern utf* utf_java_lang_Short;
128 extern utf* utf_java_lang_Integer;
129 extern utf* utf_java_lang_Long;
130 extern utf* utf_java_lang_Float;
131 extern utf* utf_java_lang_Double;
133 #if defined(ENABLE_JAVASE)
134 extern utf *utf_java_lang_StackTraceElement;
135 extern utf *utf_java_lang_reflect_Constructor;
136 extern utf *utf_java_lang_reflect_Field;
137 extern utf *utf_java_lang_reflect_Method;
138 extern utf *utf_java_util_Vector;
141 extern utf *utf_InnerClasses;
142 extern utf *utf_ConstantValue;
143 extern utf *utf_Code;
144 extern utf *utf_Exceptions;
145 extern utf *utf_LineNumberTable;
146 extern utf *utf_SourceFile;
148 #if defined(ENABLE_JAVASE)
149 extern utf *utf_EnclosingMethod;
150 extern utf *utf_Signature;
151 extern utf *utf_StackMapTable;
153 #if defined(ENABLE_ANNOTATIONS)
154 /* OpenJDKs sun.reflect.ConstantPool class is for now only
155 * used by annotations but will probably be used for other
156 * things in the future. For now I just couple it with
157 * annotation support.
159 extern utf *utf_sun_reflect_ConstantPool;
160 #if defined(WITH_CLASSPATH_GNU)
161 extern utf *utf_sun_reflect_annotation_AnnotationParser;
164 extern utf *utf_RuntimeVisibleAnnotations;
165 extern utf *utf_RuntimeInvisibleAnnotations;
166 extern utf *utf_RuntimeVisibleParameterAnnotations;
167 extern utf *utf_RuntimeInvisibleParameterAnnotations;
168 extern utf *utf_AnnotationDefault;
172 extern utf *utf_init;
173 extern utf *utf_clinit;
174 extern utf *utf_clone;
175 extern utf *utf_finalize;
179 extern utf *utf_remove;
180 extern utf *utf_addThread;
181 extern utf *utf_removeThread;
184 extern utf *utf_uncaughtException;
185 extern utf *utf_value;
187 extern utf *utf_fillInStackTrace;
188 extern utf *utf_findNative;
189 extern utf *utf_getSystemClassLoader;
190 extern utf *utf_initCause;
191 extern utf *utf_loadClass;
192 extern utf *utf_printStackTrace;
194 extern utf *utf_division_by_zero;
205 extern utf *utf_void__void;
206 extern utf *utf_boolean__void;
207 extern utf *utf_byte__void;
208 extern utf *utf_char__void;
209 extern utf *utf_short__void;
210 extern utf *utf_int__void;
211 extern utf *utf_long__void;
212 extern utf *utf_float__void;
213 extern utf *utf_double__void;
215 extern utf *utf_void__java_lang_ClassLoader;
216 extern utf *utf_void__java_lang_Object;
217 extern utf *utf_void__java_lang_Throwable;
218 extern utf *utf_java_lang_ClassLoader_java_lang_String__J;
219 extern utf *utf_java_lang_Exception__V;
220 extern utf *utf_java_lang_Object__java_lang_Object;
221 extern utf *utf_java_lang_String__void;
222 extern utf *utf_java_lang_String__java_lang_Class;
223 extern utf *utf_java_lang_Thread__V;
224 extern utf *utf_java_lang_Thread_java_lang_Throwable__V;
225 extern utf *utf_java_lang_Throwable__void;
226 extern utf *utf_java_lang_Throwable__java_lang_Throwable;
228 extern utf *utf_not_named_yet;
229 extern utf *utf_null;
230 extern utf *array_packagename;
233 /* function prototypes ********************************************************/
235 /* initialize the utf8 subsystem */
236 bool utf8_init(void);
238 u4 utf_hashkey(const char *text, u4 length);
239 u4 utf_full_hashkey(const char *text, u4 length);
241 /* determine hashkey of a unicode-symbol */
242 u4 unicode_hashkey(u2 *text, u2 length);
244 /* create new utf-symbol */
245 utf *utf_new(const char *text, u2 length);
247 /* make utf symbol from u2 array */
248 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
250 utf *utf_new_char(const char *text);
251 utf *utf_new_char_classname(const char *text);
253 /* get number of bytes */
254 u4 utf_bytes(utf *u);
256 /* get next unicode character of a utf-string */
257 u2 utf_nextu2(char **utf);
259 /* get (number of) unicode characters of a utf string (safe) */
260 s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes);
261 void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer);
263 /* get (number of) unicode characters of a utf string (UNSAFE!) */
264 u4 utf_get_number_of_u2s(utf *u);
265 u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength);
267 /* determine utf length in bytes of a u2 array */
268 u4 u2_utflength(u2 *text, u4 u2_length);
270 void utf_copy(char *buffer, utf *u);
271 void utf_cat(char *buffer, utf *u);
272 void utf_copy_classname(char *buffer, utf *u);
273 void utf_cat_classname(char *buffer, utf *u);
275 /* write utf symbol to file/buffer */
276 void utf_display_printable_ascii(utf *u);
277 void utf_display_printable_ascii_classname(utf *u);
279 void utf_sprint_convert_to_latin1(char *buffer, utf *u);
280 void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u);
282 void utf_strcat_convert_to_latin1(char *buffer, utf *u);
283 void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u);
285 void utf_fprint_printable_ascii(FILE *file, utf *u);
286 void utf_fprint_printable_ascii_classname(FILE *file, utf *u);
288 /* check if a UTF-8 string is valid */
289 bool is_valid_utf(char *utf_ptr, char *end_pos);
291 /* check if a UTF-8 string may be used as a class/field/method name */
292 bool is_valid_name(char *utf_ptr, char *end_pos);
293 bool is_valid_name_utf(utf *u);
302 * These are local overrides for various environment variables in Emacs.
303 * Please do not remove this and leave it at the end of the file, where
304 * Emacs will automagically detect them.
305 * ---------------------------------------------------------------------
308 * indent-tabs-mode: t
312 * vim:noexpandtab:sw=4:ts=4: