* src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Fixed
[cacao.git] / src / vm / utf8.h
1 /* src/vm/utf8.h - utf8 string functions
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes: Edwin Steiner
30
31    $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $
32
33 */
34
35
36 #ifndef _UTF_H
37 #define _UTF_H
38
39 #include "config.h"
40
41 #include <stdio.h>
42
43 /* forward typedefs ***********************************************************/
44
45 typedef struct utf utf;
46
47 #include "vm/types.h"
48 #include "vm/global.h"
49
50
51 /* data structure for utf8 symbols ********************************************/
52
53 struct utf {
54         utf  *hashlink;                     /* link for external hash chain       */
55         s4    blength;                      /* text length in bytes               */
56         char *text;                         /* pointer to text                    */
57 };
58
59 /* to determine the end of utf strings */
60
61 #define UTF_END(u)    ((char *) u->text + u->blength)
62
63
64 /* utf-symbols for pointer comparison of frequently used strings **************/
65
66 extern utf *utf_java_lang_Object;
67
68 extern utf *utf_java_lang_Class;
69 extern utf *utf_java_lang_ClassLoader;
70 extern utf *utf_java_lang_Cloneable;
71 extern utf *utf_java_lang_SecurityManager;
72 extern utf *utf_java_lang_String;
73 extern utf *utf_java_lang_System;
74 extern utf *utf_java_lang_ThreadGroup;
75 extern utf *utf_java_io_Serializable;
76
77 extern utf *utf_java_lang_Throwable;
78 extern utf *utf_java_lang_VMThrowable;
79 extern utf *utf_java_lang_Error;
80 extern utf *utf_java_lang_AbstractMethodError;
81 extern utf *utf_java_lang_LinkageError;
82 extern utf *utf_java_lang_NoClassDefFoundError;
83 extern utf *utf_java_lang_NoSuchMethodError;
84 extern utf *utf_java_lang_OutOfMemoryError;
85
86 extern utf *utf_java_lang_Exception;
87 extern utf *utf_java_lang_ClassCastException;
88 extern utf *utf_java_lang_ClassNotFoundException;
89 extern utf *utf_java_lang_IllegalArgumentException;
90 extern utf *utf_java_lang_IllegalMonitorStateException;
91
92 extern utf *utf_java_lang_NullPointerException;
93
94 extern utf* utf_java_lang_Void;
95 extern utf* utf_java_lang_Boolean;
96 extern utf* utf_java_lang_Byte;
97 extern utf* utf_java_lang_Character;
98 extern utf* utf_java_lang_Short;
99 extern utf* utf_java_lang_Integer;
100 extern utf* utf_java_lang_Long;
101 extern utf* utf_java_lang_Float;
102 extern utf* utf_java_lang_Double;
103
104 extern utf *utf_java_lang_StackTraceElement;
105 extern utf *utf_java_lang_reflect_Constructor;
106 extern utf *utf_java_lang_reflect_Field;
107 extern utf *utf_java_lang_reflect_Method;
108 extern utf *utf_java_util_Vector;
109
110
111 extern utf *utf_InnerClasses;
112 extern utf *utf_ConstantValue;
113 extern utf *utf_Code;
114 extern utf *utf_Exceptions;
115 extern utf *utf_LineNumberTable;
116 extern utf *utf_SourceFile;
117 extern utf *utf_Signature;
118
119 extern utf *utf_init;
120 extern utf *utf_clinit;
121 extern utf *utf_clone;
122 extern utf *utf_finalize;
123 extern utf *utf_run;
124
125 extern utf *utf_add;
126 extern utf *utf_remove;
127 extern utf *utf_removeThread;
128 extern utf *utf_put;
129 extern utf *utf_get;
130 extern utf *utf_value;
131
132 extern utf *utf_fillInStackTrace;
133 extern utf *utf_getSystemClassLoader;
134 extern utf *utf_loadClass;
135 extern utf *utf_printStackTrace;
136
137 extern utf *utf_Z;
138 extern utf *utf_B;
139 extern utf *utf_C;
140 extern utf *utf_S;
141 extern utf *utf_I;
142 extern utf *utf_J;
143 extern utf *utf_F;
144 extern utf *utf_D;
145
146 extern utf *utf_void__void;
147 extern utf *utf_boolean__void;
148 extern utf *utf_byte__void;
149 extern utf *utf_char__void;
150 extern utf *utf_short__void;
151 extern utf *utf_int__void;
152 extern utf *utf_long__void;
153 extern utf *utf_float__void;
154 extern utf *utf_double__void;
155
156 extern utf *utf_void__java_lang_ClassLoader;
157 extern utf *utf_void__java_lang_Object;
158 extern utf *utf_void__java_lang_Throwable;
159 extern utf *utf_java_lang_Object__java_lang_Object;
160 extern utf *utf_java_lang_String__void;
161 extern utf *utf_java_lang_String__java_lang_Class;
162 extern utf *utf_java_lang_Thread__V;
163 extern utf *utf_java_lang_Throwable__void;
164
165 extern utf *utf_not_named_yet;
166 extern utf *utf_null;
167 extern utf *array_packagename;
168
169
170 /* function prototypes ********************************************************/
171
172 /* initialize the utf8 subsystem */
173 bool utf8_init(void);
174
175 u4 utf_hashkey(const char *text, u4 length);
176 u4 utf_full_hashkey(const char *text, u4 length);
177
178 /* determine hashkey of a unicode-symbol */
179 u4 unicode_hashkey(u2 *text, u2 length);
180
181 /* create new utf-symbol */
182 utf *utf_new(const char *text, u2 length);
183
184 /* make utf symbol from u2 array */
185 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
186
187 utf *utf_new_char(const char *text);
188 utf *utf_new_char_classname(const char *text);
189
190 /* get number of bytes */
191 u4 utf_bytes(utf *u);
192
193 /* get next unicode character of a utf-string */
194 u2 utf_nextu2(char **utf);
195
196 /* get (number of) unicode characters of a utf string (safe) */
197 s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes);
198 void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer);
199
200 /* get (number of) unicode characters of a utf string (UNSAFE!) */
201 u4 utf_get_number_of_u2s(utf *u);
202 u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength);
203
204 /* determine utf length in bytes of a u2 array */
205 u4 u2_utflength(u2 *text, u4 u2_length);
206
207 void utf_copy(char *buffer, utf *u);
208 void utf_cat(char *buffer, utf *u);
209 void utf_copy_classname(char *buffer, utf *u);
210 void utf_cat_classname(char *buffer, utf *u);
211
212 /* write utf symbol to file/buffer */
213 void utf_display_printable_ascii(utf *u);
214 void utf_display_printable_ascii_classname(utf *u);
215
216 void utf_sprint_convert_to_latin1(char *buffer, utf *u);
217 void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u);
218
219 void utf_strcat_convert_to_latin1(char *buffer, utf *u);
220 void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u);
221
222 void utf_fprint_printable_ascii(FILE *file, utf *u);
223 void utf_fprint_printable_ascii_classname(FILE *file, utf *u);
224
225 /* check if a UTF-8 string is valid */
226 bool is_valid_utf(char *utf_ptr, char *end_pos);
227
228 /* check if a UTF-8 string may be used as a class/field/method name */
229 bool is_valid_name(char *utf_ptr, char *end_pos);
230 bool is_valid_name_utf(utf *u);
231
232 /* show utf-table */
233 void utf_show(void);
234
235 #endif /* _UTF_H */
236
237
238 /*
239  * These are local overrides for various environment variables in Emacs.
240  * Please do not remove this and leave it at the end of the file, where
241  * Emacs will automagically detect them.
242  * ---------------------------------------------------------------------
243  * Local variables:
244  * mode: c
245  * indent-tabs-mode: t
246  * c-basic-offset: 4
247  * tab-width: 4
248  * End:
249  * vim:noexpandtab:sw=4:ts=4:
250  */