From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- platform/javascript/export/export.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'platform/javascript/export/export.cpp') diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index fbc298a399..b5172651d0 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -41,7 +41,6 @@ #define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip" class EditorHTTPServer : public Reference { - private: Ref server; Ref connection; @@ -165,7 +164,6 @@ public: return; while (true) { - char *r = (char *)req_buf; int l = req_pos - 1; if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') { @@ -191,7 +189,6 @@ public: }; class EditorExportPlatformJavaScript : public EditorExportPlatform { - GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform); Ref logo; @@ -231,7 +228,6 @@ public: virtual Ref get_run_icon() const; virtual void get_platform_features(List *r_features) { - r_features->push_back("web"); r_features->push_back(get_os_name()); } @@ -246,7 +242,6 @@ public: }; void EditorExportPlatformJavaScript::_fix_html(Vector &p_html, const Ref &p_preset, const String &p_name, bool p_debug, int p_flags) { - String str_template = String::utf8(reinterpret_cast(p_html.ptr()), p_html.size()); String str_export; Vector lines = str_template.split("\n"); @@ -256,7 +251,6 @@ void EditorExportPlatformJavaScript::_fix_html(Vector &p_html, const Re flags_json = JSON::print(flags); for (int i = 0; i < lines.size(); i++) { - String current_line = lines[i]; current_line = current_line.replace("$GODOT_BASENAME", p_name); current_line = current_line.replace("$GODOT_PROJECT_NAME", ProjectSettings::get_singleton()->get_setting("application/config/name")); @@ -274,7 +268,6 @@ void EditorExportPlatformJavaScript::_fix_html(Vector &p_html, const Re } void EditorExportPlatformJavaScript::get_preset_features(const Ref &p_preset, List *r_features) { - if (p_preset->get("vram_texture_compression/for_desktop")) { r_features->push_back("s3tc"); } @@ -291,7 +284,6 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref *r_options) { - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), "")); @@ -301,22 +293,18 @@ void EditorExportPlatformJavaScript::get_export_options(List *r_op } String EditorExportPlatformJavaScript::get_name() const { - return "HTML5"; } String EditorExportPlatformJavaScript::get_os_name() const { - return "HTML5"; } Ref EditorExportPlatformJavaScript::get_logo() const { - return logo; } bool EditorExportPlatformJavaScript::can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const { - String err; bool valid = false; @@ -358,7 +346,6 @@ bool EditorExportPlatformJavaScript::can_export(const Ref &p } List EditorExportPlatformJavaScript::get_binary_extensions(const Ref &p_preset) const { - List list; list.push_back("html"); return list; @@ -376,7 +363,6 @@ Error EditorExportPlatformJavaScript::export_project(const Refshow_warning(TTR("Could not open template for export:") + "\n" + template_path); return ERR_FILE_NOT_FOUND; } @@ -434,7 +419,6 @@ Error EditorExportPlatformJavaScript::export_project(const Refshow_warning(TTR("Could not read custom HTML shell:") + "\n" + custom_html); @@ -531,11 +511,9 @@ Error EditorExportPlatformJavaScript::export_project(const Ref preset; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { - Ref ep = EditorExport::get_singleton()->get_export_preset(i); if (ep->is_runnable() && ep->get_platform() == this) { preset = ep; @@ -561,12 +539,10 @@ Ref EditorExportPlatformJavaScript::get_option_icon(int p_index) c } int EditorExportPlatformJavaScript::get_options_count() const { - return menu_options; } Error EditorExportPlatformJavaScript::run(const Ref &p_preset, int p_option, int p_debug_flags) { - if (p_option == 1) { MutexLock lock(server_lock); server->stop(); @@ -614,7 +590,6 @@ Error EditorExportPlatformJavaScript::run(const Ref &p_prese } Ref EditorExportPlatformJavaScript::get_run_icon() const { - return run_icon; } @@ -630,7 +605,6 @@ void EditorExportPlatformJavaScript::_server_thread_poll(void *data) { } EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { - server.instance(); server_quit = false; server_thread = Thread::create(_server_thread_poll, this); @@ -660,7 +634,6 @@ EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() { } void register_javascript_exporter() { - EDITOR_DEF("export/web/http_host", "localhost"); EDITOR_DEF("export/web/http_port", 8060); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "export/web/http_port", PROPERTY_HINT_RANGE, "1,65535,1")); -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: 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 --- platform/javascript/export/export.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'platform/javascript/export/export.cpp') diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index b5172651d0..3573ddac95 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -148,11 +148,13 @@ public: } void poll() { - if (!server->is_listening()) + if (!server->is_listening()) { return; + } if (connection.is_null()) { - if (!server->is_connection_available()) + if (!server->is_connection_available()) { return; + } connection = server->take_connection(); time = OS::get_singleton()->get_ticks_usec(); } @@ -160,8 +162,9 @@ public: _clear_client(); return; } - if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) + if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) { return; + } while (true) { char *r = (char *)req_buf; @@ -339,8 +342,9 @@ bool EditorExportPlatformJavaScript::can_export(const Ref &p } } - if (!err.empty()) + if (!err.empty()) { r_error = err; + } return valid; } @@ -363,10 +367,11 @@ Error EditorExportPlatformJavaScript::export_project(const Refcreate_from_image(img); Ref theme = EditorNode::get_singleton()->get_editor_theme(); - if (theme.is_valid()) + if (theme.is_valid()) { stop_icon = theme->get_icon("Stop", "EditorIcons"); - else + } else { stop_icon.instance(); + } menu_options = 0; } -- cgit v1.2.3