-/****************************** native.h ***************************************
+/* src/native/native.h - table of native functions
- Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
- See file COPYRIGHT for information on usage and disclaimer of warranties
+ This file is part of CACAO.
- Contains the codegenerator for an Alpha processor.
- This module generates Alpha machine code for a sequence of
- pseudo commands (PCMDs).
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
- Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- Last Change: 1997/03/12
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
-*******************************************************************************/
+*/
-/* Java Native Interface */
-#include "jni.h"
-/* structure for class java.lang.String */
-struct java_lang_String;
+#ifndef _NATIVE_H
+#define _NATIVE_H
-/* for raising exceptions from native methods */
-extern java_objectheader* exceptionptr;
+#include "config.h"
-/* javastring-hashtable */
-extern hashtable string_hash;
+#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H)
+# include <ltdl.h>
+#endif
-/* load classes required for native methods */
-void native_loadclasses ();
+#include <stdint.h>
-/* set searchpath for classfiles */
-void native_setclasspath (char *path);
+#include "native/jni.h"
-/* find native function */
-functionptr native_findfunction (utf *cname, utf *mname,
- utf *desc, bool isstatic);
+#include "vm/global.h"
-/* creates a new object of type java/lang/String from a utf-text */
-java_objectheader *javastring_new (utf *text);
+#include "vmcore/class.h"
+#include "vmcore/loader.h"
+#include "vmcore/method.h"
+#include "vmcore/utf8.h"
-/* creates a new object of type java/lang/String from a c-string */
-java_objectheader *javastring_new_char (char *text);
-/* make c-string from a javastring (debugging) */
-char *javastring_tochar (java_objectheader *s);
+/* defines ********************************************************************/
-/* create new object on the heap and call the initializer */
-java_objectheader *native_new_and_init (classinfo *c);
+#define NATIVE_METHODS_COUNT sizeof(methods) / sizeof(JNINativeMethod)
-/* add property to system-property vector */
-void attach_property(char *name, char *value);
-/* correct vftbl-entries of javastring-hash */
-void stringtable_update();
+/* native_methods_node_t ******************************************************/
-/* throw classnotfoundexcetion */
-void throw_classnotfoundexception();
+typedef struct native_methods_node_t native_methods_node_t;
-void throw_classnotfoundexception2(utf* classname);
+struct native_methods_node_t {
+ utf *classname; /* class name */
+ utf *name; /* method name */
+ utf *descriptor; /* descriptor name */
+ functionptr function; /* pointer to the implementation */
+};
-/* make utf symbol from javastring */
-utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
-/* make utf symbol from u2 array */
-utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
+/* hashtable_library_loader_entry *********************************************/
-/* determine utf length in bytes of a u2 array */
-u4 u2_utflength(u2 *text, u4 u2_length);
+#if defined(ENABLE_LTDL)
+typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
+typedef struct hashtable_library_name_entry hashtable_library_name_entry;
-/* create systemclassloader object and initialize its instance fields */
-void init_systemclassloader();
+struct hashtable_library_loader_entry {
+ classloader *loader; /* class loader */
+ hashtable_library_name_entry *namelink;/* libs loaded by this loader */
+ hashtable_library_loader_entry *hashlink;/* link for external chaining */
+};
+#endif
-/* search 'classinfo'-structure for a field with the specified name */
-fieldinfo *class_findfield_approx (classinfo *c, utf *name);
-/* creates a new javastring with the text of the utf-symbol */
-java_objectheader *literalstring_new (utf *u);
+/* hashtable_library_name_entry ***********************************************/
-/* creates a new javastring with the text of the u2-array */
-java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode);
+#if defined(ENABLE_LTDL)
+struct hashtable_library_name_entry {
+ utf *name; /* library name */
+ lt_dlhandle handle; /* libtool library handle */
+ hashtable_library_name_entry *hashlink; /* link for external chaining */
+};
+#endif
-/* dispose a javastring */
-void literalstring_free (java_objectheader*);
-void systemclassloader_addlibname(java_objectheader *o);
-void systemclassloader_addlibrary(java_objectheader *o);
+/* function prototypes ********************************************************/
-void copy_vftbl(vftbl **dest, vftbl *src);
+bool native_init(void);
+
+void native_method_register(utf *classname, const JNINativeMethod *methods,
+ int32_t count);
+
+#if defined(ENABLE_LTDL)
+lt_dlhandle native_library_open(utf *filename);
+void native_library_add(utf *filename, classloader *loader,
+ lt_dlhandle handle);
+hashtable_library_name_entry *native_library_find(utf *filename,
+ classloader *loader);
+#endif
+
+functionptr native_resolve_function(methodinfo *m);
+
+java_handle_t *native_new_and_init(classinfo *c);
+java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s);
+
+#endif /* _NATIVE_H */
/*
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/