diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-25 15:27:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 15:27:09 +0100 |
commit | 2f237d181b6fd769b52bded49cafc9bc5eb9f087 (patch) | |
tree | 7a675fe9331fd010c5e8486df42ac6fad188179c /platform/android | |
parent | b8f0da7bed976f889a0316981dc419e179f63df8 (diff) | |
parent | 33b5c571995cce60a21784ac33fcf958640ed1e2 (diff) |
Merge pull request #36515 from reduz/packed-array-64-bits
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/api/java_class_wrapper.h | 14 | ||||
-rw-r--r-- | platform/android/java_class_wrapper.cpp | 2 | ||||
-rw-r--r-- | platform/android/java_godot_lib_jni.cpp | 31 |
3 files changed, 27 insertions, 20 deletions
diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h index 5414b533f9..48b581958b 100644 --- a/platform/android/api/java_class_wrapper.h +++ b/platform/android/api/java_class_wrapper.h @@ -113,12 +113,12 @@ class JavaClass : public Reference { break; case ARG_TYPE_FLOAT | ARG_NUMBER_CLASS_BIT: case ARG_TYPE_FLOAT: - r_type = Variant::REAL; + r_type = Variant::FLOAT; likelihood = 1.0; break; case ARG_TYPE_DOUBLE | ARG_NUMBER_CLASS_BIT: case ARG_TYPE_DOUBLE: - r_type = Variant::REAL; + r_type = Variant::FLOAT; likelihood = 0.5; break; case ARG_TYPE_STRING: r_type = Variant::STRING; break; @@ -134,23 +134,23 @@ class JavaClass : public Reference { likelihood = 0.5; break; case ARG_ARRAY_BIT | ARG_TYPE_SHORT: - r_type = Variant::PACKED_INT_ARRAY; + r_type = Variant::PACKED_INT32_ARRAY; likelihood = 0.3; break; case ARG_ARRAY_BIT | ARG_TYPE_INT: - r_type = Variant::PACKED_INT_ARRAY; + r_type = Variant::PACKED_INT32_ARRAY; likelihood = 1.0; break; case ARG_ARRAY_BIT | ARG_TYPE_LONG: - r_type = Variant::PACKED_INT_ARRAY; + r_type = Variant::PACKED_INT32_ARRAY; likelihood = 0.5; break; case ARG_ARRAY_BIT | ARG_TYPE_FLOAT: - r_type = Variant::PACKED_REAL_ARRAY; + r_type = Variant::PACKED_FLOAT32_ARRAY; likelihood = 1.0; break; case ARG_ARRAY_BIT | ARG_TYPE_DOUBLE: - r_type = Variant::PACKED_REAL_ARRAY; + r_type = Variant::PACKED_FLOAT32_ARRAY; likelihood = 0.5; break; case ARG_ARRAY_BIT | ARG_TYPE_STRING: r_type = Variant::PACKED_STRING_ARRAY; break; diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 76213b949d..9e9b17fb99 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -97,7 +97,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, case ARG_TYPE_DOUBLE: { if (!p_args[i]->is_num()) - arg_expected = Variant::REAL; + arg_expected = Variant::FLOAT; } break; case ARG_TYPE_STRING: { diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index b99cf70659..900a452024 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -99,7 +99,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.val.i = *p_arg; }; } break; - case Variant::REAL: { + case Variant::FLOAT: { if (force_jobject) { @@ -182,7 +182,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = jdict; } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { Vector<int> array = *p_arg; jintArray arr = env->NewIntArray(array.size()); @@ -201,7 +201,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = arr; } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { Vector<float> array = *p_arg; jfloatArray arr = env->NewFloatArray(array.size()); @@ -211,6 +211,10 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = arr; } break; +#ifndef _MSC_VER +#warning This is missing 64 bits arrays, I have no idea how to do it in JNI +#endif + default: { v.val.i = 0; @@ -319,7 +323,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { jdoubleArray arr = (jdoubleArray)obj; int fCount = env->GetArrayLength(arr); - PackedRealArray sarr; + PackedFloat32Array sarr; sarr.resize(fCount); real_t *w = sarr.ptrw(); @@ -337,7 +341,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { jfloatArray arr = (jfloatArray)obj; int fCount = env->GetArrayLength(arr); - PackedRealArray sarr; + PackedFloat32Array sarr; sarr.resize(fCount); real_t *w = sarr.ptrw(); @@ -487,7 +491,7 @@ public: ret = env->CallIntMethodA(instance, E->get().method, v); } break; - case Variant::REAL: { + case Variant::FLOAT: { ret = env->CallFloatMethodA(instance, E->get().method, v); } break; @@ -505,7 +509,7 @@ public: env->DeleteLocalRef(arr); } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { jintArray arr = (jintArray)env->CallObjectMethodA(instance, E->get().method, v); @@ -519,7 +523,7 @@ public: ret = sarr; env->DeleteLocalRef(arr); } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance, E->get().method, v); @@ -534,6 +538,9 @@ public: env->DeleteLocalRef(arr); } break; +#ifndef _MSC_VER +#warning This is missing 64 bits arrays, I have no idea how to do it in JNI +#endif case Variant::DICTIONARY: { jobject obj = env->CallObjectMethodA(instance, E->get().method, v); @@ -1246,12 +1253,12 @@ static Variant::Type get_jni_type(const String &p_type) { { "void", Variant::NIL }, { "boolean", Variant::BOOL }, { "int", Variant::INT }, - { "float", Variant::REAL }, - { "double", Variant::REAL }, + { "float", Variant::FLOAT }, + { "double", Variant::FLOAT }, { "java.lang.String", Variant::STRING }, - { "[I", Variant::PACKED_INT_ARRAY }, + { "[I", Variant::PACKED_INT32_ARRAY }, { "[B", Variant::PACKED_BYTE_ARRAY }, - { "[F", Variant::PACKED_REAL_ARRAY }, + { "[F", Variant::PACKED_FLOAT32_ARRAY }, { "[Ljava.lang.String;", Variant::PACKED_STRING_ARRAY }, { "org.godotengine.godot.Dictionary", Variant::DICTIONARY }, { NULL, Variant::NIL } |