Added proper header includes.
[cacao.git] / src / native / native.h
1 /* src/native/native.h - table of native functions
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: Reinhard Grafl
28
29    Changes: Christian Thalinger
30
31    $Id: native.h 2139 2005-03-30 10:24:10Z twisti $
32
33 */
34
35
36 #ifndef _NATIVE_H
37 #define _NATIVE_H
38
39 #include "vm/class.h"
40 #include "vm/global.h"
41 #include "vm/method.h"
42 #include "vm/utf8.h"
43 #include "native/jni.h"
44 #include "native/include/java_lang_String.h"
45 #include "native/include/java_lang_ClassLoader.h"
46 #include "native/include/java_lang_Throwable.h"
47
48
49 /* table for locating native methods */
50
51 typedef struct nativeref nativeref;
52 typedef struct nativecompref nativecompref;
53
54 struct nativeref {
55         char       *classname;
56         char       *methodname;
57         char       *descriptor;
58         bool        isstatic;
59         functionptr func;
60 };
61
62 /* table for fast string comparison */
63
64 struct nativecompref {
65         utf        *classname;
66         utf        *methodname;
67         utf        *descriptor;
68         bool        isstatic;
69         functionptr func;
70 };
71
72
73 void use_class_as_object(classinfo *c);
74
75 /* load classes required for native methods */
76 bool native_init(void);
77
78 /* find native function */
79 functionptr native_findfunction(utf *cname, utf *mname, 
80                                                                 utf *desc, bool isstatic);
81
82 /* create new object on the heap and call the initializer */
83 java_objectheader *native_new_and_init(classinfo *c);
84
85 /* create new object on the heap and call the initializer 
86    mainly used for exceptions with a message */
87 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
88
89 /* create new object on the heap and call the initializer 
90    mainly used for exceptions with an index */
91 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
92
93 /* create new object on the heap and call the initializer 
94    mainly used for exceptions with cause */
95 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
96
97 /* add property to temporary property list -- located in nat/VMRuntime.c */
98 void create_property(char *key, char *value);
99
100 /* correct vftbl-entries of javastring-hash */
101 void stringtable_update();
102
103
104 /* search 'classinfo'-structure for a field with the specified name */
105 fieldinfo *class_findfield_approx(classinfo *c, utf *name);
106 s4 class_findfield_index_approx(classinfo *c, utf *name);
107
108 void copy_vftbl(vftbl_t **dest, vftbl_t *src);
109
110 utf *create_methodsig(java_objectarray* types, char *retType);
111 classinfo *get_type(char **utf_ptr,char *desc_end, bool skip);
112 java_objectarray* get_parametertypes(methodinfo *m);
113 java_objectarray* get_exceptiontypes(methodinfo *m);
114 classinfo *get_returntype(methodinfo *m);
115
116
117
118
119 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start);
120 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start);
121
122 /*----- For Static Analysis of Natives by parseRT -----*/
123
124 /*---------- global variables ---------------------------*/
125 typedef struct classMeth classMeth;
126 typedef struct nativeCall   nativeCall;
127 typedef struct methodCall   methodCall;
128 typedef struct nativeMethod nativeMethod;
129
130 typedef struct nativeCompCall   nativeCompCall;
131 typedef struct methodCompCall   methodCompCall;
132 typedef struct nativeCompMethod nativeCompMethod;
133
134 /*---------- Define Constants ---------------------------*/
135 #define MAXCALLS 30 
136
137 struct classMeth {
138         int i_class;
139         int j_method;
140         int methCnt;
141 };
142
143 struct  methodCall{
144         char *classname;
145         char *methodname;
146         char *descriptor;
147 };
148
149 struct  nativeMethod  {
150         char *methodname;
151         char *descriptor;
152         struct methodCall methodCalls[MAXCALLS];
153 };
154
155
156 struct nativeCall {
157         char *classname;
158         struct nativeMethod methods[MAXCALLS];
159         int methCnt;
160         int callCnt[MAXCALLS];
161 };
162
163
164 struct methodCompCall {
165         utf *classname;
166         utf *methodname;
167         utf *descriptor;
168 };
169
170
171 struct nativeCompMethod {
172         utf *methodname;
173         utf *descriptor;
174         struct methodCompCall methodCalls[MAXCALLS];
175 };
176
177
178 struct nativeCompCall {
179         utf *classname;
180         struct nativeCompMethod methods[MAXCALLS];
181         int methCnt;
182         int callCnt[MAXCALLS];
183 };
184
185
186 bool natcall2utf(bool);
187 void printNativeCall(nativeCall);
188 void markNativeMethodsRT(utf *, utf* , utf* ); 
189
190 #endif /* _NATIVE_H */
191
192
193 /*
194  * These are local overrides for various environment variables in Emacs.
195  * Please do not remove this and leave it at the end of the file, where
196  * Emacs will automagically detect them.
197  * ---------------------------------------------------------------------
198  * Local variables:
199  * mode: c
200  * indent-tabs-mode: t
201  * c-basic-offset: 4
202  * tab-width: 4
203  * End:
204  */