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