1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the NPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the NPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /*******************************************************************************
39 * Java Runtime Interface
40 ******************************************************************************/
54 /*******************************************************************************
56 ******************************************************************************/
58 struct JRIEnvInterface
;
61 typedef void* JRIGlobalRef
;
63 typedef jint JRIFieldID
;
64 typedef jint JRIMethodID
;
67 typedef JRIGlobalRef jglobal
;
69 typedef union JRIValue
{
81 typedef enum JRIBoolean
{
86 typedef enum JRIConstant
{
90 /* convenience types (these must be distinct struct types for c++ overloading): */
91 #if 0 /* now in jni.h */
92 typedef struct jbooleanArrayStruct
* jbooleanArray
;
93 typedef struct jbyteArrayStruct
* jbyteArray
;
94 typedef struct jcharArrayStruct
* jcharArray
;
95 typedef struct jshortArrayStruct
* jshortArray
;
96 typedef struct jintArrayStruct
* jintArray
;
97 typedef struct jlongArrayStruct
* jlongArray
;
98 typedef struct jfloatArrayStruct
* jfloatArray
;
99 typedef struct jdoubleArrayStruct
* jdoubleArray
;
100 typedef struct jobjectArrayStruct
* jobjectArray
;
102 typedef struct jstringArrayStruct
* jstringArray
;
103 typedef struct jarrayArrayStruct
* jarrayArray
;
105 #define JRIConstructorMethodName "<init>"
107 /*******************************************************************************
108 * Signature Construction Macros
109 ******************************************************************************/
112 ** These macros can be used to construct signature strings. Hopefully their names
113 ** are a little easier to remember than the single character they correspond to.
114 ** For example, to specify the signature of the method:
116 ** public int read(byte b[], int off, int len);
118 ** you could write something like this in C:
120 ** char* readSig = JRISigMethod(JRISigArray(JRISigByte)
122 ** JRISigInt) JRISigInt;
124 ** Of course, don't put commas between the types.
126 #define JRISigArray(T) "[" T
127 #define JRISigByte "B"
128 #define JRISigChar "C"
129 #define JRISigClass(name) "L" name ";"
130 #define JRISigFloat "F"
131 #define JRISigDouble "D"
132 #define JRISigMethod(args) "(" args ")"
133 #define JRISigNoArgs ""
134 #define JRISigInt "I"
135 #define JRISigLong "J"
136 #define JRISigShort "S"
137 #define JRISigVoid "V"
138 #define JRISigBoolean "Z"
140 /*******************************************************************************
142 ******************************************************************************/
144 extern JRI_PUBLIC_API(const struct JRIEnvInterface
**)
145 JRI_GetCurrentEnv(void);
147 /*******************************************************************************
148 * Specific Scalar Array Types
149 ******************************************************************************/
152 ** The JRI Native Method Interface does not support boolean arrays. This
153 ** is to allow Java runtime implementations to optimize boolean array
154 ** storage. Using the ScalarArray operations on boolean arrays is bound
155 ** to fail, so convert any boolean arrays to byte arrays in Java before
156 ** passing them to a native method.
159 #define JRI_NewByteArray(env, length, initialValues) \
160 JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues))
161 #define JRI_GetByteArrayLength(env, array) \
162 JRI_GetScalarArrayLength(env, array)
163 #define JRI_GetByteArrayElements(env, array) \
164 JRI_GetScalarArrayElements(env, array)
166 #define JRI_NewCharArray(env, length, initialValues) \
167 JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues))
168 #define JRI_GetCharArrayLength(env, array) \
169 JRI_GetScalarArrayLength(env, array)
170 #define JRI_GetCharArrayElements(env, array) \
171 ((jchar*)JRI_GetScalarArrayElements(env, array))
173 #define JRI_NewShortArray(env, length, initialValues) \
174 JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues))
175 #define JRI_GetShortArrayLength(env, array) \
176 JRI_GetScalarArrayLength(env, array)
177 #define JRI_GetShortArrayElements(env, array) \
178 ((jshort*)JRI_GetScalarArrayElements(env, array))
180 #define JRI_NewIntArray(env, length, initialValues) \
181 JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues))
182 #define JRI_GetIntArrayLength(env, array) \
183 JRI_GetScalarArrayLength(env, array)
184 #define JRI_GetIntArrayElements(env, array) \
185 ((jint*)JRI_GetScalarArrayElements(env, array))
187 #define JRI_NewLongArray(env, length, initialValues) \
188 JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues))
189 #define JRI_GetLongArrayLength(env, array) \
190 JRI_GetScalarArrayLength(env, array)
191 #define JRI_GetLongArrayElements(env, array) \
192 ((jlong*)JRI_GetScalarArrayElements(env, array))
194 #define JRI_NewFloatArray(env, length, initialValues) \
195 JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues))
196 #define JRI_GetFloatArrayLength(env, array) \
197 JRI_GetScalarArrayLength(env, array)
198 #define JRI_GetFloatArrayElements(env, array) \
199 ((jfloat*)JRI_GetScalarArrayElements(env, array))
201 #define JRI_NewDoubleArray(env, length, initialValues) \
202 JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues))
203 #define JRI_GetDoubleArrayLength(env, array) \
204 JRI_GetScalarArrayLength(env, array)
205 #define JRI_GetDoubleArrayElements(env, array) \
206 ((jdouble*)JRI_GetScalarArrayElements(env, array))
208 /******************************************************************************/
210 ** JDK Stuff -- This stuff is still needed while we're using the JDK
211 ** dynamic linking strategy to call native methods.
214 typedef union JRI_JDK_stack_item
{
215 /* Non pointer items */
225 long l
; /* == 64bits! */
227 } JRI_JDK_stack_item
;
229 typedef union JRI_JDK_Java8Str
{
237 /******************************************************************************/
241 #endif /* JRITYPES_H */
242 /******************************************************************************/