diff --git a/.clang-tidy b/.clang-tidy index 5a9532952..ce68a91d7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -75,6 +75,10 @@ CheckOptions: - { key: readability-identifier-naming.FunctionCase, value: camelBack } - { key: readability-identifier-naming.VariableCase, value: camelBack } - { key: readability-identifier-naming.ParameterCase, value: camelBack } + - { key: readability-identifier-naming.MemberCase, value: camelBack } + - { key: readability-identifier-naming.PrivateMemberCase, value: camelBack } + - { key: readability-identifier-naming.ProtectedMemberPrefix, value: m_ } + - { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ } HeaderFilterRegex: '.*' WarningsAsErrors: '*' UseColor: true diff --git a/examples/vulkan/Vulkan.cpp b/examples/vulkan/Vulkan.cpp index 225e3f5f5..841942d03 100644 --- a/examples/vulkan/Vulkan.cpp +++ b/examples/vulkan/Vulkan.cpp @@ -2569,6 +2569,7 @@ public: } private: + // NOLINTBEGIN(readability-identifier-naming) sf::WindowBase window{sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default}; bool vulkanAvailable{sf::Vulkan::isAvailable()}; @@ -2618,6 +2619,7 @@ private: std::vector imageAvailableSemaphores; std::vector renderFinishedSemaphores; std::vector fences; + // NOLINTEND(readability-identifier-naming) }; diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp index 88b6f6a6e..e5382ecd4 100644 --- a/include/SFML/Network/TcpSocket.hpp +++ b/include/SFML/Network/TcpSocket.hpp @@ -221,9 +221,9 @@ private: //////////////////////////////////////////////////////////// struct PendingPacket { - std::uint32_t Size{}; //!< Data of packet size - std::size_t SizeReceived{}; //!< Number of size bytes received so far - std::vector Data; //!< Data of the packet + std::uint32_t size{}; //!< Data of packet size + std::size_t sizeReceived{}; //!< Number of size bytes received so far + std::vector data; //!< Data of the packet }; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 11fe1c61f..8b95b088f 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -377,35 +377,35 @@ Socket::Status TcpSocket::receive(Packet& packet) // We start by getting the size of the incoming packet std::uint32_t packetSize = 0; std::size_t received = 0; - if (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size)) + if (m_pendingPacket.sizeReceived < sizeof(m_pendingPacket.size)) { // Loop until we've received the entire size of the packet // (even a 4 byte variable may be received in more than one call) - while (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size)) + while (m_pendingPacket.sizeReceived < sizeof(m_pendingPacket.size)) { - char* data = reinterpret_cast(&m_pendingPacket.Size) + m_pendingPacket.SizeReceived; - const Status status = receive(data, sizeof(m_pendingPacket.Size) - m_pendingPacket.SizeReceived, received); - m_pendingPacket.SizeReceived += received; + char* data = reinterpret_cast(&m_pendingPacket.size) + m_pendingPacket.sizeReceived; + const Status status = receive(data, sizeof(m_pendingPacket.size) - m_pendingPacket.sizeReceived, received); + m_pendingPacket.sizeReceived += received; if (status != Status::Done) return status; } // The packet size has been fully received - packetSize = ntohl(m_pendingPacket.Size); + packetSize = ntohl(m_pendingPacket.size); } else { // The packet size has already been received in a previous call - packetSize = ntohl(m_pendingPacket.Size); + packetSize = ntohl(m_pendingPacket.size); } // Loop until we receive all the packet data char buffer[1024]; - while (m_pendingPacket.Data.size() < packetSize) + while (m_pendingPacket.data.size() < packetSize) { // Receive a chunk of data - const std::size_t sizeToGet = std::min(packetSize - m_pendingPacket.Data.size(), sizeof(buffer)); + const std::size_t sizeToGet = std::min(packetSize - m_pendingPacket.data.size(), sizeof(buffer)); const Status status = receive(buffer, sizeToGet, received); if (status != Status::Done) return status; @@ -413,15 +413,15 @@ Socket::Status TcpSocket::receive(Packet& packet) // Append it into the packet if (received > 0) { - m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received); - std::byte* begin = m_pendingPacket.Data.data() + m_pendingPacket.Data.size() - received; + m_pendingPacket.data.resize(m_pendingPacket.data.size() + received); + std::byte* begin = m_pendingPacket.data.data() + m_pendingPacket.data.size() - received; std::memcpy(begin, buffer, received); } } // We have received all the packet data: we can copy it to the user packet - if (!m_pendingPacket.Data.empty()) - packet.onReceive(m_pendingPacket.Data.data(), m_pendingPacket.Data.size()); + if (!m_pendingPacket.data.empty()) + packet.onReceive(m_pendingPacket.data.data(), m_pendingPacket.data.size()); // Clear the pending packet data m_pendingPacket = PendingPacket(); diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 0821fd88f..2b7febb08 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -408,13 +408,7 @@ struct GlContext::Impl /// \brief Constructor /// //////////////////////////////////////////////////////////// - Impl() : - m_id( - []() - { - static std::atomic id(1); // start at 1, zero is "no context" - return id.fetch_add(1); - }()) + Impl() { auto& weakUnsharedGlObjects = getWeakUnsharedGlObjects(); unsharedGlObjects = weakUnsharedGlObjects.lock(); @@ -465,7 +459,12 @@ struct GlContext::Impl // Member data //////////////////////////////////////////////////////////// std::shared_ptr unsharedGlObjects; //!< The current object's handle to unshared objects - const std::uint64_t m_id; //!< Unique identifier, used for identifying contexts when managing unshareable OpenGL resources + const std::uint64_t id{ + []() + { + static std::atomic atomicId(1); // start at 1, zero is "no context" + return atomicId.fetch_add(1); + }()}; //!< Unique identifier, used for identifying contexts when managing unshareable OpenGL resources }; @@ -714,7 +713,7 @@ GlContext::~GlContext() { auto& currentContext = GlContextImpl::CurrentContext::get(); - if (m_impl->m_id == currentContext.id) + if (m_impl->id == currentContext.id) { currentContext.id = 0; currentContext.ptr = nullptr; @@ -740,7 +739,7 @@ bool GlContext::setActive(bool active) if (active) { - if (m_impl->m_id != currentContext.id) + if (m_impl->id != currentContext.id) { // We can't and don't need to lock when we are currently creating the shared context std::unique_lock lock; @@ -752,7 +751,7 @@ bool GlContext::setActive(bool active) if (makeCurrent(true)) { // Set it as the new current context for this thread - currentContext.id = m_impl->m_id; + currentContext.id = m_impl->id; currentContext.ptr = this; return true; } @@ -769,7 +768,7 @@ bool GlContext::setActive(bool active) } else { - if (m_impl->m_id == currentContext.id) + if (m_impl->id == currentContext.id) { // We can't and don't need to lock when we are currently creating the shared context std::unique_lock lock; @@ -851,7 +850,7 @@ void GlContext::cleanupUnsharedResources() GlContext* contextToRestore = currentContext.ptr; // If this context is already active there is no need to save it - if (m_impl->m_id == currentContext.id) + if (m_impl->id == currentContext.id) contextToRestore = nullptr; // Make this context active so resources can be freed @@ -863,7 +862,7 @@ void GlContext::cleanupUnsharedResources() // Destroy the unshared objects contained in this context for (auto iter = m_impl->unsharedGlObjects->begin(); iter != m_impl->unsharedGlObjects->end();) { - if (iter->contextId == m_impl->m_id) + if (iter->contextId == m_impl->id) { iter = m_impl->unsharedGlObjects->erase(iter); } diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 49129c5e7..0f0a00eec 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -97,7 +97,7 @@ namespace sf::priv //////////////////////////////////////////////////////////// struct WindowImpl::JoystickStatesImpl { - JoystickState m_states[Joystick::Count]; //!< Previous state of the joysticks + JoystickState states[Joystick::Count]; //!< Previous state of the joysticks }; //////////////////////////////////////////////////////////// @@ -121,7 +121,7 @@ WindowImpl::WindowImpl() : m_joystickStatesImpl(std::make_uniquem_states[i] = JoystickManager::getInstance().getState(i); + m_joystickStatesImpl->states[i] = JoystickManager::getInstance().getState(i); std::fill_n(m_previousAxes[i], static_cast(Joystick::AxisCount), 0.f); } @@ -226,11 +226,11 @@ void WindowImpl::processJoystickEvents() for (unsigned int i = 0; i < Joystick::Count; ++i) { // Copy the previous state of the joystick and get the new one - const JoystickState previousState = m_joystickStatesImpl->m_states[i]; - m_joystickStatesImpl->m_states[i] = JoystickManager::getInstance().getState(i); + const JoystickState previousState = m_joystickStatesImpl->states[i]; + m_joystickStatesImpl->states[i] = JoystickManager::getInstance().getState(i); // Connection state - const bool connected = m_joystickStatesImpl->m_states[i].connected; + const bool connected = m_joystickStatesImpl->states[i].connected; if (previousState.connected ^ connected) { Event event; @@ -254,7 +254,7 @@ void WindowImpl::processJoystickEvents() { const auto axis = static_cast(j); const float prevPos = m_previousAxes[i][axis]; - const float currPos = m_joystickStatesImpl->m_states[i].axes[axis]; + const float currPos = m_joystickStatesImpl->states[i].axes[axis]; if (std::abs(currPos - prevPos) >= m_joystickThreshold) { Event event; @@ -273,7 +273,7 @@ void WindowImpl::processJoystickEvents() for (unsigned int j = 0; j < caps.buttonCount; ++j) { const bool prevPressed = previousState.buttons[j]; - const bool currPressed = m_joystickStatesImpl->m_states[i].buttons[j]; + const bool currPressed = m_joystickStatesImpl->states[i].buttons[j]; if (prevPressed ^ currPressed) { diff --git a/src/SFML/Window/iOS/SFAppDelegate.mm b/src/SFML/Window/iOS/SFAppDelegate.mm index d443809b4..5a38cd303 100644 --- a/src/SFML/Window/iOS/SFAppDelegate.mm +++ b/src/SFML/Window/iOS/SFAppDelegate.mm @@ -43,6 +43,7 @@ std::vector touchPositions; @interface SFAppDelegate () +// NOLINTNEXTLINE(readability-identifier-naming) @property (nonatomic) CMMotionManager* motionManager; @end diff --git a/src/SFML/Window/iOS/SFView.mm b/src/SFML/Window/iOS/SFView.mm index 25943235d..54ead44c5 100644 --- a/src/SFML/Window/iOS/SFView.mm +++ b/src/SFML/Window/iOS/SFView.mm @@ -38,6 +38,7 @@ @interface SFView () +// NOLINTNEXTLINE(readability-identifier-naming) @property (nonatomic) NSMutableArray* touches; @end diff --git a/src/SFML/Window/macOS/AutoreleasePoolWrapper.hpp b/src/SFML/Window/macOS/AutoreleasePoolWrapper.hpp index 599f640db..5196f3a17 100644 --- a/src/SFML/Window/macOS/AutoreleasePoolWrapper.hpp +++ b/src/SFML/Window/macOS/AutoreleasePoolWrapper.hpp @@ -66,7 +66,7 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - NSAutoreleasePoolRef pool; ///< The autorelease pool. + NSAutoreleasePoolRef m_pool; ///< The autorelease pool. }; } // namespace sf diff --git a/src/SFML/Window/macOS/AutoreleasePoolWrapper.mm b/src/SFML/Window/macOS/AutoreleasePoolWrapper.mm index 07fee5a39..f3ac71f45 100644 --- a/src/SFML/Window/macOS/AutoreleasePoolWrapper.mm +++ b/src/SFML/Window/macOS/AutoreleasePoolWrapper.mm @@ -37,14 +37,14 @@ namespace sf //////////////////////////////////////////////////////// AutoreleasePool::AutoreleasePool() { - pool = [[NSAutoreleasePool alloc] init]; + m_pool = [[NSAutoreleasePool alloc] init]; } //////////////////////////////////////////////////////// AutoreleasePool::~AutoreleasePool() { - [pool drain]; + [m_pool drain]; } } // namespace sf diff --git a/src/SFML/Window/macOS/SFOpenGLView.h b/src/SFML/Window/macOS/SFOpenGLView.h index 7a5a54ff1..236431f9d 100644 --- a/src/SFML/Window/macOS/SFOpenGLView.h +++ b/src/SFML/Window/macOS/SFOpenGLView.h @@ -68,6 +68,7 @@ class WindowImplCocoa; /// the cursor (that was disconnected from the system). /// //////////////////////////////////////////////////////////// +// NOLINTBEGIN(readability-identifier-naming) @interface SFOpenGLView : NSOpenGLView { sf::priv::WindowImplCocoa* m_requester; ///< View's requester @@ -87,6 +88,7 @@ class WindowImplCocoa; SFSilentResponder* m_silentResponder; NSTextView* m_hiddenTextView; } +// NOLINTEND(readability-identifier-naming) //////////////////////////////////////////////////////////// /// \brief Create the SFML OpenGL view diff --git a/src/SFML/Window/macOS/SFViewController.h b/src/SFML/Window/macOS/SFViewController.h index 0a6322f1a..e70fdebdd 100644 --- a/src/SFML/Window/macOS/SFViewController.h +++ b/src/SFML/Window/macOS/SFViewController.h @@ -37,13 +37,14 @@ /// \brief Implementation of WindowImplDelegateProtocol for view management /// //////////////////////////////////////////////////////////// - +// NOLINTBEGIN(readability-identifier-naming) @interface SFViewController : NSObject { NSView* m_view; ///< Underlying Cocoa view SFOpenGLView* m_oglView; ///< OpenGL view sf::priv::WindowImplCocoa* m_requester; ///< View's requester } +// NOLINTEND(readability-identifier-naming) //////////////////////////////////////////////////////////// /// \brief Initialize the view controller diff --git a/src/SFML/Window/macOS/SFWindowController.h b/src/SFML/Window/macOS/SFWindowController.h index 1cecea94e..02f1147b7 100644 --- a/src/SFML/Window/macOS/SFWindowController.h +++ b/src/SFML/Window/macOS/SFWindowController.h @@ -53,6 +53,7 @@ class WindowImplCocoa; /// style is restored. /// //////////////////////////////////////////////////////////// +// NOLINTBEGIN(readability-identifier-naming) @interface SFWindowController : NSResponder { NSWindow* m_window; ///< Underlying Cocoa window to be controlled @@ -62,6 +63,7 @@ class WindowImplCocoa; BOOL m_restoreResize; ///< See note above BOOL m_highDpi; ///< Support high-DPI rendering or not } +// NOLINTEND(readability-identifier-naming) //////////////////////////////////////////////////////////// /// \brief Create the SFML window with an external Cocoa window