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