mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Cleaned up integer type usage in wpilibc (#92)
Replaced all unsigned types to signed and int32_t with int in wpilibc
This commit is contained in:
committed by
Peter Johnson
parent
ff93050b31
commit
0cd05d1a42
@@ -28,7 +28,7 @@ class ErrorBase;
|
||||
*/
|
||||
class Error {
|
||||
public:
|
||||
typedef int32_t Code;
|
||||
typedef int Code;
|
||||
|
||||
Error() = default;
|
||||
|
||||
@@ -40,12 +40,12 @@ class Error {
|
||||
std::string GetMessage() const;
|
||||
std::string GetFilename() const;
|
||||
std::string GetFunction() const;
|
||||
uint32_t GetLineNumber() const;
|
||||
int GetLineNumber() const;
|
||||
const ErrorBase* GetOriginatingObject() const;
|
||||
double GetTimestamp() const;
|
||||
void Clear();
|
||||
void Set(Code code, llvm::StringRef contextMessage, llvm::StringRef filename,
|
||||
llvm::StringRef function, uint32_t lineNumber,
|
||||
llvm::StringRef function, int lineNumber,
|
||||
const ErrorBase* originatingObject);
|
||||
|
||||
private:
|
||||
@@ -55,7 +55,7 @@ class Error {
|
||||
std::string m_message;
|
||||
std::string m_filename;
|
||||
std::string m_function;
|
||||
uint32_t m_lineNumber = 0;
|
||||
int m_lineNumber = 0;
|
||||
const ErrorBase* m_originatingObject = nullptr;
|
||||
double m_timestamp = 0.0;
|
||||
};
|
||||
|
||||
@@ -81,32 +81,32 @@ class ErrorBase {
|
||||
virtual const Error& GetError() const;
|
||||
virtual void SetErrnoError(llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
int lineNumber) const;
|
||||
virtual void SetImaqError(int success, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
int lineNumber) const;
|
||||
virtual void SetError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
int lineNumber) const;
|
||||
virtual void SetErrorRange(Error::Code code, int32_t minRange,
|
||||
int32_t maxRange, int32_t requestedValue,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
int lineNumber) const;
|
||||
virtual void SetWPIError(llvm::StringRef errorMessage, Error::Code code,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const;
|
||||
int lineNumber) const;
|
||||
virtual void CloneError(const ErrorBase& rhs) const;
|
||||
virtual void ClearError() const;
|
||||
virtual bool StatusIsFatal() const;
|
||||
static void SetGlobalError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber);
|
||||
int lineNumber);
|
||||
static void SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function, uint32_t lineNumber);
|
||||
llvm::StringRef function, int lineNumber);
|
||||
static Error& GetGlobalError();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -84,7 +84,7 @@ class LinearDigitalFilter : public Filter {
|
||||
static LinearDigitalFilter HighPass(std::shared_ptr<PIDSource> source,
|
||||
double timeConstant, double period);
|
||||
static LinearDigitalFilter MovingAverage(std::shared_ptr<PIDSource> source,
|
||||
unsigned int taps);
|
||||
int taps);
|
||||
|
||||
// Filter interface
|
||||
double Get() const override;
|
||||
|
||||
@@ -23,12 +23,12 @@ class GenericHID {
|
||||
virtual float GetZ() const = 0;
|
||||
virtual float GetTwist() const = 0;
|
||||
virtual float GetThrottle() const = 0;
|
||||
virtual float GetRawAxis(uint32_t axis) const = 0;
|
||||
virtual float GetRawAxis(int axis) const = 0;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetBumper(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetRawButton(uint32_t button) const = 0;
|
||||
virtual bool GetRawButton(int button) const = 0;
|
||||
|
||||
virtual int GetPOV(uint32_t pov = 0) const = 0;
|
||||
virtual int GetPOV(int pov = 0) const = 0;
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ class PIDController : public LiveWindowSendable,
|
||||
virtual void SetTolerance(float percent);
|
||||
virtual void SetAbsoluteTolerance(float absValue);
|
||||
virtual void SetPercentTolerance(float percentValue);
|
||||
virtual void SetToleranceBuffer(unsigned buf = 1);
|
||||
virtual void SetToleranceBuffer(int buf = 1);
|
||||
virtual bool OnTarget() const;
|
||||
|
||||
void Enable() override;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
class Task : public ErrorBase {
|
||||
public:
|
||||
static const uint32_t kDefaultPriority = 60;
|
||||
static const int kDefaultPriority = 60;
|
||||
|
||||
Task() = default;
|
||||
Task(const Task&) = delete;
|
||||
@@ -38,9 +38,9 @@ class Task : public ErrorBase {
|
||||
|
||||
bool Verify();
|
||||
|
||||
int32_t GetPriority();
|
||||
int GetPriority();
|
||||
|
||||
bool SetPriority(int32_t priority);
|
||||
bool SetPriority(int priority);
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
|
||||
@@ -32,21 +32,21 @@
|
||||
__FUNCTION__)
|
||||
|
||||
bool wpi_assert_impl(bool conditionValue, const char* conditionText,
|
||||
const char* message, const char* fileName,
|
||||
uint32_t lineNumber, const char* funcName);
|
||||
const char* message, const char* fileName, int lineNumber,
|
||||
const char* funcName);
|
||||
bool wpi_assertEqual_impl(int valueA, int valueB, const char* valueAString,
|
||||
const char* valueBString, const char* message,
|
||||
const char* fileName, uint32_t lineNumber,
|
||||
const char* fileName, int lineNumber,
|
||||
const char* funcName);
|
||||
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
|
||||
const char* valueBString, const char* message,
|
||||
const char* fileName, uint32_t lineNumber,
|
||||
const char* fileName, int lineNumber,
|
||||
const char* funcName);
|
||||
|
||||
void wpi_suspendOnAssertEnabled(bool enabled);
|
||||
|
||||
int32_t GetFPGAVersion();
|
||||
int GetFPGAVersion();
|
||||
int64_t GetFPGARevision();
|
||||
uint64_t GetFPGATime();
|
||||
bool GetUserButton();
|
||||
std::string GetStackTrace(uint32_t offset);
|
||||
std::string GetStackTrace(int offset);
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#ifdef WPI_ERRORS_DEFINE_STRINGS
|
||||
#define S(label, offset, message) \
|
||||
const char* wpi_error_s_##label = message; \
|
||||
const int32_t wpi_error_value_##label = offset
|
||||
const int wpi_error_value_##label = offset
|
||||
#else
|
||||
#define S(label, offset, message) \
|
||||
extern const char* wpi_error_s_##label; \
|
||||
const int32_t wpi_error_value_##label = offset
|
||||
const int wpi_error_value_##label = offset
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -232,7 +232,7 @@ void Scheduler::UpdateTable() {
|
||||
if (!toCancel.empty()) {
|
||||
for (commandIter = m_commands.begin(); commandIter != m_commands.end();
|
||||
++commandIter) {
|
||||
for (unsigned i = 0; i < toCancel.size(); i++) {
|
||||
for (size_t i = 0; i < toCancel.size(); i++) {
|
||||
Command* c = *commandIter;
|
||||
if (c->GetID() == toCancel[i]) {
|
||||
c->Cancel();
|
||||
|
||||
@@ -31,7 +31,7 @@ std::string Error::GetFilename() const { return m_filename; }
|
||||
|
||||
std::string Error::GetFunction() const { return m_function; }
|
||||
|
||||
uint32_t Error::GetLineNumber() const { return m_lineNumber; }
|
||||
int Error::GetLineNumber() const { return m_lineNumber; }
|
||||
|
||||
const ErrorBase* Error::GetOriginatingObject() const {
|
||||
return m_originatingObject;
|
||||
@@ -41,7 +41,7 @@ double Error::GetTimestamp() const { return m_timestamp; }
|
||||
|
||||
void Error::Set(Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber, const ErrorBase* originatingObject) {
|
||||
int lineNumber, const ErrorBase* originatingObject) {
|
||||
bool report = true;
|
||||
|
||||
if (code == m_code && GetTime() - m_timestamp < 1) {
|
||||
|
||||
@@ -41,8 +41,7 @@ void ErrorBase::ClearError() const { m_error.Clear(); }
|
||||
*/
|
||||
void ErrorBase::SetErrnoError(llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function,
|
||||
uint32_t lineNumber) const {
|
||||
llvm::StringRef function, int lineNumber) const {
|
||||
std::string err;
|
||||
int errNo = errno;
|
||||
if (errNo == 0) {
|
||||
@@ -77,7 +76,7 @@ void ErrorBase::SetErrnoError(llvm::StringRef contextMessage,
|
||||
*/
|
||||
void ErrorBase::SetImaqError(int success, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const {
|
||||
int lineNumber) const {
|
||||
// If there was an error
|
||||
if (success <= 0) {
|
||||
std::stringstream err;
|
||||
@@ -105,7 +104,7 @@ void ErrorBase::SetImaqError(int success, llvm::StringRef contextMessage,
|
||||
*/
|
||||
void ErrorBase::SetError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const {
|
||||
int lineNumber) const {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
// Set the current error information for this object.
|
||||
@@ -136,8 +135,7 @@ void ErrorBase::SetErrorRange(Error::Code code, int32_t minRange,
|
||||
int32_t maxRange, int32_t requestedValue,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function,
|
||||
uint32_t lineNumber) const {
|
||||
llvm::StringRef function, int lineNumber) const {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
size_t size = contextMessage.size() + 100;
|
||||
@@ -169,7 +167,7 @@ void ErrorBase::SetErrorRange(Error::Code code, int32_t minRange,
|
||||
void ErrorBase::SetWPIError(llvm::StringRef errorMessage, Error::Code code,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber) const {
|
||||
int lineNumber) const {
|
||||
std::string err = errorMessage.str() + ": " + contextMessage.str();
|
||||
|
||||
// Set the current error information for this object.
|
||||
@@ -195,7 +193,7 @@ bool ErrorBase::StatusIsFatal() const { return m_error.GetCode() < 0; }
|
||||
|
||||
void ErrorBase::SetGlobalError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function, uint32_t lineNumber) {
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
std::lock_guard<priority_mutex> mutex(_globalErrorMutex);
|
||||
@@ -209,8 +207,7 @@ void ErrorBase::SetGlobalError(Error::Code code, llvm::StringRef contextMessage,
|
||||
void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename,
|
||||
llvm::StringRef function,
|
||||
uint32_t lineNumber) {
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
std::string err = errorMessage.str() + ": " + contextMessage.str();
|
||||
|
||||
std::lock_guard<priority_mutex> mutex(_globalErrorMutex);
|
||||
|
||||
@@ -119,7 +119,7 @@ LinearDigitalFilter LinearDigitalFilter::HighPass(
|
||||
* slower
|
||||
*/
|
||||
LinearDigitalFilter LinearDigitalFilter::MovingAverage(
|
||||
std::shared_ptr<PIDSource> source, unsigned int taps) {
|
||||
std::shared_ptr<PIDSource> source, int taps) {
|
||||
assert(taps > 0);
|
||||
|
||||
std::vector<double> gains(taps, 1.0 / taps);
|
||||
@@ -130,10 +130,10 @@ double LinearDigitalFilter::Get() const {
|
||||
double retVal = 0.0;
|
||||
|
||||
// Calculate the new value
|
||||
for (unsigned int i = 0; i < m_inputGains.size(); i++) {
|
||||
for (size_t i = 0; i < m_inputGains.size(); i++) {
|
||||
retVal += m_inputs[i] * m_inputGains[i];
|
||||
}
|
||||
for (unsigned int i = 0; i < m_outputGains.size(); i++) {
|
||||
for (size_t i = 0; i < m_outputGains.size(); i++) {
|
||||
retVal -= m_outputs[i] * m_outputGains[i];
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ double LinearDigitalFilter::PIDGet() {
|
||||
m_inputs.PushFront(PIDGetSource());
|
||||
|
||||
// Calculate the new value
|
||||
for (unsigned int i = 0; i < m_inputGains.size(); i++) {
|
||||
for (size_t i = 0; i < m_inputGains.size(); i++) {
|
||||
retVal += m_inputs[i] * m_inputGains[i];
|
||||
}
|
||||
for (unsigned int i = 0; i < m_outputGains.size(); i++) {
|
||||
for (size_t i = 0; i < m_outputGains.size(); i++) {
|
||||
retVal -= m_outputs[i] * m_outputGains[i];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user