mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Add more readability-identifier-naming
rules
This commit is contained in:
parent
2a8a01ca6c
commit
133bcda6cb
@ -75,6 +75,10 @@ CheckOptions:
|
|||||||
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
|
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
|
||||||
- { key: readability-identifier-naming.VariableCase, value: camelBack }
|
- { key: readability-identifier-naming.VariableCase, value: camelBack }
|
||||||
- { key: readability-identifier-naming.ParameterCase, 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: '.*'
|
HeaderFilterRegex: '.*'
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
UseColor: true
|
UseColor: true
|
||||||
|
@ -2569,6 +2569,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// NOLINTBEGIN(readability-identifier-naming)
|
||||||
sf::WindowBase window{sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default};
|
sf::WindowBase window{sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default};
|
||||||
|
|
||||||
bool vulkanAvailable{sf::Vulkan::isAvailable()};
|
bool vulkanAvailable{sf::Vulkan::isAvailable()};
|
||||||
@ -2618,6 +2619,7 @@ private:
|
|||||||
std::vector<VkSemaphore> imageAvailableSemaphores;
|
std::vector<VkSemaphore> imageAvailableSemaphores;
|
||||||
std::vector<VkSemaphore> renderFinishedSemaphores;
|
std::vector<VkSemaphore> renderFinishedSemaphores;
|
||||||
std::vector<VkFence> fences;
|
std::vector<VkFence> fences;
|
||||||
|
// NOLINTEND(readability-identifier-naming)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,9 +221,9 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct PendingPacket
|
struct PendingPacket
|
||||||
{
|
{
|
||||||
std::uint32_t Size{}; //!< Data of packet size
|
std::uint32_t size{}; //!< Data of packet size
|
||||||
std::size_t SizeReceived{}; //!< Number of size bytes received so far
|
std::size_t sizeReceived{}; //!< Number of size bytes received so far
|
||||||
std::vector<std::byte> Data; //!< Data of the packet
|
std::vector<std::byte> data; //!< Data of the packet
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -377,35 +377,35 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
|||||||
// We start by getting the size of the incoming packet
|
// We start by getting the size of the incoming packet
|
||||||
std::uint32_t packetSize = 0;
|
std::uint32_t packetSize = 0;
|
||||||
std::size_t received = 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
|
// Loop until we've received the entire size of the packet
|
||||||
// (even a 4 byte variable may be received in more than one call)
|
// (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<char*>(&m_pendingPacket.Size) + m_pendingPacket.SizeReceived;
|
char* data = reinterpret_cast<char*>(&m_pendingPacket.size) + m_pendingPacket.sizeReceived;
|
||||||
const Status status = receive(data, sizeof(m_pendingPacket.Size) - m_pendingPacket.SizeReceived, received);
|
const Status status = receive(data, sizeof(m_pendingPacket.size) - m_pendingPacket.sizeReceived, received);
|
||||||
m_pendingPacket.SizeReceived += received;
|
m_pendingPacket.sizeReceived += received;
|
||||||
|
|
||||||
if (status != Status::Done)
|
if (status != Status::Done)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The packet size has been fully received
|
// The packet size has been fully received
|
||||||
packetSize = ntohl(m_pendingPacket.Size);
|
packetSize = ntohl(m_pendingPacket.size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The packet size has already been received in a previous call
|
// 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
|
// Loop until we receive all the packet data
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
while (m_pendingPacket.Data.size() < packetSize)
|
while (m_pendingPacket.data.size() < packetSize)
|
||||||
{
|
{
|
||||||
// Receive a chunk of data
|
// 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);
|
const Status status = receive(buffer, sizeToGet, received);
|
||||||
if (status != Status::Done)
|
if (status != Status::Done)
|
||||||
return status;
|
return status;
|
||||||
@ -413,15 +413,15 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
|||||||
// Append it into the packet
|
// Append it into the packet
|
||||||
if (received > 0)
|
if (received > 0)
|
||||||
{
|
{
|
||||||
m_pendingPacket.Data.resize(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::byte* begin = m_pendingPacket.data.data() + m_pendingPacket.data.size() - received;
|
||||||
std::memcpy(begin, buffer, received);
|
std::memcpy(begin, buffer, received);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have received all the packet data: we can copy it to the user packet
|
// We have received all the packet data: we can copy it to the user packet
|
||||||
if (!m_pendingPacket.Data.empty())
|
if (!m_pendingPacket.data.empty())
|
||||||
packet.onReceive(m_pendingPacket.Data.data(), m_pendingPacket.Data.size());
|
packet.onReceive(m_pendingPacket.data.data(), m_pendingPacket.data.size());
|
||||||
|
|
||||||
// Clear the pending packet data
|
// Clear the pending packet data
|
||||||
m_pendingPacket = PendingPacket();
|
m_pendingPacket = PendingPacket();
|
||||||
|
@ -408,13 +408,7 @@ struct GlContext::Impl
|
|||||||
/// \brief Constructor
|
/// \brief Constructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Impl() :
|
Impl()
|
||||||
m_id(
|
|
||||||
[]()
|
|
||||||
{
|
|
||||||
static std::atomic<std::uint64_t> id(1); // start at 1, zero is "no context"
|
|
||||||
return id.fetch_add(1);
|
|
||||||
}())
|
|
||||||
{
|
{
|
||||||
auto& weakUnsharedGlObjects = getWeakUnsharedGlObjects();
|
auto& weakUnsharedGlObjects = getWeakUnsharedGlObjects();
|
||||||
unsharedGlObjects = weakUnsharedGlObjects.lock();
|
unsharedGlObjects = weakUnsharedGlObjects.lock();
|
||||||
@ -465,7 +459,12 @@ struct GlContext::Impl
|
|||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::shared_ptr<UnsharedGlObjects> unsharedGlObjects; //!< The current object's handle to unshared objects
|
std::shared_ptr<UnsharedGlObjects> 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<std::uint64_t> 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();
|
auto& currentContext = GlContextImpl::CurrentContext::get();
|
||||||
|
|
||||||
if (m_impl->m_id == currentContext.id)
|
if (m_impl->id == currentContext.id)
|
||||||
{
|
{
|
||||||
currentContext.id = 0;
|
currentContext.id = 0;
|
||||||
currentContext.ptr = nullptr;
|
currentContext.ptr = nullptr;
|
||||||
@ -740,7 +739,7 @@ bool GlContext::setActive(bool active)
|
|||||||
|
|
||||||
if (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
|
// We can't and don't need to lock when we are currently creating the shared context
|
||||||
std::unique_lock<std::recursive_mutex> lock;
|
std::unique_lock<std::recursive_mutex> lock;
|
||||||
@ -752,7 +751,7 @@ bool GlContext::setActive(bool active)
|
|||||||
if (makeCurrent(true))
|
if (makeCurrent(true))
|
||||||
{
|
{
|
||||||
// Set it as the new current context for this thread
|
// Set it as the new current context for this thread
|
||||||
currentContext.id = m_impl->m_id;
|
currentContext.id = m_impl->id;
|
||||||
currentContext.ptr = this;
|
currentContext.ptr = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -769,7 +768,7 @@ bool GlContext::setActive(bool active)
|
|||||||
}
|
}
|
||||||
else
|
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
|
// We can't and don't need to lock when we are currently creating the shared context
|
||||||
std::unique_lock<std::recursive_mutex> lock;
|
std::unique_lock<std::recursive_mutex> lock;
|
||||||
@ -851,7 +850,7 @@ void GlContext::cleanupUnsharedResources()
|
|||||||
GlContext* contextToRestore = currentContext.ptr;
|
GlContext* contextToRestore = currentContext.ptr;
|
||||||
|
|
||||||
// If this context is already active there is no need to save it
|
// 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;
|
contextToRestore = nullptr;
|
||||||
|
|
||||||
// Make this context active so resources can be freed
|
// Make this context active so resources can be freed
|
||||||
@ -863,7 +862,7 @@ void GlContext::cleanupUnsharedResources()
|
|||||||
// Destroy the unshared objects contained in this context
|
// Destroy the unshared objects contained in this context
|
||||||
for (auto iter = m_impl->unsharedGlObjects->begin(); iter != m_impl->unsharedGlObjects->end();)
|
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);
|
iter = m_impl->unsharedGlObjects->erase(iter);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ namespace sf::priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct WindowImpl::JoystickStatesImpl
|
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_unique<JoystickStatesI
|
|||||||
JoystickManager::getInstance().update();
|
JoystickManager::getInstance().update();
|
||||||
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
||||||
{
|
{
|
||||||
m_joystickStatesImpl->m_states[i] = JoystickManager::getInstance().getState(i);
|
m_joystickStatesImpl->states[i] = JoystickManager::getInstance().getState(i);
|
||||||
std::fill_n(m_previousAxes[i], static_cast<std::size_t>(Joystick::AxisCount), 0.f);
|
std::fill_n(m_previousAxes[i], static_cast<std::size_t>(Joystick::AxisCount), 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,11 +226,11 @@ void WindowImpl::processJoystickEvents()
|
|||||||
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
||||||
{
|
{
|
||||||
// Copy the previous state of the joystick and get the new one
|
// Copy the previous state of the joystick and get the new one
|
||||||
const JoystickState previousState = m_joystickStatesImpl->m_states[i];
|
const JoystickState previousState = m_joystickStatesImpl->states[i];
|
||||||
m_joystickStatesImpl->m_states[i] = JoystickManager::getInstance().getState(i);
|
m_joystickStatesImpl->states[i] = JoystickManager::getInstance().getState(i);
|
||||||
|
|
||||||
// Connection state
|
// Connection state
|
||||||
const bool connected = m_joystickStatesImpl->m_states[i].connected;
|
const bool connected = m_joystickStatesImpl->states[i].connected;
|
||||||
if (previousState.connected ^ connected)
|
if (previousState.connected ^ connected)
|
||||||
{
|
{
|
||||||
Event event;
|
Event event;
|
||||||
@ -254,7 +254,7 @@ void WindowImpl::processJoystickEvents()
|
|||||||
{
|
{
|
||||||
const auto axis = static_cast<Joystick::Axis>(j);
|
const auto axis = static_cast<Joystick::Axis>(j);
|
||||||
const float prevPos = m_previousAxes[i][axis];
|
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)
|
if (std::abs(currPos - prevPos) >= m_joystickThreshold)
|
||||||
{
|
{
|
||||||
Event event;
|
Event event;
|
||||||
@ -273,7 +273,7 @@ void WindowImpl::processJoystickEvents()
|
|||||||
for (unsigned int j = 0; j < caps.buttonCount; ++j)
|
for (unsigned int j = 0; j < caps.buttonCount; ++j)
|
||||||
{
|
{
|
||||||
const bool prevPressed = previousState.buttons[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)
|
if (prevPressed ^ currPressed)
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,7 @@ std::vector<sf::Vector2i> touchPositions;
|
|||||||
|
|
||||||
@interface SFAppDelegate ()
|
@interface SFAppDelegate ()
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||||
@property (nonatomic) CMMotionManager* motionManager;
|
@property (nonatomic) CMMotionManager* motionManager;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
@interface SFView ()
|
@interface SFView ()
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||||
@property (nonatomic) NSMutableArray* touches;
|
@property (nonatomic) NSMutableArray* touches;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -66,7 +66,7 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
NSAutoreleasePoolRef pool; ///< The autorelease pool.
|
NSAutoreleasePoolRef m_pool; ///< The autorelease pool.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -37,14 +37,14 @@ namespace sf
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
AutoreleasePool::AutoreleasePool()
|
AutoreleasePool::AutoreleasePool()
|
||||||
{
|
{
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
m_pool = [[NSAutoreleasePool alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
AutoreleasePool::~AutoreleasePool()
|
AutoreleasePool::~AutoreleasePool()
|
||||||
{
|
{
|
||||||
[pool drain];
|
[m_pool drain];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -68,6 +68,7 @@ class WindowImplCocoa;
|
|||||||
/// the cursor (that was disconnected from the system).
|
/// the cursor (that was disconnected from the system).
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
// NOLINTBEGIN(readability-identifier-naming)
|
||||||
@interface SFOpenGLView : NSOpenGLView
|
@interface SFOpenGLView : NSOpenGLView
|
||||||
{
|
{
|
||||||
sf::priv::WindowImplCocoa* m_requester; ///< View's requester
|
sf::priv::WindowImplCocoa* m_requester; ///< View's requester
|
||||||
@ -87,6 +88,7 @@ class WindowImplCocoa;
|
|||||||
SFSilentResponder* m_silentResponder;
|
SFSilentResponder* m_silentResponder;
|
||||||
NSTextView* m_hiddenTextView;
|
NSTextView* m_hiddenTextView;
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(readability-identifier-naming)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the SFML OpenGL view
|
/// \brief Create the SFML OpenGL view
|
||||||
|
@ -37,13 +37,14 @@
|
|||||||
/// \brief Implementation of WindowImplDelegateProtocol for view management
|
/// \brief Implementation of WindowImplDelegateProtocol for view management
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
// NOLINTBEGIN(readability-identifier-naming)
|
||||||
@interface SFViewController : NSObject<WindowImplDelegateProtocol>
|
@interface SFViewController : NSObject<WindowImplDelegateProtocol>
|
||||||
{
|
{
|
||||||
NSView* m_view; ///< Underlying Cocoa view
|
NSView* m_view; ///< Underlying Cocoa view
|
||||||
SFOpenGLView* m_oglView; ///< OpenGL view
|
SFOpenGLView* m_oglView; ///< OpenGL view
|
||||||
sf::priv::WindowImplCocoa* m_requester; ///< View's requester
|
sf::priv::WindowImplCocoa* m_requester; ///< View's requester
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(readability-identifier-naming)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Initialize the view controller
|
/// \brief Initialize the view controller
|
||||||
|
@ -53,6 +53,7 @@ class WindowImplCocoa;
|
|||||||
/// style is restored.
|
/// style is restored.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
// NOLINTBEGIN(readability-identifier-naming)
|
||||||
@interface SFWindowController : NSResponder<WindowImplDelegateProtocol, NSWindowDelegate>
|
@interface SFWindowController : NSResponder<WindowImplDelegateProtocol, NSWindowDelegate>
|
||||||
{
|
{
|
||||||
NSWindow* m_window; ///< Underlying Cocoa window to be controlled
|
NSWindow* m_window; ///< Underlying Cocoa window to be controlled
|
||||||
@ -62,6 +63,7 @@ class WindowImplCocoa;
|
|||||||
BOOL m_restoreResize; ///< See note above
|
BOOL m_restoreResize; ///< See note above
|
||||||
BOOL m_highDpi; ///< Support high-DPI rendering or not
|
BOOL m_highDpi; ///< Support high-DPI rendering or not
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(readability-identifier-naming)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the SFML window with an external Cocoa window
|
/// \brief Create the SFML window with an external Cocoa window
|
||||||
|
Loading…
Reference in New Issue
Block a user