Merge pull request #67581 from aaronfranke/android-float

Use proper types for converting Java float/double arrays in Android code
This commit is contained in:
Rémi Verschelde 2022-10-31 10:36:11 +01:00
commit 638dfe2528
No known key found for this signature in database
GPG Key ID: C3336907360768E1
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;") {