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;"); jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max), Common::Android::ToJLong(env, max),
Common::Android::ToJDouble(env, progress)); Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled); 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;"); jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max), Common::Android::ToJLong(env, max),
Common::Android::ToJDouble(env, progress)); Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled); 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;"); jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) {
auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod,
Common::Android::ToJDouble(env, max), Common::Android::ToJLong(env, max),
Common::Android::ToJDouble(env, progress)); Common::Android::ToJLong(env, progress));
return Common::Android::GetJBoolean(env, jwasCancelled); return Common::Android::GetJBoolean(env, jwasCancelled);
}; };
auto& session = EmulationSession::GetInstance(); auto& session = EmulationSession::GetInstance();

View file

@ -54,6 +54,14 @@ jobject ToJInteger(JNIEnv* env, s32 value) {
return env->NewObject(GetIntegerClass(), GetIntegerConstructor(), 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) { bool GetJBoolean(JNIEnv* env, jobject jboolean) {
return env->GetBooleanField(jboolean, GetBooleanValueField()); return env->GetBooleanField(jboolean, GetBooleanValueField());
} }

View file

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

View file

@ -61,6 +61,10 @@ static jclass s_integer_class;
static jmethodID s_integer_constructor; static jmethodID s_integer_constructor;
static jfieldID s_integer_value_field; 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 jclass s_boolean_class;
static jmethodID s_boolean_constructor; static jmethodID s_boolean_constructor;
static jfieldID s_boolean_value_field; static jfieldID s_boolean_value_field;
@ -288,6 +292,18 @@ jfieldID GetIntegerValueField() {
return s_integer_value_field; 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() { jclass GetBooleanClass() {
return s_boolean_class; 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"); s_integer_value_field = env->GetFieldID(int_class, "value", "I");
env->DeleteLocalRef(int_class); 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"); const jclass boolean_class = env->FindClass("java/lang/Boolean");
s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class)); s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V"); s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");

View file

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