bump product version to 4.1.6.2
[LibreOffice.git] / np_sdk / npsdk / jritypes.h
blob03a7a9dcfe41e2265ebd302cc20cd26c7da5ad10
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
13 * License.
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.
22 * Contributor(s):
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 ******************************************************************************/
42 #ifndef JRITYPES_H
43 #define JRITYPES_H
45 #include "jri_md.h"
46 #include <stddef.h>
47 #include <stdlib.h>
48 #include <stdarg.h>
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
54 /*******************************************************************************
55 * Types
56 ******************************************************************************/
58 struct JRIEnvInterface;
60 typedef void* JRIRef;
61 typedef void* JRIGlobalRef;
63 typedef jint JRIFieldID;
64 typedef jint JRIMethodID;
66 /* synonyms: */
67 typedef JRIGlobalRef jglobal;
69 typedef union JRIValue {
70 jbool z;
71 jbyte b;
72 jchar c;
73 jshort s;
74 jint i;
75 jlong l;
76 jfloat f;
77 jdouble d;
78 jref r;
79 } JRIValue;
81 typedef enum JRIBoolean {
82 JRIFalse = 0,
83 JRITrue = 1
84 } JRIBoolean;
86 typedef enum JRIConstant {
87 JRIUninitialized = -1
88 } 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)
111 ** JRISigInt
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 /*******************************************************************************
131 * Environments
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 */
206 jint i;
207 jfloat f;
208 jint o;
209 /* Pointer items */
210 void *h;
211 void *p;
212 unsigned char *addr;
213 #ifdef IS_64
214 double d;
215 long l; /* == 64bits! */
216 #endif
217 } JRI_JDK_stack_item;
219 typedef union JRI_JDK_Java8Str {
220 jint x[2];
221 jdouble d;
222 jlong l;
223 void *p;
224 float f;
225 } JRI_JDK_Java8;
227 /******************************************************************************/
228 #ifdef __cplusplus
230 #endif
231 #endif /* JRITYPES_H */
232 /******************************************************************************/