diff --git a/.clang-format b/.clang-format index 92b40492f0..14ff7a4a86 100644 --- a/.clang-format +++ b/.clang-format @@ -3,24 +3,29 @@ Language: Cpp BasedOnStyle: Google AccessModifierOffset: -1 AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: true +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLoopsOnASingleLine: true AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: true +AlwaysBreakTemplateDeclarations: Yes BinPackArguments: true BinPackParameters: true BraceWrapping: + AfterCaseLabel: false AfterClass: false AfterControlStatement: false AfterEnum: false @@ -29,6 +34,7 @@ BraceWrapping: AfterObjCDeclaration: false AfterStruct: false AfterUnion: false + AfterExternBlock: false BeforeCatch: false BeforeElse: false IndentBraces: false @@ -38,6 +44,7 @@ BraceWrapping: BreakBeforeBinaryOperators: None BreakBeforeBraces: Attach BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon @@ -50,6 +57,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true +DeriveLineEnding: false DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false @@ -58,15 +66,25 @@ ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH +IncludeBlocks: Regroup IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 - Regex: '^<.*\.h>' Priority: 1 + SortPriority: 0 - Regex: '^<.*' Priority: 2 + SortPriority: 0 - Regex: '.*' Priority: 3 + SortPriority: 0 IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' IndentCaseLabels: true +IndentGotoLabels: true +IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false JavaScriptQuotes: Leave @@ -76,32 +94,74 @@ MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None +ObjCBinPackProtocolList: Never ObjCBlockIndentWidth: 2 ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: false +ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google ReflowComments: true SortIncludes: false SortUsingDeclarations: true SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: false +SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION TabWidth: 8 +UseCRLF: false UseTab: Never ... diff --git a/azure-templates/clang-format.sh b/azure-templates/clang-format.sh new file mode 100755 index 0000000000..0b72f3b51c --- /dev/null +++ b/azure-templates/clang-format.sh @@ -0,0 +1,62 @@ +#!/bin/bash +################################################################################ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +################################################################################ +# +# This script will install the llvm toolchain on the different +# Debian and Ubuntu versions + +set -eux + +# read optional command line argument +LLVM_VERSION=10 +if [ "$#" -eq 1 ]; then + LLVM_VERSION=$1 +fi + +DISTRO=$(lsb_release -is) +VERSION=$(lsb_release -sr) +DIST_VERSION="${DISTRO}_${VERSION}" + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root!" + exit 1 +fi + +declare -A LLVM_VERSION_PATTERNS +LLVM_VERSION_PATTERNS[9]="-9" +LLVM_VERSION_PATTERNS[10]="-10" +LLVM_VERSION_PATTERNS[11]="" + +if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then + echo "This script does not support LLVM version $LLVM_VERSION" + exit 3 +fi + +LLVM_VERSION_STRING=${LLVM_VERSION_PATTERNS[$LLVM_VERSION]} + +# find the right repository name for the distro and version +case "$DIST_VERSION" in + Debian_9* ) REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch$LLVM_VERSION_STRING main" ;; + Debian_10* ) REPO_NAME="deb http://apt.llvm.org/buster/ llvm-toolchain-buster$LLVM_VERSION_STRING main" ;; + Debian_unstable ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;; + Debian_testing ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;; + Ubuntu_16.04 ) REPO_NAME="deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial$LLVM_VERSION_STRING main" ;; + Ubuntu_18.04 ) REPO_NAME="deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic$LLVM_VERSION_STRING main" ;; + Ubuntu_18.10 ) REPO_NAME="deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic$LLVM_VERSION_STRING main" ;; + Ubuntu_19.04 ) REPO_NAME="deb http://apt.llvm.org/disco/ llvm-toolchain-disco$LLVM_VERSION_STRING main" ;; + Ubuntu_19.10 ) REPO_NAME="deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan$LLVM_VERSION_STRING main" ;; + Ubuntu_20.04 ) REPO_NAME="deb http://apt.llvm.org/focal/ llvm-toolchain-focal$LLVM_VERSION_STRING main" ;; + * ) + echo "Distribution '$DISTRO' in version '$VERSION' is not supported by this script (${DIST_VERSION})." + exit 2 +esac + + +# install everything +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +add-apt-repository "${REPO_NAME}" +apt-get update +apt-get install -y clang-format-$LLVM_VERSION diff --git a/azure-templates/job-styleguide.yml b/azure-templates/job-styleguide.yml index 6611d1f3c9..6a7b1f0bb3 100644 --- a/azure-templates/job-styleguide.yml +++ b/azure-templates/job-styleguide.yml @@ -3,7 +3,7 @@ parameters: jobName: '' pool: - vmImage: 'Ubuntu 16.04' + vmImage: 'Ubuntu 18.04' jobs: - job: Styleguide @@ -18,12 +18,16 @@ jobs: steps: - script: | + sudo apt-get update -q + sudo apt-get install gnupg lsb-release software-properties-common -y + chmod +x azure-templates/clang-format.sh + sudo ./azure-templates/clang-format.sh 10 sudo pip3 install wpiformat displayName: 'Install wpiformat' - script: | git checkout -b master - wpiformat -clang 6.0 + wpiformat -clang 10 displayName: 'Run wpiformat' - script: | diff --git a/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp b/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp index b9741696e7..3ba17846ff 100644 --- a/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp +++ b/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -62,21 +62,21 @@ int ConfigurableSourceImpl::CreateProperty(const wpi::Twine& name, int maximum, int step, int defaultValue, int value) { std::scoped_lock lock(m_mutex); - int ndx = CreateOrUpdateProperty(name, - [=] { - return std::make_unique( - name, kind, minimum, maximum, step, - defaultValue, value); - }, - [&](PropertyImpl& prop) { - // update all but value - prop.propKind = kind; - prop.minimum = minimum; - prop.maximum = maximum; - prop.step = step; - prop.defaultValue = defaultValue; - value = prop.value; - }); + int ndx = CreateOrUpdateProperty( + name, + [=] { + return std::make_unique(name, kind, minimum, maximum, + step, defaultValue, value); + }, + [&](PropertyImpl& prop) { + // update all but value + prop.propKind = kind; + prop.minimum = minimum; + prop.maximum = maximum; + prop.step = step; + prop.defaultValue = defaultValue; + value = prop.value; + }); m_notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CREATED, name, ndx, kind, value, wpi::Twine{}); return ndx; diff --git a/ntcore/manualTests/native/client.cpp b/ntcore/manualTests/native/client.cpp index 3bcb7c0bc6..bb16a9cec6 100644 --- a/ntcore/manualTests/native/client.cpp +++ b/ntcore/manualTests/native/client.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -14,12 +14,13 @@ int main() { auto inst = nt::GetDefaultInstance(); - nt::AddLogger(inst, - [](const nt::LogMessage& msg) { - std::fputs(msg.message.c_str(), stderr); - std::fputc('\n', stderr); - }, - 0, UINT_MAX); + nt::AddLogger( + inst, + [](const nt::LogMessage& msg) { + std::fputs(msg.message.c_str(), stderr); + std::fputc('\n', stderr); + }, + 0, UINT_MAX); nt::StartClient(inst, "127.0.0.1", 10000); std::this_thread::sleep_for(std::chrono::seconds(2)); diff --git a/ntcore/manualTests/native/rpc_local.cpp b/ntcore/manualTests/native/rpc_local.cpp index b8352d6e2d..3311463336 100644 --- a/ntcore/manualTests/native/rpc_local.cpp +++ b/ntcore/manualTests/native/rpc_local.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -34,12 +34,13 @@ void callback1(const nt::RpcAnswer& answer) { int main() { auto inst = nt::GetDefaultInstance(); - nt::AddLogger(inst, - [](const nt::LogMessage& msg) { - std::fputs(msg.message.c_str(), stderr); - std::fputc('\n', stderr); - }, - 0, UINT_MAX); + nt::AddLogger( + inst, + [](const nt::LogMessage& msg) { + std::fputs(msg.message.c_str(), stderr); + std::fputc('\n', stderr); + }, + 0, UINT_MAX); nt::StartServer(inst, "rpc_local.ini", "", 10000); auto entry = nt::GetEntry(inst, "func1"); diff --git a/ntcore/manualTests/native/server.cpp b/ntcore/manualTests/native/server.cpp index 9513bf845a..087ddb41f2 100644 --- a/ntcore/manualTests/native/server.cpp +++ b/ntcore/manualTests/native/server.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -14,12 +14,13 @@ int main() { auto inst = nt::GetDefaultInstance(); - nt::AddLogger(inst, - [](const nt::LogMessage& msg) { - std::fputs(msg.message.c_str(), stderr); - std::fputc('\n', stderr); - }, - 0, UINT_MAX); + nt::AddLogger( + inst, + [](const nt::LogMessage& msg) { + std::fputs(msg.message.c_str(), stderr); + std::fputc('\n', stderr); + }, + 0, UINT_MAX); nt::StartServer(inst, "persistent.ini", "", 10000); std::this_thread::sleep_for(std::chrono::seconds(1)); diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp index 8cc8312a51..281b638a31 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.cpp +++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -135,18 +135,18 @@ void NetworkConnection::ReadThreadMain() { WireDecoder decoder(is, m_proto_rev, m_logger); set_state(kHandshake); - if (!m_handshake(*this, - [&] { - decoder.set_proto_rev(m_proto_rev); - auto msg = Message::Read(decoder, m_get_entry_type); - if (!msg && decoder.error()) - DEBUG0( - "error reading in handshake: " << decoder.error()); - return msg; - }, - [&](wpi::ArrayRef> msgs) { - m_outgoing.emplace(msgs); - })) { + if (!m_handshake( + *this, + [&] { + decoder.set_proto_rev(m_proto_rev); + auto msg = Message::Read(decoder, m_get_entry_type); + if (!msg && decoder.error()) + DEBUG0("error reading in handshake: " << decoder.error()); + return msg; + }, + [&](wpi::ArrayRef> msgs) { + m_outgoing.emplace(msgs); + })) { set_state(kDead); m_active = false; goto done; diff --git a/ntcore/src/main/native/cpp/Storage.cpp b/ntcore/src/main/native/cpp/Storage.cpp index cf0d26ca64..dadb8e7f23 100644 --- a/ntcore/src/main/native/cpp/Storage.cpp +++ b/ntcore/src/main/native/cpp/Storage.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -1053,14 +1053,15 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) { conn_info.last_update = wpi::Now(); conn_info.protocol_version = 0x0300; unsigned int call_uid = msg->seq_num_uid(); - m_rpc_server.ProcessRpc(local_id, call_uid, name, msg->str(), conn_info, - [=](StringRef result) { - std::scoped_lock lock(m_mutex); - m_rpc_results.insert(std::make_pair( - RpcIdPair{local_id, call_uid}, result)); - m_rpc_results_cond.notify_all(); - }, - rpc_uid); + m_rpc_server.ProcessRpc( + local_id, call_uid, name, msg->str(), conn_info, + [=](StringRef result) { + std::scoped_lock lock(m_mutex); + m_rpc_results.insert( + std::make_pair(RpcIdPair{local_id, call_uid}, result)); + m_rpc_results_cond.notify_all(); + }, + rpc_uid); } else { auto dispatcher = m_dispatcher; lock.unlock(); diff --git a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp index 6d4197697e..ca6e8a6ae8 100644 --- a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp +++ b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -233,13 +233,13 @@ NT_EntryListener NetworkTable::AddEntryListener(const Twine& key, unsigned int flags) const { size_t prefix_len = m_path.size() + 1; auto entry = GetEntry(key); - return nt::AddEntryListener(entry.GetHandle(), - [=](const EntryNotification& event) { - listener(const_cast(this), - event.name.substr(prefix_len), entry, - event.value, event.flags); - }, - flags); + return nt::AddEntryListener( + entry.GetHandle(), + [=](const EntryNotification& event) { + listener(const_cast(this), event.name.substr(prefix_len), + entry, event.value, event.flags); + }, + flags); } void NetworkTable::RemoveEntryListener(NT_EntryListener listener) const { diff --git a/ntcore/src/main/native/cpp/ntcore_c.cpp b/ntcore/src/main/native/cpp/ntcore_c.cpp index 60745fea14..ee8eabcc2e 100644 --- a/ntcore/src/main/native/cpp/ntcore_c.cpp +++ b/ntcore/src/main/native/cpp/ntcore_c.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -260,27 +260,29 @@ NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix, size_t prefix_len, void* data, NT_EntryListenerCallback callback, unsigned int flags) { - return nt::AddEntryListener(inst, StringRef(prefix, prefix_len), - [=](const EntryNotification& event) { - NT_EntryNotification c_event; - ConvertToC(event, &c_event); - callback(data, &c_event); - DisposeEntryNotification(&c_event); - }, - flags); + return nt::AddEntryListener( + inst, StringRef(prefix, prefix_len), + [=](const EntryNotification& event) { + NT_EntryNotification c_event; + ConvertToC(event, &c_event); + callback(data, &c_event); + DisposeEntryNotification(&c_event); + }, + flags); } NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void* data, NT_EntryListenerCallback callback, unsigned int flags) { - return nt::AddEntryListener(entry, - [=](const EntryNotification& event) { - NT_EntryNotification c_event; - ConvertToC(event, &c_event); - callback(data, &c_event); - DisposeEntryNotification(&c_event); - }, - flags); + return nt::AddEntryListener( + entry, + [=](const EntryNotification& event) { + NT_EntryNotification c_event; + ConvertToC(event, &c_event); + callback(data, &c_event); + DisposeEntryNotification(&c_event); + }, + flags); } NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst) { @@ -335,14 +337,15 @@ NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout) { NT_ConnectionListener NT_AddConnectionListener( NT_Inst inst, void* data, NT_ConnectionListenerCallback callback, NT_Bool immediate_notify) { - return nt::AddConnectionListener(inst, - [=](const ConnectionNotification& event) { - NT_ConnectionNotification event_c; - ConvertToC(event, &event_c); - callback(data, &event_c); - DisposeConnectionNotification(&event_c); - }, - immediate_notify != 0); + return nt::AddConnectionListener( + inst, + [=](const ConnectionNotification& event) { + NT_ConnectionNotification event_c; + ConvertToC(event, &event_c); + callback(data, &event_c); + DisposeConnectionNotification(&event_c); + }, + immediate_notify != 0); } NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst) { @@ -639,14 +642,15 @@ uint64_t NT_Now(void) { return wpi::Now(); } NT_Logger NT_AddLogger(NT_Inst inst, void* data, NT_LogFunc func, unsigned int min_level, unsigned int max_level) { - return nt::AddLogger(inst, - [=](const LogMessage& msg) { - NT_LogMessage msg_c; - ConvertToC(msg, &msg_c); - func(data, &msg_c); - NT_DisposeLogMessage(&msg_c); - }, - min_level, max_level); + return nt::AddLogger( + inst, + [=](const LogMessage& msg) { + NT_LogMessage msg_c; + ConvertToC(msg, &msg_c); + func(data, &msg_c); + NT_DisposeLogMessage(&msg_c); + }, + min_level, max_level); } NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst) { diff --git a/ntcore/src/test/native/cpp/main.cpp b/ntcore/src/test/native/cpp/main.cpp index d0b0e3c6fb..112289f814 100644 --- a/ntcore/src/test/native/cpp/main.cpp +++ b/ntcore/src/test/native/cpp/main.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -11,12 +11,13 @@ #include "ntcore.h" int main(int argc, char** argv) { - nt::AddLogger(nt::GetDefaultInstance(), - [](const nt::LogMessage& msg) { - std::fputs(msg.message.c_str(), stderr); - std::fputc('\n', stderr); - }, - 0, UINT_MAX); + nt::AddLogger( + nt::GetDefaultInstance(), + [](const nt::LogMessage& msg) { + std::fputs(msg.message.c_str(), stderr); + std::fputc('\n', stderr); + }, + 0, UINT_MAX); ::testing::InitGoogleMock(&argc, argv); int ret = RUN_ALL_TESTS(); return ret; diff --git a/simulation/halsim_gui/src/main/native/cpp/HALSimGui.cpp b/simulation/halsim_gui/src/main/native/cpp/HALSimGui.cpp index 28e1fed44f..8e0ad84937 100644 --- a/simulation/halsim_gui/src/main/native/cpp/HALSimGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/HALSimGui.cpp @@ -580,7 +580,8 @@ void HALSIMGUI_AddExecute(void* param, void (*execute)(void*)) { void HALSIMGUI_AddWindow(const char* name, void* param, void (*display)(void*), int32_t flags) { if (display) { - HALSimGui::AddWindow(name, [=] { display(param); }, flags); + HALSimGui::AddWindow( + name, [=] { display(param); }, flags); } } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp index 826c861e58..30c3af6850 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp @@ -51,14 +51,16 @@ void CommandBase::SetSubsystem(const wpi::Twine& subsystem) { void CommandBase::InitSendable(frc::SendableBuilder& builder) { builder.SetSmartDashboardType("Command"); - builder.AddStringProperty(".name", [this] { return GetName(); }, nullptr); - builder.AddBooleanProperty("running", [this] { return IsScheduled(); }, - [this](bool value) { - bool isScheduled = IsScheduled(); - if (value && !isScheduled) { - Schedule(); - } else if (!value && isScheduled) { - Cancel(); - } - }); + builder.AddStringProperty( + ".name", [this] { return GetName(); }, nullptr); + builder.AddBooleanProperty( + "running", [this] { return IsScheduled(); }, + [this](bool value) { + bool isScheduled = IsScheduled(); + if (value && !isScheduled) { + Schedule(); + } else if (!value && isScheduled) { + Cancel(); + } + }); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp index 8ce3c3785b..ea6c105c25 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp @@ -37,15 +37,17 @@ PIDCommand::PIDCommand(PIDController controller, std::function measurementSource, double setpoint, std::function useOutput, std::initializer_list requirements) - : PIDCommand(controller, measurementSource, [setpoint] { return setpoint; }, - useOutput, requirements) {} + : PIDCommand( + controller, measurementSource, [setpoint] { return setpoint; }, + useOutput, requirements) {} PIDCommand::PIDCommand(PIDController controller, std::function measurementSource, double setpoint, std::function useOutput, wpi::ArrayRef requirements) - : PIDCommand(controller, measurementSource, [setpoint] { return setpoint; }, - useOutput, requirements) {} + : PIDCommand( + controller, measurementSource, [setpoint] { return setpoint; }, + useOutput, requirements) {} void PIDCommand::Initialize() { m_controller.Reset(); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp index 9b30fec66f..a28de20cb3 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -22,26 +22,28 @@ SubsystemBase::SubsystemBase() { void SubsystemBase::InitSendable(frc::SendableBuilder& builder) { builder.SetSmartDashboardType("Subsystem"); - builder.AddBooleanProperty(".hasDefault", - [this] { return GetDefaultCommand() != nullptr; }, - nullptr); - builder.AddStringProperty(".default", - [this]() -> std::string { - auto command = GetDefaultCommand(); - if (command == nullptr) return "none"; - return command->GetName(); - }, - nullptr); - builder.AddBooleanProperty(".hasCommand", - [this] { return GetCurrentCommand() != nullptr; }, - nullptr); - builder.AddStringProperty(".command", - [this]() -> std::string { - auto command = GetCurrentCommand(); - if (command == nullptr) return "none"; - return command->GetName(); - }, - nullptr); + builder.AddBooleanProperty( + ".hasDefault", [this] { return GetDefaultCommand() != nullptr; }, + nullptr); + builder.AddStringProperty( + ".default", + [this]() -> std::string { + auto command = GetDefaultCommand(); + if (command == nullptr) return "none"; + return command->GetName(); + }, + nullptr); + builder.AddBooleanProperty( + ".hasCommand", [this] { return GetCurrentCommand() != nullptr; }, + nullptr); + builder.AddStringProperty( + ".command", + [this]() -> std::string { + auto command = GetCurrentCommand(); + if (command == nullptr) return "none"; + return command->GetName(); + }, + nullptr); } std::string SubsystemBase::GetName() const { diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h index b685230165..fbc4f6d2a3 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h @@ -96,11 +96,12 @@ class ProfiledPIDCommand std::function goalSource, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, - [&goalSource]() { - return State{goalSource(), Velocity_t{0}}; - }, - useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, + [&goalSource]() { + return State{goalSource(), Velocity_t{0}}; + }, + useOutput, requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -117,11 +118,12 @@ class ProfiledPIDCommand std::function goalSource, std::function useOutput, wpi::ArrayRef requirements = {}) - : ProfiledPIDCommand(controller, measurementSource, - [&goalSource]() { - return State{goalSource(), Velocity_t{0}}; - }, - useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, + [&goalSource]() { + return State{goalSource(), Velocity_t{0}}; + }, + useOutput, requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -137,8 +139,9 @@ class ProfiledPIDCommand std::function measurementSource, State goal, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, - [goal] { return goal; }, useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, [goal] { return goal; }, useOutput, + requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -154,8 +157,9 @@ class ProfiledPIDCommand std::function measurementSource, State goal, std::function useOutput, wpi::ArrayRef requirements = {}) - : ProfiledPIDCommand(controller, measurementSource, - [goal] { return goal; }, useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, [goal] { return goal; }, useOutput, + requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -172,8 +176,9 @@ class ProfiledPIDCommand Distance_t goal, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, - [goal] { return goal; }, useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, [goal] { return goal; }, useOutput, + requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -190,8 +195,9 @@ class ProfiledPIDCommand Distance_t goal, std::function useOutput, wpi::ArrayRef requirements = {}) - : ProfiledPIDCommand(controller, measurementSource, - [goal] { return goal; }, useOutput, requirements) {} + : ProfiledPIDCommand( + controller, measurementSource, [goal] { return goal; }, useOutput, + requirements) {} ProfiledPIDCommand(ProfiledPIDCommand&& other) = default; diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ButtonTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ButtonTest.cpp index 829f0d2ae2..d504ff7616 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ButtonTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ButtonTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -129,9 +129,9 @@ TEST_F(ButtonTest, AndTest) { bool pressed2 = false; WaitUntilCommand command([&finished] { return finished; }); - (Trigger([&pressed1] { return pressed1; }) && - Trigger([&pressed2] { return pressed2; })) - .WhenActive(&command); + (Trigger([&pressed1] { return pressed1; }) && Trigger([&pressed2] { + return pressed2; + })).WhenActive(&command); pressed1 = true; scheduler.Run(); EXPECT_FALSE(scheduler.IsScheduled(&command)); @@ -148,18 +148,18 @@ TEST_F(ButtonTest, OrTest) { WaitUntilCommand command1([&finished] { return finished; }); WaitUntilCommand command2([&finished] { return finished; }); - (Trigger([&pressed1] { return pressed1; }) || - Trigger([&pressed2] { return pressed2; })) - .WhenActive(&command1); + (Trigger([&pressed1] { return pressed1; }) || Trigger([&pressed2] { + return pressed2; + })).WhenActive(&command1); pressed1 = true; scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(&command1)); pressed1 = false; - (Trigger([&pressed1] { return pressed1; }) || - Trigger([&pressed2] { return pressed2; })) - .WhenActive(&command2); + (Trigger([&pressed1] { return pressed1; }) || Trigger([&pressed2] { + return pressed2; + })).WhenActive(&command2); pressed2 = true; scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(&command2)); diff --git a/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp b/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp index f215083937..0cce9d01e2 100644 --- a/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp +++ b/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -66,6 +66,7 @@ void Trigger::ToggleWhenActive(Command* command) { void Trigger::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Button"); builder.SetSafeState([=]() { m_sendablePressed = false; }); - builder.AddBooleanProperty("pressed", [=]() { return Grab(); }, - [=](bool value) { m_sendablePressed = value; }); + builder.AddBooleanProperty( + "pressed", [=]() { return Grab(); }, + [=](bool value) { m_sendablePressed = value; }); } diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp index a7154c0b87..8c2abcffc7 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -251,14 +251,15 @@ void Command::InitSendable(SendableBuilder& builder) { builder.AddStringProperty( ".name", [=]() { return SendableRegistry::GetInstance().GetName(this); }, nullptr); - builder.AddBooleanProperty("running", [=]() { return IsRunning(); }, - [=](bool value) { - if (value) { - if (!IsRunning()) Start(); - } else { - if (IsRunning()) Cancel(); - } - }); - builder.AddBooleanProperty(".isParented", [=]() { return IsParented(); }, - nullptr); + builder.AddBooleanProperty( + "running", [=]() { return IsRunning(); }, + [=](bool value) { + if (value) { + if (!IsRunning()) Start(); + } else { + if (IsRunning()) Cancel(); + } + }); + builder.AddBooleanProperty( + ".isParented", [=]() { return IsParented(); }, nullptr); } diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp index 3178455420..85e800ec30 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -122,11 +122,11 @@ void Subsystem::InitSendable(SendableBuilder& builder) { builder.AddBooleanProperty( ".hasDefault", [=]() { return m_defaultCommand != nullptr; }, nullptr); - builder.AddStringProperty(".default", - [=]() { return GetDefaultCommandName(); }, nullptr); + builder.AddStringProperty( + ".default", [=]() { return GetDefaultCommandName(); }, nullptr); builder.AddBooleanProperty( ".hasCommand", [=]() { return m_currentCommand != nullptr; }, nullptr); - builder.AddStringProperty(".command", - [=]() { return GetCurrentCommandName(); }, nullptr); + builder.AddStringProperty( + ".command", [=]() { return GetCurrentCommandName(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp index be0c7d2a98..eed6a60bba 100644 --- a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -52,8 +52,8 @@ double AnalogAccelerometer::PIDGet() { return GetAcceleration(); } void AnalogAccelerometer::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Accelerometer"); - builder.AddDoubleProperty("Value", [=]() { return GetAcceleration(); }, - nullptr); + builder.AddDoubleProperty( + "Value", [=]() { return GetAcceleration(); }, nullptr); } void AnalogAccelerometer::InitAccelerometer() { diff --git a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp index a194961377..c1240da97f 100644 --- a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp +++ b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -96,9 +96,9 @@ void AnalogEncoder::Reset() { void AnalogEncoder::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("AbsoluteEncoder"); - builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); }, - nullptr); - builder.AddDoubleProperty("Distance Per Rotation", - [this] { return this->GetDistancePerRotation(); }, - nullptr); + builder.AddDoubleProperty( + "Distance", [this] { return this->GetDistance(); }, nullptr); + builder.AddDoubleProperty( + "Distance Per Rotation", + [this] { return this->GetDistancePerRotation(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp index c8197b73c8..758865b47a 100644 --- a/wpilibc/src/main/native/cpp/AnalogInput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -230,6 +230,6 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) { void AnalogInput::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Analog Input"); - builder.AddDoubleProperty("Value", [=]() { return GetAverageVoltage(); }, - nullptr); + builder.AddDoubleProperty( + "Value", [=]() { return GetAverageVoltage(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp index 041b446a7b..bf89c0cb3f 100644 --- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -69,6 +69,7 @@ int AnalogOutput::GetChannel() { return m_channel; } void AnalogOutput::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Analog Output"); - builder.AddDoubleProperty("Value", [=]() { return GetVoltage(); }, - [=](double value) { SetVoltage(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return GetVoltage(); }, + [=](double value) { SetVoltage(value); }); } diff --git a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp index d7cdef6e50..efc0fe6d1a 100644 --- a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp +++ b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -43,7 +43,10 @@ double BuiltInAccelerometer::GetZ() { return HAL_GetAccelerometerZ(); } void BuiltInAccelerometer::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("3AxisAccelerometer"); - builder.AddDoubleProperty("X", [=]() { return GetX(); }, nullptr); - builder.AddDoubleProperty("Y", [=]() { return GetY(); }, nullptr); - builder.AddDoubleProperty("Z", [=]() { return GetZ(); }, nullptr); + builder.AddDoubleProperty( + "X", [=]() { return GetX(); }, nullptr); + builder.AddDoubleProperty( + "Y", [=]() { return GetY(); }, nullptr); + builder.AddDoubleProperty( + "Z", [=]() { return GetZ(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/Compressor.cpp b/wpilibc/src/main/native/cpp/Compressor.cpp index 29789be722..0dcc483b82 100644 --- a/wpilibc/src/main/native/cpp/Compressor.cpp +++ b/wpilibc/src/main/native/cpp/Compressor.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -206,13 +206,14 @@ void Compressor::ClearAllPCMStickyFaults() { void Compressor::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Compressor"); - builder.AddBooleanProperty("Enabled", [=]() { return Enabled(); }, - [=](bool value) { - if (value) - Start(); - else - Stop(); - }); + builder.AddBooleanProperty( + "Enabled", [=]() { return Enabled(); }, + [=](bool value) { + if (value) + Start(); + else + Stop(); + }); builder.AddBooleanProperty( "Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/Counter.cpp b/wpilibc/src/main/native/cpp/Counter.cpp index d2158ca020..6f61c1e689 100644 --- a/wpilibc/src/main/native/cpp/Counter.cpp +++ b/wpilibc/src/main/native/cpp/Counter.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -332,5 +332,6 @@ bool Counter::GetDirection() const { void Counter::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Counter"); - builder.AddDoubleProperty("Value", [=]() { return Get(); }, nullptr); + builder.AddDoubleProperty( + "Value", [=]() { return Get(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index 7210750ad5..23a00fff27 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -73,5 +73,6 @@ int DigitalInput::GetChannel() const { return m_channel; } void DigitalInput::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Digital Input"); - builder.AddBooleanProperty("Value", [=]() { return Get(); }, nullptr); + builder.AddBooleanProperty( + "Value", [=]() { return Get(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index 6e9b09b3e6..f1dacfce53 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -154,6 +154,6 @@ void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) { void DigitalOutput::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Digital Output"); - builder.AddBooleanProperty("Value", [=]() { return Get(); }, - [=](bool value) { Set(value); }); + builder.AddBooleanProperty( + "Value", [=]() { return Get(); }, [=](bool value) { Set(value); }); } diff --git a/wpilibc/src/main/native/cpp/DutyCycle.cpp b/wpilibc/src/main/native/cpp/DutyCycle.cpp index 12f390e761..3812c2a637 100644 --- a/wpilibc/src/main/native/cpp/DutyCycle.cpp +++ b/wpilibc/src/main/native/cpp/DutyCycle.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -93,8 +93,8 @@ int DutyCycle::GetSourceChannel() const { return m_source->GetChannel(); } void DutyCycle::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Duty Cycle"); - builder.AddDoubleProperty("Frequency", - [this] { return this->GetFrequency(); }, nullptr); - builder.AddDoubleProperty("Output", [this] { return this->GetOutput(); }, - nullptr); + builder.AddDoubleProperty( + "Frequency", [this] { return this->GetFrequency(); }, nullptr); + builder.AddDoubleProperty( + "Output", [this] { return this->GetOutput(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp index 114b81c2d7..8b431b47c6 100644 --- a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp +++ b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp @@ -130,11 +130,11 @@ void DutyCycleEncoder::SetConnectedFrequencyThreshold(int frequency) { void DutyCycleEncoder::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("AbsoluteEncoder"); - builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); }, - nullptr); - builder.AddDoubleProperty("Distance Per Rotation", - [this] { return this->GetDistancePerRotation(); }, - nullptr); - builder.AddDoubleProperty("Is Connected", - [this] { return this->IsConnected(); }, nullptr); + builder.AddDoubleProperty( + "Distance", [this] { return this->GetDistance(); }, nullptr); + builder.AddDoubleProperty( + "Distance Per Rotation", + [this] { return this->GetDistancePerRotation(); }, nullptr); + builder.AddDoubleProperty( + "Is Connected", [this] { return this->IsConnected(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index 963bcc6a7d..440cf8b45d 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -236,11 +236,12 @@ void Encoder::InitSendable(SendableBuilder& builder) { else builder.SetSmartDashboardType("Encoder"); - builder.AddDoubleProperty("Speed", [=]() { return GetRate(); }, nullptr); - builder.AddDoubleProperty("Distance", [=]() { return GetDistance(); }, - nullptr); - builder.AddDoubleProperty("Distance per Tick", - [=]() { return GetDistancePerPulse(); }, nullptr); + builder.AddDoubleProperty( + "Speed", [=]() { return GetRate(); }, nullptr); + builder.AddDoubleProperty( + "Distance", [=]() { return GetDistance(); }, nullptr); + builder.AddDoubleProperty( + "Distance per Tick", [=]() { return GetDistancePerPulse(); }, nullptr); } void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { diff --git a/wpilibc/src/main/native/cpp/GyroBase.cpp b/wpilibc/src/main/native/cpp/GyroBase.cpp index ec67675d24..ba9b2f0bdf 100644 --- a/wpilibc/src/main/native/cpp/GyroBase.cpp +++ b/wpilibc/src/main/native/cpp/GyroBase.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -25,5 +25,6 @@ double GyroBase::PIDGet() { void GyroBase::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Gyro"); - builder.AddDoubleProperty("Value", [=]() { return GetAngle(); }, nullptr); + builder.AddDoubleProperty( + "Value", [=]() { return GetAngle(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/NidecBrushless.cpp b/wpilibc/src/main/native/cpp/NidecBrushless.cpp index 5bce36eca2..82a278e032 100644 --- a/wpilibc/src/main/native/cpp/NidecBrushless.cpp +++ b/wpilibc/src/main/native/cpp/NidecBrushless.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -70,6 +70,6 @@ void NidecBrushless::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Nidec Brushless"); builder.SetActuator(true); builder.SetSafeState([=]() { StopMotor(); }); - builder.AddDoubleProperty("Value", [=]() { return Get(); }, - [=](double value) { Set(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return Get(); }, [=](double value) { Set(value); }); } diff --git a/wpilibc/src/main/native/cpp/PIDBase.cpp b/wpilibc/src/main/native/cpp/PIDBase.cpp index c8f6fed3d5..5802d989b5 100644 --- a/wpilibc/src/main/native/cpp/PIDBase.cpp +++ b/wpilibc/src/main/native/cpp/PIDBase.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -229,16 +229,17 @@ void PIDBase::PIDWrite(double output) { SetSetpoint(output); } void PIDBase::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PIDController"); builder.SetSafeState([=]() { Reset(); }); - builder.AddDoubleProperty("p", [=]() { return GetP(); }, - [=](double value) { SetP(value); }); - builder.AddDoubleProperty("i", [=]() { return GetI(); }, - [=](double value) { SetI(value); }); - builder.AddDoubleProperty("d", [=]() { return GetD(); }, - [=](double value) { SetD(value); }); - builder.AddDoubleProperty("f", [=]() { return GetF(); }, - [=](double value) { SetF(value); }); - builder.AddDoubleProperty("setpoint", [=]() { return GetSetpoint(); }, - [=](double value) { SetSetpoint(value); }); + builder.AddDoubleProperty( + "p", [=]() { return GetP(); }, [=](double value) { SetP(value); }); + builder.AddDoubleProperty( + "i", [=]() { return GetI(); }, [=](double value) { SetI(value); }); + builder.AddDoubleProperty( + "d", [=]() { return GetD(); }, [=](double value) { SetD(value); }); + builder.AddDoubleProperty( + "f", [=]() { return GetF(); }, [=](double value) { SetF(value); }); + builder.AddDoubleProperty( + "setpoint", [=]() { return GetSetpoint(); }, + [=](double value) { SetSetpoint(value); }); } void PIDBase::Calculate() { diff --git a/wpilibc/src/main/native/cpp/PIDController.cpp b/wpilibc/src/main/native/cpp/PIDController.cpp index 0c86f55c48..a90a645110 100644 --- a/wpilibc/src/main/native/cpp/PIDController.cpp +++ b/wpilibc/src/main/native/cpp/PIDController.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -80,6 +80,7 @@ void PIDController::Reset() { void PIDController::InitSendable(SendableBuilder& builder) { PIDBase::InitSendable(builder); - builder.AddBooleanProperty("enabled", [=]() { return IsEnabled(); }, - [=](bool value) { SetEnabled(value); }); + builder.AddBooleanProperty( + "enabled", [=]() { return IsEnabled(); }, + [=](bool value) { SetEnabled(value); }); } diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp index dabcd2ee54..c2cd2e27d2 100644 --- a/wpilibc/src/main/native/cpp/PWM.cpp +++ b/wpilibc/src/main/native/cpp/PWM.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -199,6 +199,7 @@ void PWM::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PWM"); builder.SetActuator(true); builder.SetSafeState([=]() { SetDisabled(); }); - builder.AddDoubleProperty("Value", [=]() { return GetRaw(); }, - [=](double value) { SetRaw(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return GetRaw(); }, + [=](double value) { SetRaw(value); }); } diff --git a/wpilibc/src/main/native/cpp/PWMSpeedController.cpp b/wpilibc/src/main/native/cpp/PWMSpeedController.cpp index ea298de6c2..ec0be7b94e 100644 --- a/wpilibc/src/main/native/cpp/PWMSpeedController.cpp +++ b/wpilibc/src/main/native/cpp/PWMSpeedController.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -35,6 +35,7 @@ void PWMSpeedController::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Speed Controller"); builder.SetActuator(true); builder.SetSafeState([=]() { SetDisabled(); }); - builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); }, - [=](double value) { SetSpeed(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return GetSpeed(); }, + [=](double value) { SetSpeed(value); }); } diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp index 7d7d9164a8..a0ff16d5dc 100644 --- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp +++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -139,10 +139,11 @@ void PowerDistributionPanel::ClearStickyFaults() { void PowerDistributionPanel::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PowerDistributionPanel"); for (int i = 0; i < SensorUtil::kPDPChannels; ++i) { - builder.AddDoubleProperty("Chan" + wpi::Twine(i), - [=]() { return GetCurrent(i); }, nullptr); + builder.AddDoubleProperty( + "Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr); } - builder.AddDoubleProperty("Voltage", [=]() { return GetVoltage(); }, nullptr); - builder.AddDoubleProperty("TotalCurrent", [=]() { return GetTotalCurrent(); }, - nullptr); + builder.AddDoubleProperty( + "Voltage", [=]() { return GetVoltage(); }, nullptr); + builder.AddDoubleProperty( + "TotalCurrent", [=]() { return GetTotalCurrent(); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/Servo.cpp b/wpilibc/src/main/native/cpp/Servo.cpp index 4b6856a0b5..5edcebca8b 100644 --- a/wpilibc/src/main/native/cpp/Servo.cpp +++ b/wpilibc/src/main/native/cpp/Servo.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -57,8 +57,8 @@ double Servo::GetMinAngle() const { return kMinServoAngle; } void Servo::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Servo"); - builder.AddDoubleProperty("Value", [=]() { return Get(); }, - [=](double value) { Set(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return Get(); }, [=](double value) { Set(value); }); } double Servo::GetServoAngleRange() const { diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp index e0bde3cd57..ebb4a7b7bc 100644 --- a/wpilibc/src/main/native/cpp/Solenoid.cpp +++ b/wpilibc/src/main/native/cpp/Solenoid.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -93,6 +93,6 @@ void Solenoid::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Solenoid"); builder.SetActuator(true); builder.SetSafeState([=]() { Set(false); }); - builder.AddBooleanProperty("Value", [=]() { return Get(); }, - [=](bool value) { Set(value); }); + builder.AddBooleanProperty( + "Value", [=]() { return Get(); }, [=](bool value) { Set(value); }); } diff --git a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp index 7e13f27cdd..8fea1b24f8 100644 --- a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp +++ b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp @@ -66,6 +66,6 @@ void SpeedControllerGroup::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Speed Controller"); builder.SetActuator(true); builder.SetSafeState([=]() { StopMotor(); }); - builder.AddDoubleProperty("Value", [=]() { return Get(); }, - [=](double value) { Set(value); }); + builder.AddDoubleProperty( + "Value", [=]() { return Get(); }, [=](double value) { Set(value); }); } diff --git a/wpilibc/src/main/native/cpp/Ultrasonic.cpp b/wpilibc/src/main/native/cpp/Ultrasonic.cpp index fcd016ef09..bbc37f7309 100644 --- a/wpilibc/src/main/native/cpp/Ultrasonic.cpp +++ b/wpilibc/src/main/native/cpp/Ultrasonic.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -177,8 +177,8 @@ void Ultrasonic::SetPIDSourceType(PIDSourceType pidSource) { void Ultrasonic::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("Ultrasonic"); - builder.AddDoubleProperty("Value", [=]() { return GetRangeInches(); }, - nullptr); + builder.AddDoubleProperty( + "Value", [=]() { return GetRangeInches(); }, nullptr); } void Ultrasonic::Initialize() { diff --git a/wpilibc/src/main/native/cpp/controller/PIDController.cpp b/wpilibc/src/main/native/cpp/controller/PIDController.cpp index 41c4d1f694..7b9b62317d 100644 --- a/wpilibc/src/main/native/cpp/controller/PIDController.cpp +++ b/wpilibc/src/main/native/cpp/controller/PIDController.cpp @@ -119,12 +119,13 @@ void PIDController::Reset() { void PIDController::InitSendable(frc::SendableBuilder& builder) { builder.SetSmartDashboardType("PIDController"); - builder.AddDoubleProperty("p", [this] { return GetP(); }, - [this](double value) { SetP(value); }); - builder.AddDoubleProperty("i", [this] { return GetI(); }, - [this](double value) { SetI(value); }); - builder.AddDoubleProperty("d", [this] { return GetD(); }, - [this](double value) { SetD(value); }); - builder.AddDoubleProperty("setpoint", [this] { return GetSetpoint(); }, - [this](double value) { SetSetpoint(value); }); + builder.AddDoubleProperty( + "p", [this] { return GetP(); }, [this](double value) { SetP(value); }); + builder.AddDoubleProperty( + "i", [this] { return GetI(); }, [this](double value) { SetI(value); }); + builder.AddDoubleProperty( + "d", [this] { return GetD(); }, [this](double value) { SetD(value); }); + builder.AddDoubleProperty( + "setpoint", [this] { return GetSetpoint(); }, + [this](double value) { SetSetpoint(value); }); } diff --git a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp index 2d30a2b205..ce9aa058f7 100644 --- a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -216,9 +216,9 @@ void DifferentialDrive::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("DifferentialDrive"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); - builder.AddDoubleProperty("Left Motor Speed", - [=]() { return m_leftMotor->Get(); }, - [=](double value) { m_leftMotor->Set(value); }); + builder.AddDoubleProperty( + "Left Motor Speed", [=]() { return m_leftMotor->Get(); }, + [=](double value) { m_leftMotor->Set(value); }); builder.AddDoubleProperty( "Right Motor Speed", [=]() { return m_rightMotor->Get() * m_rightSideInvertMultiplier; }, diff --git a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp index e03951b992..983ce6a065 100644 --- a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -107,13 +107,13 @@ void KilloughDrive::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("KilloughDrive"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); - builder.AddDoubleProperty("Left Motor Speed", - [=]() { return m_leftMotor->Get(); }, - [=](double value) { m_leftMotor->Set(value); }); - builder.AddDoubleProperty("Right Motor Speed", - [=]() { return m_rightMotor->Get(); }, - [=](double value) { m_rightMotor->Set(value); }); - builder.AddDoubleProperty("Back Motor Speed", - [=]() { return m_backMotor->Get(); }, - [=](double value) { m_backMotor->Set(value); }); + builder.AddDoubleProperty( + "Left Motor Speed", [=]() { return m_leftMotor->Get(); }, + [=](double value) { m_leftMotor->Set(value); }); + builder.AddDoubleProperty( + "Right Motor Speed", [=]() { return m_rightMotor->Get(); }, + [=](double value) { m_rightMotor->Set(value); }); + builder.AddDoubleProperty( + "Back Motor Speed", [=]() { return m_backMotor->Get(); }, + [=](double value) { m_backMotor->Set(value); }); } diff --git a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp index 0102d6a8d4..cb11d8a810 100644 --- a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -120,9 +120,9 @@ void MecanumDrive::InitSendable(SendableBuilder& builder) { [=](double value) { m_frontRightMotor->Set(value * m_rightSideInvertMultiplier); }); - builder.AddDoubleProperty("Rear Left Motor Speed", - [=]() { return m_rearLeftMotor->Get(); }, - [=](double value) { m_rearLeftMotor->Set(value); }); + builder.AddDoubleProperty( + "Rear Left Motor Speed", [=]() { return m_rearLeftMotor->Get(); }, + [=](double value) { m_rearLeftMotor->Set(value); }); builder.AddDoubleProperty( "Rear Right Motor Speed", [=]() { return m_rearRightMotor->Get() * m_rightSideInvertMultiplier; }, diff --git a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp index b6f8ce984d..663cc19baa 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -30,7 +30,7 @@ void AddToSendableRegistry(frc::Sendable* sendable, std::string name) { } // namespace detail void SendableCameraWrapper::InitSendable(SendableBuilder& builder) { - builder.AddStringProperty(".ShuffleboardURI", [this] { return m_uri; }, - nullptr); + builder.AddStringProperty( + ".ShuffleboardURI", [this] { return m_uri; }, nullptr); } } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h index 14f1e9b93f..eaf2d6ffd7 100644 --- a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h +++ b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h @@ -339,12 +339,12 @@ class ProfiledPIDController void InitSendable(frc::SendableBuilder& builder) override { builder.SetSmartDashboardType("ProfiledPIDController"); - builder.AddDoubleProperty("p", [this] { return GetP(); }, - [this](double value) { SetP(value); }); - builder.AddDoubleProperty("i", [this] { return GetI(); }, - [this](double value) { SetI(value); }); - builder.AddDoubleProperty("d", [this] { return GetD(); }, - [this](double value) { SetD(value); }); + builder.AddDoubleProperty( + "p", [this] { return GetP(); }, [this](double value) { SetP(value); }); + builder.AddDoubleProperty( + "i", [this] { return GetI(); }, [this](double value) { SetI(value); }); + builder.AddDoubleProperty( + "d", [this] { return GetD(); }, [this](double value) { SetD(value); }); builder.AddDoubleProperty( "goal", [this] { return GetGoal().position.template to(); }, [this](double value) { SetGoal(Distance_t{value}); }); diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc index 40442a18d5..26cf4a9151 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc +++ b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc @@ -13,7 +13,7 @@ namespace frc { template SwerveDriveKinematics(Translation2d, Wheels...) - ->SwerveDriveKinematics<1 + sizeof...(Wheels)>; + -> SwerveDriveKinematics<1 + sizeof...(Wheels)>; template std::array diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc index 295d263015..57e28285fa 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -76,20 +76,21 @@ template void SendableChooser::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("String Chooser"); builder.GetEntry(kInstance).SetDouble(m_instance); - builder.AddStringArrayProperty(kOptions, - [=]() { - std::vector keys; - for (const auto& choice : m_choices) { - keys.push_back(choice.first()); - } + builder.AddStringArrayProperty( + kOptions, + [=]() { + std::vector keys; + for (const auto& choice : m_choices) { + keys.push_back(choice.first()); + } - // Unlike std::map, wpi::StringMap elements - // are not sorted - std::sort(keys.begin(), keys.end()); + // Unlike std::map, wpi::StringMap elements + // are not sorted + std::sort(keys.begin(), keys.end()); - return keys; - }, - nullptr); + return keys; + }, + nullptr); builder.AddSmallStringProperty( kDefault, [=](wpi::SmallVectorImpl&) -> wpi::StringRef { diff --git a/wpilibcExamples/src/main/cpp/commands/pidcommand/ReplaceMePIDCommand.cpp b/wpilibcExamples/src/main/cpp/commands/pidcommand/ReplaceMePIDCommand.cpp index b465b1eea0..fe8faedb05 100644 --- a/wpilibcExamples/src/main/cpp/commands/pidcommand/ReplaceMePIDCommand.cpp +++ b/wpilibcExamples/src/main/cpp/commands/pidcommand/ReplaceMePIDCommand.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -11,15 +11,16 @@ // For more information, see: // https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html ReplaceMePIDCommand::ReplaceMePIDCommand() - : CommandHelper(frc2::PIDController(0, 0, 0), - // This should return the measurement - [] { return 0; }, - // This should return the setpoint (can also be a constant) - [] { return 0; }, - // This uses the output - [](double output) { - // Use the output here - }) {} + : CommandHelper( + frc2::PIDController(0, 0, 0), + // This should return the measurement + [] { return 0; }, + // This should return the setpoint (can also be a constant) + [] { return 0; }, + // This uses the output + [](double output) { + // Use the output here + }) {} // Returns true when the command should end. bool ReplaceMePIDCommand::IsFinished() { return false; } diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/commands/TurnToAngle.cpp b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/commands/TurnToAngle.cpp index 988535cb7e..0be1f73f8c 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/commands/TurnToAngle.cpp +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/commands/TurnToAngle.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -12,15 +12,16 @@ using namespace DriveConstants; TurnToAngle::TurnToAngle(units::degree_t target, DriveSubsystem* drive) - : CommandHelper(frc2::PIDController(kTurnP, kTurnI, kTurnD), - // Close loop on heading - [drive] { return drive->GetHeading().to(); }, - // Set reference to target - target.to(), - // Pipe output to turn robot - [drive](double output) { drive->ArcadeDrive(0, output); }, - // Require the drive - {drive}) { + : CommandHelper( + frc2::PIDController(kTurnP, kTurnI, kTurnD), + // Close loop on heading + [drive] { return drive->GetHeading().to(); }, + // Set reference to target + target.to(), + // Pipe output to turn robot + [drive](double output) { drive->ArcadeDrive(0, output); }, + // Require the drive + {drive}) { // Set the controller to be continuous (because it is an angle controller) m_controller.EnableContinuousInput(-180, 180); // Set the controller tolerance - the delta tolerance ensures the robot is diff --git a/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp b/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp index de8bc2cbbe..ee5803f0c2 100644 --- a/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp +++ b/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -107,8 +107,7 @@ std::unique_ptr TCPConnector::connect_parallel( } ++result->count; result->cv.notify_all(); - }) - .detach(); + }).detach(); } // wait for a result, timeout, or all finished diff --git a/wpiutil/src/main/native/cpp/uv/GetNameInfo.cpp b/wpiutil/src/main/native/cpp/uv/GetNameInfo.cpp index 994aadc77c..6a4446fb6a 100644 --- a/wpiutil/src/main/native/cpp/uv/GetNameInfo.cpp +++ b/wpiutil/src/main/native/cpp/uv/GetNameInfo.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -19,17 +19,18 @@ GetNameInfoReq::GetNameInfoReq() { void GetNameInfo(Loop& loop, const std::shared_ptr& req, const sockaddr& addr, int flags) { - int err = uv_getnameinfo(loop.GetRaw(), req->GetRaw(), - [](uv_getnameinfo_t* req, int status, - const char* hostname, const char* service) { - auto& h = *static_cast(req->data); - if (status < 0) - h.ReportError(status); - else - h.resolved(hostname, service); - h.Release(); // this is always a one-shot - }, - &addr, flags); + int err = uv_getnameinfo( + loop.GetRaw(), req->GetRaw(), + [](uv_getnameinfo_t* req, int status, const char* hostname, + const char* service) { + auto& h = *static_cast(req->data); + if (status < 0) + h.ReportError(status); + else + h.resolved(hostname, service); + h.Release(); // this is always a one-shot + }, + &addr, flags); if (err < 0) loop.ReportError(err); else diff --git a/wpiutil/src/main/native/cpp/uv/Loop.cpp b/wpiutil/src/main/native/cpp/uv/Loop.cpp index 2602150ddc..a31ad0946e 100644 --- a/wpiutil/src/main/native/cpp/uv/Loop.cpp +++ b/wpiutil/src/main/native/cpp/uv/Loop.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -49,13 +49,14 @@ void Loop::Close() { } void Loop::Walk(std::function callback) { - uv_walk(m_loop, - [](uv_handle_t* handle, void* func) { - auto& h = *static_cast(handle->data); - auto& f = *static_cast*>(func); - f(h); - }, - &callback); + uv_walk( + m_loop, + [](uv_handle_t* handle, void* func) { + auto& h = *static_cast(handle->data); + auto& f = *static_cast*>(func); + f(h); + }, + &callback); } void Loop::Fork() { diff --git a/wpiutil/src/main/native/cpp/uv/Signal.cpp b/wpiutil/src/main/native/cpp/uv/Signal.cpp index 083b852110..4569ac235c 100644 --- a/wpiutil/src/main/native/cpp/uv/Signal.cpp +++ b/wpiutil/src/main/native/cpp/uv/Signal.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -24,12 +24,13 @@ std::shared_ptr Signal::Create(Loop& loop) { } void Signal::Start(int signum) { - Invoke(&uv_signal_start, GetRaw(), - [](uv_signal_t* handle, int signum) { - Signal& h = *static_cast(handle->data); - h.signal(signum); - }, - signum); + Invoke( + &uv_signal_start, GetRaw(), + [](uv_signal_t* handle, int signum) { + Signal& h = *static_cast(handle->data); + h.signal(signum); + }, + signum); } } // namespace uv diff --git a/wpiutil/src/main/native/cpp/uv/Timer.cpp b/wpiutil/src/main/native/cpp/uv/Timer.cpp index 749d9a8a54..0fdd3be29f 100644 --- a/wpiutil/src/main/native/cpp/uv/Timer.cpp +++ b/wpiutil/src/main/native/cpp/uv/Timer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -34,12 +34,13 @@ void Timer::SingleShot(Loop& loop, Time timeout, std::function func) { } void Timer::Start(Time timeout, Time repeat) { - Invoke(&uv_timer_start, GetRaw(), - [](uv_timer_t* handle) { - Timer& h = *static_cast(handle->data); - h.timeout(); - }, - timeout.count(), repeat.count()); + Invoke( + &uv_timer_start, GetRaw(), + [](uv_timer_t* handle) { + Timer& h = *static_cast(handle->data); + h.timeout(); + }, + timeout.count(), repeat.count()); } } // namespace uv diff --git a/wpiutil/src/main/native/cpp/uv/Work.cpp b/wpiutil/src/main/native/cpp/uv/Work.cpp index d71ef81de5..e5d7bb6e4d 100644 --- a/wpiutil/src/main/native/cpp/uv/Work.cpp +++ b/wpiutil/src/main/native/cpp/uv/Work.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -17,19 +17,20 @@ WorkReq::WorkReq() { } void QueueWork(Loop& loop, const std::shared_ptr& req) { - int err = uv_queue_work(loop.GetRaw(), req->GetRaw(), - [](uv_work_t* req) { - auto& h = *static_cast(req->data); - h.work(); - }, - [](uv_work_t* req, int status) { - auto& h = *static_cast(req->data); - if (status < 0) - h.ReportError(status); - else - h.afterWork(); - h.Release(); // this is always a one-shot - }); + int err = uv_queue_work( + loop.GetRaw(), req->GetRaw(), + [](uv_work_t* req) { + auto& h = *static_cast(req->data); + h.work(); + }, + [](uv_work_t* req, int status) { + auto& h = *static_cast(req->data); + if (status < 0) + h.ReportError(status); + else + h.afterWork(); + h.Release(); // this is always a one-shot + }); if (err < 0) loop.ReportError(err); else diff --git a/wpiutil/src/test/native/cpp/uv/UvGetAddrInfoTest.cpp b/wpiutil/src/test/native/cpp/uv/UvGetAddrInfoTest.cpp index 11ac426db4..20d27f1d32 100644 --- a/wpiutil/src/test/native/cpp/uv/UvGetAddrInfoTest.cpp +++ b/wpiutil/src/test/native/cpp/uv/UvGetAddrInfoTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -46,7 +46,8 @@ TEST(UvGetAddrInfo, BothNull) { fail_cb_called++; }); - GetAddrInfo(loop, [](const addrinfo&) { FAIL(); }, Twine::createNull()); + GetAddrInfo( + loop, [](const addrinfo&) { FAIL(); }, Twine::createNull()); loop->Run(); ASSERT_EQ(fail_cb_called, 1); } @@ -62,7 +63,8 @@ TEST(UvGetAddrInfo, FailedLookup) { }); // Use a FQDN by ending in a period - GetAddrInfo(loop, [](const addrinfo&) { FAIL(); }, "xyzzy.xyzzy.xyzzy."); + GetAddrInfo( + loop, [](const addrinfo&) { FAIL(); }, "xyzzy.xyzzy.xyzzy."); loop->Run(); ASSERT_EQ(fail_cb_called, 1); } @@ -73,7 +75,8 @@ TEST(UvGetAddrInfo, Basic) { auto loop = Loop::Create(); loop->error.connect([](Error) { FAIL(); }); - GetAddrInfo(loop, [&](const addrinfo&) { getaddrinfo_cbs++; }, "localhost"); + GetAddrInfo( + loop, [&](const addrinfo&) { getaddrinfo_cbs++; }, "localhost"); loop->Run(); @@ -90,12 +93,13 @@ TEST(UvGetAddrInfo, Concurrent) { for (int i = 0; i < CONCURRENT_COUNT; i++) { callback_counts[i] = 0; - GetAddrInfo(loop, - [i, &callback_counts, &getaddrinfo_cbs](const addrinfo&) { - callback_counts[i]++; - getaddrinfo_cbs++; - }, - "localhost"); + GetAddrInfo( + loop, + [i, &callback_counts, &getaddrinfo_cbs](const addrinfo&) { + callback_counts[i]++; + getaddrinfo_cbs++; + }, + "localhost"); } loop->Run(); diff --git a/wpiutil/src/test/native/cpp/uv/UvGetNameInfoTest.cpp b/wpiutil/src/test/native/cpp/uv/UvGetNameInfoTest.cpp index 16de32985a..76d22d95ff 100644 --- a/wpiutil/src/test/native/cpp/uv/UvGetNameInfoTest.cpp +++ b/wpiutil/src/test/native/cpp/uv/UvGetNameInfoTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -41,13 +41,14 @@ TEST(UvGetNameInfo, BasicIp4) { auto loop = Loop::Create(); loop->error.connect([](Error) { FAIL(); }); - GetNameInfo4(loop, - [&](const char* hostname, const char* service) { - ASSERT_NE(hostname, nullptr); - ASSERT_NE(service, nullptr); - getnameinfo_cbs++; - }, - "127.0.0.1", 80); + GetNameInfo4( + loop, + [&](const char* hostname, const char* service) { + ASSERT_NE(hostname, nullptr); + ASSERT_NE(service, nullptr); + getnameinfo_cbs++; + }, + "127.0.0.1", 80); loop->Run(); @@ -60,13 +61,14 @@ TEST(UvGetNameInfo, BasicIp6) { auto loop = Loop::Create(); loop->error.connect([](Error) { FAIL(); }); - GetNameInfo6(loop, - [&](const char* hostname, const char* service) { - ASSERT_NE(hostname, nullptr); - ASSERT_NE(service, nullptr); - getnameinfo_cbs++; - }, - "::1", 80); + GetNameInfo6( + loop, + [&](const char* hostname, const char* service) { + ASSERT_NE(hostname, nullptr); + ASSERT_NE(service, nullptr); + getnameinfo_cbs++; + }, + "::1", 80); loop->Run();