some words for intro and overview by andi
[cacao.git] / native.h
index 83dca4018aef096b9a9ec7e33a401957b9077cb4..a36a4457266b9dbb3d1e3ab0d278d0c38c99ec7d 100644 (file)
--- a/native.h
+++ b/native.h
-/****************************** native.h ***************************************
+/* native.h - table of native functions
 
-       Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
+   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
+   P. Tomsich, J. Wenninger
 
-       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., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
 
-*******************************************************************************/
+   Contact: cacao@complang.tuwien.ac.at
 
-/* Java Native Interface */
-#include "jni.h"
+   Authors: Reinhard Grafl
+
+   $Id: native.h 1001 2004-03-30 22:44:28Z twisti $
+
+*/
+
+
+#ifndef _NATIVE_H
+#define _NATIVE_H
 
-/* structure for class java.lang.String */
-struct java_lang_String;
+
+#include "jni.h"
+#include "nat/java_lang_String.h"
+#include "nat/java_lang_ClassLoader.h"
+
+
+/* searchpath for classfiles */
+extern char *classpath;
+
+extern classinfo *class_java_lang_Class;
+extern classinfo *class_java_lang_VMClass;
+/* extern classinfo *class_java_lang_Cloneable=0; */ /* now in global.h */
+extern classinfo *class_java_lang_System;
+extern classinfo *class_java_lang_ClassLoader;
+extern classinfo *class_java_lang_Double;
+extern classinfo *class_java_lang_Float;
+extern classinfo *class_java_lang_Long;
+extern classinfo *class_java_lang_Byte;
+extern classinfo *class_java_lang_Short;
+extern classinfo *class_java_lang_Boolean;
+extern classinfo *class_java_lang_Void;
+extern classinfo *class_java_lang_Character;
+extern classinfo *class_java_lang_Integer;
+
+
+/* specify some exception strings for code generation */
+
+extern char *string_java_lang_ArithmeticException;
+extern char *string_java_lang_ArithmeticException_message;
+extern char *string_java_lang_ArrayIndexOutOfBoundsException;
+extern char *string_java_lang_ArrayStoreException;
+extern char *string_java_lang_ClassCastException;
+extern char *string_java_lang_ClassNotFoundException;
+extern char *string_java_lang_CloneNotSupportedException;
+extern char *string_java_lang_IllegalArgumentException;
+extern char *string_java_lang_NegativeArraySizeException;
+extern char *string_java_lang_NoSuchFieldException;
+extern char *string_java_lang_NoSuchMethodException;
+extern char *string_java_lang_NullPointerException;
+
+
+/* specify some error strings for code generation */
+
+extern char *string_java_lang_ClassFormatError;
+extern char *string_java_lang_LinkageError;
+extern char *string_java_lang_NoClassDefFoundError;
+extern char *string_java_lang_NoSuchFieldError;
+extern char *string_java_lang_NoSuchMethodError;
+extern char *string_java_lang_OutOfMemoryError;
+
+
+/* the system classloader object */
+extern struct java_lang_ClassLoader *SystemClassLoader;
 
 /* for raising exceptions from native methods */
-extern java_objectheader* exceptionptr;
+/* extern java_objectheader* exceptionptr; */
 
 /* javastring-hashtable */
 extern hashtable string_hash; 
 
+/* throw an exception and exit */
+void throw_exception_exit();
+
+/* initialize new exceptions */
+java_objectheader *new_exception(char *classname);
+java_objectheader *new_exception_message(char *classname, char *message);
+java_objectheader *new_exception_utfmessage(char *classname, utf *message);
+java_objectheader *new_exception_javastring(char *classname, java_lang_String *message);
+java_objectheader *new_exception_int(char *classname, s4 i);
+
+void use_class_as_object(classinfo *c);
+
 /* load classes required for native methods */
-void native_loadclasses ();
+void native_loadclasses();
 
 /* set searchpath for classfiles */
-void native_setclasspath (char *path);
+void native_setclasspath(char *path);
 
 /* find native function */
-functionptr native_findfunction (utf *cname, utf *mname, 
-                                 utf *desc, bool isstatic);
+functionptr native_findfunction(utf *cname, utf *mname, 
+                                                               utf *desc, bool isstatic);
 
 /* creates a new object of type java/lang/String from a utf-text */
-java_objectheader *javastring_new (utf *text);
+/*  java_objectheader *javastring_new(utf *text); */
+java_lang_String *javastring_new(utf *text);
 
 /* creates a new object of type java/lang/String from a c-string */
-java_objectheader *javastring_new_char (char *text);
+/*  java_objectheader *javastring_new_char(char *text); */
+java_lang_String *javastring_new_char(char *text);
 
 /* make c-string from a javastring (debugging) */
-char *javastring_tochar (java_objectheader *s);
+char *javastring_tochar(java_objectheader *s);
 
 /* create new object on the heap and call the initializer */
-java_objectheader *native_new_and_init (classinfo *c);
+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);
 
 /* add property to system-property vector */
 void attach_property(char *name, char *value);
@@ -54,10 +143,6 @@ void attach_property(char *name, char *value);
 /* correct vftbl-entries of javastring-hash */
 void stringtable_update();
 
-/* throw classnotfoundexcetion */
-void throw_classnotfoundexception();
-
-void throw_classnotfoundexception2(utf* classname);
 
 /* make utf symbol from javastring */
 utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
@@ -72,22 +157,38 @@ u4 u2_utflength(u2 *text, u4 u2_length);
 void init_systemclassloader();
 
 /* search 'classinfo'-structure for a field with the specified name */
-fieldinfo *class_findfield_approx (classinfo *c, utf *name);
+fieldinfo *class_findfield_approx(classinfo *c, utf *name);
+s4 class_findfield_index_approx(classinfo *c, utf *name);
 
 /* creates a new javastring with the text of the utf-symbol */
-java_objectheader *literalstring_new (utf *u);
+java_objectheader *literalstring_new(utf *u);
 
 /* creates a new javastring with the text of the u2-array */
-java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode);
+java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset,
+                                                                       bool copymode);
 
 /* dispose a javastring */
-void literalstring_free (java_objectheader*);
+void literalstring_free(java_objectheader*);
 
 void systemclassloader_addlibname(java_objectheader *o);
 void systemclassloader_addlibrary(java_objectheader *o);
 
 void copy_vftbl(vftbl **dest, vftbl *src);
 
+utf *create_methodsig(java_objectarray* types, char *retType);
+classinfo *get_type(char **utf_ptr,char *desc_end, bool skip);
+java_objectarray* get_parametertypes(methodinfo *m);
+java_objectarray* get_exceptiontypes(methodinfo *m);
+classinfo *get_returntype(methodinfo *m);
+
+
+
+
+java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start);
+java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start);
+
+#endif /* _NATIVE_H */
+
 
 /*
  * These are local overrides for various environment variables in Emacs.