diff options
Diffstat (limited to 'platform/android/java_glue.cpp')
-rw-r--r-- | platform/android/java_glue.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 5bf2fc5a73..b11994eef0 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -153,6 +153,14 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar v.l=arr; } break; + case Variant::RAW_ARRAY: { + DVector<uint8_t> array = *p_arg; + jbyteArray arr = env->NewByteArray(array.size()); + DVector<uint8_t>::Read r = array.read(); + env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr())); + v.l=arr; + + } break; case Variant::REAL_ARRAY: { DVector<float> array = *p_arg; @@ -244,6 +252,19 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { return sarr; }; + if (name == "[B") { + + jbyteArray arr = (jbyteArray)obj; + int fCount = env->GetArrayLength(arr); + DVector<uint8_t> sarr; + sarr.resize(fCount); + + DVector<uint8_t>::Write w = sarr.write(); + env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr())); + w = DVector<uint8_t>::Write(); + return sarr; + }; + if (name == "java.lang.Float" || name == "java.lang.Double") { jclass nclass = env->FindClass("java/lang/Number"); @@ -354,6 +375,7 @@ public: virtual Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) { //print_line("attempt to call "+String(p_method)); + ERR_FAIL_COND_V(!instance,Variant()); r_error.error=Variant::CallError::CALL_OK; @@ -519,7 +541,10 @@ public: } - JNISingleton() {} + JNISingleton() { + instance=NULL; + + } }; @@ -1342,6 +1367,7 @@ static Variant::Type get_jni_type(const String& p_type) { {"double", Variant::REAL}, {"java.lang.String",Variant::STRING}, {"[I",Variant::INT_ARRAY}, + {"[B",Variant::RAW_ARRAY}, {"[F",Variant::REAL_ARRAY}, {"[java.lang.String",Variant::STRING_ARRAY}, {"com.android.godot.Dictionary", Variant::DICTIONARY}, @@ -1377,6 +1403,7 @@ static const char* get_jni_sig(const String& p_type) { {"java.lang.String","Ljava/lang/String;"}, {"com.android.godot.Dictionary", "Lcom/android/godot/Dictionary;"}, {"[I","[I"}, + {"[B","[B"}, {"[F","[F"}, {"[java.lang.String","[Ljava/lang/String;"}, {NULL,"V"} |