Java - unsigned long long marshalling improvements for negative numbers

Affects marshalling of negative numbers from Java to C only.
A cast to signed long long in the C layer will now result in the expected value.

Closes #623.
This commit is contained in:
William S Fulton 2016-03-31 18:42:08 +01:00
commit a15bbbaee5
5 changed files with 90 additions and 14 deletions

View file

@ -109,8 +109,11 @@ INPUT_TYPEMAP(double, jdouble, double, "D");
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
temp = 0;
for(i=0; i<sz; i++) {
temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
if (sz > 0) {
temp = ($*1_ltype)(signed char)bae[0];
for(i=1; i<sz; i++) {
temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
}
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
$1 = &temp;
@ -416,8 +419,11 @@ INOUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArr
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
temp = 0;
for(i=0; i<sz; i++) {
temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
if (sz > 0) {
temp = ($*1_ltype)(signed char)bae[0];
for(i=1; i<sz; i++) {
temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
}
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
$1 = &temp;