Nest all namespaces
The compiler supports this now. We can type less going forward.
No functional changes.
Signed-off-by: Stephan Pleines <pleines.stephan@gmail.com>
Change-Id: I29d6fa4f9aacc0e381f1a7637294db0392466995
diff --git a/motors/algorithms.cc b/motors/algorithms.cc
index 6edb532..c429a84 100644
--- a/motors/algorithms.cc
+++ b/motors/algorithms.cc
@@ -1,7 +1,6 @@
#include "motors/algorithms.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
BalancedReadings BalanceReadings(const ReadingsToBalance to_balance) {
// TODO(Brian): Get rid of the floating point divides.
@@ -46,5 +45,4 @@
return result;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/algorithms_test.cc b/motors/algorithms_test.cc
index bdf51d7..cf3ce3d 100644
--- a/motors/algorithms_test.cc
+++ b/motors/algorithms_test.cc
@@ -6,9 +6,7 @@
#include "gtest/gtest.h"
-namespace frc971 {
-namespace motors {
-namespace testing {
+namespace frc971::motors::testing {
class BalanceReadingsTest : public ::testing::Test {
protected:
@@ -97,6 +95,4 @@
CheckReadingsResult({{3424, 5013, 3424}, {2, 2, 2}});
}
-} // namespace testing
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors::testing
diff --git a/motors/big/medium_salsa.cc b/motors/big/medium_salsa.cc
index ab0f3d6..b754715 100644
--- a/motors/big/medium_salsa.cc
+++ b/motors/big/medium_salsa.cc
@@ -11,8 +11,7 @@
#include "motors/usb/usb_serial.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
struct MediumAdcReadings {
@@ -342,5 +341,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/big/motor_controls.cc b/motors/big/motor_controls.cc
index db9878d..a0fcd76 100644
--- a/motors/big/motor_controls.cc
+++ b/motors/big/motor_controls.cc
@@ -2,8 +2,7 @@
#include "motors/peripheral/configuration.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
template <int kRows, int kCols>
@@ -240,5 +239,4 @@
return debug_[theta];
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/button_board.cc b/motors/button_board.cc
index 1d20fdb..e509ea6 100644
--- a/motors/button_board.cc
+++ b/motors/button_board.cc
@@ -16,8 +16,7 @@
#include "motors/usb/usb.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
struct JoystickAdcReadings {
@@ -405,5 +404,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/core/itm.cc b/motors/core/itm.cc
index 3405881..767a0a8 100644
--- a/motors/core/itm.cc
+++ b/motors/core/itm.cc
@@ -2,9 +2,7 @@
#include "motors/core/kinetis.h"
-namespace frc971 {
-namespace motors {
-namespace itm {
+namespace frc971::motors::itm {
namespace {
// 480000 works for a bit but eventually errors out with an stlink-v2 and
@@ -52,6 +50,4 @@
ITM.LAR = 0;
}
-} // namespace itm
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors::itm
diff --git a/motors/fet12/fet12.cc b/motors/fet12/fet12.cc
index b6f2a45..61562be 100644
--- a/motors/fet12/fet12.cc
+++ b/motors/fet12/fet12.cc
@@ -12,8 +12,7 @@
#include "motors/print/print.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
struct Fet12AdcReadings {
@@ -332,5 +331,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/fet12/fet12v2.cc b/motors/fet12/fet12v2.cc
index b0a0acc..9591331 100644
--- a/motors/fet12/fet12v2.cc
+++ b/motors/fet12/fet12v2.cc
@@ -14,8 +14,7 @@
#include "motors/print/print.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
constexpr double Kv = 22000.0 * 2.0 * M_PI / 60.0 / 30.0 * 3.6;
@@ -718,5 +717,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/fet12/motor_controls.cc b/motors/fet12/motor_controls.cc
index 0ef7e3c..adc1839 100644
--- a/motors/fet12/motor_controls.cc
+++ b/motors/fet12/motor_controls.cc
@@ -2,8 +2,7 @@
#include "motors/peripheral/configuration.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
template <int kRows, int kCols>
@@ -245,5 +244,4 @@
return debug_[theta];
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/fet12/power_wheels.cc b/motors/fet12/power_wheels.cc
index 893d92f..20453dc 100644
--- a/motors/fet12/power_wheels.cc
+++ b/motors/fet12/power_wheels.cc
@@ -11,8 +11,7 @@
#include "motors/usb/usb.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
struct Fet12AdcReadings {
@@ -347,5 +346,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/math.cc b/motors/math.cc
index 574ef9a..5eac813 100644
--- a/motors/math.cc
+++ b/motors/math.cc
@@ -2,8 +2,7 @@
#include <math.h>
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace math_internal {
float sin_float_table[SinCosFloatTableSize() + 1]
@@ -35,5 +34,4 @@
}
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/math_test.cc b/motors/math_test.cc
index fb72454..63e812f 100644
--- a/motors/math_test.cc
+++ b/motors/math_test.cc
@@ -3,9 +3,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-namespace frc971 {
-namespace motors {
-namespace testing {
+namespace frc971::motors::testing {
class SinCosIntTest : public ::testing::Test {
public:
@@ -95,6 +93,4 @@
CheckSinCos(0.2);
}
-} // namespace testing
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors::testing
diff --git a/motors/motor.cc b/motors/motor.cc
index ed1296c..d2c977c 100644
--- a/motors/motor.cc
+++ b/motors/motor.cc
@@ -12,8 +12,7 @@
extern "C" float analog_ratio(uint16_t reading);
extern "C" float absolute_wheel(uint16_t reading);
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
Motor::Motor(BigFTM *pwm_ftm, LittleFTM *encoder_ftm, MotorControls *controls,
const ::std::array<volatile uint32_t *, 3> &output_registers)
@@ -445,5 +444,4 @@
return (counts_per_cycle() + width) / 2;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/peripheral/adc.cc b/motors/peripheral/adc.cc
index 64f1557..11a91ff 100644
--- a/motors/peripheral/adc.cc
+++ b/motors/peripheral/adc.cc
@@ -2,8 +2,7 @@
#include "motors/core/kinetis.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
#define ADC_SC2_BASE \
@@ -58,5 +57,4 @@
ADC_INIT_SINGLE(1, (adc1_channels == AdcChannels::kB) ? ADC_CFG2_MUXSEL : 0);
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/peripheral/adc_dma.cc b/motors/peripheral/adc_dma.cc
index 15d50eb..11cdbb6 100644
--- a/motors/peripheral/adc_dma.cc
+++ b/motors/peripheral/adc_dma.cc
@@ -52,8 +52,7 @@
// 8. Read ADC0.RB and ADC1.RB
// 9. Go back to step #3
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
namespace {
constexpr uint32_t pdb_sc(int pdb_input) {
@@ -275,5 +274,4 @@
V_PDB_EN(3) /* Enable our two */;
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/peripheral/spi.cc b/motors/peripheral/spi.cc
index 8c4ad11..59ff651 100644
--- a/motors/peripheral/spi.cc
+++ b/motors/peripheral/spi.cc
@@ -4,8 +4,7 @@
#include "motors/core/time.h"
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
Spi::~Spi() {
DisableTransmitInterrupt();
@@ -136,5 +135,4 @@
return true;
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/peripheral/uart.cc b/motors/peripheral/uart.cc
index 0617e3f..408bbfd 100644
--- a/motors/peripheral/uart.cc
+++ b/motors/peripheral/uart.cc
@@ -2,8 +2,7 @@
#include <stdint.h>
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
// Currently hard-coded for 8-bit + no parity + start bit + stop bit.
void Uart::Initialize(int baud_rate) {
@@ -152,5 +151,4 @@
}
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/peripheral/uart_buffer_test.cc b/motors/peripheral/uart_buffer_test.cc
index 223c029..0ee5a49 100644
--- a/motors/peripheral/uart_buffer_test.cc
+++ b/motors/peripheral/uart_buffer_test.cc
@@ -2,9 +2,7 @@
#include "gtest/gtest.h"
-namespace frc971 {
-namespace teensy {
-namespace testing {
+namespace frc971::teensy::testing {
// Tests that using PushSpan with single characters works correctly.
TEST(UartBufferTest, PushSpanSingle) {
@@ -281,6 +279,4 @@
}
}
-} // namespace testing
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy::testing
diff --git a/motors/pistol_grip/controller.cc b/motors/pistol_grip/controller.cc
index a88b9a0..b7c7ae5 100644
--- a/motors/pistol_grip/controller.cc
+++ b/motors/pistol_grip/controller.cc
@@ -25,8 +25,7 @@
extern const float kTriggerCoggingTorque0[4096];
extern const float kTriggerCoggingTorque1[4096];
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
::std::atomic<const float *> trigger_cogging_torque{nullptr};
@@ -1154,5 +1153,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/pistol_grip/controller_adc.cc b/motors/pistol_grip/controller_adc.cc
index 498c4e2..1e89f98 100644
--- a/motors/pistol_grip/controller_adc.cc
+++ b/motors/pistol_grip/controller_adc.cc
@@ -2,8 +2,7 @@
#include "motors/peripheral/adc.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
void AdcInitSmall() {
AdcInitCommon();
@@ -96,5 +95,4 @@
return r;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/pistol_grip/drivers_station.cc b/motors/pistol_grip/drivers_station.cc
index a1cd6d9..1cf570b 100644
--- a/motors/pistol_grip/drivers_station.cc
+++ b/motors/pistol_grip/drivers_station.cc
@@ -15,8 +15,7 @@
#include "motors/usb/usb.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
// TODO(Brian): Move this and the other two test functions somewhere else.
@@ -308,5 +307,4 @@
return 0;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/pistol_grip/motor_controls.cc b/motors/pistol_grip/motor_controls.cc
index a9c909f..ec01677 100644
--- a/motors/pistol_grip/motor_controls.cc
+++ b/motors/pistol_grip/motor_controls.cc
@@ -2,8 +2,7 @@
#include "motors/peripheral/configuration.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
template <int kRows, int kCols>
@@ -209,5 +208,4 @@
return debug_[theta];
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/print/itm.cc b/motors/print/itm.cc
index 7f472c0..be657bc 100644
--- a/motors/print/itm.cc
+++ b/motors/print/itm.cc
@@ -6,8 +6,7 @@
#include "motors/core/itm.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
template <int kPort>
@@ -96,5 +95,4 @@
return buffer.size();
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/print/semihosting.cc b/motors/print/semihosting.cc
index a266ad6..310bb49 100644
--- a/motors/print/semihosting.cc
+++ b/motors/print/semihosting.cc
@@ -4,8 +4,7 @@
#include "motors/core/semihosting.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
::std::unique_ptr<PrintingImplementation> CreatePrinting(
const PrintingParameters & /*parameters*/) {
@@ -23,5 +22,4 @@
return buffer.size() - operation.Execute();
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/print/uart.cc b/motors/print/uart.cc
index 4cfb001..f125789 100644
--- a/motors/print/uart.cc
+++ b/motors/print/uart.cc
@@ -4,8 +4,7 @@
#include "motors/core/kinetis.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
::std::atomic<teensy::InterruptBufferedUart *> global_stdout{nullptr};
@@ -65,5 +64,4 @@
return len;
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/print/usb.cc b/motors/print/usb.cc
index 9284ecd..45734b5 100644
--- a/motors/print/usb.cc
+++ b/motors/print/usb.cc
@@ -4,8 +4,7 @@
#include "motors/core/kinetis.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
::std::atomic<teensy::AcmTty *> global_stdout{nullptr};
@@ -62,5 +61,4 @@
global_stdout.store(&stdout_tty_, ::std::memory_order_release);
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/seems_reasonable/spring.cc b/motors/seems_reasonable/spring.cc
index 79ac751..80bcd31 100644
--- a/motors/seems_reasonable/spring.cc
+++ b/motors/seems_reasonable/spring.cc
@@ -4,8 +4,7 @@
#include "frc971/zeroing/wrap.h"
-namespace motors {
-namespace seems_reasonable {
+namespace motors::seems_reasonable {
namespace {
constexpr float kTwoPi = 2.0 * M_PI;
@@ -200,5 +199,4 @@
last_error_ = error;
}
-} // namespace seems_reasonable
-} // namespace motors
+} // namespace motors::seems_reasonable
diff --git a/motors/seems_reasonable/spring_test.cc b/motors/seems_reasonable/spring_test.cc
index bcc2a8a..d78a80b 100644
--- a/motors/seems_reasonable/spring_test.cc
+++ b/motors/seems_reasonable/spring_test.cc
@@ -2,9 +2,7 @@
#include "gtest/gtest.h"
-namespace motors {
-namespace seems_reasonable {
-namespace testing {
+namespace motors::seems_reasonable::testing {
// Tests that NextGoal always returns the next goal.
TEST(GoalTest, TestNextGoal) {
@@ -30,6 +28,4 @@
EXPECT_NEAR(-2.0 * M_PI + 1.0, PreviousGoal(1.0, 1.0), 1e-6);
}
-} // namespace testing
-} // namespace seems_reasonable
-} // namespace motors
+} // namespace motors::seems_reasonable::testing
diff --git a/motors/simple_receiver.cc b/motors/simple_receiver.cc
index bb10353..2ae0c9b 100644
--- a/motors/simple_receiver.cc
+++ b/motors/simple_receiver.cc
@@ -19,8 +19,7 @@
#include "motors/seems_reasonable/spring.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
using ::frc971::constants::ShifterHallEffect;
@@ -799,5 +798,4 @@
}
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/simpler_receiver.cc b/motors/simpler_receiver.cc
index 808fb83..7fad0b8 100644
--- a/motors/simpler_receiver.cc
+++ b/motors/simpler_receiver.cc
@@ -17,8 +17,7 @@
#include "motors/seems_reasonable/polydrivetrain_dog_motor_plant.h"
#include "motors/util.h"
-namespace frc971 {
-namespace motors {
+namespace frc971::motors {
namespace {
using ::frc971::constants::ShifterHallEffect;
@@ -449,5 +448,4 @@
}
}
-} // namespace motors
-} // namespace frc971
+} // namespace frc971::motors
diff --git a/motors/usb/cdc.cc b/motors/usb/cdc.cc
index e082156..5a668d8 100644
--- a/motors/usb/cdc.cc
+++ b/motors/usb/cdc.cc
@@ -19,8 +19,7 @@
} \
} while (false)
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
namespace {
// Aka the Communications Device Class code, the Communications Class code,
@@ -428,5 +427,4 @@
}
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/usb/constants.h b/motors/usb/constants.h
index 58c9ecc..6970639 100644
--- a/motors/usb/constants.h
+++ b/motors/usb/constants.h
@@ -3,8 +3,7 @@
#include <stdint.h>
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
enum class Direction : uint32_t {
kTx = 1 << 1,
@@ -108,7 +107,6 @@
static_cast<uint32_t>(Data01::kData1));
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
#endif // MOTORS_USB_CONSTANTS_H_
diff --git a/motors/usb/constants_test.cc b/motors/usb/constants_test.cc
index 4d11349..66e0ea5 100644
--- a/motors/usb/constants_test.cc
+++ b/motors/usb/constants_test.cc
@@ -2,9 +2,7 @@
#include "gtest/gtest.h"
-namespace frc971 {
-namespace teensy {
-namespace testing {
+namespace frc971::teensy::testing {
TEST(EndpointBufferStateTest, Filling) {
EXPECT_TRUE(BufferStateHasEmpty(EndpointBufferState::kBothEmptyEvenFirst));
@@ -61,6 +59,4 @@
BufferStateAfterEmpty(EndpointBufferState::kBothFullEvenFirst));
}
-} // namespace testing
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy::testing
diff --git a/motors/usb/hid.cc b/motors/usb/hid.cc
index f42842b..5efa431 100644
--- a/motors/usb/hid.cc
+++ b/motors/usb/hid.cc
@@ -1,7 +1,6 @@
#include "motors/usb/hid.h"
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
namespace {
constexpr uint8_t hid_class() { return 0x03; }
@@ -210,5 +209,4 @@
}
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/usb/interrupt_out.cc b/motors/usb/interrupt_out.cc
index 568e5c5..30f024e 100644
--- a/motors/usb/interrupt_out.cc
+++ b/motors/usb/interrupt_out.cc
@@ -1,7 +1,6 @@
#include "motors/usb/interrupt_out.h"
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
void InterruptOut::Initialize() {
interface_ = AddInterface();
@@ -86,5 +85,4 @@
}
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/usb/queue.cc b/motors/usb/queue.cc
index 270ad74..3d2e283 100644
--- a/motors/usb/queue.cc
+++ b/motors/usb/queue.cc
@@ -4,8 +4,7 @@
#include <algorithm>
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
size_t Queue::Read(char *out_data, size_t out_size) {
const size_t read_cursor = read_cursor_.load(::std::memory_order_relaxed);
@@ -30,5 +29,4 @@
return r;
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy
diff --git a/motors/usb/queue_test.cc b/motors/usb/queue_test.cc
index fed54d6..8973a6c 100644
--- a/motors/usb/queue_test.cc
+++ b/motors/usb/queue_test.cc
@@ -2,9 +2,7 @@
#include "gtest/gtest.h"
-namespace frc971 {
-namespace teensy {
-namespace testing {
+namespace frc971::teensy::testing {
TEST(QueueTest, Basic) {
Queue queue(64);
@@ -40,6 +38,4 @@
ASSERT_TRUE(queue.empty());
}
-} // namespace testing
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy::testing
diff --git a/motors/usb/usb.cc b/motors/usb/usb.cc
index 2c64b61..e5e581b 100644
--- a/motors/usb/usb.cc
+++ b/motors/usb/usb.cc
@@ -6,8 +6,7 @@
#include "motors/util.h"
-namespace frc971 {
-namespace teensy {
+namespace frc971::teensy {
namespace {
// The mask of interrupts we care about.
@@ -1068,5 +1067,4 @@
*MutableBdtEntry(endpoint, direction, odd) = bdt_entry;
}
-} // namespace teensy
-} // namespace frc971
+} // namespace frc971::teensy