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

@ -310,8 +310,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
$1 = 0;
for(i=0; i<sz; i++) {
$1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
if (sz > 0) {
$1 = ($1_type)(signed char)bae[0];
for(i=1; i<sz; i++) {
$1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
}
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@ -334,8 +337,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
$result = 0;
for(i=0; i<sz; i++) {
$result = ($result << 8) | ($1_type)(unsigned char)bae[i];
if (sz > 0) {
$result = ($1_type)(signed char)bae[0];
for(i=1; i<sz; i++) {
$result = ($result << 8) | ($1_type)(unsigned char)bae[i];
}
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@ -552,8 +558,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
sz = JCALL1(GetArrayLength, jenv, ba);
$1 = &temp;
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);
}
@ -578,8 +587,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
sz = JCALL1(GetArrayLength, jenv, ba);
$result = &temp;
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);
}