* src/vm/class.c [ENABLE_JAVASE] (arrayclass_java_lang_Object): Added
[cacao.git] / src / native / native.h
1 /* src/native/native.h - table of native functions
2
3    Copyright (C) 1996-2005, 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Christian Thalinger
29
30    $Id: native.h 6251 2006-12-27 23:15:56Z twisti $
31
32 */
33
34
35 #ifndef _NATIVE_H
36 #define _NATIVE_H
37
38 #include "config.h"
39
40 #if !defined(WITH_STATIC_CLASSPATH)
41 # include <ltdl.h>
42 #endif
43
44 #include "native/jni.h"
45 #include "native/include/java_lang_String.h"
46 #include "native/include/java_lang_Throwable.h"
47 #include "vm/class.h"
48 #include "vm/global.h"
49 #include "vm/method.h"
50 #include "vm/utf8.h"
51
52
53 /* table for locating native methods */
54
55 typedef struct nativeref nativeref;
56 typedef struct nativecompref nativecompref;
57
58
59 #if !defined(WITH_STATIC_CLASSPATH)
60 typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
61 typedef struct hashtable_library_name_entry hashtable_library_name_entry;
62
63
64 /* hashtable_library_loader_entry *********************************************/
65
66 struct hashtable_library_loader_entry {
67         java_objectheader              *loader;  /* class loader                  */
68         hashtable_library_name_entry   *namelink;/* libs loaded by this loader    */
69         hashtable_library_loader_entry *hashlink;/* link for external chaining    */
70 };
71
72
73 /* hashtable_library_name_entry ***********************************************/
74
75 struct hashtable_library_name_entry {
76         utf                          *name;      /* library name                  */
77         lt_dlhandle                   handle;    /* libtool library handle        */
78         hashtable_library_name_entry *hashlink;  /* link for external chaining    */
79 };
80 #endif
81
82
83 struct nativeref {
84         char       *classname;
85         char       *methodname;
86         char       *descriptor;
87         bool        isstatic;
88         functionptr func;
89 };
90
91 /* table for fast string comparison */
92
93 struct nativecompref {
94         utf        *classname;
95         utf        *methodname;
96         utf        *descriptor;
97         bool        isstatic;
98         functionptr func;
99 };
100
101
102 /* initialize native subsystem */
103 bool native_init(void);
104
105 #if defined(WITH_STATIC_CLASSPATH)
106
107 /* find native function */
108 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
109                                                                 bool isstatic);
110
111 #else /* defined(WITH_STATIC_CLASSPATH) */
112
113 /* add a library to the library hash */
114 void native_hashtable_library_add(utf *filename, java_objectheader *loader,
115                                                                   lt_dlhandle handle);
116
117 /* find a library entry in the library hash */
118 hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
119                                                                                                                         java_objectheader *loader);
120
121 /* resolve native function */
122 functionptr native_resolve_function(methodinfo *m);
123
124 #endif /* defined(WITH_STATIC_CLASSPATH) */
125
126 /* create new object on the heap and call the initializer */
127 java_objectheader *native_new_and_init(classinfo *c);
128
129 /* create new object on the heap and call the initializer 
130    mainly used for exceptions with a message */
131 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
132
133 /* create new object on the heap and call the initializer 
134    mainly used for exceptions with an index */
135 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
136
137 /* create new object on the heap and call the initializer 
138    mainly used for exceptions with cause */
139 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
140
141 java_objectarray *native_get_parametertypes(methodinfo *m);
142 java_objectarray *native_get_exceptiontypes(methodinfo *m);
143 classinfo *native_get_returntype(methodinfo *m);
144
145 #endif /* _NATIVE_H */
146
147
148 /*
149  * These are local overrides for various environment variables in Emacs.
150  * Please do not remove this and leave it at the end of the file, where
151  * Emacs will automagically detect them.
152  * ---------------------------------------------------------------------
153  * Local variables:
154  * mode: c
155  * indent-tabs-mode: t
156  * c-basic-offset: 4
157  * tab-width: 4
158  * End:
159  */