1 /* src/native/native.h - native library support
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
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.
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.
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
33 #include "native/jni.h"
35 #include "vm/global.h"
37 #include "vmcore/class.h"
38 #include "vmcore/loader.h"
39 #include "vmcore/method.h"
40 #include "vmcore/system.h"
41 #include "vmcore/utf8.h"
44 /* defines ********************************************************************/
46 #define NATIVE_METHODS_COUNT sizeof(methods) / sizeof(JNINativeMethod)
49 #define NATIVE_LIBRARY_PREFIX "lib"
51 #if defined(__DARWIN__)
52 # define NATIVE_LIBRARY_SUFFIX ".dylib"
54 # define NATIVE_LIBRARY_SUFFIX ".so"
58 /* native_methods_node_t ******************************************************/
60 typedef struct native_methods_node_t native_methods_node_t;
62 struct native_methods_node_t {
63 utf *classname; /* class name */
64 utf *name; /* method name */
65 utf *descriptor; /* descriptor name */
66 functionptr function; /* pointer to the implementation */
70 /* hashtable_library_loader_entry *********************************************/
72 #if defined(ENABLE_DL)
73 typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
74 typedef struct hashtable_library_name_entry hashtable_library_name_entry;
76 struct hashtable_library_loader_entry {
77 classloader_t *loader; /* class loader */
78 hashtable_library_name_entry *namelink;/* libs loaded by this loader */
79 hashtable_library_loader_entry *hashlink;/* link for external chaining */
84 /* hashtable_library_name_entry ***********************************************/
86 #if defined(ENABLE_DL)
87 struct hashtable_library_name_entry {
88 utf *name; /* library name */
89 void* handle; /* libtool library handle */
90 hashtable_library_name_entry *hashlink; /* link for external chaining */
95 /* function prototypes ********************************************************/
97 bool native_init(void);
99 void native_method_register(utf *classname, const JNINativeMethod *methods, int32_t count);
100 functionptr native_method_resolve(methodinfo *m);
102 #if defined(ENABLE_DL)
103 void* native_library_open(utf *filename);
104 void native_library_close(void* handle);
105 void native_library_add(utf *filename, classloader_t *loader, void *handle);
106 hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader);
107 int native_library_load(JNIEnv *env, utf *name, classloader_t *cl);
110 java_handle_t *native_new_and_init(classinfo *c);
111 java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s);
113 #endif /* _NATIVE_H */
117 * These are local overrides for various environment variables in Emacs.
118 * Please do not remove this and leave it at the end of the file, where
119 * Emacs will automagically detect them.
120 * ---------------------------------------------------------------------
123 * indent-tabs-mode: t
127 * vim:noexpandtab:sw=4:ts=4: