* fixed compiler warning for arm (dseg_adds8 is not used)
[cacao.git] / src / vm / utf8.h
1 /* src/vm/utf.h - utf string header
2
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
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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: utf8.h 2741 2005-06-20 09:57:14Z twisti $
32
33 */
34
35
36 #ifndef _UTF_H
37 #define _UTF_H
38
39 #include <stdio.h>
40
41
42 /* forward typedefs ***********************************************************/
43
44 typedef struct utf utf;
45
46
47 #include "vm/global.h"
48
49
50 /* data structure for utf8 symbols ********************************************/
51
52 struct utf {
53         utf  *hashlink;                     /* link for external hash chain       */
54         int   blength;                      /* text length in bytes               */
55         char *text;                         /* pointer to text                    */
56 };
57
58 /* to determine the end of utf strings */
59
60 #define UTF_END(u)    ((char *) u->text + u->blength)
61
62
63 /* utf-symbols for pointer comparison of frequently used strings **************/
64
65 extern utf *utf_java_lang_Object;
66
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;
75
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_Exception;
80 extern utf *utf_java_lang_NoClassDefFoundError;
81 extern utf *utf_java_lang_OutOfMemoryError;
82 extern utf *utf_java_lang_ClassNotFoundException;
83
84 extern utf* utf_java_lang_Void;
85 extern utf* utf_java_lang_Boolean;
86 extern utf* utf_java_lang_Byte;
87 extern utf* utf_java_lang_Character;
88 extern utf* utf_java_lang_Short;
89 extern utf* utf_java_lang_Integer;
90 extern utf* utf_java_lang_Long;
91 extern utf* utf_java_lang_Float;
92 extern utf* utf_java_lang_Double;
93
94 extern utf *utf_java_lang_StackTraceElement;
95 extern utf *utf_java_lang_reflect_Constructor;
96 extern utf *utf_java_lang_reflect_Field;
97 extern utf *utf_java_lang_reflect_Method;
98 extern utf *utf_java_util_Vector;
99
100
101 extern utf *utf_InnerClasses;
102 extern utf *utf_ConstantValue;
103 extern utf *utf_Code;
104 extern utf *utf_Exceptions;
105 extern utf *utf_LineNumberTable;
106 extern utf *utf_SourceFile;
107
108 extern utf *utf_init;
109 extern utf *utf_clinit;
110 extern utf *utf_clone;
111 extern utf *utf_finalize;
112 extern utf *utf_run;
113
114 extern utf *utf_fillInStackTrace;
115 extern utf *utf_getSystemClassLoader;
116 extern utf *utf_loadClass;
117 extern utf *utf_printStackTrace;
118
119 extern utf *utf_void__void;
120 extern utf *utf_boolean__void;
121 extern utf *utf_byte__void;
122 extern utf *utf_char__void;
123 extern utf *utf_short__void;
124 extern utf *utf_int__void;
125 extern utf *utf_long__void;
126 extern utf *utf_float__void;
127 extern utf *utf_double__void;
128
129 extern utf *utf_void__java_lang_ClassLoader;
130 extern utf *utf_void__java_lang_Object;
131 extern utf *utf_void__java_lang_Throwable;
132 extern utf *utf_java_lang_String__void;
133 extern utf *utf_java_lang_String__java_lang_Class;
134 extern utf *utf_java_lang_Throwable__void;
135
136 extern utf *utf_not_named_yet;
137
138 extern utf *array_packagename;
139
140
141 /* function prototypes ********************************************************/
142
143 void utf8_init(void);
144
145 u4 utf_hashkey(const char *text, u4 length);
146
147 /* determine hashkey of a unicode-symbol */
148 u4 unicode_hashkey(u2 *text, u2 length);
149
150 /* create new utf-symbol */
151 utf *utf_new(const char *text, u2 length);
152
153 /* without locking (caller already holding lock*/
154 utf *utf_new_intern(const char *text, u2 length);
155
156 /* make utf symbol from u2 array */
157 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
158
159 utf *utf_new_char(const char *text);
160 utf *utf_new_char_classname(const char *text);
161
162 /* get next unicode character of a utf-string */
163 u2 utf_nextu2(char **utf);
164
165 /* get number of unicode characters of a utf string */
166 u4 utf_strlen(utf *u);
167
168 /* determine utf length in bytes of a u2 array */
169 u4 u2_utflength(u2 *text, u4 u2_length);
170
171 /* write utf symbol to file/buffer */
172 void utf_display(utf *u);
173 void utf_display_classname(utf *u);
174
175 void utf_sprint(char *buffer, utf *u);
176 void utf_sprint_classname(char *buffer, utf *u);
177
178 void utf_strcat(char *buffer, utf *u);
179 void utf_strcat_classname(char *buffer, utf *u);
180
181 void utf_fprint(FILE *file, utf *u);
182 void utf_fprint_classname(FILE *file, utf *u);
183
184 /* check if a UTF-8 string is valid */
185 bool is_valid_utf(char *utf_ptr, char *end_pos);
186
187 /* check if a UTF-8 string may be used as a class/field/method name */
188 bool is_valid_name(char *utf_ptr, char *end_pos);
189 bool is_valid_name_utf(utf *u);
190
191 /* show utf-table */
192 void utf_show(void);
193
194 #endif /* _UTF_H */
195
196
197 /*
198  * These are local overrides for various environment variables in Emacs.
199  * Please do not remove this and leave it at the end of the file, where
200  * Emacs will automagically detect them.
201  * ---------------------------------------------------------------------
202  * Local variables:
203  * mode: c
204  * indent-tabs-mode: t
205  * c-basic-offset: 4
206  * tab-width: 4
207  * End:
208  */