mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user