Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9555 from JosJuice/android-jni-cleanup
Android: Some JNI cleanup
  • Loading branch information
leoetlino committed Mar 4, 2021
2 parents 6c23e16 + d99d72f commit 5efd563
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
@@ -1,6 +1,9 @@
package org.dolphinemu.dolphinemu.utils;

import androidx.annotation.Keep;

public interface BooleanSupplier
{
@Keep
boolean get();
}
15 changes: 8 additions & 7 deletions Source/Android/jni/AndroidCommon/IDCache.cpp
Expand Up @@ -271,11 +271,9 @@ jmethodID GetBooleanSupplierGet()

} // namespace IDCache

#ifdef __cplusplus
extern "C" {
#endif

jint JNI_OnLoad(JavaVM* vm, void* reserved)
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
s_java_vm = vm;

Expand Down Expand Up @@ -336,11 +334,13 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_linked_hash_map_init = env->GetMethodID(s_linked_hash_map_class, "<init>", "(I)V");
s_linked_hash_map_put = env->GetMethodID(
s_linked_hash_map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
env->DeleteLocalRef(map_class);

const jclass compress_cb_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/CompressCallback");
s_compress_cb_class = reinterpret_cast<jclass>(env->NewGlobalRef(compress_cb_class));
s_compress_cb_run = env->GetMethodID(s_compress_cb_class, "run", "(Ljava/lang/String;F)Z");
env->DeleteLocalRef(compress_cb_class);

const jclass content_handler_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/ContentHandler");
Expand All @@ -358,6 +358,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_content_handler_do_file_search =
env->GetStaticMethodID(s_content_handler_class, "doFileSearch",
"(Ljava/lang/String;[Ljava/lang/String;Z)[Ljava/lang/String;");
env->DeleteLocalRef(content_handler_class);

const jclass network_helper_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/NetworkHelper");
Expand All @@ -368,16 +369,18 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->GetStaticMethodID(s_network_helper_class, "GetNetworkPrefixLength", "()I");
s_network_helper_get_network_gateway =
env->GetStaticMethodID(s_network_helper_class, "GetNetworkGateway", "()I");
env->DeleteLocalRef(network_helper_class);

const jclass boolean_supplier_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/BooleanSupplier");
s_boolean_supplier_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_supplier_class));
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
env->DeleteLocalRef(boolean_supplier_class);

return JNI_VERSION;
}

void JNI_OnUnload(JavaVM* vm, void* reserved)
JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
{
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK)
Expand All @@ -393,8 +396,6 @@ void JNI_OnUnload(JavaVM* vm, void* reserved)
env->DeleteGlobalRef(s_compress_cb_class);
env->DeleteGlobalRef(s_content_handler_class);
env->DeleteGlobalRef(s_network_helper_class);
env->DeleteGlobalRef(s_boolean_supplier_class);
}

#ifdef __cplusplus
}
#endif
5 changes: 0 additions & 5 deletions Source/Android/jni/IniFile.cpp
Expand Up @@ -60,9 +60,7 @@ static void Set(JNIEnv* env, jobject obj, jstring section_name, jstring key, T n
->Set(GetJString(env, key), new_value);
}

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_exists(
JNIEnv* env, jobject obj, jstring key)
Expand Down Expand Up @@ -243,7 +241,4 @@ JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_copyIniFile
{
return reinterpret_cast<jlong>(new IniFile(*GetIniFilePointer(env, other)));
}

#ifdef __cplusplus
}
#endif
5 changes: 0 additions & 5 deletions Source/Android/jni/MainAndroid.cpp
Expand Up @@ -196,9 +196,7 @@ static std::string GetAnalyticValue(const std::string& key)
return stdvalue;
}

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv*,
jclass)
Expand Down Expand Up @@ -703,7 +701,4 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentTitleDescriptionUnchecked

return ToJString(env, description);
}

#ifdef __cplusplus
}
#endif
5 changes: 0 additions & 5 deletions Source/Android/jni/NativeConfig.cpp
Expand Up @@ -94,9 +94,7 @@ static void Set(jint layer, const Config::Location& location, T value)
Config::OnConfigChanged();
}

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_isSettingSaveable(
Expand Down Expand Up @@ -210,7 +208,4 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_Na
{
return Set(layer, GetLocation(env, file, section, key), value);
}

#ifdef __cplusplus
}
#endif

0 comments on commit 5efd563

Please sign in to comment.