1 /* src/vm/utf8.h - utf8 string functions
3 Copyright (C) 1996-2005, 2006 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 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
30 $Id: utf8.h 6244 2006-12-27 15:15:31Z twisti $
42 /* forward typedefs ***********************************************************/
44 typedef struct utf utf;
47 #include "vm/global.h"
50 /* data structure for utf8 symbols ********************************************/
53 utf *hashlink; /* link for external hash chain */
54 s4 blength; /* text length in bytes */
55 char *text; /* pointer to text */
58 /* to determine the end of utf strings */
60 #define UTF_END(u) ((char *) u->text + u->blength)
63 /* utf-symbols for pointer comparison of frequently used strings **************/
65 extern utf *utf_java_lang_Object;
67 extern utf *utf_java_lang_Class;
68 extern utf *utf_java_lang_ClassLoader;
69 extern utf *utf_java_lang_Cloneable;
70 extern utf *utf_java_lang_SecurityManager;
71 extern utf *utf_java_lang_String;
72 extern utf *utf_java_lang_System;
73 extern utf *utf_java_lang_ThreadGroup;
74 extern utf *utf_java_io_Serializable;
76 extern utf *utf_java_lang_Throwable;
77 extern utf *utf_java_lang_Error;
78 extern utf *utf_java_lang_LinkageError;
79 extern utf *utf_java_lang_NoClassDefFoundError;
80 extern utf *utf_java_lang_OutOfMemoryError;
81 extern utf *utf_java_lang_VirtualMachineError;
83 #if defined(ENABLE_JAVASE)
84 extern utf *utf_java_lang_AbstractMethodError;
85 extern utf *utf_java_lang_NoSuchMethodError;
88 #if defined(WITH_CLASSPATH_GNU)
89 extern utf *utf_java_lang_VMThrowable;
92 extern utf *utf_java_lang_Exception;
93 extern utf *utf_java_lang_ClassCastException;
94 extern utf *utf_java_lang_ClassNotFoundException;
95 extern utf *utf_java_lang_IllegalArgumentException;
96 extern utf *utf_java_lang_IllegalMonitorStateException;
98 extern utf *utf_java_lang_NullPointerException;
100 #if defined(ENABLE_JAVASE)
101 extern utf* utf_java_lang_Void;
104 extern utf* utf_java_lang_Boolean;
105 extern utf* utf_java_lang_Byte;
106 extern utf* utf_java_lang_Character;
107 extern utf* utf_java_lang_Short;
108 extern utf* utf_java_lang_Integer;
109 extern utf* utf_java_lang_Long;
110 extern utf* utf_java_lang_Float;
111 extern utf* utf_java_lang_Double;
113 #if defined(ENABLE_JAVASE)
114 extern utf *utf_java_lang_StackTraceElement;
115 extern utf *utf_java_lang_reflect_Constructor;
116 extern utf *utf_java_lang_reflect_Field;
117 extern utf *utf_java_lang_reflect_Method;
118 extern utf *utf_java_util_Vector;
121 extern utf *utf_InnerClasses;
122 extern utf *utf_ConstantValue;
123 extern utf *utf_Code;
124 extern utf *utf_Exceptions;
125 extern utf *utf_LineNumberTable;
126 extern utf *utf_SourceFile;
128 #if defined(ENABLE_JAVASE)
129 extern utf *utf_EnclosingMethod;
130 extern utf *utf_Signature;
131 extern utf *utf_RuntimeVisibleAnnotations;
132 extern utf *utf_StackMapTable;
135 extern utf *utf_init;
136 extern utf *utf_clinit;
137 extern utf *utf_clone;
138 extern utf *utf_finalize;
142 extern utf *utf_remove;
143 extern utf *utf_addThread;
144 extern utf *utf_removeThread;
147 extern utf *utf_value;
149 extern utf *utf_fillInStackTrace;
150 extern utf *utf_getSystemClassLoader;
151 extern utf *utf_loadClass;
152 extern utf *utf_printStackTrace;
163 extern utf *utf_void__void;
164 extern utf *utf_boolean__void;
165 extern utf *utf_byte__void;
166 extern utf *utf_char__void;
167 extern utf *utf_short__void;
168 extern utf *utf_int__void;
169 extern utf *utf_long__void;
170 extern utf *utf_float__void;
171 extern utf *utf_double__void;
173 extern utf *utf_void__java_lang_ClassLoader;
174 extern utf *utf_void__java_lang_Object;
175 extern utf *utf_void__java_lang_Throwable;
176 extern utf *utf_java_lang_Object__java_lang_Object;
177 extern utf *utf_java_lang_String__void;
178 extern utf *utf_java_lang_String__java_lang_Class;
179 extern utf *utf_java_lang_Thread__V;
180 extern utf *utf_java_lang_Throwable__void;
182 extern utf *utf_not_named_yet;
183 extern utf *utf_null;
184 extern utf *array_packagename;
187 /* function prototypes ********************************************************/
189 /* initialize the utf8 subsystem */
190 bool utf8_init(void);
192 u4 utf_hashkey(const char *text, u4 length);
193 u4 utf_full_hashkey(const char *text, u4 length);
195 /* determine hashkey of a unicode-symbol */
196 u4 unicode_hashkey(u2 *text, u2 length);
198 /* create new utf-symbol */
199 utf *utf_new(const char *text, u2 length);
201 /* make utf symbol from u2 array */
202 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
204 utf *utf_new_char(const char *text);
205 utf *utf_new_char_classname(const char *text);
207 /* get number of bytes */
208 u4 utf_bytes(utf *u);
210 /* get next unicode character of a utf-string */
211 u2 utf_nextu2(char **utf);
213 /* get (number of) unicode characters of a utf string (safe) */
214 s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes);
215 void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer);
217 /* get (number of) unicode characters of a utf string (UNSAFE!) */
218 u4 utf_get_number_of_u2s(utf *u);
219 u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength);
221 /* determine utf length in bytes of a u2 array */
222 u4 u2_utflength(u2 *text, u4 u2_length);
224 void utf_copy(char *buffer, utf *u);
225 void utf_cat(char *buffer, utf *u);
226 void utf_copy_classname(char *buffer, utf *u);
227 void utf_cat_classname(char *buffer, utf *u);
229 /* write utf symbol to file/buffer */
230 void utf_display_printable_ascii(utf *u);
231 void utf_display_printable_ascii_classname(utf *u);
233 void utf_sprint_convert_to_latin1(char *buffer, utf *u);
234 void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u);
236 void utf_strcat_convert_to_latin1(char *buffer, utf *u);
237 void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u);
239 void utf_fprint_printable_ascii(FILE *file, utf *u);
240 void utf_fprint_printable_ascii_classname(FILE *file, utf *u);
242 /* check if a UTF-8 string is valid */
243 bool is_valid_utf(char *utf_ptr, char *end_pos);
245 /* check if a UTF-8 string may be used as a class/field/method name */
246 bool is_valid_name(char *utf_ptr, char *end_pos);
247 bool is_valid_name_utf(utf *u);
256 * These are local overrides for various environment variables in Emacs.
257 * Please do not remove this and leave it at the end of the file, where
258 * Emacs will automagically detect them.
259 * ---------------------------------------------------------------------
262 * indent-tabs-mode: t
266 * vim:noexpandtab:sw=4:ts=4: