Use proper types for converting Java float/double arrays in Android code
This commit is contained in:
parent
2e3662acbd
commit
01bec83cb6
|
@ -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;") {
|
||||
|
|
Loading…
Reference in New Issue