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 2136 2005-03-30 10:03:03Z twisti $
42 /* forward typedefs ***********************************************************/
44 typedef struct utf utf;
48 #include "vm/global.h"
51 /* data structure for utf8 symbols ********************************************/
54 utf *hashlink; /* link for external hash chain */
55 int blength; /* text length in bytes */
56 char *text; /* pointer to text */
60 /* utf-symbols for pointer comparison of frequently used strings **************/
62 extern utf *utf_java_lang_Object;
64 extern utf *utf_java_lang_Class;
65 extern utf *utf_java_lang_ClassLoader;
66 extern utf *utf_java_lang_Cloneable;
67 extern utf *utf_java_lang_SecurityManager;
68 extern utf *utf_java_lang_String;
69 extern utf *utf_java_lang_System;
70 extern utf *utf_java_io_Serializable;
72 extern utf *utf_java_lang_Throwable;
73 extern utf *utf_java_lang_VMThrowable;
74 extern utf *utf_java_lang_Exception;
75 extern utf *utf_java_lang_Error;
76 extern utf *utf_java_lang_OutOfMemoryError;
78 extern utf* utf_java_lang_Void;
79 extern utf* utf_java_lang_Boolean;
80 extern utf* utf_java_lang_Byte;
81 extern utf* utf_java_lang_Character;
82 extern utf* utf_java_lang_Short;
83 extern utf* utf_java_lang_Integer;
84 extern utf* utf_java_lang_Long;
85 extern utf* utf_java_lang_Float;
86 extern utf* utf_java_lang_Double;
88 extern utf *utf_java_util_Vector;
90 extern utf *utf_InnerClasses;
91 extern utf *utf_ConstantValue;
93 extern utf *utf_Exceptions;
94 extern utf *utf_LineNumberTable;
95 extern utf *utf_SourceFile;
98 extern utf *utf_clinit;
99 extern utf *utf_finalize;
101 extern utf *utf_printStackTrace;
102 extern utf *utf_fillInStackTrace;
103 extern utf *utf_loadClass;
105 extern utf *utf_void__void;
106 extern utf *utf_boolean__void;
107 extern utf *utf_byte__void;
108 extern utf *utf_char__void;
109 extern utf *utf_short__void;
110 extern utf *utf_int__void;
111 extern utf *utf_long__void;
112 extern utf *utf_float__void;
113 extern utf *utf_double__void;
114 extern utf *utf_void__java_lang_Throwable;
115 extern utf *utf_java_lang_String__void;
116 extern utf *utf_java_lang_String__java_lang_Class;
117 extern utf *utf_java_lang_Throwable__void;
119 extern utf *array_packagename;
122 /* function prototypes ********************************************************/
124 void utf8_init(void);
126 u4 utf_hashkey(const char *text, u4 length);
128 /* determine hashkey of a unicode-symbol */
129 u4 unicode_hashkey(u2 *text, u2 length);
131 /* create new utf-symbol */
132 utf *utf_new(const char *text, u2 length);
134 /* without locking (caller already holding lock*/
135 utf *utf_new_intern(const char *text, u2 length);
137 /* make utf symbol from u2 array */
138 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
140 utf *utf_new_char(const char *text);
141 utf *utf_new_char_classname(const char *text);
143 /* get next unicode character of a utf-string */
144 u2 utf_nextu2(char **utf);
146 /* get number of unicode characters of a utf string */
147 u4 utf_strlen(utf *u);
149 /* determine utf length in bytes of a u2 array */
150 u4 u2_utflength(u2 *text, u4 u2_length);
152 /* write utf symbol to file/buffer */
153 void utf_display(utf *u);
154 void utf_display_classname(utf *u);
156 void utf_sprint(char *buffer, utf *u);
157 void utf_sprint_classname(char *buffer, utf *u);
159 void utf_strcat(char *buffer, utf *u);
160 void utf_strcat_classname(char *buffer, utf *u);
162 void utf_fprint(FILE *file, utf *u);
163 void utf_fprint_classname(FILE *file, utf *u);
165 /* check if a UTF-8 string is valid */
166 bool is_valid_utf(char *utf_ptr, char *end_pos);
168 /* check if a UTF-8 string may be used as a class/field/method name */
169 bool is_valid_name(char *utf_ptr, char *end_pos);
170 bool is_valid_name_utf(utf *u);
179 * These are local overrides for various environment variables in Emacs.
180 * Please do not remove this and leave it at the end of the file, where
181 * Emacs will automagically detect them.
182 * ---------------------------------------------------------------------
185 * indent-tabs-mode: t