OSDN Git Service

* All files: Updated copyright to reflect Cygnus purchase.
[pf3gnuchains/gcc-fork.git] / libjava / include / jni.h
1 /* Copyright (C) 1998, 1999  Red Hat, Inc.
2
3    This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7 details.  */
8
9 #ifndef __GCJ_JNI_H__
10 #define __GCJ_JNI_H__
11
12 #include <stdarg.h>
13 #define _Jv_va_list va_list
14
15 #ifdef __cplusplus
16
17 // This is wrong, because it pollutes the name-space too much!
18 #include <gcj/javaprims.h>
19
20 typedef struct _Jv_JNIEnv JNIEnv;
21 #else
22
23 typedef int    jbyte  __attribute__((__mode__(__QI__)));
24 typedef int    jshort __attribute__((__mode__(__HI__)));
25 typedef int    jint   __attribute__((__mode__(__SI__)));
26 typedef int    jlong  __attribute__((__mode__(__DI__)));
27 typedef bool   jboolean __attribute__((__mode__(__QI__)));
28 typedef unsigned short jchar __attribute__((__mode__(__HI__)));
29 typedef float  jfloat;
30 typedef double jdouble;
31 typedef jint jsize;
32
33 typedef const struct JNINativeInterface *JNIEnv;
34 #endif
35
36 typedef union jvalue
37 {
38   jboolean z;
39   jbyte    b;
40   jchar    c;
41   jshort  s;
42   jint    i;
43   jlong    j;
44   jfloat  f;
45   jdouble  d;
46   jobject l;
47 } jvalue;
48
49 typedef void * (*_Jv_func)(...);
50
51 struct JNINativeInterface
52 {
53   _Jv_func reserved0;
54   _Jv_func reserved1;
55   _Jv_func reserved2;
56   _Jv_func reserved3;
57   _Jv_func GetVersion;
58   _Jv_func DefineClass;
59   _Jv_func FindClass;
60   _Jv_func reserved4;
61   _Jv_func reserved5;
62   _Jv_func reserved6;
63   jclass   (*GetSuperclass)                (JNIEnv*, jclass);
64   jboolean (*IsAssignableFrom)             (JNIEnv*, jclass, jclass);
65   _Jv_func reserved7;
66   jint     (*Throw)                        (JNIEnv*, jthrowable);
67   _Jv_func ThrowNew;
68   _Jv_func ExceptionOccurred;
69   _Jv_func ExceptionDescribe;
70   _Jv_func ExceptionClear;
71   _Jv_func FatalError;
72   _Jv_func reserved8;
73   _Jv_func reserved9;
74   _Jv_func NewGlobalRef;
75   _Jv_func DeleteGlobalRef;
76   _Jv_func DeleteLocalRef;
77   _Jv_func IsSameObject;
78   _Jv_func reserved10;
79   _Jv_func reserved11;
80   _Jv_func AllocObject;
81   _Jv_func NewObject;
82   _Jv_func NewObjectV;
83   _Jv_func NewObjectA;
84   _Jv_func GetObjectClass;
85   _Jv_func IsInstanceOf;
86   _Jv_func GetMethodID;
87   _Jv_func CallObjectMethod;
88   _Jv_func CallObjectMethodV;
89   _Jv_func CallObjectMethodA;
90   _Jv_func CallBooleanMethod;
91   _Jv_func CallBooleanMethodV;
92   _Jv_func CallBooleanMethodA;
93   _Jv_func CallByteMethod;
94   _Jv_func CallByteMethodV;
95   _Jv_func CallByteMethodA;
96   _Jv_func CallCharMethod;
97   _Jv_func CallCharMethodV;
98   _Jv_func CallCharMethodA;
99   _Jv_func CallShortMethod;
100   _Jv_func CallShortMethodV;
101   _Jv_func CallShortMethodA;
102   _Jv_func CallIntMethod;
103   _Jv_func CallIntMethodV;
104   _Jv_func CallIntMethodA;
105   _Jv_func CallLongMethod;
106   _Jv_func CallLongMethodV;
107   _Jv_func CallLongMethodA;
108   _Jv_func CallFloatMethod;
109   _Jv_func CallFloatMethodV;
110   _Jv_func CallFloatMethodA;
111   _Jv_func CallDoubleMethod;
112   _Jv_func CallDoubleMethodV;
113   _Jv_func CallDoubleMethodA;
114   _Jv_func CallVoidMethod;
115   _Jv_func CallVoidMethodV;
116   _Jv_func CallVoidMethodA;
117   _Jv_func CallNonvirtualObjectMethod;
118   _Jv_func CallNonvirtualObjectMethodV;
119   _Jv_func CallNonvirtualObjectMethodA;
120   jboolean (*CallNonvirtualBooleanMethod)  (JNIEnv*, jobject, jclass, jmethodID, ...);
121   jboolean (*CallNonvirtualBooleanMethodV) (JNIEnv*, jobject, jclass, jmethodID, _Jv_va_list);
122   jboolean (*CallNonvirtualBooleanMethodA) (JNIEnv*, jobject, jclass, jmethodID, jvalue*);
123   _Jv_func CallNonvirtualByteMethod;
124   _Jv_func CallNonvirtualByteMethodV;
125   _Jv_func CallNonvirtualByteMethodA;
126   _Jv_func CallNonvirtualCharMethod;
127   _Jv_func CallNonvirtualCharMethodV;
128   _Jv_func CallNonvirtualCharMethodA;
129   _Jv_func CallNonvirtualShortMethod;
130   _Jv_func CallNonvirtualShortMethodV;
131   _Jv_func CallNonvirtualShortMethodA;
132   _Jv_func CallNonvirtualIntMethod;
133   _Jv_func CallNonvirtualIntMethodV;
134   _Jv_func CallNonvirtualIntMethodA;
135   _Jv_func CallNonvirtualLongMethod;
136   _Jv_func CallNonvirtualLongMethodV;
137   _Jv_func CallNonvirtualLongMethodA;
138   _Jv_func CallNonvirtualFloatMethod;
139   _Jv_func CallNonvirtualFloatMethodV;
140   _Jv_func CallNonvirtualFloatMethodA;
141   _Jv_func CallNonvirtualDoubleMethod;
142   jdouble  (*CallNonvirtualDoubleMethodV)  (JNIEnv*, jobject, jclass, jmethodID, _Jv_va_list);
143   _Jv_func CallNonvirtualDoubleMethodA;
144   _Jv_func CallNonvirtualVoidMethod;
145   _Jv_func CallNonvirtualVoidMethodV;
146   _Jv_func CallNonvirtualVoidMethodA;
147   _Jv_func GetFieldID;
148   jobject  (*GetObjectField)               (JNIEnv*, jobject, jfieldID);
149   jboolean (*GetBooleanField)              (JNIEnv*, jobject, jfieldID);
150   jbyte    (*GetByteField)                 (JNIEnv*, jobject, jfieldID);
151   jchar    (*GetCharField)                 (JNIEnv*, jobject, jfieldID);
152   jshort   (*GetShortField)                (JNIEnv*, jobject, jfieldID);
153   jint     (*GetIntField)                  (JNIEnv*, jobject, jfieldID);
154   jlong    (*GetLongField)                 (JNIEnv*, jobject, jfieldID);
155   jfloat   (*GetFloatField)                (JNIEnv*, jobject, jfieldID);
156   jdouble  (*GetDoubleField)               (JNIEnv*, jobject, jfieldID);
157   _Jv_func SetObjectField;
158   _Jv_func SetBooleanField;
159   _Jv_func SetByteField;
160   _Jv_func SetCharField;
161   _Jv_func SetShortField;
162   _Jv_func SetIntField;
163   _Jv_func SetLongField;
164   _Jv_func SetFloatField;
165   _Jv_func SetDoubleField;
166   _Jv_func GetStaticMethodID;
167   _Jv_func CallStaticObjectMethod;
168   _Jv_func CallStaticObjectMethodV;
169   _Jv_func CallStaticObjectMethodA;
170   _Jv_func CallStaticBooleanMethod;
171   _Jv_func CallStaticBooleanMethodV;
172   _Jv_func CallStaticBooleanMethodA;
173   _Jv_func CallStaticByteMethod;
174   _Jv_func CallStaticByteMethodV;
175   _Jv_func CallStaticByteMethodA;
176   _Jv_func CallStaticCharMethod;
177   _Jv_func CallStaticCharMethodV;
178   _Jv_func CallStaticCharMethodA;
179   _Jv_func CallStaticShortMethod;
180   _Jv_func CallStaticShortMethodV;
181   _Jv_func CallStaticShortMethodA;
182   _Jv_func CallStaticIntMethod;
183   _Jv_func CallStaticIntMethodV;
184   _Jv_func CallStaticIntMethodA;
185   _Jv_func CallStaticLongMethod;
186   _Jv_func CallStaticLongMethodV;
187   _Jv_func CallStaticLongMethodA;
188   _Jv_func CallStaticFloatMethod;
189   _Jv_func CallStaticFloatMethodV;
190   _Jv_func CallStaticFloatMethodA;
191   _Jv_func CallStaticDoubleMethod;
192   _Jv_func CallStaticDoubleMethodV;
193   _Jv_func CallStaticDoubleMethodA;
194   _Jv_func CallStaticVoidMethod;
195   _Jv_func CallStaticVoidMethodV;
196   _Jv_func CallStaticVoidMethodA;
197   _Jv_func GetStaticFieldID;
198   _Jv_func GetStaticObjectField;
199   _Jv_func GetStaticBooleanField;
200   _Jv_func GetStaticByteField;
201   _Jv_func GetStaticCharField;
202   _Jv_func GetStaticShortField;
203   _Jv_func GetStaticIntField;
204   _Jv_func GetStaticLongField;
205   _Jv_func GetStaticFloatField;
206   _Jv_func GetStaticDoubleField;
207   _Jv_func SetStaticObjectField;
208   _Jv_func SetStaticBooleanField;
209   _Jv_func SetStaticByteField;
210   _Jv_func SetStaticCharField;
211   _Jv_func SetStaticShortField;
212   _Jv_func SetStaticIntField;
213   _Jv_func SetStaticLongField;
214   _Jv_func SetStaticFloatField;
215   _Jv_func SetStaticDoubleField;
216   _Jv_func NewString;
217   jint     (*GetStringLength)              (JNIEnv*, jstring);
218   _Jv_func GetStringChars;
219   _Jv_func ReleaseStringChars;
220   _Jv_func NewStringUTF;
221   _Jv_func GetStringUTFLength;
222   _Jv_func GetStringUTFChars;
223   _Jv_func ReleaseStringUTFChars;
224   _Jv_func GetArrayLength;
225   _Jv_func NewObjectArray;
226   _Jv_func GetObjectArrayElement;
227   _Jv_func SetObjectArrayElement;
228   _Jv_func NewBooleanArray;
229   _Jv_func NewByteArray;
230   _Jv_func NewCharArray;
231   _Jv_func NewShortArray;
232   _Jv_func NewIntArray;
233   _Jv_func NewLongArray;
234   _Jv_func NewFloatArray;
235   _Jv_func NewDoubleArray;
236   _Jv_func GetBooleanArrayElements;
237   _Jv_func GetByteArrayElements;
238   _Jv_func GetCharArrayElements;
239   _Jv_func GetShortArrayElements;
240   _Jv_func GetIntArrayElements;
241   _Jv_func GetLongArrayElements;
242   _Jv_func GetFloatArrayElements;
243   _Jv_func GetDoubleArrayElements;
244   _Jv_func ReleaseBooleanArrayElements;
245   _Jv_func ReleaseByteArrayElements;
246   _Jv_func ReleaseCharArrayElements;
247   _Jv_func ReleaseShortArrayElements;
248   _Jv_func ReleaseIntArrayElements;
249   _Jv_func ReleaseLongArrayElements;
250   _Jv_func ReleaseFloatArrayElements;
251   _Jv_func ReleaseDoubleArrayElements;
252   _Jv_func GetBooleanArrayRegion;
253   _Jv_func GetByteArrayRegion;
254   _Jv_func GetCharArrayRegion;
255   _Jv_func GetShortArrayRegion;
256   _Jv_func GetIntArrayRegion;
257   _Jv_func GetLongArrayRegion;
258   _Jv_func GetFloatArrayRegion;
259   _Jv_func GetDoubleArrayRegion;
260   _Jv_func SetBooleanArrayRegion;
261   _Jv_func SetByteArrayRegion;
262   _Jv_func SetCharArrayRegion;
263   _Jv_func SetShortArrayRegion;
264   _Jv_func SetIntArrayRegion;
265   _Jv_func SetLongArrayRegion;
266   _Jv_func SetFloatArrayRegion;
267   _Jv_func SetDoubleArrayRegion;
268   _Jv_func RegisterNatives;
269   _Jv_func UnregisterNatives;
270   _Jv_func MonitorEnter;
271   _Jv_func MonitorExit;
272   _Jv_func GetJavaVM;
273 };
274
275 #ifdef __cplusplus
276
277 struct _Jv_JNIEnv
278 {
279   struct JNINativeInterface *p;
280
281   jclass GetSuperclass (jclass cl);
282   jsize GetStringLength (jstring str);
283
284 };
285
286 extern inline jclass
287 _Jv_JNIEnv::GetSuperclass (jclass cl)
288 { return p->GetSuperclass (this, cl); }
289
290 extern inline jsize
291 _Jv_JNIEnv::GetStringLength (jstring str)
292 { return p->GetStringLength (this, str); }
293
294 #endif
295
296 #endif /* __GCJ_JNI_H__ */