diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /modules/gdnative | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'modules/gdnative')
-rw-r--r-- | modules/gdnative/gdnative.cpp | 15 | ||||
-rw-r--r-- | modules/gdnative/gdnative/gdnative.cpp | 6 | ||||
-rw-r--r-- | modules/gdnative/gdnative_library_editor_plugin.cpp | 17 | ||||
-rw-r--r-- | modules/gdnative/gdnative_library_singleton_editor.cpp | 12 | ||||
-rw-r--r-- | modules/gdnative/nativescript/godot_nativescript.cpp | 6 | ||||
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 129 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_loader.cpp | 9 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.cpp | 33 | ||||
-rw-r--r-- | modules/gdnative/register_types.cpp | 3 | ||||
-rw-r--r-- | modules/gdnative/videodecoder/video_stream_gdnative.cpp | 18 | ||||
-rw-r--r-- | modules/gdnative/videodecoder/video_stream_gdnative.h | 3 |
11 files changed, 166 insertions, 85 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 7a231ac903..3d747ba41e 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -114,8 +114,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { // set entries List<String> entry_key_list; - if (config_file->has_section("entry")) + if (config_file->has_section("entry")) { config_file->get_section_keys("entry", &entry_key_list); + } for (List<String>::Element *E = entry_key_list.front(); E; E = E->next()) { String key = E->get(); @@ -131,8 +132,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { // set dependencies List<String> dependency_key_list; - if (config_file->has_section("dependencies")) + if (config_file->has_section("dependencies")) { config_file->get_section_keys("dependencies", &dependency_key_list); + } for (List<String>::Element *E = dependency_key_list.front(); E; E = E->next()) { String key = E->get(); @@ -156,8 +158,9 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { { List<String> entry_keys; - if (p_config_file->has_section("entry")) + if (p_config_file->has_section("entry")) { p_config_file->get_section_keys("entry", &entry_keys); + } for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { String key = E->get(); @@ -187,8 +190,9 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { { List<String> dependency_keys; - if (p_config_file->has_section("dependencies")) + if (p_config_file->has_section("dependencies")) { p_config_file->get_section_keys("dependencies", &dependency_keys); + } for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { String key = E->get(); @@ -513,8 +517,9 @@ bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const { String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (el == "gdnlib") + if (el == "gdnlib") { return "GDNativeLibrary"; + } return ""; } diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 234dbe9534..6b2b5b80a4 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -91,8 +91,9 @@ godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, god godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) { ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); - if (class_info) + if (class_info) { return (godot_class_constructor)class_info->creation_func; + } return nullptr; } @@ -175,8 +176,9 @@ void *godot_get_class_tag(const godot_string_name *p_class) { } godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) { - if (!p_object) + if (!p_object) { return nullptr; + } Object *o = (Object *)p_object; return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr; diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 278bc7217d..2a9836329e 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -128,8 +128,9 @@ void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) { if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) { EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE; - if (id == BUTTON_SELECT_DEPENDENCES) + if (id == BUTTON_SELECT_DEPENDENCES) { mode = EditorFileDialog::FILE_MODE_OPEN_FILES; + } file_dialog->set_meta("target", target); file_dialog->set_meta("section", section); @@ -192,10 +193,11 @@ void GDNativeLibraryEditor::_on_create_new_entry() { } void GDNativeLibraryEditor::_set_target_value(const String §ion, const String &target, Variant file) { - if (section == "entry") + if (section == "entry") { entry_configs[target].library = file; - else if (section == "dependencies") + } else if (section == "dependencies") { entry_configs[target].dependencies = file; + } _translate_to_config_file(); _update_tree(); } @@ -237,8 +239,9 @@ void GDNativeLibraryEditor::_translate_to_config_file() { for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { String target = E->key() + "." + it->get(); - if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) + if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) { continue; + } config->set_value("entry", target, entry_configs[target].library); config->set_value("dependencies", target, entry_configs[target].dependencies); @@ -371,8 +374,9 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { void GDNativeLibraryEditorPlugin::edit(Object *p_node) { Ref<GDNativeLibrary> new_library = Object::cast_to<GDNativeLibrary>(p_node); - if (new_library.is_valid()) + if (new_library.is_valid()) { library_editor->edit(new_library); + } } bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const { @@ -385,8 +389,9 @@ void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) { EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor); } else { - if (library_editor->is_visible_in_tree()) + if (library_editor->is_visible_in_tree()) { EditorNode::get_singleton()->hide_bottom_panel(); + } button->hide(); } } diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp index 27f18c91a8..409b6cbffe 100644 --- a/modules/gdnative/gdnative_library_singleton_editor.cpp +++ b/modules/gdnative/gdnative_library_singleton_editor.cpp @@ -135,19 +135,22 @@ void GDNativeLibrarySingletonEditor::_update_libraries() { } // The singletons list changed, we must update the settings - if (updated_disabled.size() != singletons_disabled.size()) + if (updated_disabled.size() != singletons_disabled.size()) { ProjectSettings::get_singleton()->set("gdnative/singletons_disabled", updated_disabled); + } updating = false; } void GDNativeLibrarySingletonEditor::_item_edited() { - if (updating) + if (updating) { return; + } TreeItem *item = libraries->get_edited(); - if (!item) + if (!item) { return; + } bool enabled = item->get_range(1); String path = item->get_metadata(0); @@ -165,8 +168,9 @@ void GDNativeLibrarySingletonEditor::_item_edited() { if (enabled) { disabled_paths.erase(path); } else { - if (disabled_paths.find(path) == -1) + if (disabled_paths.find(path) == -1) { disabled_paths.push_back(path); + } } undo_redo->create_action(enabled ? TTR("Enabled GDNative Singleton") : TTR("Disabled GDNative Singleton")); diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index ee944ee7cb..1bdac0dcb2 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -204,8 +204,9 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { Object *instance = (Object *)p_instance; - if (!instance) + if (!instance) { return nullptr; + } if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { return ((NativeScriptInstance *)instance->get_script_instance())->userdata; } @@ -320,8 +321,9 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) return nullptr; } - if (script->get_script_desc()) + if (script->get_script_desc()) { return script->get_script_desc()->type_tag; + } } return nullptr; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index fe9496702a..f3dfd0b68e 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -184,8 +184,9 @@ bool NativeScript::can_instance() const { Ref<Script> NativeScript::get_base_script() const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) + if (!script_data) { return Ref<Script>(); + } NativeScript *script = (NativeScript *)NSL->create_script(); Ref<NativeScript> ns = Ref<NativeScript>(script); @@ -199,8 +200,9 @@ Ref<Script> NativeScript::get_base_script() const { StringName NativeScript::get_instance_base_type() const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) + if (!script_data) { return ""; + } return script_data->base_native_type; } @@ -272,8 +274,9 @@ bool NativeScript::has_method(const StringName &p_method) const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - if (script_data->methods.has(p_method)) + if (script_data->methods.has(p_method)) { return true; + } script_data = script_data->base_data; } @@ -283,14 +286,16 @@ bool NativeScript::has_method(const StringName &p_method) const { MethodInfo NativeScript::get_method_info(const StringName &p_method) const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) + if (!script_data) { return MethodInfo(); + } while (script_data) { Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method); - if (M) + if (M) { return M->get().info; + } script_data = script_data->base_data; } @@ -304,8 +309,9 @@ bool NativeScript::is_valid() const { bool NativeScript::is_tool() const { NativeScriptDesc *script_data = get_script_desc(); - if (script_data) + if (script_data) { return script_data->is_tool; + } return false; } @@ -318,8 +324,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - if (script_data->signals_.has(p_signal)) + if (script_data->signals_.has(p_signal)) { return true; + } script_data = script_data->base_data; } return false; @@ -328,8 +335,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const { void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) + if (!script_data) { return; + } Set<MethodInfo> signals_; @@ -354,8 +362,9 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari P = script_data->properties.find(p_property); script_data = script_data->base_data; } - if (!P) + if (!P) { return false; + } r_value = P.get().default_value; return true; @@ -367,8 +376,9 @@ void NativeScript::update_exports() { void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) + if (!script_data) { return; + } Set<MethodInfo> methods; @@ -990,17 +1000,20 @@ String NativeScriptInstance::to_string(bool *r_valid) { Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) { if (ret.get_type() != Variant::STRING) { - if (r_valid) + if (r_valid) { *r_valid = false; + } ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String."); } - if (r_valid) + if (r_valid) { *r_valid = true; + } return ret.operator String(); } } - if (r_valid) + if (r_valid) { *r_valid = false; + } return String(); } @@ -1102,8 +1115,9 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method, NativeScriptInstance::~NativeScriptInstance() { NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - if (!script_data) + if (!script_data) { return; + } script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata); @@ -1155,25 +1169,30 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { // free property stuff first for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { - if (P.get().getter.free_func) + if (P.get().getter.free_func) { P.get().getter.free_func(P.get().getter.method_data); + } - if (P.get().setter.free_func) + if (P.get().setter.free_func) { P.get().setter.free_func(P.get().setter.method_data); + } } // free method stuff for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) + if (M->get().method.free_func) { M->get().method.free_func(M->get().method.method_data); + } } // free constructor/destructor - if (C->get().create_func.free_func) + if (C->get().create_func.free_func) { C->get().create_func.free_func(C->get().create_func.method_data); + } - if (C->get().destroy_func.free_func) + if (C->get().destroy_func.free_func) { C->get().destroy_func.free_func(C->get().destroy_func.method_data); + } } erase_and_unload.insert(lib_path, gdn); @@ -1407,8 +1426,9 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a int current = 0; for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { - if (current >= p_info_max) + if (current >= p_info_max) { break; + } p_info_arr[current].call_count = d->get().call_count; p_info_arr[current].self_time = d->get().self_time; @@ -1430,8 +1450,9 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in int current = 0; for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { - if (current >= p_info_max) + if (current >= p_info_max) { break; + } if (d->get().last_frame_call_count) { p_info_arr[current].call_count = d->get().last_frame_call_count; @@ -1508,14 +1529,16 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) { for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) { Vector<void *> &binding_data = *E->get(); - if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) + if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) { binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]); + } } binding_functions.write[p_idx].first = false; - if (binding_functions[p_idx].second.free_func) + if (binding_functions[p_idx].second.free_func) { binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data); + } } void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) { @@ -1525,8 +1548,9 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx); - if (!binding_data) + if (!binding_data) { return nullptr; // should never happen. + } if (binding_data->size() <= p_idx) { // okay, add new elements here. @@ -1564,14 +1588,16 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { } void NativeScriptLanguage::free_instance_binding_data(void *p_data) { - if (!p_data) + if (!p_data) { return; + } Vector<void *> &binding_data = *(Vector<void *> *)p_data; for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) + if (!binding_data[i]) { continue; + } if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) { binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]); @@ -1586,17 +1612,20 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) { void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) { void *data = p_object->get_script_instance_binding(lang_idx); - if (!data) + if (!data) { return; + } Vector<void *> &binding_data = *(Vector<void *> *)data; for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) + if (!binding_data[i]) { continue; + } - if (!binding_functions[i].first) + if (!binding_functions[i].first) { continue; + } if (binding_functions[i].second.refcount_incremented_instance_binding) { binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object); @@ -1607,19 +1636,22 @@ void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_objec bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) { void *data = p_object->get_script_instance_binding(lang_idx); - if (!data) + if (!data) { return true; + } Vector<void *> &binding_data = *(Vector<void *> *)data; bool can_die = true; for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) + if (!binding_data[i]) { continue; + } - if (!binding_functions[i].first) + if (!binding_functions[i].first) { continue; + } if (binding_functions[i].second.refcount_decremented_instance_binding) { can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object); @@ -1640,13 +1672,15 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam } const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const { - if (!global_type_tags.has(p_idx)) + if (!global_type_tags.has(p_idx)) { return nullptr; + } const HashMap<StringName, const void *> &tags = global_type_tags[p_idx]; - if (!tags.has(p_class_name)) + if (!tags.has(p_class_name)) { return nullptr; + } const void *tag = tags.get(p_class_name); @@ -1682,8 +1716,9 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>()); - if (!library_script_users.has(lib_path)) + if (!library_script_users.has(lib_path)) { library_script_users.insert(lib_path, Set<NativeScript *>()); + } void *proc_ptr; @@ -1792,16 +1827,20 @@ String NativeScriptLanguage::get_global_class_name(const String &p_path, String if (!p_path.empty()) { Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript"); if (script.is_valid()) { - if (r_base_type) + if (r_base_type) { *r_base_type = script->get_instance_base_type(); - if (r_icon_path) + } + if (r_icon_path) { *r_icon_path = script->get_script_class_icon_path(); + } return script->get_script_class_name(); } - if (r_base_type) + if (r_base_type) { *r_base_type = String(); - if (r_icon_path) + } + if (r_icon_path) { *r_icon_path = String(); + } } return String(); } @@ -1815,8 +1854,9 @@ void NativeReloadNode::_notification(int p_what) { switch (p_what) { case NOTIFICATION_WM_FOCUS_OUT: { - if (unloaded) + if (unloaded) { break; + } MutexLock lock(NSL->mutex); NSL->_unload_stuff(true); @@ -1848,8 +1888,9 @@ void NativeReloadNode::_notification(int p_what) { } break; case NOTIFICATION_WM_FOCUS_IN: { - if (!unloaded) + if (!unloaded) { break; + } MutexLock lock(NSL->mutex); Set<StringName> libs_to_remove; @@ -1891,8 +1932,9 @@ void NativeReloadNode::_notification(int p_what) { for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) { NativeScript *script = S->get(); - if (script->placeholders.size() == 0) + if (script->placeholders.size() == 0) { continue; + } for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) { script->_update_placeholder(P->get()); @@ -1928,8 +1970,9 @@ bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (el == "gdns") + if (el == "gdns") { return "NativeScript"; + } return ""; } diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index 7ce124c16a..4feee4f4a5 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -40,8 +40,9 @@ ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptL } RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) + if (r_error) { *r_error = ERR_FILE_CANT_OPEN; + } PluginScript *script = memnew(PluginScript); script->init(_language); @@ -55,8 +56,9 @@ RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p script->reload(); - if (r_error) + if (r_error) { *r_error = OK; + } return scriptres; } @@ -71,8 +73,9 @@ bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (el == _language->get_extension()) + if (el == _language->get_extension()) { return _language->get_type(); + } return ""; } diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index d659ade876..87c6288806 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -154,10 +154,12 @@ Ref<Script> PluginScript::get_base_script() const { } StringName PluginScript::get_instance_base_type() const { - if (_native_parent) + if (_native_parent) { return _native_parent; - if (_ref_base_parent.is_valid()) + } + if (_ref_base_parent.is_valid()) { return _ref_base_parent->get_instance_base_type(); + } return StringName(); } @@ -226,8 +228,9 @@ String PluginScript::get_source_code() const { } void PluginScript::set_source_code(const String &p_code) { - if (_source == p_code) + if (_source == p_code) { return; + } _source = p_code; } @@ -241,11 +244,13 @@ Error PluginScript::reload(bool p_keep_state) { _valid = false; String basedir = _path; - if (basedir == "") + if (basedir == "") { basedir = get_path(); + } - if (basedir != "") + if (basedir != "") { basedir = basedir.get_base_dir(); + } if (_data) { _desc->finish(_data); @@ -471,11 +476,11 @@ void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const { int PluginScript::get_member_line(const StringName &p_member) const { #ifdef TOOLS_ENABLED - if (_member_lines.has(p_member)) + if (_member_lines.has(p_member)) { return _member_lines[p_member]; - else + } #endif - return -1; + return -1; } Vector<ScriptNetData> PluginScript::get_rpc_methods() const { @@ -494,15 +499,17 @@ uint16_t PluginScript::get_rpc_method_id(const StringName &p_method) const { StringName PluginScript::get_rpc_method(const uint16_t p_rpc_method_id) const { ASSERT_SCRIPT_VALID_V(StringName()); - if (p_rpc_method_id >= _rpc_methods.size()) + if (p_rpc_method_id >= _rpc_methods.size()) { return StringName(); + } return _rpc_methods[p_rpc_method_id].name; } MultiplayerAPI::RPCMode PluginScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const { ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED); - if (p_rpc_method_id >= _rpc_methods.size()) + if (p_rpc_method_id >= _rpc_methods.size()) { return MultiplayerAPI::RPC_MODE_DISABLED; + } return _rpc_methods[p_rpc_method_id].mode; } @@ -527,15 +534,17 @@ uint16_t PluginScript::get_rset_property_id(const StringName &p_property) const StringName PluginScript::get_rset_property(const uint16_t p_rset_property_id) const { ASSERT_SCRIPT_VALID_V(StringName()); - if (p_rset_property_id >= _rpc_variables.size()) + if (p_rset_property_id >= _rpc_variables.size()) { return StringName(); + } return _rpc_variables[p_rset_property_id].name; } MultiplayerAPI::RPCMode PluginScript::get_rset_mode_by_id(const uint16_t p_rset_property_id) const { ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED); - if (p_rset_property_id >= _rpc_variables.size()) + if (p_rset_property_id >= _rpc_variables.size()) { return MultiplayerAPI::RPC_MODE_DISABLED; + } return _rpc_variables[p_rset_property_id].mode; } diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index bffbb86526..136af5bd1e 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -254,8 +254,9 @@ void register_gdnative_types() { for (int i = 0; i < singletons.size(); i++) { String path = singletons[i]; - if (excluded.has(path)) + if (excluded.has(path)) { continue; + } Ref<GDNativeLibrary> lib = ResourceLoader::load(path); Ref<GDNative> singleton; diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index 476f44b185..9d9c5b6473 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -208,10 +208,12 @@ VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() { } void VideoStreamPlaybackGDNative::cleanup() { - if (data_struct) + if (data_struct) { interface->destructor(data_struct); - if (pcm) + } + if (pcm) { memfree(pcm); + } pcm = nullptr; time = 0; num_channels = -1; @@ -257,8 +259,9 @@ void VideoStreamPlaybackGDNative::stop() { void VideoStreamPlaybackGDNative::seek(float p_time) { ERR_FAIL_COND(interface == nullptr); interface->seek(data_struct, p_time); - if (p_time < time) + if (p_time < time) { seek_backward = true; + } time = p_time; // reset audio buffers memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float)); @@ -320,12 +323,14 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const { Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() { Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative); VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower()); - if (decoder == nullptr) + if (decoder == nullptr) { return nullptr; + } pb->set_interface(decoder->interface); pb->set_audio_track(audio_track); - if (pb->open_file(file)) + if (pb->open_file(file)) { return pb; + } return nullptr; } @@ -382,7 +387,8 @@ bool ResourceFormatLoaderVideoStreamGDNative::handles_type(const String &p_type) String ResourceFormatLoaderVideoStreamGDNative::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (VideoDecoderServer::get_instance()->get_extensions().has(el)) + if (VideoDecoderServer::get_instance()->get_extensions().has(el)) { return "VideoStreamGDNative"; + } return ""; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index 2da63e96d6..53017a6a97 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -86,8 +86,9 @@ public: } VideoDecoderGDNative *get_decoder(const String &extension) { - if (extensions.size() == 0 || !extensions.has(extension)) + if (extensions.size() == 0 || !extensions.has(extension)) { return nullptr; + } return decoders[extensions[extension]]; } |