mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpiutil] Rename struct constants to all caps
This commit is contained in:
@@ -31,31 +31,31 @@ class StructDescriptorDatabase;
|
||||
*/
|
||||
enum class StructFieldType {
|
||||
/// bool.
|
||||
kBool,
|
||||
BOOL,
|
||||
/// char.
|
||||
kChar,
|
||||
CHAR,
|
||||
/// int8.
|
||||
kInt8,
|
||||
INT8,
|
||||
/// int16.
|
||||
kInt16,
|
||||
INT16,
|
||||
/// int32.
|
||||
kInt32,
|
||||
INT32,
|
||||
/// int64.
|
||||
kInt64,
|
||||
INT64,
|
||||
/// uint8.
|
||||
kUint8,
|
||||
UINT8,
|
||||
/// uint16.
|
||||
kUint16,
|
||||
UINT16,
|
||||
/// uint32.
|
||||
kUint32,
|
||||
UINT32,
|
||||
/// uint64.
|
||||
kUint64,
|
||||
UINT64,
|
||||
/// float.
|
||||
kFloat,
|
||||
FLOAT,
|
||||
/// double.
|
||||
kDouble,
|
||||
DOUBLE,
|
||||
/// struct.
|
||||
kStruct
|
||||
STRUCT
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -107,10 +107,9 @@ class StructFieldDescriptor {
|
||||
* @return true if signed integer, false otherwise
|
||||
*/
|
||||
bool IsInt() const {
|
||||
return m_type == StructFieldType::kInt8 ||
|
||||
m_type == StructFieldType::kInt16 ||
|
||||
m_type == StructFieldType::kInt32 ||
|
||||
m_type == StructFieldType::kInt64;
|
||||
return m_type == StructFieldType::INT8 ||
|
||||
m_type == StructFieldType::INT16 ||
|
||||
m_type == StructFieldType::INT32 || m_type == StructFieldType::INT64;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +118,10 @@ class StructFieldDescriptor {
|
||||
* @return true if unsigned integer, false otherwise
|
||||
*/
|
||||
bool IsUint() const {
|
||||
return m_type == StructFieldType::kUint8 ||
|
||||
m_type == StructFieldType::kUint16 ||
|
||||
m_type == StructFieldType::kUint32 ||
|
||||
m_type == StructFieldType::kUint64;
|
||||
return m_type == StructFieldType::UINT8 ||
|
||||
m_type == StructFieldType::UINT16 ||
|
||||
m_type == StructFieldType::UINT32 ||
|
||||
m_type == StructFieldType::UINT64;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +407,7 @@ class DynamicStruct {
|
||||
*/
|
||||
bool GetBoolField(const StructFieldDescriptor* field,
|
||||
size_t arrIndex = 0) const {
|
||||
assert(field->m_type == StructFieldType::kBool);
|
||||
assert(field->m_type == StructFieldType::BOOL);
|
||||
return GetFieldImpl(field, arrIndex);
|
||||
}
|
||||
|
||||
@@ -457,7 +456,7 @@ class DynamicStruct {
|
||||
*/
|
||||
float GetFloatField(const StructFieldDescriptor* field,
|
||||
size_t arrIndex = 0) const {
|
||||
assert(field->m_type == StructFieldType::kFloat);
|
||||
assert(field->m_type == StructFieldType::FLOAT);
|
||||
return bit_cast<float>(
|
||||
static_cast<uint32_t>(GetFieldImpl(field, arrIndex)));
|
||||
}
|
||||
@@ -471,7 +470,7 @@ class DynamicStruct {
|
||||
*/
|
||||
double GetDoubleField(const StructFieldDescriptor* field,
|
||||
size_t arrIndex = 0) const {
|
||||
assert(field->m_type == StructFieldType::kDouble);
|
||||
assert(field->m_type == StructFieldType::DOUBLE);
|
||||
return bit_cast<double>(GetFieldImpl(field, arrIndex));
|
||||
}
|
||||
|
||||
@@ -492,7 +491,7 @@ class DynamicStruct {
|
||||
*/
|
||||
DynamicStruct GetStructField(const StructFieldDescriptor* field,
|
||||
size_t arrIndex = 0) const {
|
||||
assert(field->m_type == StructFieldType::kStruct);
|
||||
assert(field->m_type == StructFieldType::STRUCT);
|
||||
assert(field->m_parent == m_desc);
|
||||
assert(m_desc->IsValid());
|
||||
assert(arrIndex < field->m_arraySize);
|
||||
@@ -552,7 +551,7 @@ class MutableDynamicStruct : public DynamicStruct {
|
||||
*/
|
||||
void SetBoolField(const StructFieldDescriptor* field, bool value,
|
||||
size_t arrIndex = 0) {
|
||||
assert(field->m_type == StructFieldType::kBool);
|
||||
assert(field->m_type == StructFieldType::BOOL);
|
||||
SetFieldImpl(field, value ? 1 : 0, arrIndex);
|
||||
}
|
||||
|
||||
@@ -591,7 +590,7 @@ class MutableDynamicStruct : public DynamicStruct {
|
||||
*/
|
||||
void SetFloatField(const StructFieldDescriptor* field, float value,
|
||||
size_t arrIndex = 0) {
|
||||
assert(field->m_type == StructFieldType::kFloat);
|
||||
assert(field->m_type == StructFieldType::FLOAT);
|
||||
SetFieldImpl(field, bit_cast<uint32_t>(value), arrIndex);
|
||||
}
|
||||
|
||||
@@ -604,7 +603,7 @@ class MutableDynamicStruct : public DynamicStruct {
|
||||
*/
|
||||
void SetDoubleField(const StructFieldDescriptor* field, double value,
|
||||
size_t arrIndex = 0) {
|
||||
assert(field->m_type == StructFieldType::kDouble);
|
||||
assert(field->m_type == StructFieldType::DOUBLE);
|
||||
SetFieldImpl(field, bit_cast<uint64_t>(value), arrIndex);
|
||||
}
|
||||
|
||||
@@ -637,7 +636,7 @@ class MutableDynamicStruct : public DynamicStruct {
|
||||
*/
|
||||
MutableDynamicStruct GetStructField(const StructFieldDescriptor* field,
|
||||
size_t arrIndex = 0) {
|
||||
assert(field->m_type == StructFieldType::kStruct);
|
||||
assert(field->m_type == StructFieldType::STRUCT);
|
||||
assert(field->m_parent == m_desc);
|
||||
assert(m_desc->IsValid());
|
||||
assert(arrIndex < field->m_arraySize);
|
||||
|
||||
@@ -20,29 +20,29 @@ struct Token {
|
||||
/** A lexed raw struct schema token kind. */
|
||||
enum Kind {
|
||||
/// Unknown.
|
||||
kUnknown,
|
||||
UNKNOWN,
|
||||
/// Integer.
|
||||
kInteger,
|
||||
INTEGER,
|
||||
/// Identifier.
|
||||
kIdentifier,
|
||||
IDENTIFIER,
|
||||
/// Left square bracket.
|
||||
kLeftBracket,
|
||||
LEFT_BRACKET,
|
||||
/// Right square bracket.
|
||||
kRightBracket,
|
||||
RIGHT_BRACKET,
|
||||
/// Left curly brace.
|
||||
kLeftBrace,
|
||||
LEFT_BRACE,
|
||||
/// Right curly brace.
|
||||
kRightBrace,
|
||||
RIGHT_BRACE,
|
||||
/// Colon.
|
||||
kColon,
|
||||
COLON,
|
||||
/// Semicolon.
|
||||
kSemicolon,
|
||||
SEMICOLON,
|
||||
/// Comma.
|
||||
kComma,
|
||||
COMMA,
|
||||
/// Equals.
|
||||
kEquals,
|
||||
EQUALS,
|
||||
/// End of input.
|
||||
kEndOfInput,
|
||||
END_OF_INPUT,
|
||||
};
|
||||
|
||||
Token() = default;
|
||||
@@ -50,7 +50,7 @@ struct Token {
|
||||
|
||||
bool Is(Kind k) const { return kind == k; }
|
||||
|
||||
Kind kind = kUnknown;
|
||||
Kind kind = UNKNOWN;
|
||||
std::string_view text;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user