Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable #83003

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/extension/gdextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void GDExtension::initialize_library(InitializationLevel p_level) {

level_initialized = int32_t(p_level);

ERR_FAIL_COND(initialization.initialize == nullptr);
ERR_FAIL_NULL(initialization.initialize);

initialization.initialize(initialization.userdata, GDExtensionInitializationLevel(p_level));
}
Expand Down
20 changes: 10 additions & 10 deletions core/io/file_access_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void godot_free(voidpf opaque, voidpf address) {
} // extern "C"

void ZipArchive::close_handle(unzFile p_file) const {
ERR_FAIL_COND_MSG(!p_file, "Cannot close a file if none is open.");
ERR_FAIL_NULL_MSG(p_file, "Cannot close a file if none is open.");
unzCloseCurrentFile(p_file);
unzClose(p_file);
}
Expand All @@ -136,7 +136,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
io.free_mem = godot_free;

unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, nullptr, "Cannot open file '" + packages[file.package].filename + "'.");
ERR_FAIL_NULL_V_MSG(pkg, nullptr, "Cannot open file '" + packages[file.package].filename + "'.");
int unz_err = unzGoToFilePos(pkg, &file.file_pos);
if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) {
unzClose(pkg);
Expand Down Expand Up @@ -168,7 +168,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6
io.zerror_file = godot_testerror;

unzFile zfile = unzOpen2(p_path.utf8().get_data(), &io);
ERR_FAIL_COND_V(!zfile, false);
ERR_FAIL_NULL_V(zfile, false);

unz_global_info64 gi;
int err = unzGetGlobalInfo64(zfile, &gi);
Expand Down Expand Up @@ -241,7 +241,7 @@ Error FileAccessZip::open_internal(const String &p_path, int p_mode_flags) {
ZipArchive *arch = ZipArchive::get_singleton();
ERR_FAIL_NULL_V(arch, FAILED);
zfile = arch->get_file_handle(p_path);
ERR_FAIL_COND_V(!zfile, FAILED);
ERR_FAIL_NULL_V(zfile, FAILED);

int err = unzGetCurrentFileInfo64(zfile, &file_info, nullptr, 0, nullptr, 0, nullptr, 0);
ERR_FAIL_COND_V(err != UNZ_OK, FAILED);
Expand All @@ -265,28 +265,28 @@ bool FileAccessZip::is_open() const {
}

void FileAccessZip::seek(uint64_t p_position) {
ERR_FAIL_COND(!zfile);
ERR_FAIL_NULL(zfile);

unzSeekCurrentFile(zfile, p_position);
}

void FileAccessZip::seek_end(int64_t p_position) {
ERR_FAIL_COND(!zfile);
ERR_FAIL_NULL(zfile);
unzSeekCurrentFile(zfile, get_length() + p_position);
}

uint64_t FileAccessZip::get_position() const {
ERR_FAIL_COND_V(!zfile, 0);
ERR_FAIL_NULL_V(zfile, 0);
return unztell(zfile);
}

uint64_t FileAccessZip::get_length() const {
ERR_FAIL_COND_V(!zfile, 0);
ERR_FAIL_NULL_V(zfile, 0);
return file_info.uncompressed_size;
}

bool FileAccessZip::eof_reached() const {
ERR_FAIL_COND_V(!zfile, true);
ERR_FAIL_NULL_V(zfile, true);

return at_eof;
}
Expand All @@ -299,7 +299,7 @@ uint8_t FileAccessZip::get_8() const {

uint64_t FileAccessZip::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(!zfile, -1);
ERR_FAIL_NULL_V(zfile, -1);

at_eof = unzeof(zfile);
if (at_eof) {
Expand Down
6 changes: 3 additions & 3 deletions core/object/callable_method_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CallableCustomMethodPointer : public CallableCustomMethodPointerBase {

virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
#endif
call_with_variant_args(data.instance, data.method, p_arguments, p_argcount, r_call_error);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ class CallableCustomMethodPointerRet : public CallableCustomMethodPointerBase {

virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
#endif
call_with_variant_args_ret(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
}
Expand Down Expand Up @@ -209,7 +209,7 @@ class CallableCustomMethodPointerRetC : public CallableCustomMethodPointerBase {

virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
#endif
call_with_variant_args_retc(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
}
Expand Down
2 changes: 1 addition & 1 deletion core/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,7 @@ Variant::operator ::RID() const {
} else if (type == OBJECT && _get_obj().obj) {
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_active()) {
ERR_FAIL_COND_V_MSG(ObjectDB::get_instance(_get_obj().id) == nullptr, ::RID(), "Invalid pointer (object was freed).");
ERR_FAIL_NULL_V_MSG(ObjectDB::get_instance(_get_obj().id), ::RID(), "Invalid pointer (object was freed).");
}
#endif
Callable::CallError ce;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
}

void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index) {
ERR_FAIL_COND(!state.canvas_instance_batches[state.current_batch_index].command);
ERR_FAIL_NULL(state.canvas_instance_batches[state.current_batch_index].command);

// Used by Polygon and Mesh.
static const GLenum prim[5] = { GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP };
Expand Down Expand Up @@ -2157,7 +2157,7 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe
GLES3::Texture *t = texture_storage->get_texture(p_texture);

if (t) {
ERR_FAIL_COND(!t->canvas_texture);
ERR_FAIL_NULL(t->canvas_texture);
ct = t->canvas_texture;
if (t->render_target) {
t->render_target->used_in_frame = true;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/material_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
return;
}

ERR_FAIL_COND(shader->data == nullptr);
ERR_FAIL_NULL(shader->data);

material->data = material_data_request_func[shader->mode](shader->data);
material->data->self = p_material;
Expand Down
6 changes: 3 additions & 3 deletions drivers/unix/dir_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
// prev_dir is the directory we are changing out of
String prev_dir;
char real_current_dir_name[2048];
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
ERR_FAIL_NULL_V(getcwd(real_current_dir_name, 2048), ERR_BUG);
if (prev_dir.parse_utf8(real_current_dir_name) != OK) {
prev_dir = real_current_dir_name; //no utf8, maybe latin?
}
Expand All @@ -361,7 +361,7 @@ Error DirAccessUnix::change_dir(String p_dir) {

String base = _get_root_path();
if (!base.is_empty() && !try_dir.begins_with(base)) {
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
ERR_FAIL_NULL_V(getcwd(real_current_dir_name, 2048), ERR_BUG);
String new_dir;
new_dir.parse_utf8(real_current_dir_name);

Expand Down Expand Up @@ -496,7 +496,7 @@ DirAccessUnix::DirAccessUnix() {

// set current directory to an absolute path of the current directory
char real_current_dir_name[2048];
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr);
ERR_FAIL_NULL(getcwd(real_current_dir_name, 2048));
if (current_dir.parse_utf8(real_current_dir_name) != OK) {
current_dir = real_current_dir_name;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/vulkan/vulkan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) {
#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \
{ \
fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \
ERR_FAIL_NULL_V_MSG(fp##entrypoint, ERR_CANT_CREATE, \
"vkGetInstanceProcAddr failed to find vk" #entrypoint); \
}

Expand Down Expand Up @@ -1689,7 +1689,7 @@ Error VulkanContext::_initialize_queues(VkSurfaceKHR p_surface) {
if (!g_gdpa) \
g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(inst, "vkGetDeviceProcAddr"); \
fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \
ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \
ERR_FAIL_NULL_V_MSG(fp##entrypoint, ERR_CANT_CREATE, \
"vkGetDeviceProcAddr failed to find vk" #entrypoint); \
}

Expand Down
2 changes: 1 addition & 1 deletion editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3903,7 +3903,7 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
ERR_FAIL_NULL(root);
ERR_FAIL_COND(history->get_path_size() == 0);
Object *obj = ObjectDB::get_instance(history->get_path_object(0));
ERR_FAIL_COND(!Object::cast_to<Node>(obj));
ERR_FAIL_NULL(Object::cast_to<Node>(obj));

// Let's build a node path.
Node *node = Object::cast_to<Node>(obj);
Expand Down
2 changes: 1 addition & 1 deletion editor/export/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
zlib_filefunc_def io = zipio_create_io(&io_fa);

unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
ERR_FAIL_NULL_V_MSG(pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");

int ret = unzGoToFirstFile(pkg);
int total_files = 0;
Expand Down
2 changes: 1 addition & 1 deletion editor/import/collada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it...
NodeJoint *nj = dynamic_cast<NodeJoint *>(state.scene_map[nodeid]);
ERR_FAIL_NULL_V(nj, false);
ERR_FAIL_COND_V(!nj->owner, false); //weird, node should have a skeleton owner
ERR_FAIL_NULL_V(nj->owner, false); // Weird, node should have a skeleton owner.

NodeSkeleton *sk = nj->owner;

Expand Down
2 changes: 1 addition & 1 deletion editor/import/resource_importer_shader_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
Error err;
Ref<FileAccess> file = FileAccess::open(p_source_file, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
ERR_FAIL_COND_V(!file.operator->(), ERR_CANT_OPEN);
ERR_FAIL_COND_V(!file.is_valid(), ERR_CANT_OPEN);

String file_txt = file->get_as_utf8_string();
Ref<RDShaderFile> shader_file;
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
return;
}

ERR_FAIL_COND(!get_tree());
ERR_FAIL_NULL(get_tree());

HashSet<Ref<Script>> scripts;

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/skeleton_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void Skeleton3DEditor::pose_to_rest(const bool p_all_bones) {

void Skeleton3DEditor::create_physical_skeleton() {
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
ERR_FAIL_COND(!get_tree());
ERR_FAIL_NULL(get_tree());
Node *owner = get_tree()->get_edited_scene_root();

const int bone_count = skeleton->get_bone_count();
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/version_control_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "scene/gui/separator.h"

#define CHECK_PLUGIN_INITIALIZED() \
ERR_FAIL_COND_MSG(!EditorVCSInterface::get_singleton(), "No VCS plugin is initialized. Select a Version Control Plugin from Project menu.");
ERR_FAIL_NULL_MSG(EditorVCSInterface::get_singleton(), "No VCS plugin is initialized. Select a Version Control Plugin from Project menu.");

VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void ProjectDialog::_nonempty_confirmation_ok_pressed() {
}

void ProjectDialog::_renderer_selected() {
ERR_FAIL_COND(!renderer_button_group->get_pressed_button());
ERR_FAIL_NULL(renderer_button_group->get_pressed_button());

String renderer_type = renderer_button_group->get_pressed_button()->get_meta(SNAME("rendering_method"));

Expand Down
4 changes: 2 additions & 2 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *top_node = selection[i];
Node *bottom_node = selection[selection.size() - 1 - i];

ERR_FAIL_COND(!top_node->get_parent());
ERR_FAIL_COND(!bottom_node->get_parent());
ERR_FAIL_NULL(top_node->get_parent());
ERR_FAIL_NULL(bottom_node->get_parent());

int bottom_node_pos = bottom_node->get_index(false);
int top_node_pos_next = top_node->get_index(false) + (MOVING_DOWN ? 1 : -1);
Expand Down
4 changes: 2 additions & 2 deletions modules/enet/enet_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int ENetConnection::get_max_channels() const {

int ENetConnection::get_local_port() const {
ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active.");
ERR_FAIL_COND_V_MSG(!(host->socket), 0, "The ENetConnection instance isn't currently bound");
ERR_FAIL_NULL_V_MSG(host->socket, 0, "The ENetConnection instance isn't currently bound.");
ENetAddress address;
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), 0, "Unable to get socket address");
return address.port;
Expand Down Expand Up @@ -344,7 +344,7 @@ void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_f

void ENetConnection::socket_send(const String &p_address, int p_port, const PackedByteArray &p_packet) {
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
ERR_FAIL_COND_MSG(!(host->socket), "The ENetConnection instance isn't currently bound");
ERR_FAIL_NULL_MSG(host->socket, "The ENetConnection instance isn't currently bound.");
ERR_FAIL_COND_MSG(p_port < 1 || p_port > 65535, "The remote port number must be between 1 and 65535 (inclusive).");

IPAddress ip;
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5410,7 +5410,7 @@ void GDScriptParser::TreePrinter::print_while(WhileNode *p_while) {
}

void GDScriptParser::TreePrinter::print_tree(const GDScriptParser &p_parser) {
ERR_FAIL_COND_MSG(p_parser.get_tree() == nullptr, "Parse the code before printing the parse tree.");
ERR_FAIL_NULL_MSG(p_parser.get_tree(), "Parse the code before printing the parse tree.");

if (p_parser.is_tool()) {
push_line("@tool");
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/managed_callable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void ManagedCallable::call(const Variant **p_arguments, int p_argcount, Variant
r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; // Can't find anything better
r_return_value = Variant();

ERR_FAIL_COND(delegate_handle.value == nullptr);
ERR_FAIL_NULL(delegate_handle.value);

GDMonoCache::managed_callbacks.DelegateUtils_InvokeWithVariantArgs(
delegate_handle, trampoline, p_arguments, p_argcount, &r_return_value);
Expand Down
4 changes: 2 additions & 2 deletions modules/openxr/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
#define GDEXTENSION_INIT_XR_FUNC(name) \
do { \
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
ERR_FAIL_COND(name##_ptr == nullptr); \
ERR_FAIL_NULL(name##_ptr); \
} while (0)

#define GDEXTENSION_INIT_XR_FUNC_V(name) \
do { \
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
ERR_FAIL_COND_V(name##_ptr == nullptr, false); \
ERR_FAIL_NULL_V(name##_ptr, false); \
} while (0)

#define EXT_PROTO_XRRESULT_FUNC1(func_name, arg1_type, arg1) \
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4084,7 +4084,7 @@ bool TextServerAdvanced::_shaped_text_add_string(const RID &p_shaped, const Stri

MutexLock lock(sd->mutex);
for (int i = 0; i < p_fonts.size(); i++) {
ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false);
ERR_FAIL_NULL_V(_get_font_data(p_fonts[i]), false);
}

if (p_text.is_empty()) {
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/text_server_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2939,7 +2939,7 @@ bool TextServerFallback::_shaped_text_add_string(const RID &p_shaped, const Stri
ERR_FAIL_COND_V(p_size <= 0, false);

for (int i = 0; i < p_fonts.size(); i++) {
ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false);
ERR_FAIL_NULL_V(_get_font_data(p_fonts[i]), false);
}

if (p_text.is_empty()) {
Expand Down
14 changes: 7 additions & 7 deletions platform/ios/display_server_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -317,37 +317,37 @@
}

bool DisplayServerIOS::tts_is_speaking() const {
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
return [tts isSpeaking];
}

bool DisplayServerIOS::tts_is_paused() const {
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
return [tts isPaused];
}

TypedArray<Dictionary> DisplayServerIOS::tts_get_voices() const {
ERR_FAIL_COND_V_MSG(!tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_V_MSG(tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
return [tts getVoices];
}

void DisplayServerIOS::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
[tts speak:p_text voice:p_voice volume:p_volume pitch:p_pitch rate:p_rate utterance_id:p_utterance_id interrupt:p_interrupt];
}

void DisplayServerIOS::tts_pause() {
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
[tts pauseSpeaking];
}

void DisplayServerIOS::tts_resume() {
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
[tts resumeSpeaking];
}

void DisplayServerIOS::tts_stop() {
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
[tts stopSpeaking];
}

Expand Down
Loading
Loading