974a02bc0046a9ebe1be80985ccbd27ff8023174
[cacao.git] / src / native / native.h
1 /* src/native/native.h - table of native functions
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _NATIVE_H
27 #define _NATIVE_H
28
29 #include "config.h"
30
31 #if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H)
32 # include <ltdl.h>
33 #endif
34
35 #include <stdint.h>
36
37 #include "native/jni.h"
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 /* defines ********************************************************************/
48
49 #define NATIVE_METHODS_COUNT    sizeof(methods) / sizeof(JNINativeMethod)
50
51
52 /* native_methods_node_t ******************************************************/
53
54 typedef struct native_methods_node_t native_methods_node_t;
55
56 struct native_methods_node_t {
57         utf         *classname;             /* class name                         */
58         utf         *name;                  /* method name                        */
59         utf         *descriptor;            /* descriptor name                    */
60         functionptr  function;              /* pointer to the implementation      */
61 };
62
63
64 /* hashtable_library_loader_entry *********************************************/
65
66 #if defined(ENABLE_LTDL)
67 typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
68 typedef struct hashtable_library_name_entry   hashtable_library_name_entry;
69
70 struct hashtable_library_loader_entry {
71         classloader_t                  *loader;  /* class loader                  */
72         hashtable_library_name_entry   *namelink;/* libs loaded by this loader    */
73         hashtable_library_loader_entry *hashlink;/* link for external chaining    */
74 };
75 #endif
76
77
78 /* hashtable_library_name_entry ***********************************************/
79
80 #if defined(ENABLE_LTDL)
81 struct hashtable_library_name_entry {
82         utf                          *name;      /* library name                  */
83         lt_dlhandle                   handle;    /* libtool library handle        */
84         hashtable_library_name_entry *hashlink;  /* link for external chaining    */
85 };
86 #endif
87
88
89 /* function prototypes ********************************************************/
90
91 bool native_init(void);
92
93 void        native_method_register(utf *classname, const JNINativeMethod *methods, int32_t count);
94 functionptr native_method_resolve(methodinfo *m);
95
96 #if defined(ENABLE_LTDL)
97 lt_dlhandle native_library_open(utf *filename);
98 void        native_library_close(lt_dlhandle handle);
99 void        native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle);
100 hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader);
101 int         native_library_load(JNIEnv *env, utf *name, classloader_t *cl);
102 #endif
103
104 java_handle_t *native_new_and_init(classinfo *c);
105 java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s);
106
107 #endif /* _NATIVE_H */
108
109
110 /*
111  * These are local overrides for various environment variables in Emacs.
112  * Please do not remove this and leave it at the end of the file, where
113  * Emacs will automagically detect them.
114  * ---------------------------------------------------------------------
115  * Local variables:
116  * mode: c
117  * indent-tabs-mode: t
118  * c-basic-offset: 4
119  * tab-width: 4
120  * End:
121  * vim:noexpandtab:sw=4:ts=4:
122  */