From c9c11269fd7b53868b988ef9e96399a969e570a9 Mon Sep 17 00:00:00 2001 From: Joseph Eng Date: Tue, 16 Jul 2024 10:35:07 -0700 Subject: [PATCH] Fix usage of namespace {} in .inc files --- .../struct/SimpleMotorFeedforwardStruct.inc | 12 ++++++------ .../struct/SwerveDriveKinematicsStruct.inc | 6 ++---- .../main/native/include/frc/struct/MatrixStruct.inc | 6 ++---- .../main/native/include/frc/struct/VectorStruct.inc | 6 ++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/wpimath/src/main/native/include/frc/controller/struct/SimpleMotorFeedforwardStruct.inc b/wpimath/src/main/native/include/frc/controller/struct/SimpleMotorFeedforwardStruct.inc index 3440efe81e5..471e700100c 100644 --- a/wpimath/src/main/native/include/frc/controller/struct/SimpleMotorFeedforwardStruct.inc +++ b/wpimath/src/main/native/include/frc/controller/struct/SimpleMotorFeedforwardStruct.inc @@ -6,16 +6,13 @@ #include "frc/controller/struct/SimpleMotorFeedforwardStruct.h" -namespace { -constexpr size_t kKsOff = 0; -constexpr size_t kKvOff = kKsOff + 8; -constexpr size_t kKaOff = kKvOff + 8; -} // namespace - template frc::SimpleMotorFeedforward wpi::Struct>::Unpack( std::span data) { + constexpr size_t kKsOff = 0; + constexpr size_t kKvOff = kKsOff + 8; + constexpr size_t kKaOff = kKvOff + 8; return {units::volt_t{wpi::UnpackStruct(data)}, units::unit_t::kv_unit>{ wpi::UnpackStruct(data)}, @@ -27,6 +24,9 @@ template void wpi::Struct>::Pack( std::span data, const frc::SimpleMotorFeedforward& value) { + constexpr size_t kKsOff = 0; + constexpr size_t kKvOff = kKsOff + 8; + constexpr size_t kKaOff = kKvOff + 8; wpi::PackStruct(data, value.kS.value()); wpi::PackStruct( data, diff --git a/wpimath/src/main/native/include/frc/kinematics/struct/SwerveDriveKinematicsStruct.inc b/wpimath/src/main/native/include/frc/kinematics/struct/SwerveDriveKinematicsStruct.inc index 3c22ca8c529..5e4dee13eeb 100644 --- a/wpimath/src/main/native/include/frc/kinematics/struct/SwerveDriveKinematicsStruct.inc +++ b/wpimath/src/main/native/include/frc/kinematics/struct/SwerveDriveKinematicsStruct.inc @@ -6,14 +6,11 @@ #include "frc/kinematics/struct/SwerveDriveKinematicsStruct.h" -namespace { -constexpr size_t kModulesOff = 0; -} // namespace - template frc::SwerveDriveKinematics wpi::Struct>::Unpack( std::span data) { + constexpr size_t kModulesOff = 0; return frc::SwerveDriveKinematics{ wpi::UnpackStructArray( data)}; @@ -23,5 +20,6 @@ template void wpi::Struct>::Pack( std::span data, const frc::SwerveDriveKinematics& value) { + constexpr size_t kModulesOff = 0; wpi::PackStructArray(data, value.GetModules()); } diff --git a/wpimath/src/main/native/include/frc/struct/MatrixStruct.inc b/wpimath/src/main/native/include/frc/struct/MatrixStruct.inc index 2c8e23c2300..4efda8a41de 100644 --- a/wpimath/src/main/native/include/frc/struct/MatrixStruct.inc +++ b/wpimath/src/main/native/include/frc/struct/MatrixStruct.inc @@ -6,15 +6,12 @@ #include "frc/struct/MatrixStruct.h" -namespace { -constexpr size_t kDataOff = 0; -} // namespace - template requires(Cols != 1) frc::Matrixd wpi::Struct>::Unpack( std::span data) { + constexpr size_t kDataOff = 0; wpi::array mat_data = wpi::UnpackStructArray(data); frc::Matrixd mat; @@ -29,6 +26,7 @@ template void wpi::Struct>::Pack( std::span data, const frc::Matrixd& value) { + constexpr size_t kDataOff = 0; wpi::array mat_data(wpi::empty_array); for (int i = 0; i < Rows * Cols; i++) { mat_data[i] = value(i); diff --git a/wpimath/src/main/native/include/frc/struct/VectorStruct.inc b/wpimath/src/main/native/include/frc/struct/VectorStruct.inc index ee2a81893f5..4fcfbb009dd 100644 --- a/wpimath/src/main/native/include/frc/struct/VectorStruct.inc +++ b/wpimath/src/main/native/include/frc/struct/VectorStruct.inc @@ -6,14 +6,11 @@ #include "frc/struct/VectorStruct.h" -namespace { -constexpr size_t kDataOff = 0; -} // namespace - template frc::Matrixd wpi::Struct>::Unpack( std::span data) { + constexpr size_t kDataOff = 0; wpi::array vec_data = wpi::UnpackStructArray(data); frc::Matrixd vec; @@ -27,6 +24,7 @@ template void wpi::Struct>::Pack( std::span data, const frc::Matrixd& value) { + constexpr size_t kDataOff = 0; wpi::array vec_data(wpi::empty_array); for (int i = 0; i < Size; i++) { vec_data[i] = value(i);