diff --git a/wpilibc/wpilibC++/include/Notifier.h b/wpilibc/wpilibC++/include/Notifier.h index 06e3c87c97..9bb108b97d 100644 --- a/wpilibc/wpilibC++/include/Notifier.h +++ b/wpilibc/wpilibC++/include/Notifier.h @@ -14,7 +14,7 @@ typedef void (*TimerEventHandler)(void *param); class Notifier : public ErrorBase { public: - Notifier(TimerEventHandler handler, void *param = NULL); + Notifier(TimerEventHandler handler, void *param = nullptr); virtual ~Notifier(); void StartSingle(double delay); void StartPeriodic(double period); diff --git a/wpilibc/wpilibC++/include/PIDController.h b/wpilibc/wpilibC++/include/PIDController.h index 19da382cbe..c60079a4c4 100644 --- a/wpilibc/wpilibC++/include/PIDController.h +++ b/wpilibc/wpilibC++/include/PIDController.h @@ -59,7 +59,7 @@ class PIDController : public LiveWindowSendable, virtual void Reset() override; - virtual void InitTable(ITable *table); + virtual void InitTable(ITable *table) override; private: float m_P; // factor for "proportional" control @@ -94,13 +94,13 @@ class PIDController : public LiveWindowSendable, PIDOutput *output, float period = 0.05); static void CallCalculate(void *controller); - virtual ITable *GetTable() const; - virtual std::string GetSmartDashboardType() const; + virtual ITable *GetTable() const override; + virtual std::string GetSmartDashboardType() const override; virtual void ValueChanged(ITable *source, const std::string &key, - EntryValue value, bool isNew); - virtual void UpdateTable(); - virtual void StartLiveWindowMode(); - virtual void StopLiveWindowMode(); + EntryValue value, bool isNew) override; + virtual void UpdateTable() override; + virtual void StartLiveWindowMode() override; + virtual void StopLiveWindowMode() override; protected: ITable *m_table; diff --git a/wpilibc/wpilibC++/include/Utility.h b/wpilibc/wpilibC++/include/Utility.h index 9b2f1d4f84..345b694c66 100644 --- a/wpilibc/wpilibC++/include/Utility.h +++ b/wpilibc/wpilibC++/include/Utility.h @@ -14,18 +14,18 @@ #include #define wpi_assert(condition) \ - wpi_assert_impl(condition, #condition, NULL, __FILE__, __LINE__, __FUNCTION__) + wpi_assert_impl(condition, #condition, nullptr, __FILE__, __LINE__, __FUNCTION__) #define wpi_assertWithMessage(condition, message) \ wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \ __FUNCTION__) #define wpi_assertEqual(a, b) \ - wpi_assertEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__) + wpi_assertEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__) #define wpi_assertEqualWithMessage(a, b, message) \ wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__) #define wpi_assertNotEqual(a, b) \ - wpi_assertNotEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__) + wpi_assertNotEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__) #define wpi_assertNotEqualWithMessage(a, b, message) \ wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \ __FUNCTION__) diff --git a/wpilibc/wpilibC++/include/WPIErrors.h b/wpilibc/wpilibC++/include/WPIErrors.h index 1a751b631f..25cb5fe7be 100644 --- a/wpilibc/wpilibC++/include/WPIErrors.h +++ b/wpilibc/wpilibC++/include/WPIErrors.h @@ -27,7 +27,7 @@ S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range"); S(NotAllocated, -2, "Attempting to free unallocated resource"); S(ResourceAlreadyAllocated, -3, "Attempted to reuse an allocated resource"); S(NoAvailableResources, -4, "No available resources to allocate"); -S(NullParameter, -5, "A pointer parameter to a method is NULL"); +S(NullParameter, -5, "A pointer parameter to a method is nullptr"); S(Timeout, -6, "A timeout has been exceeded"); S(CompassManufacturerError, -7, "Compass manufacturer doesn't match HiTechnic"); S(CompassTypeError, -8, diff --git a/wpilibc/wpilibC++/src/Buttons/Trigger.cpp b/wpilibc/wpilibC++/src/Buttons/Trigger.cpp index d605cc2a8a..97cbcc1454 100644 --- a/wpilibc/wpilibC++/src/Buttons/Trigger.cpp +++ b/wpilibc/wpilibC++/src/Buttons/Trigger.cpp @@ -13,12 +13,12 @@ #include "Buttons/ToggleButtonScheduler.h" #include "Buttons/CancelButtonScheduler.h" -Trigger::Trigger() { m_table = NULL; } +Trigger::Trigger() { m_table = nullptr; } bool Trigger::Grab() { if (Get()) return true; - else if (m_table != NULL) { + else if (m_table != nullptr) { // if (m_table->isConnected())//TODO is connected on button? return m_table->GetBoolean("pressed"); /*else @@ -28,29 +28,27 @@ bool Trigger::Grab() { } void Trigger::WhenActive(Command *command) { - PressedButtonScheduler *pbs = - new PressedButtonScheduler(Grab(), this, command); + auto pbs = new PressedButtonScheduler(Grab(), this, command); pbs->Start(); } void Trigger::WhileActive(Command *command) { - HeldButtonScheduler *hbs = new HeldButtonScheduler(Grab(), this, command); + auto hbs = new HeldButtonScheduler(Grab(), this, command); hbs->Start(); } void Trigger::WhenInactive(Command *command) { - ReleasedButtonScheduler *rbs = - new ReleasedButtonScheduler(Grab(), this, command); + auto rbs = new ReleasedButtonScheduler(Grab(), this, command); rbs->Start(); } void Trigger::CancelWhenActive(Command *command) { - CancelButtonScheduler *cbs = new CancelButtonScheduler(Grab(), this, command); + auto cbs = new CancelButtonScheduler(Grab(), this, command); cbs->Start(); } void Trigger::ToggleWhenActive(Command *command) { - ToggleButtonScheduler *tbs = new ToggleButtonScheduler(Grab(), this, command); + auto tbs = new ToggleButtonScheduler(Grab(), this, command); tbs->Start(); } @@ -58,7 +56,7 @@ std::string Trigger::GetSmartDashboardType() const { return "Button"; } void Trigger::InitTable(ITable *table) { m_table = table; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("pressed", Get()); } } diff --git a/wpilibc/wpilibC++/src/Commands/Command.cpp b/wpilibc/wpilibC++/src/Commands/Command.cpp index d465681d07..d3ec758a72 100644 --- a/wpilibc/wpilibC++/src/Commands/Command.cpp +++ b/wpilibc/wpilibC++/src/Commands/Command.cpp @@ -29,23 +29,23 @@ void Command::InitCommand(const char *name, double timeout) { m_interruptible = true; m_canceled = false; m_runWhenDisabled = false; - m_parent = NULL; - m_name = name == NULL ? std::string() : name; - m_table = NULL; + m_parent = nullptr; + m_name = name == nullptr ? std::string() : name; + m_table = nullptr; } /** * Creates a new command. * The name of this command will be default. */ -Command::Command() { InitCommand(NULL, -1.0); } +Command::Command() { InitCommand(nullptr, -1.0); } /** * Creates a new command with the given name and no timeout. * @param name the name for this command */ Command::Command(const char *name) { - if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name"); + if (name == nullptr) wpi_setWPIErrorWithContext(NullParameter, "name"); InitCommand(name, -1.0); } @@ -57,7 +57,7 @@ Command::Command(const char *name) { Command::Command(double timeout) { if (timeout < 0.0) wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0"); - InitCommand(NULL, timeout); + InitCommand(nullptr, timeout); } /** @@ -67,14 +67,14 @@ Command::Command(double timeout) { * @see Command#isTimedOut() isTimedOut() */ Command::Command(const char *name, double timeout) { - if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name"); + if (name == nullptr) wpi_setWPIErrorWithContext(NullParameter, "name"); if (timeout < 0.0) wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0"); InitCommand(name, timeout); } Command::~Command() { // TODO deal with cleaning up all listeners - /*if (m_table != NULL){ + /*if (m_table != nullptr){ m_table->RemoveChangeListener(kRunning, this); }*/ } @@ -124,7 +124,7 @@ double Command::TimeSinceInitialized() const { void Command::Requires(Subsystem *subsystem) { if (!AssertUnlocked("Can not add new requirement to command")) return; - if (subsystem != NULL) + if (subsystem != nullptr) m_requirements.insert(subsystem); else wpi_setWPIErrorWithContext(NullParameter, "subsystem"); @@ -148,7 +148,7 @@ void Command::Removed() { m_initialized = false; m_canceled = false; m_running = false; - if (m_table != NULL) m_table->PutBoolean(kRunning, false); + if (m_table != nullptr) m_table->PutBoolean(kRunning, false); } /** @@ -160,7 +160,7 @@ void Command::Removed() { */ void Command::Start() { LockChanges(); - if (m_parent != NULL) + if (m_parent != nullptr) wpi_setWPIErrorWithContext( CommandIllegalUse, "Can not start a command that is part of a command group"); @@ -173,7 +173,7 @@ void Command::Start() { * @return whether or not the command should stay within the {@link Scheduler}. */ bool Command::Run() { - if (!m_runWhenDisabled && m_parent == NULL && RobotState::IsDisabled()) + if (!m_runWhenDisabled && m_parent == nullptr && RobotState::IsDisabled()) Cancel(); if (IsCanceled()) return false; @@ -255,16 +255,16 @@ bool Command::AssertUnlocked(const char *message) { * @param parent the parent */ void Command::SetParent(CommandGroup *parent) { - if (parent == NULL) { + if (parent == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "parent"); - } else if (m_parent != NULL) { + } else if (m_parent != nullptr) { wpi_setWPIErrorWithContext(CommandIllegalUse, "Can not give command to a command group after " "already being put in a command group"); } else { LockChanges(); m_parent = parent; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean(kIsParented, true); } } @@ -285,7 +285,7 @@ void Command::SetParent(CommandGroup *parent) { void Command::StartRunning() { m_running = true; m_startTime = -1; - if (m_table != NULL) m_table->PutBoolean(kRunning, true); + if (m_table != nullptr) m_table->PutBoolean(kRunning, true); } /** @@ -308,7 +308,7 @@ bool Command::IsRunning() const { return m_running; } * instead.

*/ void Command::Cancel() { - if (m_parent != NULL) + if (m_parent != nullptr) wpi_setWPIErrorWithContext( CommandIllegalUse, "Can not cancel a command that is part of a command group"); @@ -348,7 +348,7 @@ void Command::SetInterruptible(bool interruptible) { /** * Checks if the command requires the given {@link Subsystem}. * @param system the system - * @return whether or not the subsystem is required (false if given NULL) + * @return whether or not the subsystem is required (false if given nullptr) */ bool Command::DoesRequire(Subsystem *system) const { return m_requirements.count(system) > 0; @@ -390,12 +390,12 @@ std::string Command::GetName() { std::string Command::GetSmartDashboardType() const { return "Command"; } void Command::InitTable(ITable *table) { - if (m_table != NULL) m_table->RemoveTableListener(this); + if (m_table != nullptr) m_table->RemoveTableListener(this); m_table = table; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutString(kName, GetName()); m_table->PutBoolean(kRunning, IsRunning()); - m_table->PutBoolean(kIsParented, m_parent != NULL); + m_table->PutBoolean(kIsParented, m_parent != nullptr); m_table->AddTableListener(kRunning, this, false); } } diff --git a/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp b/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp index d1058feb63..562c9d7dd8 100644 --- a/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp +++ b/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp @@ -39,7 +39,7 @@ CommandGroup::~CommandGroup() {} * @param command The {@link Command Command} to be added */ void CommandGroup::AddSequential(Command *command) { - if (command == NULL) { + if (command == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "command"); return; } @@ -52,7 +52,7 @@ void CommandGroup::AddSequential(Command *command) { // Iterate through command->GetRequirements() and call Requires() on each // required subsystem Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) Requires(*iter); } @@ -79,7 +79,7 @@ void CommandGroup::AddSequential(Command *command) { * @param timeout The timeout (in seconds) */ void CommandGroup::AddSequential(Command *command, double timeout) { - if (command == NULL) { + if (command == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "command"); return; } @@ -96,7 +96,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) { // Iterate through command->GetRequirements() and call Requires() on each // required subsystem Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) Requires(*iter); } @@ -126,7 +126,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) { * @param command The command to be added */ void CommandGroup::AddParallel(Command *command) { - if (command == NULL) { + if (command == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "command"); return; } @@ -139,7 +139,7 @@ void CommandGroup::AddParallel(Command *command) { // Iterate through command->GetRequirements() and call Requires() on each // required subsystem Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) Requires(*iter); } @@ -177,7 +177,7 @@ void CommandGroup::AddParallel(Command *command) { * @param timeout The timeout (in seconds) */ void CommandGroup::AddParallel(Command *command, double timeout) { - if (command == NULL) { + if (command == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "command"); return; } @@ -194,7 +194,7 @@ void CommandGroup::AddParallel(Command *command, double timeout) { // Iterate through command->GetRequirements() and call Requires() on each // required subsystem Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) Requires(*iter); } @@ -202,7 +202,7 @@ void CommandGroup::_Initialize() { m_currentCommandIndex = -1; } void CommandGroup::_Execute() { CommandGroupEntry entry; - Command *cmd = NULL; + Command *cmd = nullptr; bool firstRun = false; if (m_currentCommandIndex == -1) { @@ -211,7 +211,7 @@ void CommandGroup::_Execute() { } while ((unsigned)m_currentCommandIndex < m_commands.size()) { - if (cmd != NULL) { + if (cmd != nullptr) { if (entry.IsTimedOut()) cmd->_Cancel(); if (cmd->Run()) { @@ -220,13 +220,13 @@ void CommandGroup::_Execute() { cmd->Removed(); m_currentCommandIndex++; firstRun = true; - cmd = NULL; + cmd = nullptr; continue; } } entry = m_commands[m_currentCommandIndex]; - cmd = NULL; + cmd = nullptr; switch (entry.m_state) { case CommandGroupEntry::kSequence_InSequence: @@ -253,7 +253,7 @@ void CommandGroup::_Execute() { } // Run Children - CommandList::iterator iter = m_children.begin(); + auto iter = m_children.begin(); for (; iter != m_children.end();) { entry = *iter; Command *child = entry.m_command; @@ -278,7 +278,7 @@ void CommandGroup::_End() { cmd->Removed(); } - CommandList::iterator iter = m_children.begin(); + auto iter = m_children.begin(); for (; iter != m_children.end(); iter++) { Command *cmd = iter->m_command; cmd->_Cancel(); @@ -315,7 +315,7 @@ bool CommandGroup::IsInterruptible() const { if (!cmd->IsInterruptible()) return false; } - CommandList::const_iterator iter = m_children.cbegin(); + auto iter = m_children.cbegin(); for (; iter != m_children.cend(); iter++) { if (!iter->m_command->IsInterruptible()) return false; } @@ -324,13 +324,13 @@ bool CommandGroup::IsInterruptible() const { } void CommandGroup::CancelConflicts(Command *command) { - CommandList::iterator childIter = m_children.begin(); + auto childIter = m_children.begin(); for (; childIter != m_children.end();) { Command *child = childIter->m_command; bool erased = false; Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator requirementIter = requirements.begin(); + auto requirementIter = requirements.begin(); for (; requirementIter != requirements.end(); requirementIter++) { if (child->DoesRequire(*requirementIter)) { child->_Cancel(); diff --git a/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp b/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp index 10a36dbc3a..7fcaf22d34 100644 --- a/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp +++ b/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp @@ -10,7 +10,7 @@ #include "Commands/Command.h" CommandGroupEntry::CommandGroupEntry() - : m_timeout(-1.0), m_command(NULL), m_state(kSequence_InSequence) {} + : m_timeout(-1.0), m_command(nullptr), m_state(kSequence_InSequence) {} CommandGroupEntry::CommandGroupEntry(Command *command, Sequence state) : m_timeout(-1.0), m_command(command), m_state(state) {} diff --git a/wpilibc/wpilibC++/src/Commands/Scheduler.cpp b/wpilibc/wpilibC++/src/Commands/Scheduler.cpp index eb030eaae7..1515606b3c 100644 --- a/wpilibc/wpilibC++/src/Commands/Scheduler.cpp +++ b/wpilibc/wpilibC++/src/Commands/Scheduler.cpp @@ -16,21 +16,21 @@ #include #include -Scheduler *Scheduler::_instance = NULL; +Scheduler *Scheduler::_instance = nullptr; Scheduler::Scheduler() - : m_buttonsLock(NULL), m_additionsLock(NULL), m_adding(false) { + : m_buttonsLock(nullptr), m_additionsLock(nullptr), m_adding(false) { m_buttonsLock = initializeMutexNormal(); m_additionsLock = initializeMutexNormal(); HLUsageReporting::ReportScheduler(); - m_table = NULL; + m_table = nullptr; m_enabled = true; m_runningCommandsChanged = false; - toCancel = NULL; - commands = NULL; - ids = NULL; + toCancel = nullptr; + commands = nullptr; + ids = nullptr; } Scheduler::~Scheduler() { @@ -46,7 +46,7 @@ Scheduler::~Scheduler() { * @return the {@link Scheduler} */ Scheduler *Scheduler::GetInstance() { - if (_instance == NULL) _instance = new Scheduler(); + if (_instance == nullptr) _instance = new Scheduler(); return _instance; } @@ -73,7 +73,7 @@ void Scheduler::AddButton(ButtonScheduler *button) { } void Scheduler::ProcessCommandAddition(Command *command) { - if (command == NULL) return; + if (command == nullptr) return; // Check to make sure no adding during adding if (m_adding) { @@ -83,14 +83,14 @@ void Scheduler::ProcessCommandAddition(Command *command) { } // Only add if not already in - CommandSet::iterator found = m_commands.find(command); + auto found = m_commands.find(command); if (found == m_commands.end()) { // Check that the requirements can be had Command::SubsystemSet requirements = command->GetRequirements(); Command::SubsystemSet::iterator iter; for (iter = requirements.begin(); iter != requirements.end(); iter++) { Subsystem *lock = *iter; - if (lock->GetCurrentCommand() != NULL && + if (lock->GetCurrentCommand() != nullptr && !lock->GetCurrentCommand()->IsInterruptible()) return; } @@ -99,7 +99,7 @@ void Scheduler::ProcessCommandAddition(Command *command) { m_adding = true; for (iter = requirements.begin(); iter != requirements.end(); iter++) { Subsystem *lock = *iter; - if (lock->GetCurrentCommand() != NULL) { + if (lock->GetCurrentCommand() != nullptr) { lock->GetCurrentCommand()->Cancel(); Remove(lock->GetCurrentCommand()); } @@ -133,7 +133,7 @@ void Scheduler::Run() { if (!m_enabled) return; Synchronized sync(m_buttonsLock); - ButtonVector::reverse_iterator rButtonIter = m_buttons.rbegin(); + auto rButtonIter = m_buttons.rbegin(); for (; rButtonIter != m_buttons.rend(); rButtonIter++) { (*rButtonIter)->Execute(); } @@ -142,7 +142,7 @@ void Scheduler::Run() { m_runningCommandsChanged = false; // Loop through the commands - CommandSet::iterator commandIter = m_commands.begin(); + auto commandIter = m_commands.begin(); for (; commandIter != m_commands.end();) { Command *command = *commandIter; // Increment before potentially removing to keep the iterator valid @@ -156,7 +156,7 @@ void Scheduler::Run() { // Add the new things { Synchronized sync(m_additionsLock); - CommandVector::iterator additionsIter = m_additions.begin(); + auto additionsIter = m_additions.begin(); for (; additionsIter != m_additions.end(); additionsIter++) { ProcessCommandAddition(*additionsIter); } @@ -164,10 +164,10 @@ void Scheduler::Run() { } // Add in the defaults - Command::SubsystemSet::iterator subsystemIter = m_subsystems.begin(); + auto subsystemIter = m_subsystems.begin(); for (; subsystemIter != m_subsystems.end(); subsystemIter++) { Subsystem *lock = *subsystemIter; - if (lock->GetCurrentCommand() == NULL) { + if (lock->GetCurrentCommand() == nullptr) { ProcessCommandAddition(lock->GetDefaultCommand()); } lock->ConfirmCommand(); @@ -184,7 +184,7 @@ void Scheduler::Run() { * @param system the system */ void Scheduler::RegisterSubsystem(Subsystem *subsystem) { - if (subsystem == NULL) { + if (subsystem == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "subsystem"); return; } @@ -196,7 +196,7 @@ void Scheduler::RegisterSubsystem(Subsystem *subsystem) { * @param command the command to remove */ void Scheduler::Remove(Command *command) { - if (command == NULL) { + if (command == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "command"); return; } @@ -204,10 +204,10 @@ void Scheduler::Remove(Command *command) { if (!m_commands.erase(command)) return; Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) { Subsystem *lock = *iter; - lock->SetCurrentCommand(NULL); + lock->SetCurrentCommand(nullptr); } command->Removed(); @@ -228,7 +228,7 @@ void Scheduler::ResetAll() { m_buttons.clear(); m_additions.clear(); m_commands.clear(); - m_table = NULL; + m_table = nullptr; } /** @@ -237,7 +237,7 @@ void Scheduler::ResetAll() { */ void Scheduler::UpdateTable() { CommandSet::iterator commandIter; - if (m_table != NULL) { + if (m_table != nullptr) { // Get the list of possible commands to cancel m_table->RetrieveValue("Cancel", *toCancel); // m_table->RetrieveValue("Ids", *ids); diff --git a/wpilibc/wpilibC++/src/Commands/Subsystem.cpp b/wpilibc/wpilibC++/src/Commands/Subsystem.cpp index 45ced0bdf6..b039be0e21 100644 --- a/wpilibc/wpilibC++/src/Commands/Subsystem.cpp +++ b/wpilibc/wpilibC++/src/Commands/Subsystem.cpp @@ -16,12 +16,12 @@ * @param name the name of the subsystem */ Subsystem::Subsystem(const char *name) - : m_currentCommand(NULL), - m_defaultCommand(NULL), + : m_currentCommand(nullptr), + m_defaultCommand(nullptr), m_initializedDefaultCommand(false) { m_name = name; Scheduler::GetInstance()->RegisterSubsystem(this); - m_table = NULL; + m_table = nullptr; m_currentCommandChanged = true; } /** @@ -47,12 +47,12 @@ void Subsystem::InitDefaultCommand() {} * @param command the default command (or null if there should be none) */ void Subsystem::SetDefaultCommand(Command *command) { - if (command == NULL) { - m_defaultCommand = NULL; + if (command == nullptr) { + m_defaultCommand = nullptr; } else { bool found = false; Command::SubsystemSet requirements = command->GetRequirements(); - Command::SubsystemSet::iterator iter = requirements.begin(); + auto iter = requirements.begin(); for (; iter != requirements.end(); iter++) { if (*iter == this) { found = true; @@ -68,8 +68,8 @@ void Subsystem::SetDefaultCommand(Command *command) { m_defaultCommand = command; } - if (m_table != NULL) { - if (m_defaultCommand != NULL) { + if (m_table != nullptr) { + if (m_defaultCommand != nullptr) { m_table->PutBoolean("hasDefault", true); m_table->PutString("default", m_defaultCommand->GetName()); } else { @@ -115,8 +115,8 @@ Command *Subsystem::GetCurrentCommand() const { return m_currentCommand; } */ void Subsystem::ConfirmCommand() { if (m_currentCommandChanged) { - if (m_table != NULL) { - if (m_currentCommand != NULL) { + if (m_table != nullptr) { + if (m_currentCommand != nullptr) { m_table->PutBoolean("hasCommand", true); m_table->PutString("command", m_currentCommand->GetName()); } else { @@ -133,14 +133,14 @@ std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; } void Subsystem::InitTable(ITable *table) { m_table = table; - if (m_table != NULL) { - if (m_defaultCommand != NULL) { + if (m_table != nullptr) { + if (m_defaultCommand != nullptr) { m_table->PutBoolean("hasDefault", true); m_table->PutString("default", m_defaultCommand->GetName()); } else { m_table->PutBoolean("hasDefault", false); } - if (m_currentCommand != NULL) { + if (m_currentCommand != nullptr) { m_table->PutBoolean("hasCommand", true); m_table->PutString("command", m_currentCommand->GetName()); } else { diff --git a/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp b/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp index 527f11ed2d..2ec602fa01 100644 --- a/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp +++ b/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp @@ -23,5 +23,5 @@ void WaitForChildren::End() {} void WaitForChildren::Interrupted() {} bool WaitForChildren::IsFinished() { - return GetGroup() == NULL || GetGroup()->GetSize() == 0; + return GetGroup() == nullptr || GetGroup()->GetSize() == 0; } diff --git a/wpilibc/wpilibC++/src/Error.cpp b/wpilibc/wpilibC++/src/Error.cpp index fd11ba5ae4..a24e5a5f72 100644 --- a/wpilibc/wpilibC++/src/Error.cpp +++ b/wpilibc/wpilibC++/src/Error.cpp @@ -20,7 +20,7 @@ bool Error::m_suspendOnErrorEnabled = false; Error::Error() - : m_code(0), m_lineNumber(0), m_originatingObject(NULL), m_timestamp(0.0) {} + : m_code(0), m_lineNumber(0), m_originatingObject(nullptr), m_timestamp(0.0) {} Error::~Error() {} @@ -71,7 +71,7 @@ void Error::Set(Code code, const char* contextMessage, const char* filename, Report(); } - if (m_suspendOnErrorEnabled) suspendTask(0); + if (m_suspendOnErrorEnabled) suspendTask(nullptr); } void Error::Report() { @@ -93,6 +93,6 @@ void Error::Clear() { m_filename = ""; m_function = ""; m_lineNumber = 0; - m_originatingObject = NULL; + m_originatingObject = nullptr; m_timestamp = 0.0; } diff --git a/wpilibc/wpilibC++/src/ErrorBase.cpp b/wpilibc/wpilibC++/src/ErrorBase.cpp index 363ae9d94c..d0c06d4e69 100644 --- a/wpilibc/wpilibC++/src/ErrorBase.cpp +++ b/wpilibc/wpilibC++/src/ErrorBase.cpp @@ -165,7 +165,7 @@ void ErrorBase::SetGlobalError(Error::Code code, const char* contextMessage, // Set the current error information for this object. _globalError.Set(code, contextMessage, filename, function, lineNumber, - NULL); + nullptr); } } @@ -180,7 +180,7 @@ void ErrorBase::SetGlobalWPIError(const char* errorMessage, if (_globalError.GetCode() != 0) { _globalError.Clear(); } - _globalError.Set(-1, err, filename, function, lineNumber, NULL); + _globalError.Set(-1, err, filename, function, lineNumber, nullptr); } /** diff --git a/wpilibc/wpilibC++/src/HLUsageReporting.cpp b/wpilibc/wpilibC++/src/HLUsageReporting.cpp index 94cd7088f2..bcbc6b6a34 100644 --- a/wpilibc/wpilibC++/src/HLUsageReporting.cpp +++ b/wpilibc/wpilibC++/src/HLUsageReporting.cpp @@ -1,20 +1,20 @@ #include "HLUsageReporting.h" -HLUsageReportingInterface* HLUsageReporting::impl = 0; +HLUsageReportingInterface* HLUsageReporting::impl = nullptr; void HLUsageReporting::SetImplementation(HLUsageReportingInterface* i) { impl = i; } void HLUsageReporting::ReportScheduler() { - if (impl != 0) { + if (impl != nullptr) { impl->ReportScheduler(); } } void HLUsageReporting::ReportSmartDashboard() { - if (impl != 0) { + if (impl != nullptr) { impl->ReportSmartDashboard(); } } diff --git a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp index 7243c182a4..61b3cee8f7 100644 --- a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp +++ b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp @@ -39,16 +39,12 @@ void LiveWindow::SetEnabled(bool enabled) { } m_scheduler->SetEnabled(false); m_scheduler->RemoveAll(); - for (std::map::iterator it = - m_components.begin(); - it != m_components.end(); ++it) { - it->first->StartLiveWindowMode(); + for (auto& elem : m_components) { + elem.first->StartLiveWindowMode(); } } else { - for (std::map::iterator it = - m_components.begin(); - it != m_components.end(); ++it) { - it->first->StopLiveWindowMode(); + for (auto& elem : m_components) { + elem.first->StopLiveWindowMode(); } m_scheduler->SetEnabled(true); } @@ -94,7 +90,7 @@ void LiveWindow::AddSensor(std::string type, int channel, std::ostringstream oss; oss << type << "[" << channel << "]"; std::string types(oss.str()); - char *cc = new char[types.size() + 1]; + auto cc = new char[types.size() + 1]; types.copy(cc, types.size()); cc[types.size()] = '\0'; AddSensor("Ungrouped", cc, component); @@ -111,7 +107,7 @@ void LiveWindow::AddActuator(std::string type, int channel, std::ostringstream oss; oss << type << "[" << channel << "]"; std::string types(oss.str()); - char *cc = new char[types.size() + 1]; + auto cc = new char[types.size() + 1]; types.copy(cc, types.size()); cc[types.size()] = '\0'; AddActuator("Ungrouped", cc, component); @@ -125,7 +121,7 @@ void LiveWindow::AddActuator(std::string type, int module, int channel, std::ostringstream oss; oss << type << "[" << module << "," << channel << "]"; std::string types(oss.str()); - char *cc = new char[types.size() + 1]; + auto cc = new char[types.size() + 1]; types.copy(cc, types.size()); cc[types.size()] = '\0'; AddActuator("Ungrouped", cc, component); @@ -137,8 +133,8 @@ void LiveWindow::AddActuator(std::string type, int module, int channel, * SmartDashboard widgets. */ void LiveWindow::UpdateValues() { - for (unsigned int i = 0; i < m_sensors.size(); i++) { - m_sensors[i]->UpdateTable(); + for (auto& elem : m_sensors) { + elem->UpdateTable(); } } @@ -164,11 +160,9 @@ void LiveWindow::Run() { * addActuator and addSensor. */ void LiveWindow::InitializeLiveWindowComponents() { - for (std::map::iterator it = - m_components.begin(); - it != m_components.end(); ++it) { - LiveWindowSendable *component = it->first; - LiveWindowComponent c = it->second; + for (auto& elem : m_components) { + LiveWindowSendable *component = elem.first; + LiveWindowComponent c = elem.second; std::string subsystem = c.subsystem; std::string name = c.name; m_liveWindowTable->GetSubTable(subsystem) diff --git a/wpilibc/wpilibC++/src/Resource.cpp b/wpilibc/wpilibC++/src/Resource.cpp index 6246f08ad6..492e809a31 100644 --- a/wpilibc/wpilibC++/src/Resource.cpp +++ b/wpilibc/wpilibC++/src/Resource.cpp @@ -30,8 +30,8 @@ Resource::Resource(uint32_t elements) { /** * Factory method to create a Resource allocation-tracker *if* needed. * - * @param r -- address of the caller's Resource pointer. If *r == NULL, this - * will construct a Resource and make *r point to it. If *r != NULL, i.e. + * @param r -- address of the caller's Resource pointer. If *r == nullptr, this + * will construct a Resource and make *r point to it. If *r != nullptr, i.e. * the caller already has a Resource instance, this won't do anything. * @param elements -- the number of elements for this Resource allocator to * track, that is, it will allocate resource numbers in the range @@ -40,7 +40,7 @@ Resource::Resource(uint32_t elements) { /*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements) { Synchronized sync(m_createLock); - if (*r == NULL) { + if (*r == nullptr) { *r = new Resource(elements); } } diff --git a/wpilibc/wpilibC++/src/RobotState.cpp b/wpilibc/wpilibC++/src/RobotState.cpp index 0e368dfa7d..076c9c8e21 100644 --- a/wpilibc/wpilibC++/src/RobotState.cpp +++ b/wpilibc/wpilibC++/src/RobotState.cpp @@ -1,6 +1,6 @@ #include "RobotState.h" -RobotStateInterface* RobotState::impl = 0; +RobotStateInterface* RobotState::impl = nullptr; void RobotState::SetImplementation(RobotStateInterface* i) { impl = i; } diff --git a/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp b/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp index bad9d14fd2..56daed6992 100644 --- a/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp +++ b/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp @@ -44,13 +44,13 @@ void SendableChooser::AddDefault(const char *name, void *object) { /** * Returns the selected option. If there is none selected, it will return the * default. If there is none selected - * and no default, then it will return {@code NULL}. + * and no default, then it will return {@code nullptr}. * @return the option selected */ void *SendableChooser::GetSelected() { std::string selected = m_table->GetString(kSelected, m_defaultChoice); if (selected == "") - return NULL; + return nullptr; else return m_choices[selected]; } @@ -58,7 +58,7 @@ void *SendableChooser::GetSelected() { void SendableChooser::InitTable(ITable *subtable) { StringArray keys; m_table = subtable; - if (m_table != NULL) { + if (m_table != nullptr) { std::map::iterator iter; for (iter = m_choices.begin(); iter != m_choices.end(); iter++) { keys.add(iter->first); diff --git a/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp b/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp index 15321352b4..5724a97578 100644 --- a/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp +++ b/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp @@ -13,7 +13,7 @@ #include "networktables/NetworkTable.h" #include "HLUsageReporting.h" -ITable *SmartDashboard::m_table = NULL; +ITable *SmartDashboard::m_table = nullptr; std::map SmartDashboard::m_tablesToData; void SmartDashboard::init() { @@ -24,14 +24,14 @@ void SmartDashboard::init() { /** * Maps the specified key to the specified value in this table. - * The key can not be NULL. + * The key can not be nullptr. * The value can be retrieved by calling the get method with a key that is equal * to the original key. * @param keyName the key * @param value the value */ void SmartDashboard::PutData(std::string key, Sendable *data) { - if (data == NULL) { + if (data == nullptr) { wpi_setGlobalWPIErrorWithContext(NullParameter, "value"); return; } @@ -50,7 +50,7 @@ void SmartDashboard::PutData(std::string key, Sendable *data) { * @param value the value */ void SmartDashboard::PutData(NamedSendable *value) { - if (value == NULL) { + if (value == nullptr) { wpi_setGlobalWPIErrorWithContext(NullParameter, "value"); return; } @@ -65,9 +65,9 @@ void SmartDashboard::PutData(NamedSendable *value) { Sendable *SmartDashboard::GetData(std::string key) { ITable *subtable = m_table->GetSubTable(key); Sendable *data = m_tablesToData[subtable]; - if (data == NULL) { + if (data == nullptr) { wpi_setGlobalWPIErrorWithContext(SmartDashboardMissingKey, key.c_str()); - return NULL; + return nullptr; } return data; } @@ -75,7 +75,7 @@ Sendable *SmartDashboard::GetData(std::string key) { /** * Maps the specified key to the specified complex value (such as an array) in * this table. - * The key can not be NULL. + * The key can not be nullptr. * The value can be retrieved by calling the RetrieveValue method with a key * that is equal to the original key. * @param keyName the key @@ -88,7 +88,7 @@ void SmartDashboard::PutValue(std::string keyName, ComplexData &value) { /** * Retrieves the complex value (such as an array) in this table into the complex * data object - * The key can not be NULL. + * The key can not be nullptr. * @param keyName the key * @param value the object to retrieve the value into */ @@ -98,7 +98,7 @@ void SmartDashboard::RetrieveValue(std::string keyName, ComplexData &value) { /** * Maps the specified key to the specified value in this table. - * The key can not be NULL. + * The key can not be nullptr. * The value can be retrieved by calling the get method with a key that is equal * to the original key. * @param keyName the key @@ -130,7 +130,7 @@ bool SmartDashboard::GetBoolean(std::string keyName, bool defaultValue) { /** * Maps the specified key to the specified value in this table. - * The key can not be NULL. + * The key can not be nullptr. * The value can be retrieved by calling the get method with a key that is equal * to the original key. * @param keyName the key @@ -162,7 +162,7 @@ double SmartDashboard::GetNumber(std::string keyName, double defaultValue) { /** * Maps the specified key to the specified value in this table. - * Neither the key nor the value can be NULL. + * Neither the key nor the value can be nullptr. * The value can be retrieved by calling the get method with a key that is equal * to the original key. * @param keyName the key diff --git a/wpilibc/wpilibC++Devices/include/CANTalon.h b/wpilibc/wpilibC++Devices/include/CANTalon.h index b8f08af1cf..ab4f88fd6c 100644 --- a/wpilibc/wpilibC++Devices/include/CANTalon.h +++ b/wpilibc/wpilibC++Devices/include/CANTalon.h @@ -66,7 +66,7 @@ class CANTalon : public MotorSafety, virtual void SetSetpoint(float value) override; virtual void Disable() override; virtual void EnableControl(); - virtual void Enable(); + virtual void Enable() override; virtual void SetP(double p) override; virtual void SetI(double i) override; virtual void SetD(double d) override; diff --git a/wpilibc/wpilibC++Devices/include/Compressor.h b/wpilibc/wpilibC++Devices/include/Compressor.h index e13bd962c9..35571d20c2 100644 --- a/wpilibc/wpilibC++Devices/include/Compressor.h +++ b/wpilibc/wpilibC++Devices/include/Compressor.h @@ -49,7 +49,7 @@ class Compressor : public SensorBase, void InitTable(ITable *subTable) override; ITable *GetTable() const override; void ValueChanged(ITable *source, const std::string &key, EntryValue value, - bool isNew); + bool isNew) override; protected: void *m_pcm_pointer; diff --git a/wpilibc/wpilibC++Devices/include/Jaguar.h b/wpilibc/wpilibC++Devices/include/Jaguar.h index cf47e69034..228a0c1b71 100644 --- a/wpilibc/wpilibC++Devices/include/Jaguar.h +++ b/wpilibc/wpilibC++Devices/include/Jaguar.h @@ -17,9 +17,9 @@ class Jaguar : public SafePWM, public SpeedController { public: explicit Jaguar(uint32_t channel); virtual ~Jaguar(); - virtual void Set(float value, uint8_t syncGroup = 0); - virtual float Get() const; - virtual void Disable(); + virtual void Set(float value, uint8_t syncGroup = 0) override; + virtual float Get() const override; + virtual void Disable() override; virtual void PIDWrite(float output) override; virtual void SetInverted(bool isInverted) override; diff --git a/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h b/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h index 1dd6404456..8659dac3f7 100644 --- a/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h +++ b/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h @@ -31,7 +31,7 @@ class CANInterfacePlugin { * @param messageID The 29-bit CAN message ID in the lsbs. The msb can * indicate a remote frame. * @param data A pointer to a buffer containing between 0 and 8 bytes to send - * with the message. May be NULL if dataSize is 0. + * with the message. May be nullptr if dataSize is 0. * @param dataSize The number of bytes to send with the message. * @return Return any error code. On success return 0. */ @@ -101,7 +101,7 @@ class CANInterfacePlugin { * * @param interface A pointer to an object that inherits from CANInterfacePlugin * and implements - * the pure virtual interface. If NULL, unregister the current plugin. + * the pure virtual interface. If nullptr, unregister the current plugin. */ void FRC_NetworkCommunication_CANSessionMux_registerInterface( CANInterfacePlugin *interface); diff --git a/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h b/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h index ca73a2fbf2..693d0dc9c1 100644 --- a/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h +++ b/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h @@ -128,7 +128,7 @@ typedef enum { * change the feature string. */ uint32_t EXPORT_FUNC report(tResourceType resource, uint8_t instanceNumber, - uint8_t context = 0, const char *feature = NULL); + uint8_t context = 0, const char *feature = nullptr); } #ifdef __cplusplus diff --git a/wpilibc/wpilibC++Devices/include/Talon.h b/wpilibc/wpilibC++Devices/include/Talon.h index 6ff5c6ecdc..65371f058f 100644 --- a/wpilibc/wpilibC++Devices/include/Talon.h +++ b/wpilibc/wpilibC++Devices/include/Talon.h @@ -17,9 +17,9 @@ class Talon : public SafePWM, public SpeedController { public: explicit Talon(uint32_t channel); virtual ~Talon(); - virtual void Set(float value, uint8_t syncGroup = 0); - virtual float Get() const; - virtual void Disable(); + virtual void Set(float value, uint8_t syncGroup = 0) override; + virtual float Get() const override; + virtual void Disable() override; virtual void PIDWrite(float output) override; virtual void SetInverted(bool isInverted) override; diff --git a/wpilibc/wpilibC++Devices/include/Victor.h b/wpilibc/wpilibC++Devices/include/Victor.h index 1c59377624..b23023ab1d 100644 --- a/wpilibc/wpilibC++Devices/include/Victor.h +++ b/wpilibc/wpilibC++Devices/include/Victor.h @@ -20,9 +20,9 @@ class Victor : public SafePWM, public SpeedController { public: explicit Victor(uint32_t channel); virtual ~Victor(); - virtual void Set(float value, uint8_t syncGroup = 0); - virtual float Get() const; - virtual void Disable(); + virtual void Set(float value, uint8_t syncGroup = 0) override; + virtual float Get() const override; + virtual void Disable() override; virtual void PIDWrite(float output) override; diff --git a/wpilibc/wpilibC++Devices/include/VictorSP.h b/wpilibc/wpilibC++Devices/include/VictorSP.h index 3d5f52f08b..9c4f95b325 100644 --- a/wpilibc/wpilibC++Devices/include/VictorSP.h +++ b/wpilibc/wpilibC++Devices/include/VictorSP.h @@ -17,9 +17,9 @@ class VictorSP : public SafePWM, public SpeedController { public: explicit VictorSP(uint32_t channel); virtual ~VictorSP(); - virtual void Set(float value, uint8_t syncGroup = 0); - virtual float Get() const; - virtual void Disable(); + virtual void Set(float value, uint8_t syncGroup = 0) override; + virtual float Get() const override; + virtual void Disable() override; virtual void PIDWrite(float output) override; diff --git a/wpilibc/wpilibC++Devices/include/nivision.h b/wpilibc/wpilibC++Devices/include/nivision.h index 4289922e40..5c569622b2 100644 --- a/wpilibc/wpilibC++Devices/include/nivision.h +++ b/wpilibc/wpilibC++Devices/include/nivision.h @@ -54,9 +54,9 @@ //============================================================================ #ifndef NULL #ifdef __cplusplus -#define NULL 0 -#else #define NULL ((void*)0) +#else +#define NULL 0 #endif #endif diff --git a/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp b/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp index 4943c93fad..7d37fbfc1e 100644 --- a/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp +++ b/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp @@ -40,7 +40,7 @@ ADXL345_I2C::ADXL345_I2C(Port port, Range range) : I2C(port, kAddress) { */ ADXL345_I2C::~ADXL345_I2C() { // delete m_i2c; - // m_i2c = NULL; + // m_i2c = nullptr; } /** {@inheritdoc} */ @@ -102,7 +102,7 @@ void ADXL345_I2C::InitTable(ITable *subtable) { } void ADXL345_I2C::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("X", GetX()); m_table->PutNumber("Y", GetY()); m_table->PutNumber("Z", GetZ()); diff --git a/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp b/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp index 1f000b8d1b..7e430ced6b 100644 --- a/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp +++ b/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp @@ -56,7 +56,7 @@ void ADXL345_SPI::Init(Range range) { */ ADXL345_SPI::~ADXL345_SPI() { delete m_spi; - m_spi = NULL; + m_spi = nullptr; } /** {@inheritdoc} */ @@ -136,7 +136,7 @@ void ADXL345_SPI::InitTable(ITable* subtable) { } void ADXL345_SPI::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("X", GetX()); m_table->PutNumber("Y", GetY()); m_table->PutNumber("Z", GetZ()); diff --git a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp index 9e685b1045..62f7393561 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp @@ -14,7 +14,7 @@ * Common function for initializing the accelerometer. */ void AnalogAccelerometer::InitAccelerometer() { - m_table = NULL; + m_table = nullptr; m_voltsPerG = 1.0; m_zeroGVoltage = 2.5; HALReport(HALUsageReporting::kResourceType_Accelerometer, @@ -46,7 +46,7 @@ AnalogAccelerometer::AnalogAccelerometer(int32_t channel) { * accelerometer is connected to */ AnalogAccelerometer::AnalogAccelerometer(AnalogInput *channel) { - if (channel == NULL) { + if (channel == nullptr) { wpi_setWPIError(NullParameter); } else { m_AnalogInput = channel; @@ -107,7 +107,7 @@ void AnalogAccelerometer::SetZero(float zero) { m_zeroGVoltage = zero; } double AnalogAccelerometer::PIDGet() const { return GetAcceleration(); } void AnalogAccelerometer::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetAcceleration()); } } diff --git a/wpilibc/wpilibC++Devices/src/AnalogInput.cpp b/wpilibc/wpilibC++Devices/src/AnalogInput.cpp index 0ccb60d91b..d2b80d87fa 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogInput.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogInput.cpp @@ -11,7 +11,7 @@ #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" -static Resource *inputs = NULL; +static Resource *inputs = nullptr; const uint8_t AnalogInput::kAccumulatorModuleNumber; const uint32_t AnalogInput::kAccumulatorNumChannels; @@ -21,7 +21,7 @@ const uint32_t AnalogInput::kAccumulatorChannels[] = {0, 1}; * Common initialization. */ void AnalogInput::InitAnalogInput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; Resource::CreateResourceObject(&inputs, kAnalogInputs); @@ -405,7 +405,7 @@ double AnalogInput::PIDGet() const { } void AnalogInput::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetAverageVoltage()); } } diff --git a/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp b/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp index a468b1cb3c..9e5da29165 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp @@ -10,10 +10,10 @@ #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" -static Resource *outputs = NULL; +static Resource *outputs = nullptr; void AnalogOutput::InitAnalogOutput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; Resource::CreateResourceObject(&outputs, kAnalogOutputs); @@ -80,7 +80,7 @@ float AnalogOutput::GetVoltage() const { } void AnalogOutput::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetVoltage()); } } diff --git a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp index 05c9ce07d9..c529fa39a9 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp @@ -103,7 +103,7 @@ void AnalogPotentiometer::InitTable(ITable *subtable) { } void AnalogPotentiometer::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } diff --git a/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp b/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp index f5ffe64651..80be7fe862 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp @@ -156,6 +156,6 @@ bool AnalogTrigger::GetTriggerState() { * @return A pointer to a new AnalogTriggerOutput object. */ AnalogTriggerOutput *AnalogTrigger::CreateOutput(AnalogTriggerType type) { - if (StatusIsFatal()) return NULL; + if (StatusIsFatal()) return nullptr; return new AnalogTriggerOutput(this, type); } diff --git a/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp b/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp index 87f75c20bc..68348e54fc 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp @@ -30,11 +30,11 @@ AnalogTriggerOutput::AnalogTriggerOutput(AnalogTrigger *trigger, } AnalogTriggerOutput::~AnalogTriggerOutput() { - if (m_interrupt != NULL) { + if (m_interrupt != nullptr) { int32_t status = 0; cleanInterrupts(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_interrupt = NULL; + m_interrupt = nullptr; m_interrupts->Free(m_interruptIndex); } } diff --git a/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp b/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp index 4b2a7f5745..8a23749826 100644 --- a/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp +++ b/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp @@ -60,7 +60,7 @@ void BuiltInAccelerometer::InitTable(ITable* subtable) { } void BuiltInAccelerometer::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("X", GetX()); m_table->PutNumber("Y", GetY()); m_table->PutNumber("Z", GetZ()); diff --git a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp index 25782df8c8..b5450eaee6 100644 --- a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp +++ b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp @@ -32,7 +32,7 @@ static const uint32_t kFullMessageIDMask = static const int32_t kReceiveStatusAttempts = 50; -static Resource *allocated = NULL; +static Resource *allocated = nullptr; static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t period) { @@ -43,9 +43,8 @@ static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data, int32_t status = 0; - for (uint8_t i = 0; - i < (sizeof(kTrustedMessages) / sizeof(kTrustedMessages[0])); i++) { - if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) { + for (auto& kTrustedMessage : kTrustedMessages) { + if ((kFullMessageIDMask & messageID) == kTrustedMessage) { uint8_t dataBuffer[8]; dataBuffer[0] = 0; dataBuffer[1] = 0; @@ -74,7 +73,7 @@ static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data, * Common initialization code called by all constructors. */ void CANJaguar::InitCANJaguar() { - m_table = NULL; + m_table = nullptr; m_safetyHelper = new MotorSafetyHelper(this); m_value = 0.0f; @@ -231,7 +230,7 @@ void CANJaguar::InitCANJaguar() { CANJaguar::CANJaguar(uint8_t deviceNumber) : m_deviceNumber(deviceNumber), m_maxOutputVoltage(kApproxBusVoltage), - m_safetyHelper(NULL) { + m_safetyHelper(nullptr) { char buf[64]; snprintf(buf, 64, "CANJaguar device number %d", m_deviceNumber); Resource::CreateResourceObject(&allocated, 63); @@ -254,27 +253,27 @@ CANJaguar::~CANJaguar() { // Disable periodic setpoints if (m_controlMode == kPercentVbus) FRC_NetworkCommunication_CANSessionMux_sendMessage( - m_deviceNumber | LM_API_VOLT_T_SET, NULL, 0, + m_deviceNumber | LM_API_VOLT_T_SET, nullptr, 0, CAN_SEND_PERIOD_STOP_REPEATING, &status); else if (m_controlMode == kSpeed) FRC_NetworkCommunication_CANSessionMux_sendMessage( - m_deviceNumber | LM_API_SPD_T_SET, NULL, 0, + m_deviceNumber | LM_API_SPD_T_SET, nullptr, 0, CAN_SEND_PERIOD_STOP_REPEATING, &status); else if (m_controlMode == kPosition) FRC_NetworkCommunication_CANSessionMux_sendMessage( - m_deviceNumber | LM_API_POS_T_SET, NULL, 0, + m_deviceNumber | LM_API_POS_T_SET, nullptr, 0, CAN_SEND_PERIOD_STOP_REPEATING, &status); else if (m_controlMode == kCurrent) FRC_NetworkCommunication_CANSessionMux_sendMessage( - m_deviceNumber | LM_API_ICTRL_T_SET, NULL, 0, + m_deviceNumber | LM_API_ICTRL_T_SET, nullptr, 0, CAN_SEND_PERIOD_STOP_REPEATING, &status); else if (m_controlMode == kVoltage) FRC_NetworkCommunication_CANSessionMux_sendMessage( - m_deviceNumber | LM_API_VCOMP_T_SET, NULL, 0, + m_deviceNumber | LM_API_VCOMP_T_SET, nullptr, 0, CAN_SEND_PERIOD_STOP_REPEATING, &status); delete m_safetyHelper; - m_safetyHelper = NULL; + m_safetyHelper = nullptr; } /** @@ -478,7 +477,7 @@ void CANJaguar::sendMessage(uint32_t messageID, const uint8_t *data, * every "period" milliseconds. */ void CANJaguar::requestMessage(uint32_t messageID, int32_t period) { - sendMessageHelper(messageID | m_deviceNumber, NULL, 0, period); + sendMessageHelper(messageID | m_deviceNumber, nullptr, 0, period); } /** @@ -2000,19 +1999,19 @@ void CANJaguar::ValueChanged(ITable *source, const std::string &key, } void CANJaguar::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } void CANJaguar::StartLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void CANJaguar::StopLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/CANTalon.cpp b/wpilibc/wpilibC++Devices/src/CANTalon.cpp index 5e4860d754..cf69a7f307 100644 --- a/wpilibc/wpilibC++Devices/src/CANTalon.cpp +++ b/wpilibc/wpilibC++Devices/src/CANTalon.cpp @@ -1283,19 +1283,19 @@ void CANTalon::ValueChanged(ITable* source, const std::string& key, } void CANTalon::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } void CANTalon::StartLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void CANTalon::StopLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/CameraServer.cpp b/wpilibc/wpilibC++Devices/src/CameraServer.cpp index c639a2c004..8a541a08ba 100644 --- a/wpilibc/wpilibC++Devices/src/CameraServer.cpp +++ b/wpilibc/wpilibC++Devices/src/CameraServer.cpp @@ -13,7 +13,7 @@ constexpr uint8_t CameraServer::kMagicNumber[]; CameraServer* CameraServer::s_instance = nullptr; CameraServer* CameraServer::GetInstance() { - if (s_instance == NULL) { + if (s_instance == nullptr) { s_instance = new CameraServer; } return s_instance; @@ -225,7 +225,7 @@ void CameraServer::Serve() { std::unique_lock lock(m_imageMutex); m_newImageVariable.wait(lock); imageData = m_imageData; - m_imageData = std::make_tuple(nullptr, 0, 0, false); + m_imageData = std::make_tuple(nullptr, 0, 0, false); } unsigned int size = std::get<1>(imageData); diff --git a/wpilibc/wpilibC++Devices/src/Compressor.cpp b/wpilibc/wpilibC++Devices/src/Compressor.cpp index 79c6131f4c..cc965df569 100644 --- a/wpilibc/wpilibC++Devices/src/Compressor.cpp +++ b/wpilibc/wpilibC++Devices/src/Compressor.cpp @@ -6,7 +6,7 @@ #include "WPIErrors.h" void Compressor::InitCompressor(uint8_t pcmID) { - m_table = 0; + m_table = nullptr; m_pcm_pointer = initializeCompressor(pcmID); SetClosedLoopControl(true); diff --git a/wpilibc/wpilibC++Devices/src/Counter.cpp b/wpilibc/wpilibC++Devices/src/Counter.cpp index b36b2154f5..e92edcf39a 100644 --- a/wpilibc/wpilibC++Devices/src/Counter.cpp +++ b/wpilibc/wpilibC++Devices/src/Counter.cpp @@ -21,15 +21,15 @@ * @param mode The counter mode */ void Counter::InitCounter(Mode mode) { - m_table = NULL; + m_table = nullptr; int32_t status = 0; m_index = 0; m_counter = initializeCounter(mode, &m_index, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_upSource = NULL; - m_downSource = NULL; + m_upSource = nullptr; + m_downSource = nullptr; m_allocatedUpSource = false; m_allocatedDownSource = false; @@ -46,7 +46,7 @@ void Counter::InitCounter(Mode mode) { * * The counter will start counting immediately. */ -Counter::Counter() : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { +Counter::Counter() : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); } @@ -63,7 +63,7 @@ Counter::Counter() : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { * as the Up Source. */ Counter::Counter(DigitalSource *source) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); SetUpSource(source); ClearDownSource(); @@ -82,7 +82,7 @@ Counter::Counter(DigitalSource *source) * set as the Up Source. */ Counter::Counter(DigitalSource &source) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); SetUpSource(&source); ClearDownSource(); @@ -97,7 +97,7 @@ Counter::Counter(DigitalSource &source) * 10-25 are on the MXP */ Counter::Counter(int32_t channel) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); SetUpSource(channel); ClearDownSource(); @@ -112,7 +112,7 @@ Counter::Counter(int32_t channel) * @param trigger The pointer to the existing AnalogTrigger object. */ Counter::Counter(AnalogTrigger *trigger) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); SetUpSource(trigger->CreateOutput(kState)); ClearDownSource(); @@ -128,7 +128,7 @@ Counter::Counter(AnalogTrigger *trigger) * @param trigger The reference to the existing AnalogTrigger object. */ Counter::Counter(AnalogTrigger &trigger) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { InitCounter(); SetUpSource(trigger.CreateOutput(kState)); ClearDownSource(); @@ -146,7 +146,7 @@ Counter::Counter(AnalogTrigger &trigger) Counter::Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted) - : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) { + : m_upSource(nullptr), m_downSource(nullptr), m_counter(nullptr) { if (encodingType != k1X && encodingType != k2X) { wpi_setWPIErrorWithContext( ParameterOutOfRange, @@ -177,17 +177,17 @@ Counter::~Counter() { SetUpdateWhenEmpty(true); if (m_allocatedUpSource) { delete m_upSource; - m_upSource = NULL; + m_upSource = nullptr; } if (m_allocatedDownSource) { delete m_downSource; - m_downSource = NULL; + m_downSource = nullptr; } int32_t status = 0; freeCounter(m_counter, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_counter = NULL; + m_counter = nullptr; } /** @@ -232,7 +232,7 @@ void Counter::SetUpSource(DigitalSource *source) { if (StatusIsFatal()) return; if (m_allocatedUpSource) { delete m_upSource; - m_upSource = NULL; + m_upSource = nullptr; m_allocatedUpSource = false; } m_upSource = source; @@ -261,10 +261,10 @@ void Counter::SetUpSource(DigitalSource &source) { SetUpSource(&source); } */ void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) { if (StatusIsFatal()) return; - if (m_upSource == NULL) { + if (m_upSource == nullptr) { wpi_setWPIErrorWithContext( NullParameter, - "Must set non-NULL UpSource before setting UpSourceEdge"); + "Must set non-nullptr UpSource before setting UpSourceEdge"); } int32_t status = 0; setCounterUpSourceEdge(m_counter, risingEdge, fallingEdge, &status); @@ -278,7 +278,7 @@ void Counter::ClearUpSource() { if (StatusIsFatal()) return; if (m_allocatedUpSource) { delete m_upSource; - m_upSource = NULL; + m_upSource = nullptr; m_allocatedUpSource = false; } int32_t status = 0; @@ -330,7 +330,7 @@ void Counter::SetDownSource(DigitalSource *source) { if (StatusIsFatal()) return; if (m_allocatedDownSource) { delete m_downSource; - m_downSource = NULL; + m_downSource = nullptr; m_allocatedDownSource = false; } m_downSource = source; @@ -359,10 +359,10 @@ void Counter::SetDownSource(DigitalSource &source) { SetDownSource(&source); } */ void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge) { if (StatusIsFatal()) return; - if (m_downSource == NULL) { + if (m_downSource == nullptr) { wpi_setWPIErrorWithContext( NullParameter, - "Must set non-NULL DownSource before setting DownSourceEdge"); + "Must set non-nullptr DownSource before setting DownSourceEdge"); } int32_t status = 0; setCounterDownSourceEdge(m_counter, risingEdge, fallingEdge, &status); @@ -376,7 +376,7 @@ void Counter::ClearDownSource() { if (StatusIsFatal()) return; if (m_allocatedDownSource) { delete m_downSource; - m_downSource = NULL; + m_downSource = nullptr; m_allocatedDownSource = false; } int32_t status = 0; @@ -597,7 +597,7 @@ void Counter::SetReverseDirection(bool reverseDirection) { } void Counter::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } diff --git a/wpilibc/wpilibC++Devices/src/DigitalInput.cpp b/wpilibc/wpilibC++Devices/src/DigitalInput.cpp index afa39cac80..e4a2a61d8c 100644 --- a/wpilibc/wpilibC++Devices/src/DigitalInput.cpp +++ b/wpilibc/wpilibC++Devices/src/DigitalInput.cpp @@ -17,7 +17,7 @@ * constructors. */ void DigitalInput::InitDigitalInput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckDigitalChannel(channel)) { @@ -48,11 +48,11 @@ DigitalInput::DigitalInput(uint32_t channel) { InitDigitalInput(channel); } */ DigitalInput::~DigitalInput() { if (StatusIsFatal()) return; - if (m_interrupt != NULL) { + if (m_interrupt != nullptr) { int32_t status = 0; cleanInterrupts(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_interrupt = NULL; + m_interrupt = nullptr; m_interrupts->Free(m_interruptIndex); } @@ -93,7 +93,7 @@ uint32_t DigitalInput::GetModuleForRouting() const { return 0; } bool DigitalInput::GetAnalogTriggerForRouting() const { return false; } void DigitalInput::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("Value", Get()); } } diff --git a/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp b/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp index 1e597442e6..7594e3305b 100644 --- a/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp +++ b/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp @@ -15,7 +15,7 @@ * constructors. */ void DigitalOutput::InitDigitalOutput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckDigitalChannel(channel)) { @@ -210,13 +210,13 @@ void DigitalOutput::ValueChanged(ITable *source, const std::string &key, void DigitalOutput::UpdateTable() {} void DigitalOutput::StartLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void DigitalOutput::StopLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp index 2973bbaf4e..376b7b1d80 100644 --- a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp +++ b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp @@ -13,7 +13,7 @@ * Common function to implement constructor behaviour. */ void DoubleSolenoid::InitSolenoid() { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckSolenoidModule(m_moduleNumber)) { snprintf(buf, 64, "Solenoid Module %d", m_moduleNumber); @@ -171,7 +171,7 @@ void DoubleSolenoid::ValueChanged(ITable *source, const std::string &key, } void DoubleSolenoid::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutString( "Value", (Get() == kForward ? "Forward" : (Get() == kReverse ? "Reverse" : "Off"))); @@ -180,14 +180,14 @@ void DoubleSolenoid::UpdateTable() { void DoubleSolenoid::StartLiveWindowMode() { Set(kOff); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void DoubleSolenoid::StopLiveWindowMode() { Set(kOff); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/DriverStation.cpp b/wpilibc/wpilibC++Devices/src/DriverStation.cpp index 372383bd2f..829155b579 100644 --- a/wpilibc/wpilibC++Devices/src/DriverStation.cpp +++ b/wpilibc/wpilibC++Devices/src/DriverStation.cpp @@ -28,7 +28,7 @@ const double JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL = 1.0; Log().Get(level) const uint32_t DriverStation::kJoystickPorts; -DriverStation* DriverStation::m_instance = NULL; +DriverStation* DriverStation::m_instance = nullptr; /** * DriverStation constructor. @@ -82,10 +82,10 @@ DriverStation::DriverStation() DriverStation::~DriverStation() { m_task.Stop(); - m_instance = NULL; + m_instance = nullptr; deleteMultiWait(m_waitForDataSem); // Unregister our semaphore. - HALSetNewDataSem(0); + HALSetNewDataSem(nullptr); deleteMultiWait(m_packetDataAvailableMultiWait); deleteMutex(m_packetDataAvailableMutex); deleteMutex(m_waitForDataMutex); @@ -120,7 +120,7 @@ void DriverStation::Run() { * @return Pointer to the DS instance */ DriverStation* DriverStation::GetInstance() { - if (m_instance == NULL) { + if (m_instance == nullptr) { m_instance = new DriverStation(); } return m_instance; diff --git a/wpilibc/wpilibC++Devices/src/Encoder.cpp b/wpilibc/wpilibC++Devices/src/Encoder.cpp index 0ff27e251a..0ff68870c8 100644 --- a/wpilibc/wpilibC++Devices/src/Encoder.cpp +++ b/wpilibc/wpilibC++Devices/src/Encoder.cpp @@ -31,7 +31,7 @@ * or be double (2x) the spec'd count. */ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { - m_table = NULL; + m_table = nullptr; m_encodingType = encodingType; m_index = 0; switch (encodingType) { @@ -53,7 +53,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { m_bSource->GetAnalogTriggerForRouting(), reverseDirection, &m_index, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_counter = NULL; + m_counter = nullptr; SetMaxPeriod(.5); break; } @@ -102,7 +102,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { */ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, EncodingType encodingType) - : m_encoder(NULL), m_counter(NULL) { + : m_encoder(nullptr), m_counter(nullptr) { m_aSource = new DigitalInput(aChannel); m_bSource = new DigitalInput(bChannel); InitEncoder(reverseDirection, encodingType); @@ -137,12 +137,12 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, */ Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection, EncodingType encodingType) - : m_encoder(NULL), m_counter(NULL) { + : m_encoder(nullptr), m_counter(nullptr) { m_aSource = aSource; m_bSource = bSource; m_allocatedASource = false; m_allocatedBSource = false; - if (m_aSource == NULL || m_bSource == NULL) + if (m_aSource == nullptr || m_bSource == nullptr) wpi_setWPIError(NullParameter); else InitEncoder(reverseDirection, encodingType); @@ -175,7 +175,7 @@ Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource, */ Encoder::Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection, EncodingType encodingType) - : m_encoder(NULL), m_counter(NULL) { + : m_encoder(nullptr), m_counter(nullptr) { m_aSource = &aSource; m_bSource = &bSource; m_allocatedASource = false; @@ -555,7 +555,7 @@ void Encoder::SetIndexSource(DigitalSource &source, } void Encoder::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Speed", GetRate()); m_table->PutNumber("Distance", GetDistance()); m_table->PutNumber("Distance per Tick", m_distancePerPulse); diff --git a/wpilibc/wpilibC++Devices/src/Gyro.cpp b/wpilibc/wpilibC++Devices/src/Gyro.cpp index becfb6156e..618898457e 100644 --- a/wpilibc/wpilibC++Devices/src/Gyro.cpp +++ b/wpilibc/wpilibC++Devices/src/Gyro.cpp @@ -31,13 +31,13 @@ constexpr float Gyro::kDefaultVoltsPerDegreePerSecond; * rest before the competition starts. */ void Gyro::InitGyro() { - m_table = NULL; + m_table = nullptr; if (!m_analog->IsAccumulatorChannel()) { wpi_setWPIErrorWithContext(ParameterOutOfRange, " channel (must be accumulator channel)"); if (m_channelAllocated) { delete m_analog; - m_analog = NULL; + m_analog = nullptr; } return; } @@ -96,7 +96,7 @@ Gyro::Gyro(int32_t channel) { Gyro::Gyro(AnalogInput *channel) { m_analog = channel; m_channelAllocated = false; - if (channel == NULL) { + if (channel == nullptr) { wpi_setWPIError(NullParameter); } else { InitGyro(); @@ -230,7 +230,7 @@ double Gyro::PIDGet() const { } void Gyro::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetAngle()); } } diff --git a/wpilibc/wpilibC++Devices/src/I2C.cpp b/wpilibc/wpilibC++Devices/src/I2C.cpp index 50c3ea71c9..258da4ee68 100644 --- a/wpilibc/wpilibC++Devices/src/I2C.cpp +++ b/wpilibc/wpilibC++Devices/src/I2C.cpp @@ -72,7 +72,7 @@ bool I2C::Transaction(uint8_t *dataToSend, uint8_t sendSize, */ bool I2C::AddressOnly() { int32_t status = 0; - status = Transaction(NULL, 0, NULL, 0); + status = Transaction(nullptr, 0, nullptr, 0); return status < 0; } @@ -131,7 +131,7 @@ bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t *buffer) { wpi_setWPIErrorWithContext(ParameterOutOfRange, "count"); return true; } - if (buffer == NULL) { + if (buffer == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "buffer"); return true; } @@ -160,7 +160,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t *buffer) { wpi_setWPIErrorWithContext(ParameterOutOfRange, "count"); return true; } - if (buffer == NULL) { + if (buffer == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "buffer"); return true; } diff --git a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp index 4ea14021a0..b5402bbd2a 100644 --- a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp +++ b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp @@ -9,10 +9,10 @@ #include "Utility.h" #include "WPIErrors.h" -Resource *InterruptableSensorBase::m_interrupts = NULL; +Resource *InterruptableSensorBase::m_interrupts = nullptr; InterruptableSensorBase::InterruptableSensorBase() { - m_interrupt = NULL; + m_interrupt = nullptr; Resource::CreateResourceObject(&m_interrupts, interrupt_kNumSystems); } @@ -74,7 +74,7 @@ void InterruptableSensorBase::RequestInterrupts() { } void InterruptableSensorBase::AllocateInterrupts(bool watcher) { - wpi_assert(m_interrupt == NULL); + wpi_assert(m_interrupt == nullptr); // Expects the calling leaf class to allocate an interrupt index. int32_t status = 0; m_interrupt = initializeInterrupts(m_interruptIndex, watcher, &status); @@ -87,11 +87,11 @@ void InterruptableSensorBase::AllocateInterrupts(bool watcher) { */ void InterruptableSensorBase::CancelInterrupts() { if (StatusIsFatal()) return; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; cleanInterrupts(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); - m_interrupt = NULL; + m_interrupt = nullptr; m_interrupts->Free(m_interruptIndex); } @@ -109,7 +109,7 @@ void InterruptableSensorBase::CancelInterrupts() { InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt( float timeout, bool ignorePrevious) { if (StatusIsFatal()) return InterruptableSensorBase::kTimeout; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; uint32_t result; @@ -127,7 +127,7 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt( */ void InterruptableSensorBase::EnableInterrupts() { if (StatusIsFatal()) return; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; enableInterrupts(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); @@ -138,7 +138,7 @@ void InterruptableSensorBase::EnableInterrupts() { */ void InterruptableSensorBase::DisableInterrupts() { if (StatusIsFatal()) return; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; disableInterrupts(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); @@ -153,7 +153,7 @@ void InterruptableSensorBase::DisableInterrupts() { */ double InterruptableSensorBase::ReadRisingTimestamp() { if (StatusIsFatal()) return 0.0; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; double timestamp = readRisingTimestamp(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); @@ -169,7 +169,7 @@ double InterruptableSensorBase::ReadRisingTimestamp() { */ double InterruptableSensorBase::ReadFallingTimestamp() { if (StatusIsFatal()) return 0.0; - wpi_assert(m_interrupt != NULL); + wpi_assert(m_interrupt != nullptr); int32_t status = 0; double timestamp = readFallingTimestamp(m_interrupt, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); @@ -187,13 +187,13 @@ double InterruptableSensorBase::ReadFallingTimestamp() { void InterruptableSensorBase::SetUpSourceEdge(bool risingEdge, bool fallingEdge) { if (StatusIsFatal()) return; - if (m_interrupt == NULL) { + if (m_interrupt == nullptr) { wpi_setWPIErrorWithContext( NullParameter, "You must call RequestInterrupts before SetUpSourceEdge"); return; } - if (m_interrupt != NULL) { + if (m_interrupt != nullptr) { int32_t status = 0; setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); diff --git a/wpilibc/wpilibC++Devices/src/Joystick.cpp b/wpilibc/wpilibC++Devices/src/Joystick.cpp index ea18262bb1..dd2cd89b4e 100644 --- a/wpilibc/wpilibC++Devices/src/Joystick.cpp +++ b/wpilibc/wpilibC++Devices/src/Joystick.cpp @@ -30,10 +30,10 @@ static bool joySticksInitialized = false; * (0-5). */ Joystick::Joystick(uint32_t port) - : m_ds(NULL), + : m_ds(nullptr), m_port(port), - m_axes(NULL), - m_buttons(NULL), + m_axes(nullptr), + m_buttons(nullptr), m_outputs(0), m_leftRumble(0), m_rightRumble(0) { @@ -63,14 +63,13 @@ Joystick::Joystick(uint32_t port) */ Joystick::Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes) - : m_ds(NULL), m_port(port), m_axes(NULL), m_buttons(NULL) { + : m_ds(nullptr), m_port(port), m_axes(nullptr), m_buttons(nullptr) { InitJoystick(numAxisTypes, numButtonTypes); } void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) { if (!joySticksInitialized) { - for (unsigned i = 0; i < DriverStation::kJoystickPorts; i++) - joysticks[i] = NULL; + for (auto& joystick : joysticks) joystick = nullptr; joySticksInitialized = true; } if (m_port >= DriverStation::kJoystickPorts) { @@ -86,7 +85,7 @@ void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) { Joystick *Joystick::GetStickForPort(uint32_t port) { Joystick *stick = joysticks[port]; - if (stick == NULL) { + if (stick == nullptr) { stick = new Joystick(port); joysticks[port] = stick; } diff --git a/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp b/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp index 2fbc04a8f2..9271ee7b3b 100644 --- a/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp +++ b/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp @@ -14,7 +14,7 @@ #include -MotorSafetyHelper *MotorSafetyHelper::m_headHelper = NULL; +MotorSafetyHelper *MotorSafetyHelper::m_headHelper = nullptr; ReentrantSemaphore MotorSafetyHelper::m_listMutex; /** @@ -46,9 +46,9 @@ MotorSafetyHelper::~MotorSafetyHelper() { if (m_headHelper == this) { m_headHelper = m_nextHelper; } else { - MotorSafetyHelper *prev = NULL; + MotorSafetyHelper *prev = nullptr; MotorSafetyHelper *cur = m_headHelper; - while (cur != this && cur != NULL) prev = cur, cur = cur->m_nextHelper; + while (cur != this && cur != nullptr) prev = cur, cur = cur->m_nextHelper; if (cur == this) prev->m_nextHelper = cur->m_nextHelper; } } @@ -141,7 +141,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const { */ void MotorSafetyHelper::CheckMotors() { Synchronized sync(m_listMutex); - for (MotorSafetyHelper *msh = m_headHelper; msh != NULL; + for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr; msh = msh->m_nextHelper) { msh->Check(); } diff --git a/wpilibc/wpilibC++Devices/src/Notifier.cpp b/wpilibc/wpilibC++Devices/src/Notifier.cpp index 3511bb3f63..91fb0be00f 100644 --- a/wpilibc/wpilibC++Devices/src/Notifier.cpp +++ b/wpilibc/wpilibC++Devices/src/Notifier.cpp @@ -11,9 +11,9 @@ #include "WPIErrors.h" #include "HAL/HAL.hpp" -Notifier *Notifier::timerQueueHead = NULL; +Notifier *Notifier::timerQueueHead = nullptr; ReentrantSemaphore Notifier::queueSemaphore; -void *Notifier::m_notifier = NULL; +void *Notifier::m_notifier = nullptr; int Notifier::refcount = 0; /** @@ -22,14 +22,14 @@ int Notifier::refcount = 0; * using StartSingle or StartPeriodic. */ Notifier::Notifier(TimerEventHandler handler, void *param) { - if (handler == NULL) - wpi_setWPIErrorWithContext(NullParameter, "handler must not be NULL"); + if (handler == nullptr) + wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr"); m_handler = handler; m_param = param; m_periodic = false; m_expirationTime = 0; m_period = 0; - m_nextEvent = NULL; + m_nextEvent = nullptr; m_queued = false; m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL); { @@ -79,7 +79,7 @@ Notifier::~Notifier() { * that is taking care of synchronizing access to the queue. */ void Notifier::UpdateAlarm() { - if (timerQueueHead != NULL) { + if (timerQueueHead != nullptr) { int32_t status = 0; updateNotifierAlarm(m_notifier, (uint32_t)(timerQueueHead->m_expirationTime * 1e6), @@ -104,7 +104,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params) { Synchronized sync(queueSemaphore); double currentTime = GetClock(); current = timerQueueHead; - if (current == NULL || current->m_expirationTime > currentTime) { + if (current == nullptr || current->m_expirationTime > currentTime) { break; // no more timer events to process } // need to process this entry @@ -152,7 +152,7 @@ void Notifier::InsertInQueue(bool reschedule) { if (m_expirationTime > Timer::kRolloverTime) { m_expirationTime -= Timer::kRolloverTime; } - if (timerQueueHead == NULL || + if (timerQueueHead == nullptr || timerQueueHead->m_expirationTime >= this->m_expirationTime) { // the queue is empty or greater than the new entry // the new entry becomes the first element @@ -167,7 +167,7 @@ void Notifier::InsertInQueue(bool reschedule) { for (Notifier **npp = &(timerQueueHead->m_nextEvent);; npp = &(*npp)->m_nextEvent) { Notifier *n = *npp; - if (n == NULL || n->m_expirationTime > this->m_expirationTime) { + if (n == nullptr || n->m_expirationTime > this->m_expirationTime) { *npp = this; this->m_nextEvent = n; break; @@ -189,13 +189,13 @@ void Notifier::InsertInQueue(bool reschedule) { void Notifier::DeleteFromQueue() { if (m_queued) { m_queued = false; - wpi_assert(timerQueueHead != NULL); + wpi_assert(timerQueueHead != nullptr); if (timerQueueHead == this) { // remove the first item in the list - update the alarm timerQueueHead = this->m_nextEvent; UpdateAlarm(); } else { - for (Notifier *n = timerQueueHead; n != NULL; n = n->m_nextEvent) { + for (Notifier *n = timerQueueHead; n != nullptr; n = n->m_nextEvent) { if (n->m_nextEvent == this) { // this element is the next element from *n from the queue n->m_nextEvent = this->m_nextEvent; // point around this one diff --git a/wpilibc/wpilibC++Devices/src/PIDController.cpp b/wpilibc/wpilibC++Devices/src/PIDController.cpp index 321db72eec..99800e4862 100644 --- a/wpilibc/wpilibC++Devices/src/PIDController.cpp +++ b/wpilibc/wpilibC++Devices/src/PIDController.cpp @@ -58,7 +58,7 @@ PIDController::PIDController(float Kp, float Ki, float Kd, float Kf, void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf, PIDSource *source, PIDOutput *output, float period) { - m_table = NULL; + m_table = nullptr; m_semaphore = initializeMutexNormal(); @@ -140,8 +140,8 @@ void PIDController::Calculate() { } END_REGION; - if (pidInput == NULL) return; - if (pidOutput == NULL) return; + if (pidInput == nullptr) return; + if (pidOutput == nullptr) return; if (enabled) { { @@ -205,7 +205,7 @@ void PIDController::SetPID(double p, double i, double d) { } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("p", m_P); m_table->PutNumber("i", m_I); m_table->PutNumber("d", m_D); @@ -229,7 +229,7 @@ void PIDController::SetPID(double p, double i, double d, double f) { } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("p", m_P); m_table->PutNumber("i", m_I); m_table->PutNumber("d", m_D); @@ -346,7 +346,7 @@ void PIDController::SetSetpoint(float setpoint) { } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("setpoint", m_setpoint); } } @@ -451,7 +451,7 @@ void PIDController::Enable() { CRITICAL_REGION(m_semaphore) { m_enabled = true; } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("enabled", true); } } @@ -466,7 +466,7 @@ void PIDController::Disable() { } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("enabled", false); } } @@ -500,9 +500,9 @@ std::string PIDController::GetSmartDashboardType() const { } void PIDController::InitTable(ITable *table) { - if (m_table != NULL) m_table->RemoveTableListener(this); + if (m_table != nullptr) m_table->RemoveTableListener(this); m_table = table; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber(kP, GetP()); m_table->PutNumber(kI, GetI()); m_table->PutNumber(kD, GetD()); diff --git a/wpilibc/wpilibC++Devices/src/PWM.cpp b/wpilibc/wpilibC++Devices/src/PWM.cpp index 468db5c0f9..e18324e0d7 100644 --- a/wpilibc/wpilibC++Devices/src/PWM.cpp +++ b/wpilibc/wpilibC++Devices/src/PWM.cpp @@ -30,7 +30,7 @@ const int32_t PWM::kPwmDisabled; * port */ void PWM::InitPWM(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckPWMChannel(channel)) { @@ -351,21 +351,21 @@ void PWM::ValueChanged(ITable* source, const std::string& key, EntryValue value, } void PWM::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetSpeed()); } } void PWM::StartLiveWindowMode() { SetSpeed(0); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void PWM::StopLiveWindowMode() { SetSpeed(0); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp index e2daa83534..86b1497721 100644 --- a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp +++ b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp @@ -150,7 +150,7 @@ void PowerDistributionPanel::ClearStickyFaults() { } void PowerDistributionPanel::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Chan0", GetCurrent(0)); m_table->PutNumber("Chan1", GetCurrent(1)); m_table->PutNumber("Chan2", GetCurrent(2)); diff --git a/wpilibc/wpilibC++Devices/src/Preferences.cpp b/wpilibc/wpilibC++Devices/src/Preferences.cpp index aadc7c6f01..2d419540fa 100644 --- a/wpilibc/wpilibC++Devices/src/Preferences.cpp +++ b/wpilibc/wpilibC++Devices/src/Preferences.cpp @@ -25,12 +25,12 @@ static const char *kValuePrefix = "=\""; /** The characters to put after the value */ static const char *kValueSuffix = "\"\n"; /** The singleton instance */ -Preferences *Preferences::_instance = NULL; +Preferences *Preferences::_instance = nullptr; Preferences::Preferences() - : m_fileLock(NULL), - m_fileOpStarted(NULL), - m_tableLock(NULL), + : m_fileLock(nullptr), + m_fileOpStarted(nullptr), + m_tableLock(nullptr), m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask), m_writeTask("PreferencesWriteTask", (FUNCPTR)Preferences::InitWriteTask) { m_fileLock = initializeMutexRecursive(); @@ -57,7 +57,7 @@ Preferences::~Preferences() { * @return pointer to the {@link Preferences} */ Preferences *Preferences::GetInstance() { - if (_instance == NULL) _instance = new Preferences; + if (_instance == nullptr) _instance = new Preferences; return _instance; } @@ -106,7 +106,7 @@ int Preferences::GetInt(const char *key, int defaultValue) { std::string value = Get(key); if (value.empty()) return defaultValue; - return strtol(value.c_str(), NULL, 0); + return strtol(value.c_str(), nullptr, 0); } /** @@ -120,7 +120,7 @@ double Preferences::GetDouble(const char *key, double defaultValue) { std::string value = Get(key); if (value.empty()) return defaultValue; - return strtod(value.c_str(), NULL); + return strtod(value.c_str(), nullptr); } /** @@ -134,7 +134,7 @@ float Preferences::GetFloat(const char *key, float defaultValue) { std::string value = Get(key); if (value.empty()) return defaultValue; - return strtod(value.c_str(), NULL); + return strtod(value.c_str(), nullptr); } /** @@ -172,7 +172,7 @@ int64_t Preferences::GetLong(const char *key, int64_t defaultValue) { if (value.empty()) return defaultValue; // Ummm... not available in our VxWorks... - // return strtoll(value.c_str(), NULL, 0); + // return strtoll(value.c_str(), nullptr, 0); int64_t intVal; sscanf(value.c_str(), "%lld", &intVal); return intVal; @@ -192,7 +192,7 @@ int64_t Preferences::GetLong(const char *key, int64_t defaultValue) { * @param value the value */ void Preferences::PutString(const char *key, const char *value) { - if (value == NULL) { + if (value == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "value"); return; } @@ -323,7 +323,7 @@ bool Preferences::ContainsKey(const char *key) { return !Get(key).empty(); } */ void Preferences::Remove(const char *key) { m_values.erase(std::string(key)); - std::vector::iterator it = m_keys.begin(); + auto it = m_keys.begin(); for (; it != m_keys.end(); it++) { if (it->compare(key) == 0) { m_keys.erase(it); @@ -339,7 +339,7 @@ void Preferences::Remove(const char *key) { */ std::string Preferences::Get(const char *key) { Synchronized sync(m_tableLock); - if (key == NULL) { + if (key == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "key"); return std::string(""); } @@ -353,7 +353,7 @@ std::string Preferences::Get(const char *key) { */ void Preferences::Put(const char *key, std::string value) { Synchronized sync(m_tableLock); - if (key == NULL) { + if (key == nullptr) { wpi_setWPIErrorWithContext(NullParameter, "key"); return; } @@ -385,10 +385,10 @@ void Preferences::ReadTaskRun() { std::string comment; - FILE *file = NULL; + FILE *file = nullptr; file = fopen(kFileName, "r"); - if (file != NULL) { + if (file != nullptr) { std::string buffer; while (true) { char value; @@ -469,7 +469,7 @@ void Preferences::ReadTaskRun() { wpi_setErrnoErrorWithContext("Opening preferences file"); } - if (file != NULL) fclose(file); + if (file != nullptr) fclose(file); if (!comment.empty()) m_endComment = comment; @@ -486,11 +486,11 @@ void Preferences::WriteTaskRun() { Synchronized sync(m_tableLock); giveSemaphore(m_fileOpStarted); - FILE *file = NULL; + FILE *file = nullptr; file = fopen(kFileName, "w"); fputs("[Preferences]\n", file); - std::vector::iterator it = m_keys.begin(); + auto it = m_keys.begin(); for (; it != m_keys.end(); it++) { std::string key = *it; std::string value = m_values[key]; @@ -506,14 +506,13 @@ void Preferences::WriteTaskRun() { if (!m_endComment.empty()) fputs(m_endComment.c_str(), file); - if (file != NULL) fclose(file); + if (file != nullptr) fclose(file); NetworkTable::GetTable(kTableName)->PutBoolean(kSaveField, false); } static bool isKeyAcceptable(const std::string &value) { - for (unsigned int i = 0; i < value.length(); i++) { - char letter = value.at(i); + for (auto letter : value) { switch (letter) { case '=': case '\n': @@ -538,7 +537,7 @@ void Preferences::ValueChanged(ITable *table, const std::string &key, table->GetString(key, "").find('"') != std::string::npos) { if (m_values.find(key) != m_values.end()) { m_values.erase(key); - std::vector::iterator it = m_keys.begin(); + auto it = m_keys.begin(); for (; it != m_keys.end(); it++) { if (key == *it) { m_keys.erase(it); diff --git a/wpilibc/wpilibC++Devices/src/Relay.cpp b/wpilibc/wpilibC++Devices/src/Relay.cpp index 2813da5f1f..b91481366b 100644 --- a/wpilibc/wpilibC++Devices/src/Relay.cpp +++ b/wpilibc/wpilibC++Devices/src/Relay.cpp @@ -15,7 +15,7 @@ #include "HAL/HAL.hpp" // Allocate each direction separately. -static Resource *relayChannels = NULL; +static Resource *relayChannels = nullptr; /** * Common relay initialization method. @@ -25,7 +25,7 @@ static Resource *relayChannels = NULL; * lines at 0v. */ void Relay::InitRelay() { - m_table = NULL; + m_table = nullptr; char buf[64]; Resource::CreateResourceObject(&relayChannels, dio_kNumSystems * kRelayChannels * 2); @@ -210,7 +210,7 @@ void Relay::ValueChanged(ITable *source, const std::string &key, } void Relay::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { if (Get() == kOn) { m_table->PutString("Value", "On"); } else if (Get() == kForward) { @@ -224,13 +224,13 @@ void Relay::UpdateTable() { } void Relay::StartLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void Relay::StopLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/RobotBase.cpp b/wpilibc/wpilibC++Devices/src/RobotBase.cpp index 1ce3953f9c..fdaa251abb 100644 --- a/wpilibc/wpilibC++Devices/src/RobotBase.cpp +++ b/wpilibc/wpilibC++Devices/src/RobotBase.cpp @@ -26,10 +26,10 @@ #include #endif -RobotBase *RobotBase::m_instance = NULL; +RobotBase *RobotBase::m_instance = nullptr; void RobotBase::setInstance(RobotBase *robot) { - wpi_assert(m_instance == NULL); + wpi_assert(m_instance == nullptr); m_instance = robot; } @@ -52,18 +52,18 @@ void RobotBase::robotSetup(RobotBase *robot) { * nice to put this code into it's own task that loads on boot so ensure that it * runs. */ -RobotBase::RobotBase() : m_task(NULL), m_ds(NULL) { +RobotBase::RobotBase() : m_task(nullptr), m_ds(nullptr) { m_ds = DriverStation::GetInstance(); RobotState::SetImplementation(DriverStation::GetInstance()); HLUsageReporting::SetImplementation(new HardwareHLReporting()); RobotBase::setInstance(this); - FILE *file = NULL; + FILE *file = nullptr; file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w"); fputs("2015 C++ 1.2.0", file); - if (file != NULL) fclose(file); + if (file != nullptr) fclose(file); } /** @@ -75,8 +75,8 @@ RobotBase::RobotBase() : m_task(NULL), m_ds(NULL) { RobotBase::~RobotBase() { SensorBase::DeleteSingletons(); delete m_task; - m_task = NULL; - m_instance = NULL; + m_task = nullptr; + m_instance = nullptr; } /** diff --git a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp index 1c42aedada..0f221ab85b 100644 --- a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp +++ b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp @@ -37,10 +37,10 @@ const int32_t RobotDrive::kMaxNumberOfMotors; * robot drive. */ void RobotDrive::InitRobotDrive() { - m_frontLeftMotor = NULL; - m_frontRightMotor = NULL; - m_rearRightMotor = NULL; - m_rearLeftMotor = NULL; + m_frontLeftMotor = nullptr; + m_frontRightMotor = nullptr; + m_rearRightMotor = nullptr; + m_rearLeftMotor = nullptr; m_sensitivity = 0.5; m_maxOutput = 1.0; m_safetyHelper = new MotorSafetyHelper(this); @@ -105,9 +105,9 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor, RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor) { InitRobotDrive(); - if (leftMotor == NULL || rightMotor == NULL) { + if (leftMotor == nullptr || rightMotor == nullptr) { wpi_setWPIError(NullParameter); - m_rearLeftMotor = m_rearRightMotor = NULL; + m_rearLeftMotor = m_rearRightMotor = nullptr; return; } m_rearLeftMotor = leftMotor; @@ -141,8 +141,8 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor) { InitRobotDrive(); - if (frontLeftMotor == NULL || rearLeftMotor == NULL || - frontRightMotor == NULL || rearRightMotor == NULL) { + if (frontLeftMotor == nullptr || rearLeftMotor == nullptr || + frontRightMotor == nullptr || rearRightMotor == nullptr) { wpi_setWPIError(NullParameter); return; } @@ -230,7 +230,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve) { */ void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs) { - if (leftStick == NULL || rightStick == NULL) { + if (leftStick == nullptr || rightStick == nullptr) { wpi_setWPIError(NullParameter); return; } @@ -255,7 +255,7 @@ void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick, void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis, GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs) { - if (leftStick == NULL || rightStick == NULL) { + if (leftStick == nullptr || rightStick == nullptr) { wpi_setWPIError(NullParameter); return; } @@ -591,13 +591,13 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction, * @param rightOutput The speed to send to the right side of the robot. */ void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) { - wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL); + wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr); - if (m_frontLeftMotor != NULL) + if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup); m_rearLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup); - if (m_frontRightMotor != NULL) + if (m_frontRightMotor != nullptr) m_frontRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup); m_rearRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup); @@ -734,9 +734,9 @@ void RobotDrive::GetDescription(char *desc) const { } void RobotDrive::StopMotor() { - if (m_frontLeftMotor != NULL) m_frontLeftMotor->Disable(); - if (m_frontRightMotor != NULL) m_frontRightMotor->Disable(); - if (m_rearLeftMotor != NULL) m_rearLeftMotor->Disable(); - if (m_rearRightMotor != NULL) m_rearRightMotor->Disable(); + if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Disable(); + if (m_frontRightMotor != nullptr) m_frontRightMotor->Disable(); + if (m_rearLeftMotor != nullptr) m_rearLeftMotor->Disable(); + if (m_rearRightMotor != nullptr) m_rearRightMotor->Disable(); m_safetyHelper->Feed(); } diff --git a/wpilibc/wpilibC++Devices/src/SPI.cpp b/wpilibc/wpilibC++Devices/src/SPI.cpp index 3d00828fd8..c0ac0975d1 100644 --- a/wpilibc/wpilibC++Devices/src/SPI.cpp +++ b/wpilibc/wpilibC++Devices/src/SPI.cpp @@ -151,7 +151,7 @@ int32_t SPI::Write(uint8_t* data, uint8_t size) { int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) { int32_t retVal = 0; if (initiate) { - uint8_t* dataToSend = new uint8_t[size]; + auto dataToSend = new uint8_t[size]; memset(dataToSend, 0, size); retVal = spiTransaction(m_port, dataToSend, dataReceived, size); } else diff --git a/wpilibc/wpilibC++Devices/src/SensorBase.cpp b/wpilibc/wpilibC++Devices/src/SensorBase.cpp index 991cc950c9..54a84bb788 100644 --- a/wpilibc/wpilibC++Devices/src/SensorBase.cpp +++ b/wpilibc/wpilibC++Devices/src/SensorBase.cpp @@ -19,7 +19,7 @@ const uint32_t SensorBase::kPwmChannels; const uint32_t SensorBase::kRelayChannels; const uint32_t SensorBase::kPDPChannels; const uint32_t SensorBase::kChassisSlots; -SensorBase* SensorBase::m_singletonList = NULL; +SensorBase* SensorBase::m_singletonList = nullptr; static bool portsInitialized = false; void* SensorBase::m_digital_ports[kDigitalChannels]; @@ -80,12 +80,12 @@ void SensorBase::AddToSingletonList() { * their resources can be freed. */ void SensorBase::DeleteSingletons() { - for (SensorBase* next = m_singletonList; next != NULL;) { + for (SensorBase* next = m_singletonList; next != nullptr;) { SensorBase* tmp = next; next = next->m_nextSingleton; delete tmp; } - m_singletonList = NULL; + m_singletonList = nullptr; } /** diff --git a/wpilibc/wpilibC++Devices/src/SerialPort.cpp b/wpilibc/wpilibC++Devices/src/SerialPort.cpp index 80b0089eee..b124a6a071 100644 --- a/wpilibc/wpilibC++Devices/src/SerialPort.cpp +++ b/wpilibc/wpilibC++Devices/src/SerialPort.cpp @@ -53,7 +53,7 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits, // viInstallHandler(m_portHandle, VI_EVENT_IO_COMPLETION, ioCompleteHandler, // this); - // viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL); + // viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_nullptr); HALReport(HALUsageReporting::kResourceType_SerialPort, 0); } @@ -226,4 +226,4 @@ void SerialPort::Reset() { int32_t status = 0; serialClear(m_port, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); -} \ No newline at end of file +} diff --git a/wpilibc/wpilibC++Devices/src/Servo.cpp b/wpilibc/wpilibC++Devices/src/Servo.cpp index 0ab2c2179d..63a034593c 100644 --- a/wpilibc/wpilibC++Devices/src/Servo.cpp +++ b/wpilibc/wpilibC++Devices/src/Servo.cpp @@ -24,7 +24,7 @@ constexpr float Servo::kDefaultMinServoPWM; * well as the minimum and maximum PWM values supported by the servo. */ void Servo::InitServo() { - m_table = NULL; + m_table = nullptr; SetBounds(kDefaultMaxServoPWM, 0.0, 0.0, 0.0, kDefaultMinServoPWM); SetPeriodMultiplier(kPeriodMultiplier_4X); @@ -112,19 +112,19 @@ void Servo::ValueChanged(ITable* source, const std::string& key, } void Servo::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } void Servo::StartLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void Servo::StopLiveWindowMode() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/Solenoid.cpp b/wpilibc/wpilibC++Devices/src/Solenoid.cpp index ab84754390..ec9d280518 100644 --- a/wpilibc/wpilibC++Devices/src/Solenoid.cpp +++ b/wpilibc/wpilibC++Devices/src/Solenoid.cpp @@ -14,7 +14,7 @@ * Common function to implement constructor behavior. */ void Solenoid::InitSolenoid() { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckSolenoidModule(m_moduleNumber)) { snprintf(buf, 64, "Solenoid Module %d", m_moduleNumber); @@ -113,21 +113,21 @@ void Solenoid::ValueChanged(ITable* source, const std::string& key, } void Solenoid::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("Value", Get()); } } void Solenoid::StartLiveWindowMode() { Set(false); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void Solenoid::StopLiveWindowMode() { Set(false); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp index 8d8dfc3b7a..4bbc7d4a5b 100644 --- a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp +++ b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp @@ -8,7 +8,7 @@ #include "SolenoidBase.h" // Needs to be global since the protected resource spans all Solenoid objects. -Resource* SolenoidBase::m_allocated = NULL; +Resource* SolenoidBase::m_allocated = nullptr; void* SolenoidBase::m_ports[m_maxModules][m_maxPorts]; /** diff --git a/wpilibc/wpilibC++Devices/src/Task.cpp b/wpilibc/wpilibC++Devices/src/Task.cpp index 316eaf8e08..892413c316 100644 --- a/wpilibc/wpilibC++Devices/src/Task.cpp +++ b/wpilibc/wpilibC++Devices/src/Task.cpp @@ -41,7 +41,7 @@ Task::Task(const char* name, FUNCPTR function, int32_t priority, Task::~Task() { if (m_taskID != NULL_TASK) Stop(); delete[] m_taskName; - m_taskName = NULL; + m_taskName = nullptr; } /** @@ -144,7 +144,7 @@ bool Task::SetPriority(int32_t priority) { /** * Returns the name of the task. - * @returns Pointer to the name of the task or NULL if not allocated + * @returns Pointer to the name of the task or nullptr if not allocated */ const char* Task::GetName() const { return m_taskName; } diff --git a/wpilibc/wpilibC++Devices/src/Timer.cpp b/wpilibc/wpilibC++Devices/src/Timer.cpp index 29440aa83c..1ca792c05e 100644 --- a/wpilibc/wpilibC++Devices/src/Timer.cpp +++ b/wpilibc/wpilibC++Devices/src/Timer.cpp @@ -63,7 +63,7 @@ Timer::Timer() : m_startTime(0.0), m_accumulatedTime(0.0), m_running(false), - m_semaphore(0) { + m_semaphore(nullptr) { // Creates a semaphore to control access to critical regions. // Initially 'open' m_semaphore = initializeMutexNormal(); diff --git a/wpilibc/wpilibC++Devices/src/USBCamera.cpp b/wpilibc/wpilibC++Devices/src/USBCamera.cpp index 7e577a0f36..edc88ff26c 100644 --- a/wpilibc/wpilibC++Devices/src/USBCamera.cpp +++ b/wpilibc/wpilibC++Devices/src/USBCamera.cpp @@ -148,7 +148,7 @@ void USBCamera::UpdateSettings() { uInt32 count = 0; uInt32 currentMode = 0; - SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, NULL, &count, ¤tMode); + SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, nullptr, &count, ¤tMode); IMAQdxVideoMode modes[count]; SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, modes, &count, ¤tMode); diff --git a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp index 82b8c8713a..e82a656067 100644 --- a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp +++ b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp @@ -28,9 +28,9 @@ Task Ultrasonic::m_task( (FUNCPTR) UltrasonicChecker); // task doing the round-robin automatic sensing Ultrasonic *Ultrasonic::m_firstSensor = - NULL; // head of the ultrasonic sensor list + nullptr; // head of the ultrasonic sensor list bool Ultrasonic::m_automaticEnabled = false; // automatic round robin mode -SEMAPHORE_ID Ultrasonic::m_semaphore = 0; +SEMAPHORE_ID Ultrasonic::m_semaphore = nullptr; /** * Background task that goes through the list of ultrasonic sensors and pings @@ -45,10 +45,10 @@ SEMAPHORE_ID Ultrasonic::m_semaphore = 0; * anything with the sensors!! */ void Ultrasonic::UltrasonicChecker() { - Ultrasonic *u = NULL; + Ultrasonic *u = nullptr; while (m_automaticEnabled) { - if (u == NULL) u = m_firstSensor; - if (u == NULL) return; + if (u == nullptr) u = m_firstSensor; + if (u == nullptr) return; if (u->IsEnabled()) u->m_pingChannel->Pulse(kPingTime); // do the ping u = u->m_nextSensor; Wait(0.1); // wait for ping to return @@ -66,9 +66,9 @@ void Ultrasonic::UltrasonicChecker() { * restored. */ void Ultrasonic::Initialize() { - m_table = NULL; + m_table = nullptr; bool originalMode = m_automaticEnabled; - if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_FULL); + if (m_semaphore == nullptr) m_semaphore = initializeSemaphore(SEMAPHORE_FULL); SetAutomaticMode(false); // kill task when adding a new sensor takeSemaphore(m_semaphore); // link this instance on the list { @@ -124,7 +124,7 @@ Ultrasonic::Ultrasonic(uint32_t pingChannel, uint32_t echoChannel, */ Ultrasonic::Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel, DistanceUnit units) { - if (pingChannel == NULL || echoChannel == NULL) { + if (pingChannel == nullptr || echoChannel == nullptr) { wpi_setWPIError(NullParameter); return; } @@ -169,18 +169,18 @@ Ultrasonic::~Ultrasonic() { delete m_pingChannel; delete m_echoChannel; } - wpi_assert(m_firstSensor != NULL); + wpi_assert(m_firstSensor != nullptr); takeSemaphore(m_semaphore); { if (this == m_firstSensor) { m_firstSensor = m_nextSensor; - if (m_firstSensor == NULL) { + if (m_firstSensor == nullptr) { SetAutomaticMode(false); } } else { - wpi_assert(m_firstSensor->m_nextSensor != NULL); - for (Ultrasonic *s = m_firstSensor; s != NULL; s = s->m_nextSensor) { + wpi_assert(m_firstSensor->m_nextSensor != nullptr); + for (Ultrasonic *s = m_firstSensor; s != nullptr; s = s->m_nextSensor) { if (this == s->m_nextSensor) { s->m_nextSensor = s->m_nextSensor->m_nextSensor; break; @@ -189,7 +189,7 @@ Ultrasonic::~Ultrasonic() { } } giveSemaphore(m_semaphore); - if (m_firstSensor != NULL && wasAutomaticMode) SetAutomaticMode(true); + if (m_firstSensor != nullptr && wasAutomaticMode) SetAutomaticMode(true); } /** @@ -211,7 +211,7 @@ void Ultrasonic::SetAutomaticMode(bool enabling) { if (enabling) { // enabling automatic mode. // Clear all the counters so no data is valid - for (Ultrasonic *u = m_firstSensor; u != NULL; u = u->m_nextSensor) { + for (Ultrasonic *u = m_firstSensor; u != nullptr; u = u->m_nextSensor) { u->m_counter->Reset(); } // Start round robin task @@ -225,7 +225,7 @@ void Ultrasonic::SetAutomaticMode(bool enabling) { // stop // clear all the counters (data now invalid) since automatic mode is stopped - for (Ultrasonic *u = m_firstSensor; u != NULL; u = u->m_nextSensor) { + for (Ultrasonic *u = m_firstSensor; u != nullptr; u = u->m_nextSensor) { u->m_counter->Reset(); } m_task.Stop(); @@ -313,7 +313,7 @@ Ultrasonic::DistanceUnit Ultrasonic::GetDistanceUnits() const { } void Ultrasonic::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetRangeInches()); } } diff --git a/wpilibc/wpilibC++Devices/src/Utility.cpp b/wpilibc/wpilibC++Devices/src/Utility.cpp index ee8b5e6ad4..73bb0ef981 100644 --- a/wpilibc/wpilibC++Devices/src/Utility.cpp +++ b/wpilibc/wpilibC++Devices/src/Utility.cpp @@ -62,7 +62,7 @@ bool wpi_assert_impl(bool conditionValue, const char *conditionText, std::cout << error << std::endl; HALSetErrorData(error.c_str(), error.size(), 100); - if (suspendOnAssertEnabled) suspendTask(0); + if (suspendOnAssertEnabled) suspendTask(nullptr); } return conditionValue; @@ -99,7 +99,7 @@ void wpi_assertEqual_common_impl(const char *valueA, const char *valueB, std::cout << error << std::endl; HALSetErrorData(error.c_str(), error.size(), 100); - if (suspendOnAssertEnabled) suspendTask(0); + if (suspendOnAssertEnabled) suspendTask(nullptr); } /** @@ -200,7 +200,7 @@ static std::string demangle(char const *mangledSymbol) { int status; if (sscanf(mangledSymbol, "%*[^(]%*[(]%255[^)+]", buffer)) { - char *symbol = abi::__cxa_demangle(buffer, NULL, &length, &status); + char *symbol = abi::__cxa_demangle(buffer, nullptr, &length, &status); if (status == 0) { return symbol; } else { diff --git a/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp b/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp index babeeadd55..18be836e96 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp @@ -112,7 +112,7 @@ int AxisCamera::GetImage(ColorImage *image) { * @return a pointer to an HSLImage object */ HSLImage *AxisCamera::GetImage() { - HSLImage *image = new HSLImage(); + auto image = new HSLImage(); GetImage(image); return image; } @@ -131,22 +131,22 @@ HSLImage *AxisCamera::GetImage() { int AxisCamera::CopyJPEG(char **destImage, unsigned int &destImageSize, unsigned int &destImageBufferSize) { std::lock_guard lock(m_imageDataMutex); - if (destImage == NULL) - wpi_setWPIErrorWithContext(NullParameter, "destImage must not be NULL"); + if (destImage == nullptr) + wpi_setWPIErrorWithContext(NullParameter, "destImage must not be nullptr"); if (m_imageData.size() == 0) return 0; // if no source image if (destImageBufferSize < m_imageData.size()) // if current destination buffer too small { - if (*destImage != NULL) delete[] * destImage; + if (*destImage != nullptr) delete[] * destImage; destImageBufferSize = m_imageData.size() + kImageBufferAllocationIncrement; *destImage = new char[destImageBufferSize]; - if (*destImage == NULL) return 0; + if (*destImage == nullptr) return 0; } // copy this image into destination buffer - if (*destImage == NULL) { - wpi_setWPIErrorWithContext(NullParameter, "*destImage must not be NULL"); + if (*destImage == nullptr) { + wpi_setWPIErrorWithContext(NullParameter, "*destImage must not be nullptr"); } std::copy(m_imageData.begin(), m_imageData.end(), *destImage); @@ -415,7 +415,7 @@ void AxisCamera::Capture() { * This function actually reads the images from the camera. */ void AxisCamera::ReadImagesFromCamera() { - char *imgBuffer = NULL; + char *imgBuffer = nullptr; int imgBufferLength = 0; // TODO: these recv calls must be non-blocking. Otherwise if the camera @@ -441,7 +441,7 @@ void AxisCamera::ReadImagesFromCamera() { // after // there is at least 4 bytes total. Kind of obscure. // look for 2 blank lines (\r\n) - if (NULL != strstr(trailingPtr, "\r\n\r\n")) { + if (nullptr != strstr(trailingPtr, "\r\n\r\n")) { --counter; } if (++trailingCounter >= 4) { @@ -450,7 +450,7 @@ void AxisCamera::ReadImagesFromCamera() { } counter = 1; char *contentLength = strstr(initialReadBuffer, "Content-Length: "); - if (contentLength == NULL) { + if (contentLength == nullptr) { wpi_setWPIErrorWithContext(IncompatibleMode, "No content-length token found in packet"); close(m_cameraSocket); @@ -464,7 +464,7 @@ void AxisCamera::ReadImagesFromCamera() { if (imgBuffer) delete[] imgBuffer; imgBufferLength = readLength + kImageBufferAllocationIncrement; imgBuffer = new char[imgBufferLength]; - if (imgBuffer == NULL) { + if (imgBuffer == nullptr) { imgBufferLength = 0; continue; } @@ -567,7 +567,7 @@ bool AxisCamera::WriteParameters() { */ int AxisCamera::CreateCameraSocket(std::string const &requestString, bool setError) { - struct addrinfo *address = 0; + struct addrinfo *address = nullptr; int camSocket; /* create socket */ @@ -577,7 +577,7 @@ int AxisCamera::CreateCameraSocket(std::string const &requestString, return -1; } - if (getaddrinfo(m_cameraHost.c_str(), "80", 0, &address) == -1) { + if (getaddrinfo(m_cameraHost.c_str(), "80", nullptr, &address) == -1) { if (setError) wpi_setErrnoErrorWithContext("Failed to create the camera socket"); return -1; diff --git a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp index fe2944a7ed..5059e1e5cc 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp @@ -129,7 +129,7 @@ void dprintf(const char *tempString, ...) /* Variable argument list */ break; case DEBUG_MOSTLY_OFF: if (fatalFlag) { - if ((outfile_fd = fopen(filepath, "a+")) != NULL) { + if ((outfile_fd = fopen(filepath, "a+")) != nullptr) { fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd); fclose(outfile_fd); } @@ -139,14 +139,14 @@ void dprintf(const char *tempString, ...) /* Variable argument list */ printf("%s", outtext); break; case DEBUG_FILE_ONLY: - if ((outfile_fd = fopen(filepath, "a+")) != NULL) { + if ((outfile_fd = fopen(filepath, "a+")) != nullptr) { fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd); fclose(outfile_fd); } break; case DEBUG_SCREEN_AND_FILE: // BOTH printf("%s", outtext); - if ((outfile_fd = fopen(filepath, "a+")) != NULL) { + if ((outfile_fd = fopen(filepath, "a+")) != nullptr) { fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd); fclose(outfile_fd); } @@ -223,7 +223,7 @@ double SinPosition(double *period, double sinStart) { double sinArg; // 1st call - if (period != NULL) { + if (period != nullptr) { sinePeriod = *period; timestamp = GetTime(); return 0.0; @@ -270,7 +270,7 @@ void panInit(double period) { void panForTarget(Servo *panServo) { panForTarget(panServo, 0.0); } void panForTarget(Servo *panServo, double sinStart) { - float normalizedSinPosition = (float)SinPosition(NULL, sinStart); + float normalizedSinPosition = (float)SinPosition(nullptr, sinStart); float newServoPosition = NormalizeToRange(normalizedSinPosition); panServo->Set(newServoPosition); // ShowActivity ("pan x: normalized %f newServoPosition = %f" , @@ -296,13 +296,13 @@ int processFile(char *inputFile, char *outputString, int lineNumber) { if (lineNumber < 0) return (-1); - if ((infile = fopen(inputFile, "r")) == NULL) { + if ((infile = fopen(inputFile, "r")) == nullptr) { printf("Fatal error opening file %s\n", inputFile); return (0); } while (!feof(infile)) { - if (fgets(inputStr, stringSize, infile) != NULL) { + if (fgets(inputStr, stringSize, infile) != nullptr) { // Skip empty lines if (emptyString(inputStr)) continue; // Skip comment lines @@ -339,7 +339,7 @@ int processFile(char *inputFile, char *outputString, int lineNumber) { int emptyString(char *string) { int i, len; - if (string == NULL) return (1); + if (string == nullptr) return (1); len = strlen(string); for (i = 0; i < len; i++) { @@ -358,7 +358,7 @@ int emptyString(char *string) { void stripString(char *string) { int i, j, len; - if (string == NULL) return; + if (string == nullptr) return; len = strlen(string); for (i = 0, j = 0; i < len; i++) { diff --git a/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp index 541a69729b..832cec65c4 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp @@ -107,8 +107,7 @@ void BinaryImage::GetParticleAnalysisReport(int particleNumber, */ vector * BinaryImage::GetOrderedParticleAnalysisReports() { - vector *particles = - new vector; + auto particles = new vector; int particleCount = GetNumberParticles(); for (int particleIndex = 0; particleIndex < particleCount; particleIndex++) { particles->push_back(GetParticleAnalysisReport(particleIndex)); @@ -197,23 +196,23 @@ bool BinaryImage::CompareParticleSizes(ParticleAnalysisReport particle1, } BinaryImage *BinaryImage::RemoveSmallObjects(bool connectivity8, int erosions) { - BinaryImage *result = new BinaryImage(); + auto result = new BinaryImage(); int success = imaqSizeFilter(result->GetImaqImage(), m_imaqImage, - connectivity8, erosions, IMAQ_KEEP_LARGE, NULL); + connectivity8, erosions, IMAQ_KEEP_LARGE, nullptr); wpi_setImaqErrorWithContext(success, "Error in RemoveSmallObjects"); return result; } BinaryImage *BinaryImage::RemoveLargeObjects(bool connectivity8, int erosions) { - BinaryImage *result = new BinaryImage(); + auto result = new BinaryImage(); int success = imaqSizeFilter(result->GetImaqImage(), m_imaqImage, - connectivity8, erosions, IMAQ_KEEP_SMALL, NULL); + connectivity8, erosions, IMAQ_KEEP_SMALL, nullptr); wpi_setImaqErrorWithContext(success, "Error in RemoveLargeObjects"); return result; } BinaryImage *BinaryImage::ConvexHull(bool connectivity8) { - BinaryImage *result = new BinaryImage(); + auto result = new BinaryImage(); int success = imaqConvexHull(result->GetImaqImage(), m_imaqImage, connectivity8); wpi_setImaqErrorWithContext(success, "Error in convex hull operation"); @@ -222,12 +221,12 @@ BinaryImage *BinaryImage::ConvexHull(bool connectivity8) { BinaryImage *BinaryImage::ParticleFilter(ParticleFilterCriteria2 *criteria, int criteriaCount) { - BinaryImage *result = new BinaryImage(); + auto result = new BinaryImage(); int numParticles; ParticleFilterOptions2 filterOptions = {0, 0, 0, 1}; int success = imaqParticleFilter4(result->GetImaqImage(), m_imaqImage, criteria, - criteriaCount, &filterOptions, NULL, &numParticles); + criteriaCount, &filterOptions, nullptr, &numParticles); wpi_setImaqErrorWithContext(success, "Error in particle filter operation"); return result; } diff --git a/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp index 3a52337a78..f3e4ff617f 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp @@ -22,7 +22,7 @@ ColorImage::~ColorImage() {} BinaryImage *ColorImage::ComputeThreshold(ColorMode colorMode, int low1, int high1, int low2, int high2, int low3, int high3) { - BinaryImage *result = new BinaryImage(); + auto result = new BinaryImage(); Range range1 = {low1, high1}, range2 = {low2, high2}, range3 = {low3, high3}; int success = imaqColorThreshold(result->GetImaqImage(), m_imaqImage, 1, @@ -154,12 +154,12 @@ BinaryImage *ColorImage::ThresholdHSI(Threshold &t) { * @returns A pointer to a MonoImage that represents the extracted plane. */ MonoImage *ColorImage::ExtractColorPlane(ColorMode mode, int planeNumber) { - MonoImage *result = new MonoImage(); - if (m_imaqImage == NULL) wpi_setWPIError(NullParameter); + auto result = new MonoImage(); + if (m_imaqImage == nullptr) wpi_setWPIError(NullParameter); int success = imaqExtractColorPlanes( - m_imaqImage, mode, (planeNumber == 1) ? result->GetImaqImage() : NULL, - (planeNumber == 2) ? result->GetImaqImage() : NULL, - (planeNumber == 3) ? result->GetImaqImage() : NULL); + m_imaqImage, mode, (planeNumber == 1) ? result->GetImaqImage() : nullptr, + (planeNumber == 2) ? result->GetImaqImage() : nullptr, + (planeNumber == 3) ? result->GetImaqImage() : nullptr); wpi_setImaqErrorWithContext(success, "Imaq ExtractColorPlanes failed"); return result; } @@ -274,9 +274,9 @@ void ColorImage::ReplacePlane(ColorMode mode, MonoImage *plane, int planeNumber) { int success = imaqReplaceColorPlanes(m_imaqImage, (const Image *)m_imaqImage, mode, - (planeNumber == 1) ? plane->GetImaqImage() : NULL, - (planeNumber == 2) ? plane->GetImaqImage() : NULL, - (planeNumber == 3) ? plane->GetImaqImage() : NULL); + (planeNumber == 1) ? plane->GetImaqImage() : nullptr, + (planeNumber == 2) ? plane->GetImaqImage() : nullptr, + (planeNumber == 3) ? plane->GetImaqImage() : nullptr); wpi_setImaqErrorWithContext(success, "Imaq ReplaceColorPlanes failed"); } diff --git a/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp b/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp index 7cd1fbf512..f0b4725c61 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp @@ -319,7 +319,7 @@ const char* GetVisionErrorText(int errorCode) { break; } case -1074395269: { - errorText = "ERR_NULL_POINTER"; + errorText = "ERR_nullptr_POINTER"; break; } case -1074395270: { @@ -563,7 +563,7 @@ const char* GetVisionErrorText(int errorCode) { break; } case -1074395343: { - errorText = "ERR_FILE_FILENAME_NULL"; + errorText = "ERR_FILE_FILENAME_nullptr"; break; } case -1074395345: { @@ -2083,7 +2083,7 @@ const char* GetVisionErrorText(int errorCode) { break; } case -1074396098: { - errorText = "ERR_RESERVED_MUST_BE_NULL"; + errorText = "ERR_RESERVED_MUST_BE_nullptr"; break; } case -1074396099: { diff --git a/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp index 11670a8325..7347f01fde 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp @@ -16,7 +16,7 @@ HSLImage::HSLImage() : ColorImage(IMAQ_IMAGE_HSL) {} * @param fileName The path of the file to load. */ HSLImage::HSLImage(const char *fileName) : ColorImage(IMAQ_IMAGE_HSL) { - int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL); + int success = imaqReadFile(m_imaqImage, fileName, nullptr, nullptr); wpi_setImaqErrorWithContext(success, "Imaq ReadFile error"); } diff --git a/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp b/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp index 8b6adaf195..f35234adab 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp @@ -31,7 +31,7 @@ ImageBase::~ImageBase() { * @param fileName The name of the file to write */ void ImageBase::Write(const char *fileName) { - int success = imaqWriteFile(m_imaqImage, fileName, NULL); + int success = imaqWriteFile(m_imaqImage, fileName, nullptr); wpi_setImaqErrorWithContext(success, "Imaq Image writeFile error"); } @@ -41,7 +41,7 @@ void ImageBase::Write(const char *fileName) { */ int ImageBase::GetHeight() { int height; - imaqGetImageSize(m_imaqImage, NULL, &height); + imaqGetImageSize(m_imaqImage, nullptr, &height); return height; } @@ -51,7 +51,7 @@ int ImageBase::GetHeight() { */ int ImageBase::GetWidth() { int width; - imaqGetImageSize(m_imaqImage, &width, NULL); + imaqGetImageSize(m_imaqImage, &width, nullptr); return width; } diff --git a/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp index 1351939cba..2706360268 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp @@ -29,8 +29,8 @@ vector *MonoImage::DetectEllipses( EllipseMatch *e = imaqDetectEllipses(m_imaqImage, ellipseDescriptor, curveOptions, shapeDetectionOptions, roi, &numberOfMatches); - vector *ellipses = new vector; - if (e == NULL) { + auto ellipses = new vector; + if (e == nullptr) { return ellipses; } for (int i = 0; i < numberOfMatches; i++) { @@ -43,6 +43,6 @@ vector *MonoImage::DetectEllipses( vector *MonoImage::DetectEllipses( EllipseDescriptor *ellipseDescriptor) { vector *ellipses = - DetectEllipses(ellipseDescriptor, NULL, NULL, NULL); + DetectEllipses(ellipseDescriptor, nullptr, nullptr, nullptr); return ellipses; } diff --git a/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp index ef2dffe1ad..fe24dfba0e 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp @@ -16,7 +16,7 @@ RGBImage::RGBImage() : ColorImage(IMAQ_IMAGE_RGB) {} * @param fileName The path of the file to load. */ RGBImage::RGBImage(const char *fileName) : ColorImage(IMAQ_IMAGE_RGB) { - int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL); + int success = imaqReadFile(m_imaqImage, fileName, nullptr, nullptr); wpi_setImaqErrorWithContext(success, "Imaq ReadFile error"); } diff --git a/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp b/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp index 6e0b7ada3a..32bab7f48e 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp @@ -31,7 +31,7 @@ int VisionAPI_debugFlag = 1; * * @param type Type of image to create * @return Image* On success, this function returns the created image. On -* failure, it returns NULL. +* failure, it returns nullptr. */ Image* frcCreateImage(ImageType type) { return imaqCreateImage(type, DEFAULT_BORDER_SIZE); @@ -50,7 +50,7 @@ int frcDispose(void* object) { return imaqDispose(object); } * * @param functionName The name of the function * @param ... A list of pointers to structures that need to be disposed of. -* The last pointer in the list should always be set to NULL. +* The last pointer in the list should always be set to nullptr. * * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). @@ -63,7 +63,7 @@ int frcDispose(const char* functionName, ...) /* Variable argument list */ va_start(disposalPtrList, functionName); /* start of variable list */ disposalPtr = va_arg(disposalPtrList, void*); - while (disposalPtr != NULL) { + while (disposalPtr != nullptr) { success = imaqDispose(disposalPtr); if (!success) { returnValue = 0; @@ -78,7 +78,7 @@ int frcDispose(const char* functionName, ...) /* Variable argument list */ * Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL, IMAQ_IMAGE_RGB, * IMAQ_IMAGE_HSL. * -* @param dest Copy of image. On failure, dest is NULL. Must have already been +* @param dest Copy of image. On failure, dest is nullptr. Must have already been * created using frcCreateImage(). * When you are finished with the created image, dispose of it by calling * frcDispose(). @@ -135,13 +135,13 @@ int frcScale(Image* dest, const Image* source, int xScale, int yScale, * IMAQ_IMAGE_RGB, IMAQ_IMAGE_HSL, IMAQ_IMAGE_RGB_U64. * * @param image Image read in - * @param fileName File to read. Cannot be NULL + * @param fileName File to read. Cannot be nullptr * * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). */ int frcReadImage(Image* image, const char* fileName) { - return imaqReadFile(image, fileName, NULL, NULL); + return imaqReadFile(image, fileName, nullptr, nullptr); } /** @@ -168,14 +168,14 @@ int frcReadImage(Image* image, const char* fileName) { * PNG, TIFF, JPEG2000 8-bit, 16-bit, RGB, RGBU64 * * @param image Image to write -* @param fileName File to read. Cannot be NULL. The extension determines the +* @param fileName File to read. Cannot be nullptr. The extension determines the * file format that is written. * * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). */ int frcWriteImage(const Image* image, const char* fileName) { - RGBValue* colorTable = NULL; + RGBValue* colorTable = nullptr; return imaqWriteFile(image, fileName, colorTable); } @@ -214,7 +214,7 @@ int frcWriteImage(const Image* image, const char* fileName) { * @return On success, this function returns a report describing the pixel value * classification. * When you are finished with the report, dispose of it by calling frcDispose(). -* On failure, this function returns NULL. To get extended error information, +* On failure, this function returns nullptr. To get extended error information, * call GetLastError(). * */ @@ -233,24 +233,24 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min, success = imaqAddRectContour(pRoi, rect); if (!success) { GetLastVisionError(); - return NULL; + return nullptr; } /* make a mask from the ROI */ Image* pMask = frcCreateImage(IMAQ_IMAGE_U8); - success = imaqROIToMask(pMask, pRoi, fillValue, NULL, NULL); + success = imaqROIToMask(pMask, pRoi, fillValue, nullptr, nullptr); if (!success) { GetLastVisionError(); - frcDispose(__FUNCTION__, pRoi, NULL); - return NULL; + frcDispose(__FUNCTION__, pRoi, nullptr); + return nullptr; } /* get a histogram report */ - HistogramReport* pHr = NULL; + HistogramReport* pHr = nullptr; pHr = imaqHistogram(image, numClasses, min, max, pMask); /* clean up */ - frcDispose(__FUNCTION__, pRoi, pMask, NULL); + frcDispose(__FUNCTION__, pRoi, pMask, nullptr); return pHr; } @@ -268,7 +268,7 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min, * @param mask An optional mask image. This image must be an IMAQ_IMAGE_U8 image. * The function calculates the histogram using only those pixels in the image * whose -* corresponding pixels in the mask are non-zero. Set this parameter to NULL to +* corresponding pixels in the mask are non-zero. Set this parameter to nullptr to * calculate * the histogram of the entire image, or use the simplified call. * @@ -276,17 +276,17 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min, * classification * of each plane in a HistogramReport. * When you are finished with the report, dispose of it by calling frcDispose(). -* On failure, this function returns NULL. +* On failure, this function returns nullptr. * To get extended error information, call imaqGetLastError(). */ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, ColorMode mode) { - return frcColorHistogram(image, numClasses, mode, NULL); + return frcColorHistogram(image, numClasses, mode, nullptr); } ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, ColorMode mode, Image* mask) { - return imaqColorHistogram2((Image*)image, numClasses, mode, NULL, mask); + return imaqColorHistogram2((Image*)image, numClasses, mode, nullptr, mask); } /** @@ -299,7 +299,7 @@ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, * @param image The image whose pixel value the function queries * @param pixel The coordinates of the pixel that the function queries * @param value On return, the value of the specified image pixel. This parameter -* cannot be NULL. +* cannot be nullptr. * This data structure contains either grayscale, RGB, HSL, Complex or * RGBU64Value depending on the type of image. * @return On success: 1. On failure: 0. To get extended error information, call @@ -319,7 +319,7 @@ int frcGetPixelValue(const Image* image, Point pixel, PixelValue* value) { * as the Source image. It will contain only the filtered particles. * @param source The image containing the particles to filter. * @param criteria An array of criteria to apply to the particles in the source -* image. This array cannot be NULL. +* image. This array cannot be nullptr. * See the NIVisionCVI.chm help file for definitions of criteria. * @param criteriaCount The number of elements in the criteria array. * @param options Binary filter options, including rejectMatches, rejectBorder, @@ -371,7 +371,7 @@ int frcParticleFilter(Image* dest, Image* source, * GetLastError(). */ int frcMorphology(Image* dest, Image* source, MorphologyMethod method) { - return imaqMorphology(dest, source, method, NULL); + return imaqMorphology(dest, source, method, nullptr); } int frcMorphology(Image* dest, Image* source, MorphologyMethod method, @@ -539,7 +539,7 @@ int frcParticleAnalysis(Image* image, int particleNumber, * will be copied. Only those pixels in the Image Src (Small) image that * correspond to an equivalent non-zero pixel in the mask image are copied. All * other pixels keep their original values. The entire image is processed if Image -* Mask is NULL or this parameter is omitted. +* Mask is nullptr or this parameter is omitted. * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). * @@ -548,7 +548,7 @@ int frcParticleAnalysis(Image* image, int particleNumber, * minMatchScore = DEFAULT_MINMAX_SCORE (800) */ int frcEqualize(Image* dest, const Image* source, float min, float max) { - return frcEqualize(dest, source, min, max, NULL); + return frcEqualize(dest, source, min, max, nullptr); } int frcEqualize(Image* dest, const Image* source, float min, float max, @@ -695,11 +695,11 @@ int frcSimpleThreshold(Image* dest, const Image* source, float rangeMin, * @param mode The color space to perform the threshold in. valid values are: * IMAQ_RGB, IMAQ_HSL. * @param plane1Range The selection range for the first plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * @param plane2Range The selection range for the second plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * @param plane3Range The selection range for the third plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). @@ -726,11 +726,11 @@ int frcColorThreshold(Image* dest, const Image* source, ColorMode mode, * @param mode The color space to perform the threshold in. valid values are: * IMAQ_RGB, IMAQ_HSL. * @param plane1Range The selection range for the first plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * @param plane2Range The selection range for the second plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * @param plane3Range The selection range for the third plane of the image. Set -* this parameter to NULL to use a selection range from 0 to 255. +* this parameter to nullptr to use a selection range from 0 to 255. * * @return On success: 1. On failure: 0. To get extended error information, call * GetLastError(). @@ -784,11 +784,11 @@ int frcHueThreshold(Image* dest, const Image* source, const Range* hueRange, * @param image The source image that the function extracts the planes from. * @param mode The color space that the function extracts the planes from. Valid * values are IMAQ_RGB, IMAQ_HSL, IMAQ_HSV, IMAQ_HSI. -* @param plane1 On return, the first extracted plane. Set this parameter to NULL +* @param plane1 On return, the first extracted plane. Set this parameter to nullptr * if you do not need this information. RGB-Red, HSL/HSV/HSI-Hue. * @param plane2 On return, the second extracted plane. Set this parameter to -* NULL if you do not need this information. RGB-Green, HSL/HSV/HSI-Saturation. -* @param plane3 On return, the third extracted plane. Set this parameter to NULL +* nullptr if you do not need this information. RGB-Green, HSL/HSV/HSI-Saturation. +* @param plane3 On return, the third extracted plane. Set this parameter to nullptr * if you do not need this information. RGB-Blue, HSL-Luminance, HSV-Value, * HSI-Intensity. * @@ -816,5 +816,5 @@ int frcExtractHuePlane(const Image* image, Image* huePlane) { } int frcExtractHuePlane(const Image* image, Image* huePlane, int minSaturation) { - return frcExtractColorPlanes(image, IMAQ_HSL, huePlane, NULL, NULL); + return frcExtractColorPlanes(image, IMAQ_HSL, huePlane, nullptr, nullptr); } diff --git a/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp index 5066375458..7d600fcce6 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp @@ -297,9 +297,7 @@ TEST_F(CANJaguarTest, VoltageModeWorks) { float setpoints[] = {M_PI, 8.0f, -10.0f}; - for (unsigned int i = 0; i < sizeof(setpoints) / sizeof(setpoints[0]); i++) { - float setpoint = setpoints[i]; - + for (auto setpoint : setpoints) { SetJaguar(kMotorTime, setpoint); EXPECT_NEAR(setpoint, m_jaguar->GetOutputVoltage(), kVoltageTolerance); } @@ -354,9 +352,9 @@ TEST_F(CANJaguarTest, DISABLED_CurrentModeWorks) { float setpoints[] = {1.6f, 2.0f, -1.6f}; - for (unsigned int i = 0; i < sizeof(setpoints) / sizeof(setpoints[0]); i++) { - float setpoint = setpoints[i]; - float expectedCurrent = std::abs(setpoints[i]); + for (auto& setpoints_i : setpoints) { + float setpoint = setpoints_i; + float expectedCurrent = std::abs(setpoints_i); /* It should get to each setpoint within 10 seconds */ for (int j = 0; j < 10; j++) { diff --git a/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp index 3a920eaf73..8075ed7997 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp @@ -104,7 +104,7 @@ static void *InterruptTriggerer(void *data) { output->Set(false); Wait(kSynchronousInterruptTime); output->Set(true); - return NULL; + return nullptr; } TEST_F(DIOLoopTest, SynchronousInterruptWorks) { @@ -113,7 +113,7 @@ TEST_F(DIOLoopTest, SynchronousInterruptWorks) { // If we have another thread trigger the interrupt in a few seconds pthread_t interruptTriggererLoop; - pthread_create(&interruptTriggererLoop, NULL, InterruptTriggerer, m_output); + pthread_create(&interruptTriggererLoop, nullptr, InterruptTriggerer, m_output); // Then this thread should pause and resume after that number of seconds Timer timer; diff --git a/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp index 475693fc09..7c4da8aa20 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp @@ -32,7 +32,7 @@ class MotorInvertingTest protected: SpeedController *m_speedController; Encoder *m_encoder; - virtual void SetUp() { + virtual void SetUp() override { switch (GetParam()) { case TEST_VICTOR: m_speedController = new Victor(TestBench::kVictorChannel); @@ -53,7 +53,7 @@ class MotorInvertingTest break; } } - virtual void TearDown() { + virtual void TearDown() override { delete m_speedController; delete m_encoder; } diff --git a/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp index 8258ad1b9d..18f69a63db 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp @@ -19,8 +19,8 @@ void notifierHandler(void *) { notifierCounter++; } TEST(NotifierTest, DISABLED_TestTimerNotifications) { std::cout << "NotifierTest..." << std::endl; notifierCounter = 0; - std::cout << "notifier(notifierHandler, NULL)..." << std::endl; - Notifier notifier(notifierHandler, NULL); + std::cout << "notifier(notifierHandler, nullptr)..." << std::endl; + Notifier notifier(notifierHandler, nullptr); std::cout << "Start Periodic..." << std::endl; notifier.StartPeriodic(1.0); diff --git a/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp index 69b939cf6e..796f45a0ec 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp @@ -63,14 +63,14 @@ TEST(PreferencesTest, WritePreferencesToFile) { "testFileGetLong=\"1000000000000000000\""}; std::ifstream preferencesFile(kFileName); - for (int i = 0; i < 7; i++) { + for (auto& kExpectedFileContent : kExpectedFileContents) { ASSERT_FALSE(preferencesFile.eof()) << "Preferences file prematurely reached EOF"; std::string line; std::getline(preferencesFile, line); - ASSERT_EQ(kExpectedFileContents[i], line) + ASSERT_EQ(kExpectedFileContent, line) << "A line in wpilib-preferences.ini was not correct"; } } diff --git a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp index caa5c42b1d..078044332c 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp @@ -58,7 +58,7 @@ class TiltPanCameraTest : public testing::Test { } }; -Gyro *TiltPanCameraTest::m_gyro = 0; +Gyro *TiltPanCameraTest::m_gyro = nullptr; /** * Test if the gyro angle defaults to 0 immediately after being reset. diff --git a/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp index 9c7ede98ce..c71d15ab45 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp @@ -44,10 +44,10 @@ class ASubsystem : public Subsystem { Command *m_command; public: - ASubsystem(const char *name) : Subsystem(name) { m_command = NULL; } + ASubsystem(const char *name) : Subsystem(name) { m_command = nullptr; } virtual void InitDefaultCommand() override { - if (m_command != NULL) { + if (m_command != nullptr) { SetDefaultCommand(m_command); } } @@ -214,7 +214,7 @@ TEST_F(CommandTest, ThreeCommandOnSubSystem) { // CommandSequentialGroupTest ported from CommandSequentialGroupTest.java TEST_F(CommandTest, OneCommandSupersedingAnotherBecauseOfDependencies) { - ASubsystem *subsystem = new ASubsystem("Command Superseding Test Subsystem"); + auto subsystem = new ASubsystem("Command Superseding Test Subsystem"); MockCommand command1; command1.Requires(subsystem); MockCommand command2; diff --git a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h index 12923c893f..82db41d485 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h +++ b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h @@ -10,7 +10,7 @@ using namespace gazebo; class MainNode { public: static MainNode* GetInstance() { - if (instance == NULL) { + if (instance == nullptr) { instance = new MainNode(); } return instance; diff --git a/wpilibc/wpilibC++Sim/src/AnalogInput.cpp b/wpilibc/wpilibC++Sim/src/AnalogInput.cpp index 479f586f4c..3be39bb133 100644 --- a/wpilibc/wpilibC++Sim/src/AnalogInput.cpp +++ b/wpilibc/wpilibC++Sim/src/AnalogInput.cpp @@ -13,7 +13,7 @@ */ void AnalogInput::InitAnalogInput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; m_channel = channel; char buffer[50]; @@ -82,7 +82,7 @@ double AnalogInput::PIDGet() const } void AnalogInput::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetAverageVoltage()); } } diff --git a/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp b/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp index 97dac4374f..2685cbc98b 100644 --- a/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp +++ b/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp @@ -67,7 +67,7 @@ void AnalogPotentiometer::InitTable(ITable *subtable) { } void AnalogPotentiometer::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", Get()); } } diff --git a/wpilibc/wpilibC++Sim/src/DigitalInput.cpp b/wpilibc/wpilibC++Sim/src/DigitalInput.cpp index cebbf80979..40775660cd 100644 --- a/wpilibc/wpilibC++Sim/src/DigitalInput.cpp +++ b/wpilibc/wpilibC++Sim/src/DigitalInput.cpp @@ -14,7 +14,7 @@ */ void DigitalInput::InitDigitalInput(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; m_channel = channel; int n = sprintf(buf, "dio/%d", channel); @@ -57,7 +57,7 @@ uint32_t DigitalInput::GetChannel() const } void DigitalInput::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("Value", Get()); } } diff --git a/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp b/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp index 0d418fc0dc..87e26aebba 100644 --- a/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp +++ b/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp @@ -102,21 +102,21 @@ void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryV } void DoubleSolenoid::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutString("Value", (Get() == kForward ? "Forward" : (Get() == kReverse ? "Reverse" : "Off"))); } } void DoubleSolenoid::StartLiveWindowMode() { Set(kOff); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void DoubleSolenoid::StopLiveWindowMode() { Set(kOff); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Sim/src/DriverStation.cpp b/wpilibc/wpilibC++Sim/src/DriverStation.cpp index da75f4249e..63af0f2ebd 100644 --- a/wpilibc/wpilibC++Sim/src/DriverStation.cpp +++ b/wpilibc/wpilibC++Sim/src/DriverStation.cpp @@ -26,7 +26,7 @@ const uint32_t DriverStation::kBatteryChannel; const uint32_t DriverStation::kJoystickPorts; const uint32_t DriverStation::kJoystickAxes; constexpr float DriverStation::kUpdatePeriod; -DriverStation* DriverStation::m_instance = NULL; +DriverStation* DriverStation::m_instance = nullptr; uint8_t DriverStation::m_updateNumber = 0; /** @@ -77,7 +77,7 @@ DriverStation::DriverStation() DriverStation::~DriverStation() { - m_instance = NULL; + m_instance = nullptr; deleteMultiWait(m_waitForDataSem); deleteMutex(m_waitForDataMutex); // TODO: Release m_stateSemaphore and m_joystickSemaphore? @@ -88,7 +88,7 @@ DriverStation::~DriverStation() */ DriverStation* DriverStation::GetInstance() { - if (m_instance == NULL) + if (m_instance == nullptr) { m_instance = new DriverStation(); } @@ -126,7 +126,7 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) return 0.0; } CRITICAL_REGION(m_joystickSemaphore) - if (joysticks[stick] == NULL || axis >= joysticks[stick]->axes().size()) + if (joysticks[stick] == nullptr || axis >= joysticks[stick]->axes().size()) { return 0.0; } @@ -150,7 +150,7 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) return false; } CRITICAL_REGION(m_joystickSemaphore) - if (joysticks[stick] == NULL || button >= joysticks[stick]->buttons().size()) + if (joysticks[stick] == nullptr || button >= joysticks[stick]->buttons().size()) { return false; } @@ -243,7 +243,7 @@ bool DriverStation::GetDigitalOut(uint32_t channel) bool DriverStation::IsEnabled() const { CRITICAL_REGION(m_stateSemaphore) - return state != NULL ? state->enabled() : false; + return state != nullptr ? state->enabled() : false; END_REGION } @@ -255,7 +255,7 @@ bool DriverStation::IsDisabled() const bool DriverStation::IsAutonomous() const { CRITICAL_REGION(m_stateSemaphore) - return state != NULL ? + return state != nullptr ? state->state() == msgs::DriverStation_State_AUTO : false; END_REGION; } @@ -268,7 +268,7 @@ bool DriverStation::IsOperatorControl() const bool DriverStation::IsTest() const { CRITICAL_REGION(m_stateSemaphore) - return state != NULL ? + return state != nullptr ? state->state() == msgs::DriverStation_State_TEST : false; END_REGION; } diff --git a/wpilibc/wpilibC++Sim/src/Encoder.cpp b/wpilibc/wpilibC++Sim/src/Encoder.cpp index fc40ead0e4..8d3d2a5206 100644 --- a/wpilibc/wpilibC++Sim/src/Encoder.cpp +++ b/wpilibc/wpilibC++Sim/src/Encoder.cpp @@ -24,7 +24,7 @@ */ void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, EncodingType encodingType) { - m_table = NULL; + m_table = nullptr; this->channelA = channelA; this->channelB = channelB; m_encodingType = encodingType; @@ -92,14 +92,14 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, En * or be double (2x) the spec'd count. */ /* TODO: [Not Supported] Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection, EncodingType encodingType) : - m_encoder(NULL), - m_counter(NULL) + m_encoder(nullptr), + m_counter(nullptr) { m_aSource = aSource; m_bSource = bSource; m_allocatedASource = false; m_allocatedBSource = false; - if (m_aSource == NULL || m_bSource == NULL) + if (m_aSource == nullptr || m_bSource == nullptr) wpi_setWPIError(NullParameter); else InitEncoder(reverseDirection, encodingType); @@ -124,8 +124,8 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, En * or be double (2x) the spec'd count. */ /*// TODO: [Not Supported] Encoder::Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection, EncodingType encodingType) : - m_encoder(NULL), - m_counter(NULL) + m_encoder(nullptr), + m_counter(nullptr) { m_aSource = &aSource; m_bSource = &bSource; @@ -342,7 +342,7 @@ double Encoder::PIDGet() const } void Encoder::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Speed", GetRate()); m_table->PutNumber("Distance", GetDistance()); m_table->PutNumber("Distance per Tick", m_reverseDirection ? -m_distancePerPulse : m_distancePerPulse); diff --git a/wpilibc/wpilibC++Sim/src/Gyro.cpp b/wpilibc/wpilibC++Sim/src/Gyro.cpp index 63c6427376..fe66793f83 100644 --- a/wpilibc/wpilibC++Sim/src/Gyro.cpp +++ b/wpilibc/wpilibC++Sim/src/Gyro.cpp @@ -25,7 +25,7 @@ constexpr float Gyro::kDefaultVoltsPerDegreePerSecond; */ void Gyro::InitGyro(int channel) { - m_table = NULL; + m_table = nullptr; SetPIDSourceParameter(kAngle); char buffer[50]; @@ -116,7 +116,7 @@ double Gyro::PIDGet() const } void Gyro::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetAngle()); } } diff --git a/wpilibc/wpilibC++Sim/src/Joystick.cpp b/wpilibc/wpilibC++Sim/src/Joystick.cpp index 372f7cc9b1..a116f21248 100644 --- a/wpilibc/wpilibC++Sim/src/Joystick.cpp +++ b/wpilibc/wpilibC++Sim/src/Joystick.cpp @@ -26,10 +26,10 @@ static bool joySticksInitialized = false; * @param port The port on the driver station that the joystick is plugged into. */ Joystick::Joystick(uint32_t port) - : m_ds (NULL) + : m_ds (nullptr) , m_port (port) - , m_axes (NULL) - , m_buttons (NULL) + , m_axes (nullptr) + , m_buttons (nullptr) { InitJoystick(kNumAxisTypes, kNumButtonTypes); @@ -54,10 +54,10 @@ Joystick::Joystick(uint32_t port) * @param numButtonTypes The number of button types in the enum. */ Joystick::Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes) - : m_ds (NULL) + : m_ds (nullptr) , m_port (port) - , m_axes (NULL) - , m_buttons (NULL) + , m_axes (nullptr) + , m_buttons (nullptr) { InitJoystick(numAxisTypes, numButtonTypes); } @@ -67,7 +67,7 @@ void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) if ( !joySticksInitialized ) { for (unsigned i = 0; i < DriverStation::kJoystickPorts; i++) - joysticks[i] = NULL; + joysticks[i] = nullptr; joySticksInitialized = true; } joysticks[m_port] = this; @@ -80,7 +80,7 @@ void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) Joystick * Joystick::GetStickForPort(uint32_t port) { Joystick *stick = joysticks[port]; - if (stick == NULL) + if (stick == nullptr) { stick = new Joystick(port); joysticks[port] = stick; diff --git a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp index 040ff10edc..8af177a15b 100644 --- a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp +++ b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp @@ -13,7 +13,7 @@ #include -MotorSafetyHelper *MotorSafetyHelper::m_headHelper = NULL; +MotorSafetyHelper *MotorSafetyHelper::m_headHelper = nullptr; ReentrantSemaphore MotorSafetyHelper::m_listMutex; /** @@ -47,9 +47,9 @@ MotorSafetyHelper::~MotorSafetyHelper() } else { - MotorSafetyHelper *prev = NULL; + MotorSafetyHelper *prev = nullptr; MotorSafetyHelper *cur = m_headHelper; - while (cur != this && cur != NULL) + while (cur != this && cur != nullptr) prev = cur, cur = cur->m_nextHelper; if (cur == this) prev->m_nextHelper = cur->m_nextHelper; @@ -149,7 +149,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const void MotorSafetyHelper::CheckMotors() { Synchronized sync(m_listMutex); - for (MotorSafetyHelper *msh = m_headHelper; msh != NULL; msh = msh->m_nextHelper) + for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr; msh = msh->m_nextHelper) { msh->Check(); } diff --git a/wpilibc/wpilibC++Sim/src/Notifier.cpp b/wpilibc/wpilibC++Sim/src/Notifier.cpp index bf16c1002a..4ad630ae15 100644 --- a/wpilibc/wpilibC++Sim/src/Notifier.cpp +++ b/wpilibc/wpilibC++Sim/src/Notifier.cpp @@ -9,9 +9,9 @@ #include "Utility.h" #include "WPIErrors.h" -Notifier *Notifier::timerQueueHead = NULL; +Notifier *Notifier::timerQueueHead = nullptr; ReentrantSemaphore Notifier::queueSemaphore; -Task* Notifier::task = NULL; +Task* Notifier::task = nullptr; int Notifier::refcount = 0; /** @@ -21,14 +21,14 @@ int Notifier::refcount = 0; */ Notifier::Notifier(TimerEventHandler handler, void *param) { - if (handler == NULL) - wpi_setWPIErrorWithContext(NullParameter, "handler must not be NULL"); + if (handler == nullptr) + wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr"); m_handler = handler; m_param = param; m_periodic = false; m_expirationTime = 0; m_period = 0; - m_nextEvent = NULL; + m_nextEvent = nullptr; m_queued = false; m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL); { @@ -95,7 +95,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params) Synchronized sync(queueSemaphore); double currentTime = GetClock(); current = timerQueueHead; - if (current == NULL || current->m_expirationTime > currentTime) + if (current == nullptr || current->m_expirationTime > currentTime) { break; // no more timer events to process } @@ -144,7 +144,7 @@ void Notifier::InsertInQueue(bool reschedule) { m_expirationTime = GetClock() + m_period; } - if (timerQueueHead == NULL || timerQueueHead->m_expirationTime >= this->m_expirationTime) + if (timerQueueHead == nullptr || timerQueueHead->m_expirationTime >= this->m_expirationTime) { // the queue is empty or greater than the new entry // the new entry becomes the first element @@ -161,7 +161,7 @@ void Notifier::InsertInQueue(bool reschedule) for (Notifier **npp = &(timerQueueHead->m_nextEvent); ; npp = &(*npp)->m_nextEvent) { Notifier *n = *npp; - if (n == NULL || n->m_expirationTime > this->m_expirationTime) + if (n == nullptr || n->m_expirationTime > this->m_expirationTime) { *npp = this; this->m_nextEvent = n; @@ -184,7 +184,7 @@ void Notifier::DeleteFromQueue() if (m_queued) { m_queued = false; - wpi_assert(timerQueueHead != NULL); + wpi_assert(timerQueueHead != nullptr); if (timerQueueHead == this) { // remove the first item in the list - update the alarm @@ -193,7 +193,7 @@ void Notifier::DeleteFromQueue() } else { - for (Notifier *n = timerQueueHead; n != NULL; n = n->m_nextEvent) + for (Notifier *n = timerQueueHead; n != nullptr; n = n->m_nextEvent) { if (n->m_nextEvent == this) { @@ -253,8 +253,8 @@ void Notifier::Stop() void Notifier::Run() { while (true) { - Notifier::ProcessQueue(0, NULL); - if (timerQueueHead != NULL) + Notifier::ProcessQueue(0, nullptr); + if (timerQueueHead != nullptr) { Wait(timerQueueHead->m_expirationTime - GetClock()); } diff --git a/wpilibc/wpilibC++Sim/src/PIDController.cpp b/wpilibc/wpilibC++Sim/src/PIDController.cpp index 97f5b233b9..e929b594a0 100644 --- a/wpilibc/wpilibC++Sim/src/PIDController.cpp +++ b/wpilibc/wpilibC++Sim/src/PIDController.cpp @@ -60,7 +60,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf, PIDSource *source, PIDOutput *output, float period) { - m_table = NULL; + m_table = nullptr; m_P = Kp; m_I = Ki; @@ -211,7 +211,7 @@ void PIDController::SetPID(double p, double i, double d) } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("p", m_P); m_table->PutNumber("i", m_I); m_table->PutNumber("d", m_D); @@ -237,7 +237,7 @@ void PIDController::SetPID(double p, double i, double d, double f) } END_REGION; - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("p", m_P); m_table->PutNumber("i", m_I); m_table->PutNumber("d", m_D); @@ -386,9 +386,9 @@ void PIDController::SetSetpoint(float setpoint) m_setpoint = setpoint; } } - END_REGION; - - if (m_table != NULL) { + END_REGION; + + if (m_table != nullptr) { m_table->PutNumber("setpoint", m_setpoint); } } @@ -504,9 +504,9 @@ void PIDController::Enable() { m_enabled = true; } - END_REGION; - - if (m_table != NULL) { + END_REGION; + + if (m_table != nullptr) { m_table->PutBoolean("enabled", true); } } @@ -522,8 +522,8 @@ void PIDController::Disable() m_enabled = false; } END_REGION; - - if (m_table != NULL) { + + if (m_table != nullptr) { m_table->PutBoolean("enabled", false); } } @@ -563,10 +563,10 @@ std::string PIDController::GetSmartDashboardType() const { } void PIDController::InitTable(ITable* table){ - if(m_table!=NULL) + if(m_table!=nullptr) m_table->RemoveTableListener(this); m_table = table; - if(m_table!=NULL){ + if(m_table!=nullptr){ m_table->PutNumber(kP, GetP()); m_table->PutNumber(kI, GetI()); m_table->PutNumber(kD, GetD()); diff --git a/wpilibc/wpilibC++Sim/src/PWM.cpp b/wpilibc/wpilibC++Sim/src/PWM.cpp index 2f63f93abf..eeabbfe886 100644 --- a/wpilibc/wpilibC++Sim/src/PWM.cpp +++ b/wpilibc/wpilibC++Sim/src/PWM.cpp @@ -24,7 +24,7 @@ const int32_t PWM::kPwmDisabled; */ void PWM::InitPWM(uint32_t channel) { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!CheckPWMChannel(channel)) @@ -240,21 +240,21 @@ void PWM::ValueChanged(ITable* source, const std::string& key, EntryValue value, } void PWM::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutNumber("Value", GetSpeed()); } } void PWM::StartLiveWindowMode() { SetSpeed(0); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void PWM::StopLiveWindowMode() { SetSpeed(0); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Sim/src/Relay.cpp b/wpilibc/wpilibC++Sim/src/Relay.cpp index bbcd4425ba..ae6f3b8a32 100644 --- a/wpilibc/wpilibC++Sim/src/Relay.cpp +++ b/wpilibc/wpilibC++Sim/src/Relay.cpp @@ -17,7 +17,7 @@ */ void Relay::InitRelay() { - m_table = NULL; + m_table = nullptr; char buf[64]; if (!SensorBase::CheckRelayChannel(m_channel)) { @@ -156,7 +156,7 @@ void Relay::ValueChanged(ITable* source, const std::string& key, EntryValue valu } void Relay::UpdateTable() { - if(m_table != NULL){ + if(m_table != nullptr){ if (Get() == kOn) { m_table->PutString("Value", "On"); } @@ -173,13 +173,13 @@ void Relay::UpdateTable() { } void Relay::StartLiveWindowMode() { - if(m_table != NULL){ + if(m_table != nullptr){ m_table->AddTableListener("Value", this, true); } } void Relay::StopLiveWindowMode() { - if(m_table != NULL){ + if(m_table != nullptr){ m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Sim/src/RobotBase.cpp b/wpilibc/wpilibC++Sim/src/RobotBase.cpp index 1fb710a42e..08f8f589d7 100644 --- a/wpilibc/wpilibC++Sim/src/RobotBase.cpp +++ b/wpilibc/wpilibC++Sim/src/RobotBase.cpp @@ -10,11 +10,11 @@ #include -RobotBase* RobotBase::m_instance = NULL; +RobotBase* RobotBase::m_instance = nullptr; void RobotBase::setInstance(RobotBase* robot) { - wpi_assert(m_instance == NULL); + wpi_assert(m_instance == nullptr); m_instance = robot; } diff --git a/wpilibc/wpilibC++Sim/src/RobotDrive.cpp b/wpilibc/wpilibC++Sim/src/RobotDrive.cpp index 58468b73a5..6493afc48a 100644 --- a/wpilibc/wpilibC++Sim/src/RobotDrive.cpp +++ b/wpilibc/wpilibC++Sim/src/RobotDrive.cpp @@ -32,10 +32,10 @@ const int32_t RobotDrive::kMaxNumberOfMotors; * initialize all the motor assignments. The default timeout is set for the robot drive. */ void RobotDrive::InitRobotDrive() { - m_frontLeftMotor = NULL; - m_frontRightMotor = NULL; - m_rearRightMotor = NULL; - m_rearLeftMotor = NULL; + m_frontLeftMotor = nullptr; + m_frontRightMotor = nullptr; + m_rearRightMotor = nullptr; + m_rearLeftMotor = nullptr; m_sensitivity = 0.5; m_maxOutput = 1.0; // FIXME: m_safetyHelper = new MotorSafetyHelper(this); @@ -99,10 +99,10 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor, RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor) { InitRobotDrive(); - if (leftMotor == NULL || rightMotor == NULL) + if (leftMotor == nullptr || rightMotor == nullptr) { wpi_setWPIError(NullParameter); - m_rearLeftMotor = m_rearRightMotor = NULL; + m_rearLeftMotor = m_rearRightMotor = nullptr; return; } m_rearLeftMotor = leftMotor; @@ -138,7 +138,7 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLef SpeedController *frontRightMotor, SpeedController *rearRightMotor) { InitRobotDrive(); - if (frontLeftMotor == NULL || rearLeftMotor == NULL || frontRightMotor == NULL || rearRightMotor == NULL) + if (frontLeftMotor == nullptr || rearLeftMotor == nullptr || frontRightMotor == nullptr || rearRightMotor == nullptr) { wpi_setWPIError(NullParameter); return; @@ -239,7 +239,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve) */ void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs) { - if (leftStick == NULL || rightStick == NULL) + if (leftStick == nullptr || rightStick == nullptr) { wpi_setWPIError(NullParameter); return; @@ -264,7 +264,7 @@ void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick, bool s void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis, GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs) { - if (leftStick == NULL || rightStick == NULL) + if (leftStick == nullptr || rightStick == nullptr) { wpi_setWPIError(NullParameter); return; @@ -586,15 +586,15 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction, float rotation */ void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) { - wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL); + wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr); uint8_t syncGroup = 0x80; - if (m_frontLeftMotor != NULL) + if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, syncGroup); m_rearLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kRearLeftMotor] * m_maxOutput, syncGroup); - if (m_frontRightMotor != NULL) + if (m_frontRightMotor != nullptr) m_frontRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kFrontRightMotor] * m_maxOutput, syncGroup); m_rearRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kRearRightMotor] * m_maxOutput, syncGroup); @@ -725,8 +725,8 @@ void RobotDrive::GetDescription(char *desc) const void RobotDrive::StopMotor() { - if (m_frontLeftMotor != NULL) m_frontLeftMotor->Disable(); - if (m_frontRightMotor != NULL) m_frontRightMotor->Disable(); - if (m_rearLeftMotor != NULL) m_rearLeftMotor->Disable(); - if (m_rearRightMotor != NULL) m_rearRightMotor->Disable(); + if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Disable(); + if (m_frontRightMotor != nullptr) m_frontRightMotor->Disable(); + if (m_rearLeftMotor != nullptr) m_rearLeftMotor->Disable(); + if (m_rearRightMotor != nullptr) m_rearRightMotor->Disable(); } diff --git a/wpilibc/wpilibC++Sim/src/SensorBase.cpp b/wpilibc/wpilibC++Sim/src/SensorBase.cpp index 80db28c5c3..cadf41be36 100644 --- a/wpilibc/wpilibC++Sim/src/SensorBase.cpp +++ b/wpilibc/wpilibC++Sim/src/SensorBase.cpp @@ -16,7 +16,7 @@ const uint32_t SensorBase::kPwmChannels; const uint32_t SensorBase::kRelayChannels; const uint32_t SensorBase::kPDPChannels; const uint32_t SensorBase::kChassisSlots; -SensorBase *SensorBase::m_singletonList = NULL; +SensorBase *SensorBase::m_singletonList = nullptr; /** * Creates an instance of the sensor base and gets an FPGA handle @@ -54,13 +54,13 @@ void SensorBase::AddToSingletonList() */ void SensorBase::DeleteSingletons() { - for (SensorBase *next = m_singletonList; next != NULL;) + for (SensorBase *next = m_singletonList; next != nullptr;) { SensorBase *tmp = next; next = next->m_nextSingleton; delete tmp; } - m_singletonList = NULL; + m_singletonList = nullptr; } /** diff --git a/wpilibc/wpilibC++Sim/src/Solenoid.cpp b/wpilibc/wpilibC++Sim/src/Solenoid.cpp index c3622992ab..02d52b33a4 100644 --- a/wpilibc/wpilibC++Sim/src/Solenoid.cpp +++ b/wpilibc/wpilibC++Sim/src/Solenoid.cpp @@ -76,21 +76,21 @@ void Solenoid::ValueChanged(ITable* source, const std::string& key, EntryValue v } void Solenoid::UpdateTable() { - if (m_table != NULL) { + if (m_table != nullptr) { m_table->PutBoolean("Value", Get()); } } void Solenoid::StartLiveWindowMode() { Set(false); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->AddTableListener("Value", this, true); } } void Solenoid::StopLiveWindowMode() { Set(false); - if (m_table != NULL) { + if (m_table != nullptr) { m_table->RemoveTableListener(this); } } diff --git a/wpilibc/wpilibC++Sim/src/Task.cpp b/wpilibc/wpilibC++Sim/src/Task.cpp index 7b603c470e..80a212e08d 100644 --- a/wpilibc/wpilibC++Sim/src/Task.cpp +++ b/wpilibc/wpilibC++Sim/src/Task.cpp @@ -38,7 +38,7 @@ Task::~Task() { if (m_taskID != NULL_TASK) Stop(); delete [] m_taskName; - m_taskName = NULL; + m_taskName = nullptr; } /** @@ -159,7 +159,7 @@ bool Task::SetPriority(int32_t priority) /** * Returns the name of the task. - * @returns Pointer to the name of the task or NULL if not allocated + * @returns Pointer to the name of the task or nullptr if not allocated */ const char* Task::GetName() const { diff --git a/wpilibc/wpilibC++Sim/src/Utility.cpp b/wpilibc/wpilibC++Sim/src/Utility.cpp index e1bf26d554..c5e78c2d8e 100644 --- a/wpilibc/wpilibC++Sim/src/Utility.cpp +++ b/wpilibc/wpilibC++Sim/src/Utility.cpp @@ -71,7 +71,7 @@ bool wpi_assert_impl(bool conditionValue, // If an error message was specified, include it // Build error string - if(message != NULL) { + if(message != nullptr) { sprintf(error, "Assertion failed: \"%s\", \"%s\" failed in %s() in %s at line %dd\n", message, conditionText, funcName, fileName, lineNumber); } else { @@ -106,7 +106,7 @@ void wpi_assertEqual_common_impl(int valueA, // If an error message was specified, include it // Build error string - if(message != NULL) { + if(message != nullptr) { sprintf(error, "Assertion failed: \"%s\", \"%d\" %s \"%d\" in %s() in %s at line %d\n", message, valueA, equalityType, valueB, funcName, fileName, lineNumber); } else { @@ -183,7 +183,7 @@ static std::string demangle(char const *mangledSymbol) if(sscanf(mangledSymbol, "%*[^(]%*[^_]%255[^)+]", buffer)) { - char *symbol = abi::__cxa_demangle(buffer, NULL, &length, &status); + char *symbol = abi::__cxa_demangle(buffer, nullptr, &length, &status); if(status == 0) { diff --git a/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp b/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp index dafbac2ff6..ef00026d6d 100644 --- a/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp +++ b/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp @@ -1,3 +1,3 @@ #include "simulation/MainNode.h" -MainNode* MainNode::instance = NULL; +MainNode* MainNode::instance = nullptr; diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp index de7a6ca657..c22631fed2 100644 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp +++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp @@ -21,9 +21,9 @@ namespace msgs { namespace { -const ::google::protobuf::Descriptor* Bool_descriptor_ = NULL; +const ::google::protobuf::Descriptor* Bool_descriptor_ = nullptr; const ::google::protobuf::internal::GeneratedMessageReflection* - Bool_reflection_ = NULL; + Bool_reflection_ = nullptr; } // namespace @@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2fbool_2eproto() { const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "msgs/bool.proto"); - GOOGLE_CHECK(file != NULL); + GOOGLE_CHECK(file != nullptr); Bool_descriptor_ = file->message_type(0); static const int Bool_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, data_), @@ -141,11 +141,11 @@ const ::google::protobuf::Descriptor* Bool::descriptor() { } const Bool& Bool::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fbool_2eproto(); + if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fbool_2eproto(); return *default_instance_; } -Bool* Bool::default_instance_ = NULL; +Bool* Bool::default_instance_ = nullptr; Bool* Bool::New() const { return new Bool; @@ -249,7 +249,7 @@ void Bool::MergeFrom(const ::google::protobuf::Message& from) { const Bool* source = ::google::protobuf::internal::dynamic_cast_if_available( &from); - if (source == NULL) { + if (source == nullptr) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp index 01ca2daaa0..4f5289139f 100644 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp +++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp @@ -21,10 +21,10 @@ namespace msgs { namespace { -const ::google::protobuf::Descriptor* DriverStation_descriptor_ = NULL; +const ::google::protobuf::Descriptor* DriverStation_descriptor_ = nullptr; const ::google::protobuf::internal::GeneratedMessageReflection* - DriverStation_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = NULL; + DriverStation_reflection_ = nullptr; +const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = nullptr; } // namespace @@ -34,7 +34,7 @@ void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto() { const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "msgs/driver-station.proto"); - GOOGLE_CHECK(file != NULL); + GOOGLE_CHECK(file != nullptr); DriverStation_descriptor_ = file->message_type(0); static const int DriverStation_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, enabled_), @@ -172,11 +172,11 @@ const ::google::protobuf::Descriptor* DriverStation::descriptor() { } const DriverStation& DriverStation::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); + if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); return *default_instance_; } -DriverStation* DriverStation::default_instance_ = NULL; +DriverStation* DriverStation::default_instance_ = nullptr; DriverStation* DriverStation::New() const { return new DriverStation; @@ -320,7 +320,7 @@ void DriverStation::MergeFrom(const ::google::protobuf::Message& from) { const DriverStation* source = ::google::protobuf::internal::dynamic_cast_if_available( &from); - if (source == NULL) { + if (source == nullptr) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp index e9462c04f4..37701e1dbb 100644 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp +++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp @@ -21,9 +21,9 @@ namespace msgs { namespace { -const ::google::protobuf::Descriptor* Float64_descriptor_ = NULL; +const ::google::protobuf::Descriptor* Float64_descriptor_ = nullptr; const ::google::protobuf::internal::GeneratedMessageReflection* - Float64_reflection_ = NULL; + Float64_reflection_ = nullptr; } // namespace @@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2ffloat64_2eproto() { const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "msgs/float64.proto"); - GOOGLE_CHECK(file != NULL); + GOOGLE_CHECK(file != nullptr); Float64_descriptor_ = file->message_type(0); static const int Float64_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, data_), @@ -141,11 +141,11 @@ const ::google::protobuf::Descriptor* Float64::descriptor() { } const Float64& Float64::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2ffloat64_2eproto(); + if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2ffloat64_2eproto(); return *default_instance_; } -Float64* Float64::default_instance_ = NULL; +Float64* Float64::default_instance_ = nullptr; Float64* Float64::New() const { return new Float64; @@ -249,7 +249,7 @@ void Float64::MergeFrom(const ::google::protobuf::Message& from) { const Float64* source = ::google::protobuf::internal::dynamic_cast_if_available( &from); - if (source == NULL) { + if (source == nullptr) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp index 11a2d5ea3d..8677b26a14 100644 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp +++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp @@ -21,9 +21,9 @@ namespace msgs { namespace { -const ::google::protobuf::Descriptor* Joystick_descriptor_ = NULL; +const ::google::protobuf::Descriptor* Joystick_descriptor_ = nullptr; const ::google::protobuf::internal::GeneratedMessageReflection* - Joystick_reflection_ = NULL; + Joystick_reflection_ = nullptr; } // namespace @@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2fjoystick_2eproto() { const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "msgs/joystick.proto"); - GOOGLE_CHECK(file != NULL); + GOOGLE_CHECK(file != nullptr); Joystick_descriptor_ = file->message_type(0); static const int Joystick_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, axes_), @@ -143,11 +143,11 @@ const ::google::protobuf::Descriptor* Joystick::descriptor() { } const Joystick& Joystick::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fjoystick_2eproto(); + if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fjoystick_2eproto(); return *default_instance_; } -Joystick* Joystick::default_instance_ = NULL; +Joystick* Joystick::default_instance_ = nullptr; Joystick* Joystick::New() const { return new Joystick; @@ -300,7 +300,7 @@ void Joystick::MergeFrom(const ::google::protobuf::Message& from) { const Joystick* source = ::google::protobuf::internal::dynamic_cast_if_available( &from); - if (source == NULL) { + if (source == nullptr) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source);