fbfea8adc90e465674aefbceabcf1c41434c7f7e
[cacao.git] / src / vm / stringlocal.h
1 /* src/vm/stringlocal.h - string header
2
3    Copyright (C) 1996-2005, 2006, 2007 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    $Id: stringlocal.h 8357 2007-08-19 22:59:43Z twisti $
26
27 */
28
29
30 #ifndef _STRINGLOCAL_H
31 #define _STRINGLOCAL_H
32
33 typedef struct literalstring literalstring;
34
35
36 #include "config.h"
37 #include "vm/types.h"
38
39 #include "toolbox/hashtable.h"
40
41 #include "vm/global.h"
42
43 #include "vmcore/utf8.h"
44
45
46 /* data structure of internal javastrings stored in global hashtable **********/
47
48 struct literalstring {
49         literalstring     *hashlink;        /* link for external hash chain       */
50         java_object_t     *string;  
51 };
52
53
54 /* javastring-hashtable */
55 extern hashtable hashtable_string;
56
57
58 /* function prototypes ********************************************************/
59
60 /* initialize string subsystem */
61 bool string_init(void);
62
63 void stringtable_update(void);
64
65 /* creates a new object of type java/lang/String from a utf-text */
66 java_handle_t *javastring_new(utf *text);
67
68 /* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */
69 java_handle_t *javastring_new_slash_to_dot(utf *text);
70
71 /* creates a new object of type java/lang/String from an ASCII c-string */
72 java_handle_t *javastring_new_from_ascii(const char *text);
73
74 /* creates a new object of type java/lang/String from UTF-8 */
75 java_handle_t *javastring_new_from_utf_string(const char *utfstr);
76
77 /* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */
78 java_handle_t *javastring_safe_new_from_utf8(const char *text);
79
80 /* make c-string from a javastring (debugging) */
81 char *javastring_tochar(java_handle_t *string);
82
83 /* make utf symbol from javastring */
84 utf *javastring_toutf(java_handle_t *string, bool isclassname);
85
86 /* creates a new javastring with the text of the u2-array */
87 java_object_t *literalstring_u2(java_chararray_t *a, u4 length, u4 offset,
88                                                                 bool copymode);
89
90 /* creates a new javastring with the text of the utf-symbol */
91 java_object_t *literalstring_new(utf *u);
92
93 /* dispose a javastring */
94 void literalstring_free(java_object_t*);
95
96 java_handle_t *javastring_intern(java_handle_t *s);
97 void           javastring_print(java_handle_t *s);
98
99 #endif /* _STRINGLOCAL_H */
100
101
102 /*
103  * These are local overrides for various environment variables in Emacs.
104  * Please do not remove this and leave it at the end of the file, where
105  * Emacs will automagically detect them.
106  * ---------------------------------------------------------------------
107  * Local variables:
108  * mode: c
109  * indent-tabs-mode: t
110  * c-basic-offset: 4
111  * tab-width: 4
112  * End:
113  * vim:noexpandtab:sw=4:ts=4:
114  */