diff --git a/.clang-format b/.clang-format index 840c27d1..8fa41c88 100644 --- a/.clang-format +++ b/.clang-format @@ -163,6 +163,10 @@ SpacesInSquareBrackets: false # Line endings UseCRLF: false +# Qualifiers (const, volatile, static, etc) +QualifierAlignment: Custom +QualifierOrder: ['static', 'inline', 'constexpr', 'const', 'volatile', 'type'] + --- Language: ObjC IndentWidth: 4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 657329a5..373d987c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,23 +190,21 @@ jobs: cmake --build $GITHUB_WORKSPACE/test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.suffix}} format: - name: Formatting with clang-format-${{ matrix.version }} + name: Formatting runs-on: ubuntu-22.04 strategy: fail-fast: false - matrix: - version: [12, 13, 14] steps: - name: Checkout Code uses: actions/checkout@v3 - name: Install Dependencies - run: sudo apt-get install clang-format-${{ matrix.version }} + run: sudo apt-get install clang-format-14 - name: Format Code - run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-${{ matrix.version }} -P $GITHUB_WORKSPACE/cmake/Format.cmake + run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-14 -P $GITHUB_WORKSPACE/cmake/Format.cmake - name: Check Formatting run: git diff --exit-code diff --git a/cmake/Format.cmake b/cmake/Format.cmake index eb8c14d6..416914c6 100644 --- a/cmake/Format.cmake +++ b/cmake/Format.cmake @@ -13,12 +13,8 @@ endif() execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION) string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION}) unset(CLANG_FORMAT_VERSION) -if(CMAKE_MATCH_1 LESS 12) - message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} is too low") -elseif(CMAKE_MATCH_1 GREATER 14) - message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} is too high") -else() - message(STATUS "Using clang-format version ${CMAKE_MATCH_1}") +if(NOT CMAKE_MATCH_1 EQUAL 14) + message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 14") endif() # Run diff --git a/src/SFML/Window/Android/SensorImpl.cpp b/src/SFML/Window/Android/SensorImpl.cpp index cecd32aa..859b1ad7 100644 --- a/src/SFML/Window/Android/SensorImpl.cpp +++ b/src/SFML/Window/Android/SensorImpl.cpp @@ -137,7 +137,7 @@ void SensorImpl::setEnabled(bool enabled) //////////////////////////////////////////////////////////// -ASensor const* SensorImpl::getDefaultSensor(Sensor::Type sensor) +const ASensor* SensorImpl::getDefaultSensor(Sensor::Type sensor) { // Find the Android sensor type static int types[] = {ASENSOR_TYPE_ACCELEROMETER, diff --git a/src/SFML/Window/Android/SensorImpl.hpp b/src/SFML/Window/Android/SensorImpl.hpp index d62073eb..6790e503 100644 --- a/src/SFML/Window/Android/SensorImpl.hpp +++ b/src/SFML/Window/Android/SensorImpl.hpp @@ -104,7 +104,7 @@ private: /// \return The default Android sensor, a null pointer otherwise /// //////////////////////////////////////////////////////////// - static ASensor const* getDefaultSensor(Sensor::Type sensor); + static const ASensor* getDefaultSensor(Sensor::Type sensor); //////////////////////////////////////////////////////////// /// \brief Process the pending sensor data available and add them to our lists diff --git a/src/SFML/Window/OSX/ClipboardImpl.mm b/src/SFML/Window/OSX/ClipboardImpl.mm index a1d1c2ab..39047640 100644 --- a/src/SFML/Window/OSX/ClipboardImpl.mm +++ b/src/SFML/Window/OSX/ClipboardImpl.mm @@ -42,7 +42,7 @@ String ClipboardImpl::getString() NSPasteboard* const pboard = [NSPasteboard generalPasteboard]; NSString* const data = [pboard stringForType:NSPasteboardTypeString]; - char const* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding]; + const char* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding]; const NSUInteger length = [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; return String::fromUtf8(utf8, utf8 + length); diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm index d31c7fe4..3a5e9052 100644 --- a/src/SFML/Window/OSX/HIDInputManager.mm +++ b/src/SFML/Window/OSX/HIDInputManager.mm @@ -864,7 +864,7 @@ void HIDInputManager::buildMappings() if (translateToString) { // Unicode string length is usually less or equal to 4 - UniCharCount const maxLength = 4; + const UniCharCount maxLength = 4; UniChar string[maxLength]; UniCharCount length = 0; std::uint32_t deadKeyState = 0; // unused value diff --git a/src/SFML/Window/iOS/ClipboardImpl.mm b/src/SFML/Window/iOS/ClipboardImpl.mm index c3f9d261..f18dc646 100644 --- a/src/SFML/Window/iOS/ClipboardImpl.mm +++ b/src/SFML/Window/iOS/ClipboardImpl.mm @@ -42,7 +42,7 @@ String ClipboardImpl::getString() { NSString* data = pboard.string; - char const* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding]; + const char* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding]; NSUInteger length = [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; return String::fromUtf8(utf8, utf8 + length);