diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3493219ea7e..6f77645584e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 + rev: v17.0.6 hooks: - id: clang-format files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java|glsl)$ @@ -14,7 +14,7 @@ repos: ) - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.3.0 + rev: 24.2.0 hooks: - id: black files: (\.py$|SConstruct|SCsub) diff --git a/core/core_builders.py b/core/core_builders.py index 8b6b87ad830..61b7bd695c6 100644 --- a/core/core_builders.py +++ b/core/core_builders.py @@ -2,6 +2,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import zlib from platform_methods import subprocess_main diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index 0c96c32187a..f96a8873caf 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -1415,7 +1415,7 @@ static void gdextension_editor_help_load_xml_from_utf8_chars(const char *p_data) #endif } -#define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr)&gdextension_##m_name) +#define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr) & gdextension_##m_name) void gdextension_setup_interface() { REGISTER_INTERFACE_FUNC(get_godot_version); diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index e2edf8b23e1..4d554551666 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -393,7 +393,7 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i return; } -#define vert(m_idx) Vector3(((m_idx)&4) >> 2, ((m_idx)&2) >> 1, (m_idx)&1) +#define vert(m_idx) Vector3(((m_idx) & 4) >> 2, ((m_idx) & 2) >> 1, (m_idx) & 1) static const uint8_t indices[6][4] = { { 7, 6, 4, 5 }, diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 171074188f6..79bed9be337 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -810,7 +810,7 @@ struct VariantInternalAccessor { #define VARIANT_ACCESSOR_NUMBER(m_type) \ template <> \ struct VariantInternalAccessor { \ - static _FORCE_INLINE_ m_type get(const Variant *v) { return (m_type)*VariantInternal::get_int(v); } \ + static _FORCE_INLINE_ m_type get(const Variant *v) { return (m_type) * VariantInternal::get_int(v); } \ static _FORCE_INLINE_ void set(Variant *v, m_type p_value) { *VariantInternal::get_int(v) = p_value; } \ }; diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 50c9c10987b..20941b944fb 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -433,9 +433,9 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const { } \ m_assign_type num; \ if (value->get_type() == Variant::INT) { \ - num = (m_assign_type)*VariantGetInternalPtr::get_ptr(value); \ + num = (m_assign_type) * VariantGetInternalPtr::get_ptr(value); \ } else if (value->get_type() == Variant::FLOAT) { \ - num = (m_assign_type)*VariantGetInternalPtr::get_ptr(value); \ + num = (m_assign_type) * VariantGetInternalPtr::get_ptr(value); \ } else { \ *oob = false; \ *valid = false; \ @@ -495,9 +495,9 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const { } \ m_assign_type num; \ if (value->get_type() == Variant::INT) { \ - num = (m_assign_type)*VariantGetInternalPtr::get_ptr(value); \ + num = (m_assign_type) * VariantGetInternalPtr::get_ptr(value); \ } else if (value->get_type() == Variant::FLOAT) { \ - num = (m_assign_type)*VariantGetInternalPtr::get_ptr(value); \ + num = (m_assign_type) * VariantGetInternalPtr::get_ptr(value); \ } else { \ *oob = false; \ *valid = false; \ diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index aae06505cdf..dd8bceb573b 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -47,7 +47,7 @@ #include #ifdef _MSC_VER -#define S_ISREG(m) ((m)&_S_IFREG) +#define S_ISREG(m) ((m) & _S_IFREG) #endif void FileAccessWindows::check_errors() const { diff --git a/gles3_builders.py b/gles3_builders.py index 055451f298a..f1cdf7ac8c2 100644 --- a/gles3_builders.py +++ b/gles3_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os.path from typing import Optional diff --git a/glsl_builders.py b/glsl_builders.py index a6ca9aa2f3b..ce52ec247da 100644 --- a/glsl_builders.py +++ b/glsl_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os.path from typing import Optional, Iterable diff --git a/main/main_builders.py b/main/main_builders.py index c880bfa3c43..59d9d7dc3d0 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + from platform_methods import subprocess_main diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index aa37df67520..f2d70db7a47 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -73,7 +73,7 @@ using namespace godot; /*************************************************************************/ -#define OT_TAG(c1, c2, c3, c4) ((int32_t)((((uint32_t)(c1)&0xff) << 24) | (((uint32_t)(c2)&0xff) << 16) | (((uint32_t)(c3)&0xff) << 8) | ((uint32_t)(c4)&0xff))) +#define OT_TAG(c1, c2, c3, c4) ((int32_t)((((uint32_t)(c1) & 0xff) << 24) | (((uint32_t)(c2) & 0xff) << 16) | (((uint32_t)(c3) & 0xff) << 8) | ((uint32_t)(c4) & 0xff))) bool TextServerFallback::_has_feature(Feature p_feature) const { switch (p_feature) { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 53182b8e2d9..db0352db012 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -387,7 +387,7 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) { d.description += "Chipset: " + p.get_slice("=", 1).strip_edges() + "\n"; } else if (p.begins_with("ro.opengles.version=")) { uint32_t opengl = p.get_slice("=", 1).to_int(); - d.description += "OpenGL: " + itos(opengl >> 16) + "." + itos((opengl >> 8) & 0xFF) + "." + itos((opengl)&0xFF) + "\n"; + d.description += "OpenGL: " + itos(opengl >> 16) + "." + itos((opengl >> 8) & 0xFF) + "." + itos((opengl) & 0xFF) + "\n"; } } diff --git a/platform/linuxbsd/platform_linuxbsd_builders.py b/platform/linuxbsd/platform_linuxbsd_builders.py index 58234f37486..85d55f0ac6f 100644 --- a/platform/linuxbsd/platform_linuxbsd_builders.py +++ b/platform/linuxbsd/platform_linuxbsd_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index b2014f28496..7ec2d0f65fb 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -4102,7 +4102,7 @@ void DisplayServerMacOS::cursor_set_custom_image(const Ref &p_cursor, uint8_t alpha = (color >> 24) & 0xFF; pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255; pixels[i * 4 + 1] = ((color >> 8) & 0xFF) * alpha / 255; - pixels[i * 4 + 2] = ((color)&0xFF) * alpha / 255; + pixels[i * 4 + 2] = ((color) & 0xFF) * alpha / 255; pixels[i * 4 + 3] = alpha; } diff --git a/platform/macos/platform_macos_builders.py b/platform/macos/platform_macos_builders.py index 3a1cc92bd2a..a1228b96eb7 100644 --- a/platform/macos/platform_macos_builders.py +++ b/platform/macos/platform_macos_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4bb6d2f3f50..3162bb3fb9a 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -3094,9 +3094,9 @@ void DisplayServerWindows::set_context(Context p_context) { #define SIGNATURE_MASK 0xFFFFFF00 // Keeping the name suggested by Microsoft, but this macro really answers: // Is this mouse event emulated from touch or pen input? -#define IsPenEvent(dw) (((dw)&SIGNATURE_MASK) == MI_WP_SIGNATURE) +#define IsPenEvent(dw) (((dw) & SIGNATURE_MASK) == MI_WP_SIGNATURE) // This one tells whether the event comes from touchscreen (and not from pen). -#define IsTouchEvent(dw) (IsPenEvent(dw) && ((dw)&0x80)) +#define IsTouchEvent(dw) (IsPenEvent(dw) && ((dw) & 0x80)) void DisplayServerWindows::_touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx) { if (touch_state.has(idx) == p_pressed) { diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py index 652dc06acf4..99e96338009 100644 --- a/platform/windows/platform_windows_builders.py +++ b/platform/windows/platform_windows_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from detect import get_mingw_bin_prefix from detect import try_cmd diff --git a/scu_builders.py b/scu_builders.py index 2579398ad63..8cd87a13d5e 100644 --- a/scu_builders.py +++ b/scu_builders.py @@ -1,5 +1,6 @@ """Functions used to generate scu build source files during build time """ + import glob, os import math from pathlib import Path diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp index 0c2b935554a..e6219773267 100644 --- a/servers/physics_3d/godot_soft_body_3d.cpp +++ b/servers/physics_3d/godot_soft_body_3d.cpp @@ -595,7 +595,7 @@ void GodotSoftBody3D::generate_bending_constraints(int p_distance) { const uint32_t adj_size = n * n; unsigned *adj = memnew_arr(unsigned, adj_size); -#define IDX(_x_, _y_) ((_y_)*n + (_x_)) +#define IDX(_x_, _y_) ((_y_) * n + (_x_)) for (j = 0; j < n; ++j) { for (i = 0; i < n; ++i) { int idx_ij = j * n + i; diff --git a/tests/test_macros.h b/tests/test_macros.h index bc85ec6ddc9..a173b37a2de 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -161,11 +161,11 @@ int register_test_command(String p_command, TestFunc p_function); MessageQueue::get_singleton()->flush(); \ } -#define _UPDATE_EVENT_MODIFERS(m_event, m_modifers) \ - m_event->set_shift_pressed(((m_modifers)&KeyModifierMask::SHIFT) != Key::NONE); \ - m_event->set_alt_pressed(((m_modifers)&KeyModifierMask::ALT) != Key::NONE); \ - m_event->set_ctrl_pressed(((m_modifers)&KeyModifierMask::CTRL) != Key::NONE); \ - m_event->set_meta_pressed(((m_modifers)&KeyModifierMask::META) != Key::NONE); +#define _UPDATE_EVENT_MODIFERS(m_event, m_modifers) \ + m_event->set_shift_pressed(((m_modifers) & KeyModifierMask::SHIFT) != Key::NONE); \ + m_event->set_alt_pressed(((m_modifers) & KeyModifierMask::ALT) != Key::NONE); \ + m_event->set_ctrl_pressed(((m_modifers) & KeyModifierMask::CTRL) != Key::NONE); \ + m_event->set_meta_pressed(((m_modifers) & KeyModifierMask::META) != Key::NONE); #define _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifers) \ Ref event; \