1 /* src/vm/utf.h - utf string header
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: utf8.h 3541 2005-11-03 20:33:51Z 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 int 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_VMThrowable;
78 extern utf *utf_java_lang_Error;
79 extern utf *utf_java_lang_NoClassDefFoundError;
80 extern utf *utf_java_lang_OutOfMemoryError;
82 extern utf *utf_java_lang_Exception;
83 extern utf *utf_java_lang_ClassNotFoundException;
84 extern utf *utf_java_lang_IllegalArgumentException;
85 extern utf *utf_java_lang_IllegalMonitorStateException;
87 extern utf *utf_java_lang_NullPointerException;
89 extern utf* utf_java_lang_Void;
90 extern utf* utf_java_lang_Boolean;
91 extern utf* utf_java_lang_Byte;
92 extern utf* utf_java_lang_Character;
93 extern utf* utf_java_lang_Short;
94 extern utf* utf_java_lang_Integer;
95 extern utf* utf_java_lang_Long;
96 extern utf* utf_java_lang_Float;
97 extern utf* utf_java_lang_Double;
99 extern utf *utf_java_lang_StackTraceElement;
100 extern utf *utf_java_lang_reflect_Constructor;
101 extern utf *utf_java_lang_reflect_Field;
102 extern utf *utf_java_lang_reflect_Method;
103 extern utf *utf_java_util_Vector;
106 extern utf *utf_InnerClasses;
107 extern utf *utf_ConstantValue;
108 extern utf *utf_Code;
109 extern utf *utf_Exceptions;
110 extern utf *utf_LineNumberTable;
111 extern utf *utf_SourceFile;
113 extern utf *utf_init;
114 extern utf *utf_clinit;
115 extern utf *utf_clone;
116 extern utf *utf_finalize;
120 extern utf *utf_remove;
123 extern utf *utf_value;
125 extern utf *utf_fillInStackTrace;
126 extern utf *utf_getSystemClassLoader;
127 extern utf *utf_loadClass;
128 extern utf *utf_printStackTrace;
139 extern utf *utf_void__void;
140 extern utf *utf_boolean__void;
141 extern utf *utf_byte__void;
142 extern utf *utf_char__void;
143 extern utf *utf_short__void;
144 extern utf *utf_int__void;
145 extern utf *utf_long__void;
146 extern utf *utf_float__void;
147 extern utf *utf_double__void;
149 extern utf *utf_void__java_lang_ClassLoader;
150 extern utf *utf_void__java_lang_Object;
151 extern utf *utf_void__java_lang_Throwable;
152 extern utf *utf_java_lang_Object__java_lang_Object;
153 extern utf *utf_java_lang_String__void;
154 extern utf *utf_java_lang_String__java_lang_Class;
155 extern utf *utf_java_lang_Throwable__void;
157 extern utf *utf_not_named_yet;
159 extern utf *array_packagename;
162 /* function prototypes ********************************************************/
164 void utf8_init(void);
166 u4 utf_hashkey(const char *text, u4 length);
168 /* determine hashkey of a unicode-symbol */
169 u4 unicode_hashkey(u2 *text, u2 length);
171 /* create new utf-symbol */
172 utf *utf_new(const char *text, u2 length);
174 /* without locking (caller already holding lock*/
175 utf *utf_new_intern(const char *text, u2 length);
177 /* make utf symbol from u2 array */
178 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
180 utf *utf_new_char(const char *text);
181 utf *utf_new_char_classname(const char *text);
183 /* get next unicode character of a utf-string */
184 u2 utf_nextu2(char **utf);
186 /* get number of unicode characters of a utf string */
187 u4 utf_strlen(utf *u);
189 /* determine utf length in bytes of a u2 array */
190 u4 u2_utflength(u2 *text, u4 u2_length);
192 /* write utf symbol to file/buffer */
193 void utf_display(utf *u);
194 void utf_display_classname(utf *u);
196 void utf_sprint(char *buffer, utf *u);
197 void utf_sprint_classname(char *buffer, utf *u);
199 void utf_strcat(char *buffer, utf *u);
200 void utf_strcat_classname(char *buffer, utf *u);
202 void utf_fprint(FILE *file, utf *u);
203 void utf_fprint_classname(FILE *file, utf *u);
205 /* check if a UTF-8 string is valid */
206 bool is_valid_utf(char *utf_ptr, char *end_pos);
208 /* check if a UTF-8 string may be used as a class/field/method name */
209 bool is_valid_name(char *utf_ptr, char *end_pos);
210 bool is_valid_name_utf(utf *u);
219 * These are local overrides for various environment variables in Emacs.
220 * Please do not remove this and leave it at the end of the file, where
221 * Emacs will automagically detect them.
222 * ---------------------------------------------------------------------
225 * indent-tabs-mode: t