mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +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.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
|
||||
|
@ -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<VkSemaphore> imageAvailableSemaphores;
|
||||
std::vector<VkSemaphore> renderFinishedSemaphores;
|
||||
std::vector<VkFence> fences;
|
||||
// NOLINTEND(readability-identifier-naming)
|
||||
};
|
||||
|
||||
|
||||
|
@ -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<std::byte> 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<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
|
||||
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<char*>(&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<char*>(&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();
|
||||
|
@ -408,13 +408,7 @@ struct GlContext::Impl
|
||||
/// \brief Constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Impl() :
|
||||
m_id(
|
||||
[]()
|
||||
{
|
||||
static std::atomic<std::uint64_t> 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> 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();
|
||||
|
||||
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<std::recursive_mutex> 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<std::recursive_mutex> 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);
|
||||
}
|
||||
|
@ -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_unique<JoystickStatesI
|
||||
JoystickManager::getInstance().update();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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<Joystick::Axis>(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)
|
||||
{
|
||||
|
@ -43,6 +43,7 @@ std::vector<sf::Vector2i> touchPositions;
|
||||
|
||||
@interface SFAppDelegate ()
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
@property (nonatomic) CMMotionManager* motionManager;
|
||||
|
||||
@end
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
@interface SFView ()
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
@property (nonatomic) NSMutableArray* touches;
|
||||
|
||||
@end
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
NSAutoreleasePoolRef pool; ///< The autorelease pool.
|
||||
NSAutoreleasePoolRef m_pool; ///< The autorelease pool.
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -37,13 +37,14 @@
|
||||
/// \brief Implementation of WindowImplDelegateProtocol for view management
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
@interface SFViewController : NSObject<WindowImplDelegateProtocol>
|
||||
{
|
||||
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
|
||||
|
@ -53,6 +53,7 @@ class WindowImplCocoa;
|
||||
/// style is restored.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
@interface SFWindowController : NSResponder<WindowImplDelegateProtocol, NSWindowDelegate>
|
||||
{
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user