diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/android/android_common.cpp (renamed from src/android/app/src/main/jni/android_common/android_common.cpp) | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/android/app/src/main/jni/android_common/android_common.cpp b/src/common/android/android_common.cpp index 7018a52af..e79005658 100644 --- a/src/android/app/src/main/jni/android_common/android_common.cpp +++ b/src/common/android/android_common.cpp | |||
| @@ -1,15 +1,17 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "jni/android_common/android_common.h" | 4 | #include "android_common.h" |
| 5 | 5 | ||
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include <string_view> | 7 | #include <string_view> |
| 8 | 8 | ||
| 9 | #include <jni.h> | 9 | #include <jni.h> |
| 10 | 10 | ||
| 11 | #include "common/android/id_cache.h" | ||
| 11 | #include "common/string_util.h" | 12 | #include "common/string_util.h" |
| 12 | #include "jni/id_cache.h" | 13 | |
| 14 | namespace Common::Android { | ||
| 13 | 15 | ||
| 14 | std::string GetJString(JNIEnv* env, jstring jstr) { | 16 | std::string GetJString(JNIEnv* env, jstring jstr) { |
| 15 | if (!jstr) { | 17 | if (!jstr) { |
| @@ -18,7 +20,8 @@ std::string GetJString(JNIEnv* env, jstring jstr) { | |||
| 18 | 20 | ||
| 19 | const jchar* jchars = env->GetStringChars(jstr, nullptr); | 21 | const jchar* jchars = env->GetStringChars(jstr, nullptr); |
| 20 | const jsize length = env->GetStringLength(jstr); | 22 | const jsize length = env->GetStringLength(jstr); |
| 21 | const std::u16string_view string_view(reinterpret_cast<const char16_t*>(jchars), length); | 23 | const std::u16string_view string_view(reinterpret_cast<const char16_t*>(jchars), |
| 24 | static_cast<u32>(length)); | ||
| 22 | const std::string converted_string = Common::UTF16ToUTF8(string_view); | 25 | const std::string converted_string = Common::UTF16ToUTF8(string_view); |
| 23 | env->ReleaseStringChars(jstr, jchars); | 26 | env->ReleaseStringChars(jstr, jchars); |
| 24 | 27 | ||
| @@ -36,25 +39,27 @@ jstring ToJString(JNIEnv* env, std::u16string_view str) { | |||
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | double GetJDouble(JNIEnv* env, jobject jdouble) { | 41 | double GetJDouble(JNIEnv* env, jobject jdouble) { |
| 39 | return env->GetDoubleField(jdouble, IDCache::GetDoubleValueField()); | 42 | return env->GetDoubleField(jdouble, GetDoubleValueField()); |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 42 | jobject ToJDouble(JNIEnv* env, double value) { | 45 | jobject ToJDouble(JNIEnv* env, double value) { |
| 43 | return env->NewObject(IDCache::GetDoubleClass(), IDCache::GetDoubleConstructor(), value); | 46 | return env->NewObject(GetDoubleClass(), GetDoubleConstructor(), value); |
| 44 | } | 47 | } |
| 45 | 48 | ||
| 46 | s32 GetJInteger(JNIEnv* env, jobject jinteger) { | 49 | s32 GetJInteger(JNIEnv* env, jobject jinteger) { |
| 47 | return env->GetIntField(jinteger, IDCache::GetIntegerValueField()); | 50 | return env->GetIntField(jinteger, GetIntegerValueField()); |
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | jobject ToJInteger(JNIEnv* env, s32 value) { | 53 | jobject ToJInteger(JNIEnv* env, s32 value) { |
| 51 | return env->NewObject(IDCache::GetIntegerClass(), IDCache::GetIntegerConstructor(), value); | 54 | return env->NewObject(GetIntegerClass(), GetIntegerConstructor(), value); |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | bool GetJBoolean(JNIEnv* env, jobject jboolean) { | 57 | bool GetJBoolean(JNIEnv* env, jobject jboolean) { |
| 55 | return env->GetBooleanField(jboolean, IDCache::GetBooleanValueField()); | 58 | return env->GetBooleanField(jboolean, GetBooleanValueField()); |
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | jobject ToJBoolean(JNIEnv* env, bool value) { | 61 | jobject ToJBoolean(JNIEnv* env, bool value) { |
| 59 | return env->NewObject(IDCache::GetBooleanClass(), IDCache::GetBooleanConstructor(), value); | 62 | return env->NewObject(GetBooleanClass(), GetBooleanConstructor(), value); |
| 60 | } | 63 | } |
| 64 | |||
| 65 | } // namespace Common::Android | ||