diff --git a/wpimath/src/main/native/include/frc/proto/MatrixProto.h b/wpimath/src/main/native/include/frc/proto/MatrixProto.h index 6d3d9e30c36..5fbe5d68ea3 100644 --- a/wpimath/src/main/native/include/frc/proto/MatrixProto.h +++ b/wpimath/src/main/native/include/frc/proto/MatrixProto.h @@ -9,12 +9,16 @@ #include "frc/EigenCore.h" -template -struct WPILIB_DLLEXPORT wpi::Protobuf> { +template + requires(Cols != 1) +struct WPILIB_DLLEXPORT + wpi::Protobuf> { static google::protobuf::Message* New(google::protobuf::Arena* arena); - static frc::Matrixd Unpack(const google::protobuf::Message& msg); - static void Pack(google::protobuf::Message* msg, - const frc::Matrixd& value); + static frc::Matrixd Unpack( + const google::protobuf::Message& msg); + static void Pack( + google::protobuf::Message* msg, + const frc::Matrixd& value); }; #include "frc/proto/MatrixProto.inc" diff --git a/wpimath/src/main/native/include/frc/proto/MatrixProto.inc b/wpimath/src/main/native/include/frc/proto/MatrixProto.inc index 5e95d8a57d9..34c0e1bd969 100644 --- a/wpimath/src/main/native/include/frc/proto/MatrixProto.inc +++ b/wpimath/src/main/native/include/frc/proto/MatrixProto.inc @@ -7,15 +7,19 @@ #include "frc/proto/MatrixProto.h" #include "wpimath.pb.h" -template -google::protobuf::Message* wpi::Protobuf>::New( +template + requires(Cols != 1) +google::protobuf::Message* +wpi::Protobuf>::New( google::protobuf::Arena* arena) { return google::protobuf::Arena::CreateMessage( arena); } -template -frc::Matrixd wpi::Protobuf>::Unpack( +template + requires(Cols != 1) +frc::Matrixd +wpi::Protobuf>::Unpack( const google::protobuf::Message& msg) { auto m = static_cast(&msg); if (m->num_rows() != Rows || m->num_cols() != Cols) { @@ -24,16 +28,18 @@ frc::Matrixd wpi::Protobuf>::Unpack( if (m->data_size() != Rows * Cols) { // TODO Error } - frc::Matrixd mat; + frc::Matrixd mat; for (int i = 0; i < Rows * Cols; i++) { mat(i) = m->data(i); } return mat; } -template -void wpi::Protobuf>::Pack( - google::protobuf::Message* msg, const frc::Matrixd& value) { +template + requires(Cols != 1) +void wpi::Protobuf>::Pack( + google::protobuf::Message* msg, + const frc::Matrixd& value) { auto m = static_cast(msg); m->set_num_rows(Rows); m->set_num_cols(Cols); diff --git a/wpimath/src/main/native/include/frc/proto/VectorProto.h b/wpimath/src/main/native/include/frc/proto/VectorProto.h index 190950e4304..25c54b4e540 100644 --- a/wpimath/src/main/native/include/frc/proto/VectorProto.h +++ b/wpimath/src/main/native/include/frc/proto/VectorProto.h @@ -9,12 +9,15 @@ #include "frc/EigenCore.h" -template -struct WPILIB_DLLEXPORT wpi::Protobuf> { +template +struct WPILIB_DLLEXPORT + wpi::Protobuf> { static google::protobuf::Message* New(google::protobuf::Arena* arena); - static frc::Vectord Unpack(const google::protobuf::Message& msg); - static void Pack(google::protobuf::Message* msg, - const frc::Vectord& value); + static frc::Matrixd Unpack( + const google::protobuf::Message& msg); + static void Pack( + google::protobuf::Message* msg, + const frc::Matrixd& value); }; #include "frc/proto/VectorProto.inc" diff --git a/wpimath/src/main/native/include/frc/proto/VectorProto.inc b/wpimath/src/main/native/include/frc/proto/VectorProto.inc index 98761d2dfc9..b2d9040fd62 100644 --- a/wpimath/src/main/native/include/frc/proto/VectorProto.inc +++ b/wpimath/src/main/native/include/frc/proto/VectorProto.inc @@ -7,30 +7,33 @@ #include "frc/proto/VectorProto.h" #include "wpimath.pb.h" -template -google::protobuf::Message* wpi::Protobuf>::New( +template +google::protobuf::Message* +wpi::Protobuf>::New( google::protobuf::Arena* arena) { return google::protobuf::Arena::CreateMessage( arena); } -template -frc::Vectord wpi::Protobuf>::Unpack( +template +frc::Matrixd +wpi::Protobuf>::Unpack( const google::protobuf::Message& msg) { auto m = static_cast(&msg); if (m->rows_size() != Size) { // TODO Error } - frc::Vectord vec; + frc::Matrixd vec; for (int i = 0; i < Size; i++) { vec(i) = m->rows(i); } return vec; } -template -void wpi::Protobuf>::Pack(google::protobuf::Message* msg, - const frc::Vectord& value) { +template +void wpi::Protobuf>::Pack( + google::protobuf::Message* msg, + const frc::Matrixd& value) { auto m = static_cast(msg); m->clear_rows(); for (int i = 0; i < Size; i++) {