From 356c06f4f346d3c168cc3b7ec0d663ad16e6014d Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 8 Oct 2021 23:08:15 +0100 Subject: [PATCH] Tidying lambdas --- src/Application.hpp | 2 +- src/DebugServers/GdbRsp/GdbRspDebugServer.cpp | 4 ++-- src/EventManager/EventListener.cpp | 4 ++-- src/EventManager/EventListener.hpp | 4 ++-- .../UserInterfaces/InsightWindow/InsightWindow.cpp | 4 ++-- .../UserInterfaces/InsightWindow/UiLoader.cpp | 12 ++++++------ .../TargetRegisterInspectorWindow.cpp | 4 ++-- .../Widgets/TargetRegistersPane/RegisterWidget.cpp | 2 +- src/TargetController/TargetController.hpp | 10 +++++----- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 4 ++-- .../AVR8/TargetDescription/TargetDescriptionFile.cpp | 4 ++-- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Application.hpp b/src/Application.hpp index 6161b572..0dfdae95 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -45,7 +45,7 @@ namespace Bloom return std::map()>> { { "avr-gdb-rsp", - [this]() -> std::unique_ptr { + [this] () -> std::unique_ptr { return std::make_unique(this->eventManager); } }, diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp index 6f7380c7..bd59ccbf 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp @@ -100,7 +100,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPackets::ReadRegisters& packet) { std::remove_if( registerSet.begin(), registerSet.end(), - [®isterNumberToDescriptorMapping](const TargetRegister& reg) { + [®isterNumberToDescriptorMapping] (const TargetRegister& reg) { return !registerNumberToDescriptorMapping.contains(reg.descriptor); } ), @@ -114,7 +114,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPackets::ReadRegisters& packet) { std::sort( registerSet.begin(), registerSet.end(), - [this, ®isterNumberToDescriptorMapping](const TargetRegister& registerA, const TargetRegister& registerB) { + [this, ®isterNumberToDescriptorMapping] (const TargetRegister& registerA, const TargetRegister& registerB) { return registerNumberToDescriptorMapping.valueAt(registerA.descriptor) < registerNumberToDescriptorMapping.valueAt(registerB.descriptor); } diff --git a/src/EventManager/EventListener.cpp b/src/EventManager/EventListener.cpp index 051a454c..6ea9907c 100644 --- a/src/EventManager/EventListener.cpp +++ b/src/EventManager/EventListener.cpp @@ -29,7 +29,7 @@ void EventListener::waitAndDispatch(int msTimeout) { auto registeredEventTypes = this->getRegisteredEventTypes(); std::optional event; - auto eventsFound = [®isteredEventTypes, &event, &eventQueueByType]() -> bool { + auto eventsFound = [®isteredEventTypes, &event, &eventQueueByType] () -> bool { for (auto& eventQueue: eventQueueByType) { if (registeredEventTypes.contains(eventQueue.first) && !eventQueue.second.empty()) { return true; @@ -86,7 +86,7 @@ std::vector EventListener::getEvents() { } } - std::sort(output.begin(), output.end(), [](const SharedGenericEventPointer& a, const SharedGenericEventPointer& b) { + std::sort(output.begin(), output.end(), [] (const SharedGenericEventPointer& a, const SharedGenericEventPointer& b) { return a->id < b->id; }); diff --git a/src/EventManager/EventListener.hpp b/src/EventManager/EventListener.hpp index a9698756..a68b929e 100644 --- a/src/EventManager/EventListener.hpp +++ b/src/EventManager/EventListener.hpp @@ -107,7 +107,7 @@ namespace Bloom void registerCallbackForEventType(std::function callback) { // We encapsulate the callback in a lambda to handle the downcasting. std::function parentCallback = - [callback](const Events::Event& event) { + [callback] (const Events::Event& event) { // Downcast the event to the expected type callback(dynamic_cast(event)); } @@ -242,7 +242,7 @@ namespace Bloom } Events::SharedGenericEventPointer foundEvent = nullptr; - auto eventsFound = [&eventTypes, &eventQueueByType, &correlationId, &foundEvent]() -> bool { + auto eventsFound = [&eventTypes, &eventQueueByType, &correlationId, &foundEvent] () -> bool { for (const auto& eventType : eventTypes) { if (eventQueueByType.find(eventType) != eventQueueByType.end() && !eventQueueByType.find(eventType)->second.empty() diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 8bdbe5cd..28fead77 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -385,11 +385,11 @@ void InsightWindow::activate() { * considered a duplicate. */ auto processedVariants = std::vector(); - auto isDuplicateVariant = [&processedVariants](const TargetVariant& variantA) { + auto isDuplicateVariant = [&processedVariants] (const TargetVariant& variantA) { return std::ranges::any_of( processedVariants.begin(), processedVariants.end(), - [&variantA, &processedVariants](const TargetVariant& variantB) { + [&variantA, &processedVariants] (const TargetVariant& variantB) { if (variantA.package != variantB.package) { return false; } diff --git a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp index 84b34c96..0f988b54 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp @@ -17,7 +17,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) { { "PanelWidget", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new PanelWidget(parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); @@ -26,7 +26,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { }, { "RotatableLabel", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new RotatableLabel("", parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); @@ -35,7 +35,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { }, { "ExpandingHeightScrollAreaWidget", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new ExpandingHeightScrollAreaWidget(parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); @@ -44,7 +44,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { }, { "SvgWidget", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new SvgWidget(parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); @@ -53,7 +53,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { }, { "SvgToolButton", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new SvgToolButton(parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); @@ -62,7 +62,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { }, { "TargetPackageWidgetContainer", - [this](QWidget* parent, const QString& name) { + [this] (QWidget* parent, const QString& name) { auto widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent); widget->setObjectName(name); widget->setStyleSheet(parent->styleSheet()); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp index 236e6a77..8c2d47d7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp @@ -314,7 +314,7 @@ void TargetRegisterInspectorWindow::refreshRegisterValue() { readTargetRegisterTask, &ReadTargetRegisters::targetRegistersRead, this, - [this](Targets::TargetRegisters targetRegisters) { + [this] (Targets::TargetRegisters targetRegisters) { this->registerValueContainer->setDisabled(false); for (const auto& targetRegister : targetRegisters) { @@ -352,7 +352,7 @@ void TargetRegisterInspectorWindow::applyChanges() { this->registerHistoryWidget->selectCurrentItem(); }); - this->connect(writeRegisterTask, &InsightWorkerTask::failed, this, [this](QString errorMessage) { + this->connect(writeRegisterTask, &InsightWorkerTask::failed, this, [this] (QString errorMessage) { this->registerValueContainer->setDisabled(false); auto errorDialogue = new ErrorDialogue( "Error", diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp index e904e945..2319b020 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp @@ -156,7 +156,7 @@ void RegisterWidget::refreshValue() { readRegisterTask, &ReadTargetRegisters::targetRegistersRead, this, - [this](Targets::TargetRegisters registers) { + [this] (Targets::TargetRegisters registers) { for (const auto& targetRegister : registers) { if (targetRegister.descriptor == this->descriptor) { this->setRegisterValue(targetRegister); diff --git a/src/TargetController/TargetController.hpp b/src/TargetController/TargetController.hpp index d3a3a242..ff7a4bae 100644 --- a/src/TargetController/TargetController.hpp +++ b/src/TargetController/TargetController.hpp @@ -102,19 +102,19 @@ namespace Bloom static auto mapping = std::map()>> { { "atmel-ice", - []() { + [] { return std::make_unique(); } }, { "power-debugger", - []() { + [] { return std::make_unique(); } }, { "snap", - []() { + [] { return std::make_unique(); } }, @@ -136,7 +136,7 @@ namespace Bloom mapping = { { "avr8", - []() { + [] { return std::make_unique(); } }, @@ -158,7 +158,7 @@ namespace Bloom if (!mapping.contains(targetName)) { mapping.insert({ targetName, - [targetName, targetSignatureHex]() { + [targetName, targetSignatureHex] { return std::make_unique( targetName, Targets::Microchip::Avr::TargetSignature(targetSignatureHex) diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index bcac1e32..1268f131 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -134,7 +134,7 @@ TargetDescriptor Avr8Bit::Avr8::getDescriptor() { this->targetVariantsById.begin(), this->targetVariantsById.end(), std::back_inserter(descriptor.variants), - [](auto& variantToIdPair) { + [] (auto& variantToIdPair) { return variantToIdPair.second; } ); @@ -272,7 +272,7 @@ std::map Avr8::getPinStates(int variantId) { * be considered when the need for it becomes apparent. */ std::map cachedMemoryByStartAddress; - auto readMemoryBitset = [this, &cachedMemoryByStartAddress](std::uint16_t startAddress) { + auto readMemoryBitset = [this, &cachedMemoryByStartAddress] (std::uint16_t startAddress) { if (!cachedMemoryByStartAddress.contains(startAddress)) { cachedMemoryByStartAddress.insert( std::pair( diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index 19c62cd0..8b49f480 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -37,7 +37,7 @@ TargetDescriptionFile::TargetDescriptionFile( descriptionFilesJsonArray.begin(), descriptionFilesJsonArray.end(), std::back_inserter(matchingDescriptionFiles), - [&targetName](const QJsonValue& value) { + [&targetName] (const QJsonValue& value) { auto pdTargetName = value.toObject().find("targetName")->toString().toLower().toStdString(); return !targetName.has_value() || (targetName.has_value() && targetName.value() == pdTargetName); } @@ -67,7 +67,7 @@ TargetDescriptionFile::TargetDescriptionFile( matchingDescriptionFiles.begin(), matchingDescriptionFiles.end(), std::back_inserter(targetNames), - [](const QJsonValue& descriptionFile) { + [] (const QJsonValue& descriptionFile) { return QString("\"" + descriptionFile.toObject().find("targetName")->toString().toLower() + "\""); } );