diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-09-15 19:48:18 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-09-15 19:48:18 +0200 |
commit | 48e1c19deaadac57172b8d3e3cf13cd53a1c8341 (patch) | |
tree | 55035b87d5c563e3a23330bbaa08408b41dbbad7 /platform/android | |
parent | df6cd37a697fcc2f63940d7984726661069c18b6 (diff) | |
parent | 3565d1bf7ebd2e36556736479cb8ba9523d70a63 (diff) | |
download | redot-engine-48e1c19deaadac57172b8d3e3cf13cd53a1c8341.tar.gz |
Merge pull request #81583 from AThousandShips/null_check_drivers_platform
[Drivers,Platform] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/dir_access_jandroid.cpp | 26 | ||||
-rw-r--r-- | platform/android/file_access_filesystem_jandroid.cpp | 26 | ||||
-rw-r--r-- | platform/android/tts_android.cpp | 16 |
3 files changed, 34 insertions, 34 deletions
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 6bd09fe00a..d24d3fa389 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -67,7 +67,7 @@ String DirAccessJAndroid::get_next() { ERR_FAIL_COND_V(id == 0, ""); if (_dir_next) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ""); + ERR_FAIL_NULL_V(env, ""); jstring str = (jstring)env->CallObjectMethod(dir_access_handler, _dir_next, get_access_type(), id); if (!str) { return ""; @@ -84,7 +84,7 @@ String DirAccessJAndroid::get_next() { bool DirAccessJAndroid::current_is_dir() const { if (_dir_is_dir) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(dir_access_handler, _dir_is_dir, get_access_type(), id); } else { return false; @@ -94,7 +94,7 @@ bool DirAccessJAndroid::current_is_dir() const { bool DirAccessJAndroid::current_is_hidden() const { if (_current_is_hidden) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(dir_access_handler, _current_is_hidden, get_access_type(), id); } return false; @@ -112,7 +112,7 @@ void DirAccessJAndroid::list_dir_end() { int DirAccessJAndroid::get_drive_count() { if (_get_drive_count) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); return env->CallIntMethod(dir_access_handler, _get_drive_count, get_access_type()); } else { return 0; @@ -122,7 +122,7 @@ int DirAccessJAndroid::get_drive_count() { String DirAccessJAndroid::get_drive(int p_drive) { if (_get_drive) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ""); + ERR_FAIL_NULL_V(env, ""); jstring j_drive = (jstring)env->CallObjectMethod(dir_access_handler, _get_drive, get_access_type(), p_drive); if (!j_drive) { return ""; @@ -191,7 +191,7 @@ String DirAccessJAndroid::get_absolute_path(String p_path) { bool DirAccessJAndroid::file_exists(String p_file) { if (_file_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = get_absolute_path(p_file); jstring j_path = env->NewStringUTF(path.utf8().get_data()); @@ -206,7 +206,7 @@ bool DirAccessJAndroid::file_exists(String p_file) { bool DirAccessJAndroid::dir_exists(String p_dir) { if (_dir_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = get_absolute_path(p_dir); jstring j_path = env->NewStringUTF(path.utf8().get_data()); @@ -226,7 +226,7 @@ Error DirAccessJAndroid::make_dir_recursive(String p_dir) { if (_make_dir) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = get_absolute_path(p_dir); jstring j_dir = env->NewStringUTF(path.utf8().get_data()); @@ -249,7 +249,7 @@ Error DirAccessJAndroid::make_dir(String p_dir) { Error DirAccessJAndroid::rename(String p_from, String p_to) { if (_rename) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String from_path = get_absolute_path(p_from); jstring j_from = env->NewStringUTF(from_path.utf8().get_data()); @@ -273,7 +273,7 @@ Error DirAccessJAndroid::rename(String p_from, String p_to) { Error DirAccessJAndroid::remove(String p_name) { if (_remove) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = get_absolute_path(p_name); jstring j_name = env->NewStringUTF(path.utf8().get_data()); @@ -292,7 +292,7 @@ Error DirAccessJAndroid::remove(String p_name) { uint64_t DirAccessJAndroid::get_space_left() { if (_get_space_left) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); return env->CallLongMethod(dir_access_handler, _get_space_left, get_access_type()); } else { return 0; @@ -331,7 +331,7 @@ DirAccessJAndroid::~DirAccessJAndroid() { int DirAccessJAndroid::dir_open(String p_path) { if (_dir_open) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); String path = get_absolute_path(p_path); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -346,7 +346,7 @@ int DirAccessJAndroid::dir_open(String p_path) { void DirAccessJAndroid::dir_close(int p_id) { if (_dir_close) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(dir_access_handler, _dir_close, get_access_type(), p_id); } } diff --git a/platform/android/file_access_filesystem_jandroid.cpp b/platform/android/file_access_filesystem_jandroid.cpp index a1865fb1d4..beea73fd61 100644 --- a/platform/android/file_access_filesystem_jandroid.cpp +++ b/platform/android/file_access_filesystem_jandroid.cpp @@ -69,7 +69,7 @@ Error FileAccessFilesystemJAndroid::open_internal(const String &p_path, int p_mo if (_file_open) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = fix_path(p_path).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -103,7 +103,7 @@ void FileAccessFilesystemJAndroid::_close() { if (_file_close) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(file_access_handler, _file_close, id); } id = 0; @@ -116,7 +116,7 @@ bool FileAccessFilesystemJAndroid::is_open() const { void FileAccessFilesystemJAndroid::seek(uint64_t p_position) { if (_file_seek) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_seek, id, p_position); } @@ -125,7 +125,7 @@ void FileAccessFilesystemJAndroid::seek(uint64_t p_position) { void FileAccessFilesystemJAndroid::seek_end(int64_t p_position) { if (_file_seek_end) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_seek_end, id, p_position); } @@ -134,7 +134,7 @@ void FileAccessFilesystemJAndroid::seek_end(int64_t p_position) { uint64_t FileAccessFilesystemJAndroid::get_position() const { if (_file_tell) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use."); return env->CallLongMethod(file_access_handler, _file_tell, id); } else { @@ -145,7 +145,7 @@ uint64_t FileAccessFilesystemJAndroid::get_position() const { uint64_t FileAccessFilesystemJAndroid::get_length() const { if (_file_get_size) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use."); return env->CallLongMethod(file_access_handler, _file_get_size, id); } else { @@ -156,7 +156,7 @@ uint64_t FileAccessFilesystemJAndroid::get_length() const { bool FileAccessFilesystemJAndroid::eof_reached() const { if (_file_eof) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); ERR_FAIL_COND_V_MSG(!is_open(), false, "File must be opened before use."); return env->CallBooleanMethod(file_access_handler, _file_eof, id); } else { @@ -169,7 +169,7 @@ void FileAccessFilesystemJAndroid::_set_eof(bool eof) { ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(file_access_handler, _file_set_eof, id, eof); } } @@ -235,7 +235,7 @@ uint64_t FileAccessFilesystemJAndroid::get_buffer(uint8_t *p_dst, uint64_t p_len } JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); jobject j_buffer = env->NewDirectByteBuffer(p_dst, p_length); int length = env->CallIntMethod(file_access_handler, _file_read, id, j_buffer); @@ -258,7 +258,7 @@ void FileAccessFilesystemJAndroid::store_buffer(const uint8_t *p_src, uint64_t p } JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); jobject j_buffer = env->NewDirectByteBuffer((void *)p_src, p_length); env->CallVoidMethod(file_access_handler, _file_write, id, j_buffer); @@ -276,7 +276,7 @@ Error FileAccessFilesystemJAndroid::get_error() const { void FileAccessFilesystemJAndroid::flush() { if (_file_flush) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_flush, id); } @@ -285,7 +285,7 @@ void FileAccessFilesystemJAndroid::flush() { bool FileAccessFilesystemJAndroid::file_exists(const String &p_path) { if (_file_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = fix_path(p_path).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -300,7 +300,7 @@ bool FileAccessFilesystemJAndroid::file_exists(const String &p_path) { uint64_t FileAccessFilesystemJAndroid::_get_modified_time(const String &p_file) { if (_file_last_modified) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = fix_path(p_file).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); diff --git a/platform/android/tts_android.cpp b/platform/android/tts_android.cpp index aef59c2584..93517d8045 100644 --- a/platform/android/tts_android.cpp +++ b/platform/android/tts_android.cpp @@ -54,7 +54,7 @@ void TTS_Android::setup(jobject p_tts) { bool tts_enabled = GLOBAL_GET("audio/general/text_to_speech"); if (tts_enabled) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); tts = env->NewGlobalRef(p_tts); @@ -103,7 +103,7 @@ bool TTS_Android::is_speaking() { if (_is_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(tts, _is_speaking); } else { return false; @@ -115,7 +115,7 @@ bool TTS_Android::is_paused() { if (_is_paused) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(tts, _is_paused); } else { return false; @@ -127,7 +127,7 @@ Array TTS_Android::get_voices() { Array list; if (_get_voices) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, list); + ERR_FAIL_NULL_V(env, list); jobject voices_object = env->CallObjectMethod(tts, _get_voices); jobjectArray *arr = reinterpret_cast<jobjectArray *>(&voices_object); @@ -165,7 +165,7 @@ void TTS_Android::speak(const String &p_text, const String &p_voice, int p_volum if (_speak) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); jstring jStrT = env->NewStringUTF(p_text.utf8().get_data()); jstring jStrV = env->NewStringUTF(p_voice.utf8().get_data()); @@ -178,7 +178,7 @@ void TTS_Android::pause() { if (_pause_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _pause_speaking); } } @@ -188,7 +188,7 @@ void TTS_Android::resume() { if (_resume_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _resume_speaking); } } @@ -203,7 +203,7 @@ void TTS_Android::stop() { if (_stop_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _stop_speaking); } } |