mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Add clang-tidy modernize-loop-convert check
This commit is contained in:
parent
8dc28909d3
commit
8c3f07de80
@ -2,6 +2,7 @@ Checks: >
|
||||
-*,
|
||||
clang-analyzer-*,
|
||||
modernize-concat-nested-namespaces,
|
||||
modernize-loop-convert,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-nullptr,
|
||||
|
@ -87,8 +87,8 @@ bool systemDown()
|
||||
|
||||
void uninitFileDescriptors()
|
||||
{
|
||||
for (std::vector<int>::iterator itr = fileDescriptors.begin(); itr != fileDescriptors.end(); ++itr)
|
||||
close(*itr);
|
||||
for (const auto& fileDescriptor : fileDescriptors)
|
||||
close(fileDescriptor);
|
||||
}
|
||||
|
||||
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
|
||||
@ -317,35 +317,35 @@ TouchSlot& atSlot(int idx)
|
||||
|
||||
void processSlots()
|
||||
{
|
||||
for (std::vector<TouchSlot>::iterator slot = touchSlots.begin(); slot != touchSlots.end(); ++slot)
|
||||
for (auto& slot : touchSlots)
|
||||
{
|
||||
sf::Event event;
|
||||
|
||||
event.touch.x = slot->pos.x;
|
||||
event.touch.y = slot->pos.y;
|
||||
event.touch.x = slot.pos.x;
|
||||
event.touch.y = slot.pos.y;
|
||||
|
||||
if (slot->oldId == slot->id)
|
||||
if (slot.oldId == slot.id)
|
||||
{
|
||||
event.type = sf::Event::TouchMoved;
|
||||
event.touch.finger = static_cast<unsigned int>(slot->id);
|
||||
event.touch.finger = static_cast<unsigned int>(slot.id);
|
||||
pushEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slot->oldId != -1)
|
||||
if (slot.oldId != -1)
|
||||
{
|
||||
event.type = sf::Event::TouchEnded;
|
||||
event.touch.finger = static_cast<unsigned int>(slot->oldId);
|
||||
event.touch.finger = static_cast<unsigned int>(slot.oldId);
|
||||
pushEvent(event);
|
||||
}
|
||||
if (slot->id != -1)
|
||||
if (slot.id != -1)
|
||||
{
|
||||
event.type = sf::Event::TouchBegan;
|
||||
event.touch.finger = static_cast<unsigned int>(slot->id);
|
||||
event.touch.finger = static_cast<unsigned int>(slot.id);
|
||||
pushEvent(event);
|
||||
}
|
||||
|
||||
slot->oldId = slot->id;
|
||||
slot.oldId = slot.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,10 +371,10 @@ bool eventProcess(sf::Event& event)
|
||||
ssize_t bytesRead;
|
||||
|
||||
// Check all the open file descriptors for the next event
|
||||
for (std::vector<int>::iterator itr = fileDescriptors.begin(); itr != fileDescriptors.end(); ++itr)
|
||||
for (auto& fileDescriptor : fileDescriptors)
|
||||
{
|
||||
input_event inputEvent;
|
||||
bytesRead = read(*itr, &inputEvent, sizeof(inputEvent));
|
||||
bytesRead = read(fileDescriptor, &inputEvent, sizeof(inputEvent));
|
||||
|
||||
while (bytesRead > 0)
|
||||
{
|
||||
@ -467,30 +467,30 @@ bool eventProcess(sf::Event& event)
|
||||
{
|
||||
case ABS_MT_SLOT:
|
||||
currentSlot = inputEvent.value;
|
||||
touchFd = *itr;
|
||||
touchFd = fileDescriptor;
|
||||
break;
|
||||
case ABS_MT_TRACKING_ID:
|
||||
atSlot(currentSlot).id = inputEvent.value;
|
||||
touchFd = *itr;
|
||||
touchFd = fileDescriptor;
|
||||
break;
|
||||
case ABS_MT_POSITION_X:
|
||||
atSlot(currentSlot).pos.x = inputEvent.value;
|
||||
touchFd = *itr;
|
||||
touchFd = fileDescriptor;
|
||||
break;
|
||||
case ABS_MT_POSITION_Y:
|
||||
atSlot(currentSlot).pos.y = inputEvent.value;
|
||||
touchFd = *itr;
|
||||
touchFd = fileDescriptor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (inputEvent.type == EV_SYN && inputEvent.code == SYN_REPORT && *itr == touchFd)
|
||||
else if (inputEvent.type == EV_SYN && inputEvent.code == SYN_REPORT && fileDescriptor == touchFd)
|
||||
{
|
||||
// This pushes events directly to the queue, because it
|
||||
// can generate more than one event.
|
||||
processSlots();
|
||||
}
|
||||
|
||||
bytesRead = read(*itr, &inputEvent, sizeof(inputEvent));
|
||||
bytesRead = read(fileDescriptor, &inputEvent, sizeof(inputEvent));
|
||||
}
|
||||
|
||||
if ((bytesRead < 0) && (errno != EAGAIN))
|
||||
@ -628,9 +628,9 @@ void InputImpl::setMousePosition(const Vector2i& position, const WindowBase& /*r
|
||||
////////////////////////////////////////////////////////////
|
||||
bool InputImpl::isTouchDown(unsigned int finger)
|
||||
{
|
||||
for (std::vector<TouchSlot>::iterator slot = touchSlots.begin(); slot != touchSlots.end(); ++slot)
|
||||
for (const auto& slot : touchSlots)
|
||||
{
|
||||
if (slot->id == static_cast<int>(finger))
|
||||
if (slot.id == static_cast<int>(finger))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -641,10 +641,10 @@ bool InputImpl::isTouchDown(unsigned int finger)
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2i InputImpl::getTouchPosition(unsigned int finger)
|
||||
{
|
||||
for (std::vector<TouchSlot>::iterator slot = touchSlots.begin(); slot != touchSlots.end(); ++slot)
|
||||
for (const auto& slot : touchSlots)
|
||||
{
|
||||
if (slot->id == static_cast<int>(finger))
|
||||
return slot->pos;
|
||||
if (slot.id == static_cast<int>(finger))
|
||||
return slot.pos;
|
||||
}
|
||||
|
||||
return Vector2i();
|
||||
|
@ -314,12 +314,12 @@ void HIDInputManager::freeUp()
|
||||
|
||||
m_manager = nil;
|
||||
|
||||
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
||||
for (auto& key : m_keys)
|
||||
{
|
||||
for (IOHIDElementRef iohidElementRef : m_keys[i])
|
||||
for (IOHIDElementRef iohidElementRef : key)
|
||||
CFRelease(iohidElementRef);
|
||||
|
||||
m_keys[i].clear();
|
||||
key.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ bool JoystickImpl::isConnected(unsigned int index)
|
||||
// opened joystick devices then we find the new one.
|
||||
|
||||
unsigned int openedCount = 0;
|
||||
for (unsigned int i(0); i < sf::Joystick::Count; ++i)
|
||||
for (const auto& locationID : m_locationIDs)
|
||||
{
|
||||
if (m_locationIDs[i] != 0)
|
||||
if (locationID != 0)
|
||||
++openedCount;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user