1 /* native.h - table of native functions
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5 M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6 P. Tomsich, J. Wenninger
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
29 $Id: native.h 1465 2004-11-08 11:09:01Z twisti $
39 #include "nat/java_lang_String.h"
40 #include "nat/java_lang_ClassLoader.h"
41 #include "nat/java_lang_Throwable.h"
44 /* table for locating native methods */
46 typedef struct nativeref nativeref;
47 typedef struct nativecompref nativecompref;
57 /* table for fast string comparison */
59 struct nativecompref {
68 extern classinfo *class_java_lang_Class;
69 extern classinfo *class_java_lang_VMClass;
70 extern classinfo *class_java_lang_System;
71 extern classinfo *class_java_lang_ClassLoader;
72 extern classinfo *class_java_lang_Double;
73 extern classinfo *class_java_lang_Float;
74 extern classinfo *class_java_lang_Long;
75 extern classinfo *class_java_lang_Byte;
76 extern classinfo *class_java_lang_Short;
77 extern classinfo *class_java_lang_Boolean;
78 extern classinfo *class_java_lang_Void;
79 extern classinfo *class_java_lang_Character;
80 extern classinfo *class_java_lang_Integer;
83 /* the system classloader object */
84 extern java_lang_ClassLoader *SystemClassLoader;
86 /* for raising exceptions from native methods */
87 /* extern java_objectheader* exceptionptr; */
89 /* javastring-hashtable */
90 extern hashtable string_hash;
92 void use_class_as_object(classinfo *c);
94 /* load classes required for native methods */
95 void native_loadclasses();
97 /* find native function */
98 functionptr native_findfunction(utf *cname, utf *mname,
99 utf *desc, bool isstatic);
101 /* creates a new object of type java/lang/String from a utf-text */
102 /* java_objectheader *javastring_new(utf *text); */
103 java_lang_String *javastring_new(utf *text);
105 /* creates a new object of type java/lang/String from a c-string */
106 /* java_objectheader *javastring_new_char(char *text); */
107 java_lang_String *javastring_new_char(char *text);
109 /* make c-string from a javastring (debugging) */
110 char *javastring_tochar(java_objectheader *s);
112 /* create new object on the heap and call the initializer */
113 java_objectheader *native_new_and_init(classinfo *c);
115 /* create new object on the heap and call the initializer
116 mainly used for exceptions with a message */
117 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s);
119 /* create new object on the heap and call the initializer
120 mainly used for exceptions with an index */
121 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
123 /* create new object on the heap and call the initializer
124 mainly used for exceptions with cause */
125 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
127 /* add property to temporary property list -- located in nat/VMRuntime.c */
128 void create_property(char *key, char *value);
130 /* correct vftbl-entries of javastring-hash */
131 void stringtable_update();
134 /* make utf symbol from javastring */
135 utf *javastring_toutf(java_lang_String *string, bool isclassname);
137 /* make utf symbol from u2 array */
138 utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
140 /* determine utf length in bytes of a u2 array */
141 u4 u2_utflength(u2 *text, u4 u2_length);
143 /* create systemclassloader object and initialize its instance fields */
144 void init_systemclassloader();
146 /* search 'classinfo'-structure for a field with the specified name */
147 fieldinfo *class_findfield_approx(classinfo *c, utf *name);
148 s4 class_findfield_index_approx(classinfo *c, utf *name);
150 /* creates a new javastring with the text of the utf-symbol */
151 java_objectheader *literalstring_new(utf *u);
153 /* creates a new javastring with the text of the u2-array */
154 java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset,
157 /* dispose a javastring */
158 void literalstring_free(java_objectheader*);
160 void copy_vftbl(vftbl_t **dest, vftbl_t *src);
162 utf *create_methodsig(java_objectarray* types, char *retType);
163 classinfo *get_type(char **utf_ptr,char *desc_end, bool skip);
164 java_objectarray* get_parametertypes(methodinfo *m);
165 java_objectarray* get_exceptiontypes(methodinfo *m);
166 classinfo *get_returntype(methodinfo *m);
171 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start);
172 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start);
174 #endif /* _NATIVE_H */
178 * These are local overrides for various environment variables in Emacs.
179 * Please do not remove this and leave it at the end of the file, where
180 * Emacs will automagically detect them.
181 * ---------------------------------------------------------------------
184 * indent-tabs-mode: t