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): */
92 typedef struct jstringArrayStruct
* jstringArray
;
93 typedef struct jarrayArrayStruct
* jarrayArray
;
95 #define JRIConstructorMethodName "<init>"
97 /*******************************************************************************
98 * Signature Construction Macros
99 ******************************************************************************/
102 ** These macros can be used to construct signature strings. Hopefully their names
103 ** are a little easier to remember than the single character they correspond to.
104 ** For example, to specify the signature of the method:
106 ** public int read(byte b[], int off, int len);
108 ** you could write something like this in C:
110 ** char* readSig = JRISigMethod(JRISigArray(JRISigByte)
112 ** JRISigInt) JRISigInt;
114 ** Of course, don't put commas between the types.
116 #define JRISigArray(T) "[" T
117 #define JRISigByte "B"
118 #define JRISigChar "C"
119 #define JRISigClass(name) "L" name ";"
120 #define JRISigFloat "F"
121 #define JRISigDouble "D"
122 #define JRISigMethod(args) "(" args ")"
123 #define JRISigNoArgs ""
124 #define JRISigInt "I"
125 #define JRISigLong "J"
126 #define JRISigShort "S"
127 #define JRISigVoid "V"
128 #define JRISigBoolean "Z"
130 /*******************************************************************************
132 ******************************************************************************/
134 extern JRI_PUBLIC_API(const struct JRIEnvInterface
**)
135 JRI_GetCurrentEnv(void);
137 /*******************************************************************************
138 * Specific Scalar Array Types
139 ******************************************************************************/
142 ** The JRI Native Method Interface does not support boolean arrays. This
143 ** is to allow Java runtime implementations to optimize boolean array
144 ** storage. Using the ScalarArray operations on boolean arrays is bound
145 ** to fail, so convert any boolean arrays to byte arrays in Java before
146 ** passing them to a native method.
149 #define JRI_NewByteArray(env, length, initialValues) \
150 JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues))
151 #define JRI_GetByteArrayLength(env, array) \
152 JRI_GetScalarArrayLength(env, array)
153 #define JRI_GetByteArrayElements(env, array) \
154 JRI_GetScalarArrayElements(env, array)
156 #define JRI_NewCharArray(env, length, initialValues) \
157 JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues))
158 #define JRI_GetCharArrayLength(env, array) \
159 JRI_GetScalarArrayLength(env, array)
160 #define JRI_GetCharArrayElements(env, array) \
161 ((jchar*)JRI_GetScalarArrayElements(env, array))
163 #define JRI_NewShortArray(env, length, initialValues) \
164 JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues))
165 #define JRI_GetShortArrayLength(env, array) \
166 JRI_GetScalarArrayLength(env, array)
167 #define JRI_GetShortArrayElements(env, array) \
168 ((jshort*)JRI_GetScalarArrayElements(env, array))
170 #define JRI_NewIntArray(env, length, initialValues) \
171 JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues))
172 #define JRI_GetIntArrayLength(env, array) \
173 JRI_GetScalarArrayLength(env, array)
174 #define JRI_GetIntArrayElements(env, array) \
175 ((jint*)JRI_GetScalarArrayElements(env, array))
177 #define JRI_NewLongArray(env, length, initialValues) \
178 JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues))
179 #define JRI_GetLongArrayLength(env, array) \
180 JRI_GetScalarArrayLength(env, array)
181 #define JRI_GetLongArrayElements(env, array) \
182 ((jlong*)JRI_GetScalarArrayElements(env, array))
184 #define JRI_NewFloatArray(env, length, initialValues) \
185 JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues))
186 #define JRI_GetFloatArrayLength(env, array) \
187 JRI_GetScalarArrayLength(env, array)
188 #define JRI_GetFloatArrayElements(env, array) \
189 ((jfloat*)JRI_GetScalarArrayElements(env, array))
191 #define JRI_NewDoubleArray(env, length, initialValues) \
192 JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues))
193 #define JRI_GetDoubleArrayLength(env, array) \
194 JRI_GetScalarArrayLength(env, array)
195 #define JRI_GetDoubleArrayElements(env, array) \
196 ((jdouble*)JRI_GetScalarArrayElements(env, array))
198 /******************************************************************************/
200 ** JDK Stuff -- This stuff is still needed while we're using the JDK
201 ** dynamic linking strategy to call native methods.
204 typedef union JRI_JDK_stack_item
{
205 /* Non pointer items */
215 long l
; /* == 64bits! */
217 } JRI_JDK_stack_item
;
219 typedef union JRI_JDK_Java8Str
{
227 /******************************************************************************/
231 #endif /* JRITYPES_H */
232 /******************************************************************************/