* Moved all files from vmcore/ to vm/.
[cacao.git] / src / vm / string.hpp
1 /* src/vm/string.hpp - string header
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _STRINGLOCAL_H
27 #define _STRINGLOCAL_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 typedef struct literalstring literalstring;
34
35
36 #include "config.h"
37
38 #include "vm/types.h"
39
40 #include "toolbox/hashtable.h"
41
42 #include "vm/global.h"
43 #include "vm/os.hpp"
44 #include "vm/utf8.h"
45
46
47 /* data structure of internal javastrings stored in global hashtable **********/
48
49 struct literalstring {
50         literalstring     *hashlink;        /* link for external hash chain       */
51         java_object_t     *string;  
52 };
53
54
55 /* javastring-hashtable */
56 extern hashtable hashtable_string;
57
58
59 /* function prototypes ********************************************************/
60
61 /* initialize string subsystem */
62 bool string_init(void);
63
64 void stringtable_update(void);
65
66 /* creates a new object of type java/lang/String from a utf-text */
67 java_handle_t *javastring_new(utf *text);
68
69 /* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */
70 java_handle_t *javastring_new_slash_to_dot(utf *text);
71
72 /* creates a new object of type java/lang/String from an ASCII c-string */
73 java_handle_t *javastring_new_from_ascii(const char *text);
74
75 /* creates a new object of type java/lang/String from UTF-8 */
76 java_handle_t *javastring_new_from_utf_string(const char *utfstr);
77
78 /* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */
79 java_handle_t *javastring_safe_new_from_utf8(const char *text);
80
81 /* make c-string from a javastring (debugging) */
82 char *javastring_tochar(java_handle_t *string);
83
84 /* make utf symbol from javastring */
85 utf *javastring_toutf(java_handle_t *string, bool isclassname);
86
87 /* creates a new javastring with the text of the utf-symbol */
88 java_object_t *literalstring_new(utf *u);
89
90 java_handle_t *javastring_intern(java_handle_t *s);
91 void           javastring_fprint(java_handle_t *s, FILE *stream);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* _STRINGLOCAL_H */
98
99
100 /*
101  * These are local overrides for various environment variables in Emacs.
102  * Please do not remove this and leave it at the end of the file, where
103  * Emacs will automagically detect them.
104  * ---------------------------------------------------------------------
105  * Local variables:
106  * mode: c
107  * indent-tabs-mode: t
108  * c-basic-offset: 4
109  * tab-width: 4
110  * End:
111  * vim:noexpandtab:sw=4:ts=4:
112  */