21 #ifndef jtie_tconv_ptrbyval_impl_hpp
22 #define jtie_tconv_ptrbyval_impl_hpp
27 #include "jtie_tconv_ptrbyval.hpp"
28 #include "jtie_tconv_impl.hpp"
29 #include "jtie_tconv_array_impl.hpp"
30 #include "jtie_tconv_utils_impl.hpp"
31 #include "helpers.hpp"
40 ensureMinArraySize(jarray ja, JNIEnv * env) {
47 jsize
n = env->GetArrayLength(ja);
48 if (env->ExceptionCheck() != JNI_OK) {
53 const char * c =
"java/lang/IllegalArgumentException";
54 const char * m = (
"JTie: the Java array's length is too small for"
55 " the mapped parameter (file: " __FILE__
")");
56 registerException(env, c, m);
66 template<
typename J,
typename C >
69 convert(cstatus & s,
typename J::JA_t * j, JNIEnv * env) {
70 TRACE(
"C * ArrayPtrParam.convert(cstatus &, typename J::JA_t *, JNIEnv *)");
79 if (ensureMinArraySize< J::length >(j, env) != 0) {
82 assert(env->GetArrayLength(j) >= J::length);
100 release(C * c,
typename J::JA_t * j, JNIEnv * env) {
101 TRACE(
"void ArrayPtrParam.release(C *, typename J::JA_t *, JNIEnv *)");
118 const jint copyBackMode
136 template<
typename J,
typename C >
139 convert(C * c, JNIEnv * env) {
140 TRACE(
"J * ArrayPtrResult.convert(C *, JNIEnv *)");
150 J * ja =
static_cast< J *
>(jja);
154 assert(env->GetArrayLength(ja) == J::length);
172 template<
typename C >
173 struct Param< _jbooleanArray *, C *
const >
175 template<
typename C >
176 struct Param< _jbyteArray *, C *
const >
178 template<
typename C >
179 struct Param< _jshortArray *, C *
const >
181 template<
typename C >
182 struct Param< _jintArray *, C *
const >
184 template<
typename C >
185 struct Param< _jlongArray *, C *
const >
187 template<
typename C >
188 struct Param< _jfloatArray *, C *
const >
190 template<
typename C >
191 struct Param< _jdoubleArray *, C *
const >
195 template<
typename C >
196 struct Result< _jbooleanArray *, C *
const >
198 template<
typename C >
199 struct Result< _jbyteArray *, C *
const >
201 template<
typename C >
202 struct Result< _jshortArray *, C *
const >
204 template<
typename C >
207 template<
typename C >
208 struct Result< _jlongArray *, C *
const >
210 template<
typename C >
211 struct Result< _jfloatArray *, C *
const >
213 template<
typename C >
214 struct Result< _jdoubleArray *, C *
const >
218 template<
typename J,
typename C >
221 template<
typename J,
typename C >
230 template<
typename J,
typename C >
233 template<
typename J,
typename C >
242 #define JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING( J, C ) \
244 struct Param< J *, C * > \
245 : ArrayPtrParam< _jtie_j_BoundedArray< J, 0 >, C > {}; \
247 struct Param< J *, const C * > \
248 : ArrayPtrParam< _jtie_j_BoundedArray< J, 0 >, const C > {}; \
250 struct Result< J *, C * > \
251 : ArrayPtrResult< _jtie_j_BoundedArray< J, 0 >, C > {}; \
253 struct Result< J *, const C * > \
254 : ArrayPtrResult< _jtie_j_BoundedArray< J, 0 >, const C > {};
260 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jbooleanArray,
bool)
262 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jbyteArray,
char)
263 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jbyteArray,
signed char)
264 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jbyteArray,
unsigned char)
266 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jfloatArray,
float)
267 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jdoubleArray,
double)
274 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jshortArray,
signed short)
275 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jshortArray,
unsigned short)
278 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jshortArray,
signed int)
279 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jshortArray,
unsigned int)
282 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jintArray,
signed int)
283 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jintArray,
unsigned int)
286 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jintArray,
signed long)
287 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jintArray,
unsigned long)
290 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
signed int)
291 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
unsigned int)
294 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
signed long)
295 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
unsigned long)
298 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
signed long long)
299 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jlongArray,
unsigned long long)
302 JTIE_SPECIALIZE_ARRAY_TYPE_MAPPING(_jdoubleArray,
long double)
306 #endif // jtie_tconv_ptrbyval_impl_hpp