summaryrefslogtreecommitdiff
path: root/platform/android/jni_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/jni_utils.cpp')
-rw-r--r--platform/android/jni_utils.cpp34
1 files changed, 0 insertions, 34 deletions
diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp
index ded79a668f..8e1ae53b78 100644
--- a/platform/android/jni_utils.cpp
+++ b/platform/android/jni_utils.cpp
@@ -31,13 +31,10 @@
#include "jni_utils.h"
jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_arg, bool force_jobject) {
-
jvalret v;
switch (p_type) {
-
case Variant::BOOL: {
-
if (force_jobject) {
jclass bclass = env->FindClass("java/lang/Boolean");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(Z)V");
@@ -52,9 +49,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::INT: {
-
if (force_jobject) {
-
jclass bclass = env->FindClass("java/lang/Integer");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(I)V");
jvalue val;
@@ -69,9 +64,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::FLOAT: {
-
if (force_jobject) {
-
jclass bclass = env->FindClass("java/lang/Double");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(D)V");
jvalue val;
@@ -86,19 +79,16 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::STRING: {
-
String s = *p_arg;
jstring jStr = env->NewStringUTF(s.utf8().get_data());
v.val.l = jStr;
v.obj = jStr;
} break;
case Variant::PACKED_STRING_ARRAY: {
-
Vector<String> sarray = *p_arg;
jobjectArray arr = env->NewObjectArray(sarray.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (int j = 0; j < sarray.size(); j++) {
-
jstring str = env->NewStringUTF(sarray[j].utf8().get_data());
env->SetObjectArrayElement(arr, j, str);
env->DeleteLocalRef(str);
@@ -109,7 +99,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::DICTIONARY: {
-
Dictionary dict = *p_arg;
jclass dclass = env->FindClass("org/godotengine/godot/Dictionary");
jmethodID ctor = env->GetMethodID(dclass, "<init>", "()V");
@@ -152,7 +141,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::PACKED_INT32_ARRAY: {
-
Vector<int> array = *p_arg;
jintArray arr = env->NewIntArray(array.size());
const int *r = array.ptr();
@@ -171,7 +159,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
Vector<float> array = *p_arg;
jfloatArray arr = env->NewFloatArray(array.size());
const float *r = array.ptr();
@@ -185,7 +172,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
#endif
default: {
-
v.val.i = 0;
} break;
}
@@ -193,7 +179,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
}
String _get_class_name(JNIEnv *env, jclass cls, bool *array) {
-
jclass cclass = env->FindClass("java/lang/Class");
jmethodID getName = env->GetMethodID(cclass, "getName", "()Ljava/lang/String;");
jstring clsName = (jstring)env->CallObjectMethod(cls, getName);
@@ -210,7 +195,6 @@ String _get_class_name(JNIEnv *env, jclass cls, bool *array) {
}
Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
-
if (obj == nullptr) {
return Variant();
}
@@ -220,12 +204,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
String name = _get_class_name(env, c, &array);
if (name == "java.lang.String") {
-
return jstring_to_string((jstring)obj, env);
};
if (name == "[Ljava.lang.String;") {
-
jobjectArray arr = (jobjectArray)obj;
int stringCount = env->GetArrayLength(arr);
Vector<String> sarr;
@@ -240,14 +222,12 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.lang.Boolean") {
-
jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
bool ret = env->CallBooleanMethod(obj, boolValue);
return ret;
};
if (name == "java.lang.Integer" || name == "java.lang.Long") {
-
jclass nclass = env->FindClass("java/lang/Number");
jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J");
jlong ret = env->CallLongMethod(obj, longValue);
@@ -255,7 +235,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[I") {
-
jintArray arr = (jintArray)obj;
int fCount = env->GetArrayLength(arr);
Vector<int> sarr;
@@ -267,7 +246,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[B") {
-
jbyteArray arr = (jbyteArray)obj;
int fCount = env->GetArrayLength(arr);
Vector<uint8_t> sarr;
@@ -279,7 +257,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.lang.Float" || name == "java.lang.Double") {
-
jclass nclass = env->FindClass("java/lang/Number");
jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
double ret = env->CallDoubleMethod(obj, doubleValue);
@@ -287,7 +264,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[D") {
-
jdoubleArray arr = (jdoubleArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
@@ -296,7 +272,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
real_t *w = sarr.ptrw();
for (int i = 0; i < fCount; i++) {
-
double n;
env->GetDoubleArrayRegion(arr, i, 1, &n);
w[i] = n;
@@ -305,7 +280,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[F") {
-
jfloatArray arr = (jfloatArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
@@ -314,7 +288,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
real_t *w = sarr.ptrw();
for (int i = 0; i < fCount; i++) {
-
float n;
env->GetFloatArrayRegion(arr, i, 1, &n);
w[i] = n;
@@ -323,7 +296,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[Ljava.lang.Object;") {
-
jobjectArray arr = (jobjectArray)obj;
int objCount = env->GetArrayLength(arr);
Array varr;
@@ -339,7 +311,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
-
Dictionary ret;
jclass oclass = c;
jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
@@ -355,7 +326,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
env->DeleteLocalRef(arr);
for (int i = 0; i < keys.size(); i++) {
-
ret[keys[i]] = vals[i];
};
@@ -368,7 +338,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
}
Variant::Type get_jni_type(const String &p_type) {
-
static struct {
const char *name;
Variant::Type type;
@@ -390,7 +359,6 @@ Variant::Type get_jni_type(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
-
if (p_type == _type_to_vtype[idx].name)
return _type_to_vtype[idx].type;
@@ -401,7 +369,6 @@ Variant::Type get_jni_type(const String &p_type) {
}
const char *get_jni_sig(const String &p_type) {
-
static struct {
const char *name;
const char *sig;
@@ -423,7 +390,6 @@ const char *get_jni_sig(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
-
if (p_type == _type_to_vtype[idx].name)
return _type_to_vtype[idx].sig;