* src/vmcore/linker.c (build_display): Removed superfluous recursion; return
[cacao.git] / src / native / native.h
index 0da019cbfce10ea20e693a9312e306a7a580c0f3..974a02bc0046a9ebe1be80985ccbd27ff8023174 100644 (file)
@@ -1,9 +1,7 @@
 /* src/native/native.h - table of native functions
 
-   Copyright (C) 1996-2005 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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Reinhard Grafl
-
-   Changes: Christian Thalinger
-
-   $Id: native.h 4210 2006-01-15 12:28:57Z twisti $
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
 
 #include "config.h"
 
-#if !defined(ENABLE_STATICVM)
+#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H)
 # include <ltdl.h>
 #endif
 
-#include "vm/class.h"
-#include "vm/global.h"
-#include "vm/method.h"
-#include "vm/utf8.h"
+#include <stdint.h>
+
 #include "native/jni.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_Throwable.h"
 
+#include "vm/global.h"
 
-/* table for locating native methods */
+#include "vmcore/class.h"
+#include "vmcore/loader.h"
+#include "vmcore/method.h"
+#include "vmcore/utf8.h"
 
-typedef struct nativeref nativeref;
-typedef struct nativecompref nativecompref;
 
+/* defines ********************************************************************/
 
-#if !defined(ENABLE_STATICVM)
-typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
-typedef struct hashtable_library_name_entry hashtable_library_name_entry;
+#define NATIVE_METHODS_COUNT    sizeof(methods) / sizeof(JNINativeMethod)
+
+
+/* native_methods_node_t ******************************************************/
+
+typedef struct native_methods_node_t native_methods_node_t;
+
+struct native_methods_node_t {
+       utf         *classname;             /* class name                         */
+       utf         *name;                  /* method name                        */
+       utf         *descriptor;            /* descriptor name                    */
+       functionptr  function;              /* pointer to the implementation      */
+};
 
 
 /* hashtable_library_loader_entry *********************************************/
 
+#if defined(ENABLE_LTDL)
+typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
+typedef struct hashtable_library_name_entry   hashtable_library_name_entry;
+
 struct hashtable_library_loader_entry {
-       java_objectheader              *loader;  /* class loader                  */
+       classloader_t                  *loader;  /* class loader                  */
        hashtable_library_name_entry   *namelink;/* libs loaded by this loader    */
        hashtable_library_loader_entry *hashlink;/* link for external chaining    */
 };
+#endif
 
 
 /* hashtable_library_name_entry ***********************************************/
 
+#if defined(ENABLE_LTDL)
 struct hashtable_library_name_entry {
        utf                          *name;      /* library name                  */
        lt_dlhandle                   handle;    /* libtool library handle        */
@@ -82,67 +86,23 @@ struct hashtable_library_name_entry {
 #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 ********************************************************/
 
-
-/* initialize native subsystem */
 bool native_init(void);
 
-#if defined(ENABLE_STATICVM)
-
-/* find native function */
-functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
-                                                               bool isstatic);
-
-#else /* defined(ENABLE_STATICVM) */
-
-/* add a library to the library hash */
-void native_hashtable_library_add(utf *filename, java_objectheader *loader,
-                                                                 lt_dlhandle handle);
+void        native_method_register(utf *classname, const JNINativeMethod *methods, int32_t count);
+functionptr native_method_resolve(methodinfo *m);
 
-/* find a library entry in the library hash */
-hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
-                                                                                                                       java_objectheader *loader);
-
-/* resolve native function */
-functionptr native_resolve_function(methodinfo *m);
-
-#endif /* defined(ENABLE_STATICVM) */
-
-/* create new object on the heap and call the initializer */
-java_objectheader *native_new_and_init(classinfo *c);
-
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with a message */
-java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
-
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with an index */
-java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
-
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with cause */
-java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
+#if defined(ENABLE_LTDL)
+lt_dlhandle native_library_open(utf *filename);
+void        native_library_close(lt_dlhandle handle);
+void        native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle);
+hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader);
+int         native_library_load(JNIEnv *env, utf *name, classloader_t *cl);
+#endif
 
-java_objectarray *native_get_parametertypes(methodinfo *m);
-java_objectarray *native_get_exceptiontypes(methodinfo *m);
-classinfo *native_get_returntype(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 */
 
@@ -158,4 +118,5 @@ classinfo *native_get_returntype(methodinfo *m);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */