mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
artf4107: clang-modernize was run on WPILib
Loops were converted to their range-based equivalents, variable types were replaced with auto where the type was already specified on the same line, the override keyword was added, and instances of NULL and assignments of 0 to pointers were replaced with nullptr. Change-Id: If281e46a2e2e1c37f278d56df9915236d4b2c864
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user