1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* For details of the HDF libraries, see the HDF Documentation at:
* http://hdfdfgroup.org/HDF5/doc/
*
*/
#include <jni.h>
#include "H5version.h"
#include <string.h>
#include "H5private.h"
#ifndef _Included_h5jni
#define _Included_h5jni
#ifdef __cplusplus
#define ENVPTR (env)
#define ENVPAR
#define ENVONLY
#define CBENVPTR (cbenv)
#define CBENVPAR
#define JVMPTR (jvm)
#define JVMPAR
#define JVMPAR2
#else /* __cplusplus */
#define ENVPTR (*env)
#define ENVPAR env,
#define ENVONLY env
#define CBENVPTR (*cbenv)
#define CBENVPAR cbenv,
#define JVMPTR (*jvm)
#define JVMPAR jvm
#define JVMPAR2 jvm,
#endif /* __cplusplus */
/* Macros for class access */
/* Calling code must define ret_obj as jobject */
#define CALL_CONSTRUCTOR(classname,classsig,args) { \
jclass cls; \
jmethodID constructor; \
cls = ENVPTR->FindClass(ENVPAR (classname)); \
if (cls == 0) { \
h5JNIFatalError(env, "JNI error: GetObjectClass\n"); \
ret_obj = NULL; \
} \
constructor = ENVPTR->GetMethodID(ENVPAR cls, "<init>", (classsig)); \
if (constructor == 0) { \
h5JNIFatalError(env, "JNI error: GetMethodID failed\n"); \
ret_obj = NULL; \
} \
ret_obj = ENVPTR->NewObjectA(ENVPAR cls, constructor, (args)); \
}
/* Macros for string access */
#define PIN_JAVA_STRING(javastr,localstr) { \
jboolean isCopy; \
(localstr) = NULL; \
if ((javastr) == NULL) { \
h5nullArgument(env, "java string is NULL"); \
} \
else { \
(localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \
if ((localstr) == NULL) { \
h5JNIFatalError(env, "local c string is not pinned"); \
} \
} \
}
#define UNPIN_JAVA_STRING(javastr,localstr) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
}
#define PIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \
jboolean isCopy; \
(localstr) = NULL; \
(local2str) = NULL; \
if ((javastr) == NULL) { \
h5nullArgument(env, "java string is NULL"); \
} \
else if ((java2str) == NULL) { \
h5nullArgument(env, "second java string is NULL"); \
} \
else { \
(localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \
if ((localstr) == NULL) { \
h5JNIFatalError(env, "local c string is not pinned"); \
} \
else { \
(local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \
if ((local2str) == NULL) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
h5JNIFatalError(env, "second local c string is not pinned"); \
} \
} \
} \
}
#define UNPIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \
}
#define PIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \
jboolean isCopy; \
(localstr) = NULL; \
(local2str) = NULL; \
(local3str) = NULL; \
if ((javastr) == NULL) { \
h5nullArgument(env, "java string is NULL"); \
} \
else if ((java2str) == NULL) { \
h5nullArgument(env, "second java string is NULL"); \
} \
else if ((java3str) == NULL) { \
h5nullArgument(env, "third java string is NULL"); \
} \
else { \
(localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \
if ((localstr) == NULL) { \
h5JNIFatalError(env, "local c string is not pinned"); \
} \
else { \
(local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \
if ((local2str) == NULL) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
h5JNIFatalError(env, "second local c string is not pinned"); \
} \
else { \
(local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \
if ((local3str) == NULL) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \
h5JNIFatalError(env, "third local c string is not pinned"); \
} \
} \
} \
} \
}
#define UNPIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \
ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \
ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \
ENVPTR->ReleaseStringUTFChars(ENVPAR (java3str), (local3str)); \
}
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern jboolean h5JNIFatalError(JNIEnv *, const char *);
extern jboolean h5nullArgument(JNIEnv *, const char *);
extern jboolean h5badArgument (JNIEnv *, const char *);
extern jboolean h5outOfMemory (JNIEnv *, const char *);
extern jboolean h5libraryError(JNIEnv *env );
extern jboolean h5raiseException(JNIEnv *, const char *, const char *);
extern jboolean h5unimplemented( JNIEnv *env, const char *functName);
/* implemented at H5.c */
extern jint get_enum_value(JNIEnv *env, jobject enum_obj);
extern jobject get_enum_object(JNIEnv *env, const char* enum_class_name,
jint enum_val, const char* enum_field_desc);
/* implemented at H5G.c */
extern jobject create_H5G_info_t(JNIEnv *env, H5G_info_t group_info);
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
#endif /* _Included_h5jni */
|