Merge commit 'ab4c093976' into torzu-merging

This commit is contained in:
marius david 2025-01-01 19:30:37 +01:00
commit ab0b473a8e
5 changed files with 43 additions and 6 deletions

View File

@ -459,8 +459,8 @@ int Java_dev_suyu_suyu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject
jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max),
Common::Android::ToJDouble(env, progress));
Common::Android::ToJLong(env, max),
Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled);
};
@ -791,8 +791,8 @@ jobjectArray Java_dev_suyu_suyu_1emu_NativeLibrary_verifyInstalledContents(JNIEn
jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max),
Common::Android::ToJDouble(env, progress));
Common::Android::ToJLong(env, max),
Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled);
};
@ -814,8 +814,8 @@ jint Java_dev_suyu_suyu_1emu_NativeLibrary_verifyGameContents(JNIEnv* env, jobje
jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max),
Common::Android::ToJDouble(env, progress));
Common::Android::ToJLong(env, max),
Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled);
};
auto& session = EmulationSession::GetInstance();

View File

@ -54,6 +54,14 @@ jobject ToJInteger(JNIEnv* env, s32 value) {
return env->NewObject(GetIntegerClass(), GetIntegerConstructor(), value);
}
s64 GetJLong(JNIEnv* env, jobject jlong) {
return env->GetLongField(jlong, GetIntegerValueField());
}
jobject ToJLong(JNIEnv* env, s64 value) {
return env->NewObject(GetLongClass(), GetLongConstructor(), value);
}
bool GetJBoolean(JNIEnv* env, jobject jboolean) {
return env->GetBooleanField(jboolean, GetBooleanValueField());
}

View File

@ -20,6 +20,9 @@ jobject ToJDouble(JNIEnv* env, double value);
s32 GetJInteger(JNIEnv* env, jobject jinteger);
jobject ToJInteger(JNIEnv* env, s32 value);
s64 GetJLong(JNIEnv* env, jobject jlong);
jobject ToJLong(JNIEnv* env, s64 value);
bool GetJBoolean(JNIEnv* env, jobject jboolean);
jobject ToJBoolean(JNIEnv* env, bool value);

View File

@ -61,6 +61,10 @@ static jclass s_integer_class;
static jmethodID s_integer_constructor;
static jfieldID s_integer_value_field;
static jclass s_long_class;
static jmethodID s_long_constructor;
static jfieldID s_long_value_field;
static jclass s_boolean_class;
static jmethodID s_boolean_constructor;
static jfieldID s_boolean_value_field;
@ -288,6 +292,18 @@ jfieldID GetIntegerValueField() {
return s_integer_value_field;
}
jclass GetLongClass() {
return s_long_class;
}
jmethodID GetLongConstructor() {
return s_long_constructor;
}
jfieldID GetLongValueField() {
return s_long_value_field;
}
jclass GetBooleanClass() {
return s_boolean_class;
}
@ -493,6 +509,12 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
s_integer_value_field = env->GetFieldID(int_class, "value", "I");
env->DeleteLocalRef(int_class);
const jclass long_class = env->FindClass("java/lang/Long");
s_long_class = reinterpret_cast<jclass>(env->NewGlobalRef(long_class));
s_long_constructor = env->GetMethodID(long_class, "<init>", "(J)V");
s_long_value_field = env->GetFieldID(long_class, "value", "J");
env->DeleteLocalRef(long_class);
const jclass boolean_class = env->FindClass("java/lang/Boolean");
s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");

View File

@ -81,6 +81,10 @@ jclass GetIntegerClass();
jmethodID GetIntegerConstructor();
jfieldID GetIntegerValueField();
jclass GetLongClass();
jmethodID GetLongConstructor();
jfieldID GetLongValueField();
jclass GetBooleanClass();
jmethodID GetBooleanConstructor();
jfieldID GetBooleanValueField();