* Removed all Id tags.
[cacao.git] / src / native / native.h
index f60b6972191e6c3a1031cfa5f9c9be0be53c9b0c..ee0403283c7a7a7e42e985590d6241005f7ee3bf 100644 (file)
-/****************************** 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/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();
+/* table for locating native methods */
 
-/* throw classnotfoundexcetion */
-void throw_classnotfoundexception();
+#if defined(WITH_STATIC_CLASSPATH)
+typedef struct nativeref nativeref;
+typedef struct nativecompref nativecompref;
+#endif
 
-/* 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);
+/* native_methods_node_t ******************************************************/
 
-/* determine utf length in bytes of a u2 array */
-u4 u2_utflength(u2 *text, u4 u2_length);
+typedef struct native_methods_node_t native_methods_node_t;
 
-/* create systemclassloader object and initialize its instance fields  */
-void init_systemclassloader();
+struct native_methods_node_t {
+       utf         *classname;             /* class name                         */
+       utf         *name;                  /* method name                        */
+       utf         *descriptor;            /* descriptor name                    */
+       functionptr  function;              /* pointer to the implementation      */
+};
 
-/* 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_loader_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)
+typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
+typedef struct hashtable_library_name_entry   hashtable_library_name_entry;
 
-/* dispose a javastring */
-void literalstring_free (java_objectheader*);
+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
 
-void systemclassloader_addlibname(java_objectheader *o);
-void systemclassloader_addlibrary(java_objectheader *o);
 
-void copy_vftbl(vftbl **dest, vftbl *src);
+/* hashtable_library_name_entry ***********************************************/
+
+#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
+
+
+struct nativeref {
+       char       *classname;
+       char       *methodname;
+       char       *descriptor;
+       bool        isstatic;
+       functionptr func;
+};
+
+/* table for fast string comparison */
+
+struct nativecompref {
+       utf        *classname;
+       utf        *methodname;
+       utf        *descriptor;
+       bool        isstatic;
+       functionptr func;
+};
+
+
+/* function prototypes ********************************************************/
+
+bool native_init(void);
+
+void native_method_register(utf *classname, const JNINativeMethod *methods,
+                                                       int32_t count);
+
+#if defined(WITH_STATIC_CLASSPATH)
+
+functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
+                                                               bool isstatic);
+
+#else /* defined(WITH_STATIC_CLASSPATH) */
+
+# 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);
+
+#endif /* defined(WITH_STATIC_CLASSPATH) */
+
+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 */
 
 
 /*