Skip to content

Commit

Permalink
Use proper types for converting Java float/double arrays in Android code
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Oct 18, 2022
1 parent 2e3662a commit 01bec83
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions platform/android/jni_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;") {
Expand Down

0 comments on commit 01bec83

Please sign in to comment.