[wpiutil] Struct: Change from GetTypeString() to GetTypeName() (#6872)

This makes it easier to define schemas when the type name is non-trivial (e.g., templated structs).

This is breaking for a) custom struct implementations and b) anything calling `wpi::Struct<T>::GetTypeString(info...)` in C++ directly. In both cases, it's a simple translation: For A, rename `GetTypeString()` to `GetTypeName()` and remove the struct: at the beginning, and for B, use `wpi::GetStructTypeString<T>(info...)` instead.
This commit is contained in:
Joseph Eng
2024-07-27 20:23:45 -07:00
committed by GitHub
parent 5dcaa6d671
commit 158fb23072
58 changed files with 185 additions and 162 deletions

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Ellipse2d> {
static constexpr std::string_view GetTypeString() {
return "struct:Ellipse2d";
}
static constexpr std::string_view GetTypeName() { return "Ellipse2d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Pose2d>() + 16;
}

View File

@@ -11,7 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose2d> {
static constexpr std::string_view GetTypeString() { return "struct:Pose2d"; }
static constexpr std::string_view GetTypeName() { return "Pose2d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Translation2d>() +
wpi::GetStructSize<frc::Rotation2d>();

View File

@@ -11,7 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose3d> {
static constexpr std::string_view GetTypeString() { return "struct:Pose3d"; }
static constexpr std::string_view GetTypeName() { return "Pose3d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Translation3d>() +
wpi::GetStructSize<frc::Rotation3d>();

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Quaternion> {
static constexpr std::string_view GetTypeString() {
return "struct:Quaternion";
}
static constexpr std::string_view GetTypeName() { return "Quaternion"; }
static constexpr size_t GetSize() { return 32; }
static constexpr std::string_view GetSchema() {
return "double w;double x;double y;double z";

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rectangle2d> {
static constexpr std::string_view GetTypeString() {
return "struct:Rectangle2d";
}
static constexpr std::string_view GetTypeName() { return "Rectangle2d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Pose2d>() + 16;
}

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation2d> {
static constexpr std::string_view GetTypeString() {
return "struct:Rotation2d";
}
static constexpr std::string_view GetTypeName() { return "Rotation2d"; }
static constexpr size_t GetSize() { return 8; }
static constexpr std::string_view GetSchema() { return "double value"; }

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation3d> {
static constexpr std::string_view GetTypeString() {
return "struct:Rotation3d";
}
static constexpr std::string_view GetTypeName() { return "Rotation3d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Quaternion>();
}

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform2d> {
static constexpr std::string_view GetTypeString() {
return "struct:Transform2d";
}
static constexpr std::string_view GetTypeName() { return "Transform2d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Translation2d>() +
wpi::GetStructSize<frc::Rotation2d>();

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform3d> {
static constexpr std::string_view GetTypeString() {
return "struct:Transform3d";
}
static constexpr std::string_view GetTypeName() { return "Transform3d"; }
static constexpr size_t GetSize() {
return wpi::GetStructSize<frc::Translation3d>() +
wpi::GetStructSize<frc::Rotation3d>();

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation2d> {
static constexpr std::string_view GetTypeString() {
return "struct:Translation2d";
}
static constexpr std::string_view GetTypeName() { return "Translation2d"; }
static constexpr size_t GetSize() { return 16; }
static constexpr std::string_view GetSchema() { return "double x;double y"; }

View File

@@ -11,9 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation3d> {
static constexpr std::string_view GetTypeString() {
return "struct:Translation3d";
}
static constexpr std::string_view GetTypeName() { return "Translation3d"; }
static constexpr size_t GetSize() { return 24; }
static constexpr std::string_view GetSchema() {
return "double x;double y;double z";

View File

@@ -11,7 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist2d> {
static constexpr std::string_view GetTypeString() { return "struct:Twist2d"; }
static constexpr std::string_view GetTypeName() { return "Twist2d"; }
static constexpr size_t GetSize() { return 24; }
static constexpr std::string_view GetSchema() {
return "double dx;double dy;double dtheta";

View File

@@ -11,7 +11,7 @@
template <>
struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist3d> {
static constexpr std::string_view GetTypeString() { return "struct:Twist3d"; }
static constexpr std::string_view GetTypeName() { return "Twist3d"; }
static constexpr size_t GetSize() { return 48; }
static constexpr std::string_view GetSchema() {
return "double dx;double dy;double dz;double rx;double ry;double rz";