Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / nsplugins / sdk / jritypes.h
blob89a50fdf02c5640bf78860269d551b76eac3e027
1 //krazy:excludeall=license,copyright
2 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Netscape Public License
7 * Version 1.1 (the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/NPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the NPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the NPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /*******************************************************************************
40 * Java Runtime Interface
41 ******************************************************************************/
43 #ifndef JRITYPES_H
44 #define JRITYPES_H
46 #include "jri_md.h"
47 #include "jni.h"
48 #include <stddef.h>
49 #include <stdlib.h>
50 #include <stdarg.h>
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
56 /*******************************************************************************
57 * Types
58 ******************************************************************************/
60 struct JRIEnvInterface;
62 typedef void* JRIRef;
63 typedef void* JRIGlobalRef;
65 typedef jint JRIFieldID;
66 typedef jint JRIMethodID;
68 /* synonyms: */
69 typedef JRIGlobalRef jglobal;
71 typedef union JRIValue {
72 jbool z;
73 jbyte b;
74 jchar c;
75 jshort s;
76 jint i;
77 jlong l;
78 jfloat f;
79 jdouble d;
80 jref r;
81 } JRIValue;
83 typedef enum JRIBoolean {
84 JRIFalse = 0,
85 JRITrue = 1
86 } JRIBoolean;
88 typedef enum JRIConstant {
89 JRIUninitialized = -1
90 } JRIConstant;
92 /* convenience types (these must be distinct struct types for c++ overloading): */
93 #if 0 /* now in jni.h */
94 typedef struct jbooleanArrayStruct* jbooleanArray;
95 typedef struct jbyteArrayStruct* jbyteArray;
96 typedef struct jcharArrayStruct* jcharArray;
97 typedef struct jshortArrayStruct* jshortArray;
98 typedef struct jintArrayStruct* jintArray;
99 typedef struct jlongArrayStruct* jlongArray;
100 typedef struct jfloatArrayStruct* jfloatArray;
101 typedef struct jdoubleArrayStruct* jdoubleArray;
102 typedef struct jobjectArrayStruct* jobjectArray;
103 #endif
104 typedef struct jstringArrayStruct* jstringArray;
105 typedef struct jarrayArrayStruct* jarrayArray;
107 #define JRIConstructorMethodName "<init>"
109 /*******************************************************************************
110 * Signature Construction Macros
111 ******************************************************************************/
114 ** These macros can be used to construct signature strings. Hopefully their names
115 ** are a little easier to remember than the single character they correspond to.
116 ** For example, to specify the signature of the method:
118 ** public int read(byte b[], int off, int len);
120 ** you could write something like this in C:
122 ** char* readSig = JRISigMethod(JRISigArray(JRISigByte)
123 ** JRISigInt
124 ** JRISigInt) JRISigInt;
126 ** Of course, don't put commas between the types.
128 #define JRISigArray(T) "[" T
129 #define JRISigByte "B"
130 #define JRISigChar "C"
131 #define JRISigClass(name) "L" name ";"
132 #define JRISigFloat "F"
133 #define JRISigDouble "D"
134 #define JRISigMethod(args) "(" args ")"
135 #define JRISigNoArgs ""
136 #define JRISigInt "I"
137 #define JRISigLong "J"
138 #define JRISigShort "S"
139 #define JRISigVoid "V"
140 #define JRISigBoolean "Z"
142 /*******************************************************************************
143 * Environments
144 ******************************************************************************/
146 extern JRI_PUBLIC_API(const struct JRIEnvInterface**)
147 JRI_GetCurrentEnv(void);
149 /*******************************************************************************
150 * Specific Scalar Array Types
151 ******************************************************************************/
154 ** The JRI Native Method Interface does not support boolean arrays. This
155 ** is to allow Java runtime implementations to optimize boolean array
156 ** storage. Using the ScalarArray operations on boolean arrays is bound
157 ** to fail, so convert any boolean arrays to byte arrays in Java before
158 ** passing them to a native method.
161 #define JRI_NewByteArray(env, length, initialValues) \
162 JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues))
163 #define JRI_GetByteArrayLength(env, array) \
164 JRI_GetScalarArrayLength(env, array)
165 #define JRI_GetByteArrayElements(env, array) \
166 JRI_GetScalarArrayElements(env, array)
168 #define JRI_NewCharArray(env, length, initialValues) \
169 JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues))
170 #define JRI_GetCharArrayLength(env, array) \
171 JRI_GetScalarArrayLength(env, array)
172 #define JRI_GetCharArrayElements(env, array) \
173 ((jchar*)JRI_GetScalarArrayElements(env, array))
175 #define JRI_NewShortArray(env, length, initialValues) \
176 JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues))
177 #define JRI_GetShortArrayLength(env, array) \
178 JRI_GetScalarArrayLength(env, array)
179 #define JRI_GetShortArrayElements(env, array) \
180 ((jshort*)JRI_GetScalarArrayElements(env, array))
182 #define JRI_NewIntArray(env, length, initialValues) \
183 JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues))
184 #define JRI_GetIntArrayLength(env, array) \
185 JRI_GetScalarArrayLength(env, array)
186 #define JRI_GetIntArrayElements(env, array) \
187 ((jint*)JRI_GetScalarArrayElements(env, array))
189 #define JRI_NewLongArray(env, length, initialValues) \
190 JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues))
191 #define JRI_GetLongArrayLength(env, array) \
192 JRI_GetScalarArrayLength(env, array)
193 #define JRI_GetLongArrayElements(env, array) \
194 ((jlong*)JRI_GetScalarArrayElements(env, array))
196 #define JRI_NewFloatArray(env, length, initialValues) \
197 JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues))
198 #define JRI_GetFloatArrayLength(env, array) \
199 JRI_GetScalarArrayLength(env, array)
200 #define JRI_GetFloatArrayElements(env, array) \
201 ((jfloat*)JRI_GetScalarArrayElements(env, array))
203 #define JRI_NewDoubleArray(env, length, initialValues) \
204 JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues))
205 #define JRI_GetDoubleArrayLength(env, array) \
206 JRI_GetScalarArrayLength(env, array)
207 #define JRI_GetDoubleArrayElements(env, array) \
208 ((jdouble*)JRI_GetScalarArrayElements(env, array))
210 /******************************************************************************/
212 ** JDK Stuff -- This stuff is still needed while we're using the JDK
213 ** dynamic linking strategy to call native methods.
216 typedef union JRI_JDK_stack_item {
217 /* Non pointer items */
218 jint i;
219 jfloat f;
220 jint o;
221 /* Pointer items */
222 void *h;
223 void *p;
224 unsigned char *addr;
225 #ifdef IS_64
226 double d;
227 long l; /* == 64bits! */
228 #endif
229 } JRI_JDK_stack_item;
231 typedef union JRI_JDK_Java8Str {
232 jint x[2];
233 jdouble d;
234 jlong l;
235 void *p;
236 float f;
237 } JRI_JDK_Java8;
239 /******************************************************************************/
240 #ifdef __cplusplus
242 #endif
243 #endif /* JRITYPES_H */
244 /******************************************************************************/