1 /* src/native/native.h - table of native functions
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: Reinhard Grafl
29 Changes: Christian Thalinger
31 $Id: native.h 3196 2005-09-16 12:32:43Z twisti $
39 #if !defined(ENABLE_STATICVM)
40 # include "libltdl/ltdl.h"
44 #include "vm/global.h"
45 #include "vm/method.h"
47 #include "native/jni.h"
48 #include "native/include/java_lang_String.h"
49 #include "native/include/java_lang_ClassLoader.h"
50 #include "native/include/java_lang_Throwable.h"
53 /* table for locating native methods */
55 typedef struct nativeref nativeref;
56 typedef struct nativecompref nativecompref;
59 #if !defined(ENABLE_STATICVM)
60 typedef struct library_hash_loader_entry library_hash_loader_entry;
61 typedef struct library_hash_name_entry library_hash_name_entry;
63 /* library_hash_loader_entry **************************************************/
65 struct library_hash_loader_entry {
66 java_objectheader *loader; /* class loader */
67 library_hash_name_entry *namelink;/* libraries loaded by this loader */
68 library_hash_loader_entry *hashlink;/* link for external chaining */
72 /* library_hash_name_entry ****************************************************/
74 struct library_hash_name_entry {
75 utf *name; /* library name */
76 lt_dlhandle handle; /* libtool library handle */
77 library_hash_name_entry *hashlink; /* link for external chaining */
90 /* table for fast string comparison */
92 struct nativecompref {
101 bool use_class_as_object(classinfo *c);
103 /* initialize native subsystem */
104 bool native_init(void);
106 /* find native function */
107 functionptr native_findfunction(utf *cname, utf *mname,
108 utf *desc, bool isstatic);
110 #if !defined(ENABLE_STATICVM)
111 /* add a library to the library hash */
112 void native_library_hash_add(utf *filename, java_objectheader *loader,
115 /* find a library in the library hash */
116 library_hash_name_entry *native_library_hash_find(utf *filename,
117 java_objectheader *loader);
118 /* resolve native function */
119 functionptr native_resolve_function(methodinfo *m);
122 /* create new object on the heap and call the initializer */
123 java_objectheader *native_new_and_init(classinfo *c);
125 /* create new object on the heap and call the initializer
126 mainly used for exceptions with a message */
127 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
129 /* create new object on the heap and call the initializer
130 mainly used for exceptions with an index */
131 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
133 /* create new object on the heap and call the initializer
134 mainly used for exceptions with cause */
135 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
137 /* add property to temporary property list -- located in nat/VMRuntime.c */
138 void create_property(char *key, char *value);
140 /* search 'classinfo'-structure for a field with the specified name */
141 fieldinfo *class_findfield_approx(classinfo *c, utf *name);
142 s4 class_findfield_index_approx(classinfo *c, utf *name);
144 void copy_vftbl(vftbl_t **dest, vftbl_t *src);
146 utf *create_methodsig(java_objectarray* types, char *retType);
148 java_objectarray *native_get_parametertypes(methodinfo *m);
149 java_objectarray *native_get_exceptiontypes(methodinfo *m);
150 classinfo *native_get_returntype(methodinfo *m);
153 /*----- For Static Analysis of Natives by parseRT -----*/
155 /*---------- global variables ---------------------------*/
156 typedef struct classMeth classMeth;
157 typedef struct nativeCall nativeCall;
158 typedef struct methodCall methodCall;
159 typedef struct nativeMethod nativeMethod;
161 typedef struct nativeCompCall nativeCompCall;
162 typedef struct methodCompCall methodCompCall;
163 typedef struct nativeCompMethod nativeCompMethod;
165 /*---------- Define Constants ---------------------------*/
180 struct nativeMethod {
183 struct methodCall methodCalls[MAXCALLS];
189 struct nativeMethod methods[MAXCALLS];
191 int callCnt[MAXCALLS];
195 struct methodCompCall {
202 struct nativeCompMethod {
205 struct methodCompCall methodCalls[MAXCALLS];
209 struct nativeCompCall {
211 struct nativeCompMethod methods[MAXCALLS];
213 int callCnt[MAXCALLS];
217 bool natcall2utf(bool);
218 void printNativeCall(nativeCall);
219 void markNativeMethodsRT(utf *, utf* , utf* );
221 #endif /* _NATIVE_H */
225 * These are local overrides for various environment variables in Emacs.
226 * Please do not remove this and leave it at the end of the file, where
227 * Emacs will automagically detect them.
228 * ---------------------------------------------------------------------
231 * indent-tabs-mode: t