Use proper types for converting Java float/double arrays in Android code

This commit is contained in:
Aaron Franke 2022-10-18 08:26:04 -05:00
parent 2e3662acbd
commit 01bec83cb6
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
1 changed files with 8 additions and 8 deletions

View File

@ -265,33 +265,33 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
if (name == "[D") {
jdoubleArray arr = (jdoubleArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
sarr.resize(fCount);
PackedFloat64Array packed_array;
packed_array.resize(fCount);
real_t *w = sarr.ptrw();
double *w = packed_array.ptrw();
for (int i = 0; i < fCount; i++) {
double n;
env->GetDoubleArrayRegion(arr, i, 1, &n);
w[i] = n;
}
return sarr;
return packed_array;
}
if (name == "[F") {
jfloatArray arr = (jfloatArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
sarr.resize(fCount);
PackedFloat32Array packed_array;
packed_array.resize(fCount);
real_t *w = sarr.ptrw();
float *w = packed_array.ptrw();
for (int i = 0; i < fCount; i++) {
float n;
env->GetFloatArrayRegion(arr, i, 1, &n);
w[i] = n;
}
return sarr;
return packed_array;
}
if (name == "[Ljava.lang.Object;") {