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 2061 2005-03-23 11:10:33Z twisti $
39 typedef struct utf utf;
43 #include "vm/global.h"
46 /* utf-symbols for pointer comparison of frequently used strings **************/
48 extern utf *utf_java_lang_Object;
50 extern utf *utf_java_lang_Class;
51 extern utf *utf_java_lang_ClassLoader;
52 extern utf *utf_java_lang_Cloneable;
53 extern utf *utf_java_lang_SecurityManager;
54 extern utf *utf_java_lang_String;
55 extern utf *utf_java_lang_System;
56 extern utf *utf_java_io_Serializable;
58 extern utf *utf_java_lang_Throwable;
59 extern utf *utf_java_lang_VMThrowable;
60 extern utf *utf_java_lang_Exception;
61 extern utf *utf_java_lang_Error;
62 extern utf *utf_java_lang_OutOfMemoryError;
64 extern utf* utf_java_lang_Void;
65 extern utf* utf_java_lang_Boolean;
66 extern utf* utf_java_lang_Byte;
67 extern utf* utf_java_lang_Character;
68 extern utf* utf_java_lang_Short;
69 extern utf* utf_java_lang_Integer;
70 extern utf* utf_java_lang_Long;
71 extern utf* utf_java_lang_Float;
72 extern utf* utf_java_lang_Double;
74 extern utf *utf_java_util_Vector;
76 extern utf *utf_InnerClasses;
77 extern utf *utf_ConstantValue;
79 extern utf *utf_Exceptions;
80 extern utf *utf_LineNumberTable;
81 extern utf *utf_SourceFile;
84 extern utf *utf_clinit;
85 extern utf *utf_finalize;
87 extern utf *utf_printStackTrace;
88 extern utf *utf_fillInStackTrace;
89 extern utf *utf_loadClass;
91 extern utf *utf_void__void;
92 extern utf *utf_boolean__void;
93 extern utf *utf_byte__void;
94 extern utf *utf_char__void;
95 extern utf *utf_short__void;
96 extern utf *utf_int__void;
97 extern utf *utf_long__void;
98 extern utf *utf_float__void;
99 extern utf *utf_double__void;
100 extern utf *utf_void__java_lang_Throwable;
101 extern utf *utf_java_lang_String__void;
102 extern utf *utf_java_lang_String__java_lang_Class;
103 extern utf *utf_java_lang_Throwable__void;
105 extern utf* utf_java_lang_Character;
106 extern utf* utf_java_lang_Boolean;
107 extern utf* utf_java_lang_Byte;
108 extern utf* utf_java_lang_Short;
109 extern utf* utf_java_lang_Integer;
110 extern utf* utf_java_lang_Long;
111 extern utf* utf_java_lang_Float;
112 extern utf* utf_java_lang_Double;
115 /* data structure for utf8 symbols ********************************************/
118 utf *hashlink; /* link for external hash chain */
119 int blength; /* text length in bytes */
120 char *text; /* pointer to text */
123 /* function prototypes ********************************************************/
125 void utf8_init(void);
127 u4 utf_hashkey(const char *text, u4 length);
129 /* determine hashkey of a unicode-symbol */
130 u4 unicode_hashkey(u2 *text, u2 length);
132 /* create new utf-symbol */
133 utf *utf_new(const char *text, u2 length);
135 /* without locking (caller already holding lock*/
136 utf *utf_new_intern(const char *text, u2 length);
138 /* make utf symbol from u2 array */
139 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
141 utf *utf_new_char(const char *text);
142 utf *utf_new_char_classname(const char *text);
144 /* get next unicode character of a utf-string */
145 u2 utf_nextu2(char **utf);
147 /* get number of unicode characters of a utf string */
148 u4 utf_strlen(utf *u);
150 /* determine utf length in bytes of a u2 array */
151 u4 u2_utflength(u2 *text, u4 u2_length);
153 /* write utf symbol to file/buffer */
154 void utf_display(utf *u);
155 void utf_display_classname(utf *u);
156 void utf_sprint(char *buffer, utf *u);
157 void utf_sprint_classname(char *buffer, utf *u);
158 void utf_fprint(FILE *file, utf *u);
159 void utf_fprint_classname(FILE *file, utf *u);
161 /* check if a UTF-8 string is valid */
162 bool is_valid_utf(char *utf_ptr, char *end_pos);
164 /* check if a UTF-8 string may be used as a class/field/method name */
165 bool is_valid_name(char *utf_ptr, char *end_pos);
166 bool is_valid_name_utf(utf *u);
175 * These are local overrides for various environment variables in Emacs.
176 * Please do not remove this and leave it at the end of the file, where
177 * Emacs will automagically detect them.
178 * ---------------------------------------------------------------------
181 * indent-tabs-mode: t