HAND FIXES: Manual cleanup of namespaces

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:38 -05:00
committed by Peter Johnson
parent ad138270a8
commit 3f740894c9
35 changed files with 77 additions and 59 deletions

View File

@@ -24,7 +24,7 @@ VisionRunnerBase::VisionRunnerBase(cs::VideoSource videoSource)
VisionRunnerBase::~VisionRunnerBase() = default;
void VisionRunnerBase::RunOnce() {
auto csShared = wpi::vision::GetCameraServerShared();
auto csShared = wpi::GetCameraServerShared();
auto res = csShared->GetRobotMainThreadId();
if (res.second && (std::this_thread::get_id() == res.first)) {
csShared->SetVisionRunnerError(
@@ -41,7 +41,7 @@ void VisionRunnerBase::RunOnce() {
}
void VisionRunnerBase::RunForever() {
auto csShared = wpi::vision::GetCameraServerShared();
auto csShared = wpi::GetCameraServerShared();
auto res = csShared->GetRobotMainThreadId();
if (res.second && (std::this_thread::get_id() == res.first)) {
csShared->SetVisionRunnerError(

View File

@@ -9,7 +9,7 @@
#include "wpi/commands2/CommandPtr.hpp"
#include "wpi/math/filter/Debouncer.hpp"
using namespace frc;
using namespace wpi;
using namespace wpi::cmd;
Trigger::Trigger(const Trigger& other) = default;

View File

@@ -161,7 +161,7 @@ class DataLog {
template <wpi::util::ProtobufSerializable T>
void AddProtobufSchema(wpi::util::ProtobufMessage<T>& msg, int64_t timestamp = 0) {
if (timestamp == 0) {
timestamp = Now();
timestamp = wpi::util::Now();
}
msg.ForEachProtobufDescriptor(
[this](auto typeString) { return HasSchema(typeString); },
@@ -182,7 +182,7 @@ class DataLog {
requires wpi::util::StructSerializable<T, I...>
void AddStructSchema(const I&... info, int64_t timestamp = 0) {
if (timestamp == 0) {
timestamp = Now();
timestamp = wpi::util::Now();
}
wpi::util::ForEachStructSchema<T>(
[this, timestamp](auto typeString, auto schema) {

View File

@@ -18,7 +18,7 @@ namespace wpi::romi {
*
* A general use PWM motor controller representing the motors on a Romi robot
*/
class RomiMotor : public PWMMotorController {
class RomiMotor : public wpi::PWMMotorController {
public:
/**
* Constructor for a RomiMotor.

View File

@@ -612,9 +612,9 @@ void Analyzer::DisplayFeedbackGains() {
sysid::CreateTooltip(
"Gain presets represent how feedback gains are calculated for your "
"specific feedback controller:\n\n"
"Default, WPILib (2020-): For use with the new WPILib wpi::math::PIDController "
"Default, WPILib (2020-): For use with the new WPILib PIDController "
"class.\n"
"WPILib (Pre-2020): For use with the old WPILib wpi::math::PIDController class.\n"
"WPILib (Pre-2020): For use with the old WPILib PIDController class.\n"
"CTRE: For use with CTRE units. These are the default units that ship "
"with CTRE motor controllers.\n"
"REV (Brushless): For use with NEO and NEO 550 motors on a SPARK MAX.\n"

View File

@@ -25,7 +25,9 @@ namespace wpi {
namespace log {
class DataLogReaderEntry;
} // namespace log
class wpi::util::Logger;
namespace util {
class Logger;
}
} // namespace wpi
namespace sysid {

View File

@@ -25,7 +25,9 @@ namespace log {
class DataLogReaderEntry;
class DataLogReaderThread;
} // namespace log
class wpi::util::Logger;
namespace util {
class Logger;
}
} // namespace wpi
namespace sysid {

View File

@@ -13,7 +13,7 @@
#include "wpi/sysid/analysis/FilteringUtils.hpp"
#include "wpi/sysid/analysis/Storage.hpp"
TEST(FilterTest, wpi::math::MedianFilter) {
TEST(FilterTest, MedianFilter) {
std::vector<sysid::PreparedData> testData{
sysid::PreparedData{0_s, 0, 0, 0}, sysid::PreparedData{0_s, 0, 0, 1},
sysid::PreparedData{0_s, 0, 0, 10}, sysid::PreparedData{0_s, 0, 0, 5},

View File

@@ -288,7 +288,7 @@ compose_r_core(// output
Described here:
Altmann, Simon L. "Hamilton, Rodrigues, and the wpi::math::Quaternion Scandal."
Altmann, Simon L. "Hamilton, Rodrigues, and the Quaternion Scandal."
Mathematics Magazine, vol. 62, no. 5, 1989, pp. 291308
Available here:

View File

@@ -6,6 +6,8 @@
#include "wpi/util/Color8Bit.hpp"
#include <memory>
using namespace wpi;
MechanismRoot2d::MechanismRoot2d(std::string_view name, double x, double y,

View File

@@ -9,7 +9,7 @@
#include "wpi/event/BooleanEvent.hpp"
namespace nt {
namespace wpi::nt {
class BooleanSubscriber;
class BooleanTopic;
class NetworkTable;

View File

@@ -17,10 +17,13 @@
#include "wpi/util/SmallVector.hpp"
#include "wpi/util/mutex.hpp"
namespace wpi::math {
class Trajectory;
}
namespace wpi {
class Field2d;
class wpi::math::Trajectory;
/**
* Game field object on a Field2d.

View File

@@ -14,7 +14,7 @@
#include "wpi/nt/NetworkTableEntry.hpp"
#include "wpi/nt/NetworkTableValue.hpp"
namespace wpi {
namespace wpi::util {
class Sendable;
} // namespace wpi

View File

@@ -2,7 +2,7 @@ classes:
wpi::sim::DifferentialDrivetrainSim:
typealias:
- wpi::math::DCMotor
- template <int S, int I, int O> using wpi::math::LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int S, int I, int O> using LinearSystem = wpi::math::LinearSystem<S, I, O>
methods:
DifferentialDrivetrainSim:
overloads:

View File

@@ -2,8 +2,8 @@ classes:
wpi::sim::ElevatorSim:
typealias:
- wpi::math::DCMotor
- template <int S, int I, int O> using wpi::math::LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using wpi::math::Vectord = wpi::math::Vectord<I>
- template <int S, int I, int O> using LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using Vectord = wpi::math::Vectord<I>
methods:
ElevatorSim:
overloads:

View File

@@ -2,7 +2,7 @@ classes:
wpi::sim::FlywheelSim:
typealias:
- wpi::math::DCMotor
- template <int S, int I, int O> using wpi::math::LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int S, int I, int O> using LinearSystem = wpi::math::LinearSystem<S, I, O>
methods:
FlywheelSim:
overloads:

View File

@@ -1,8 +1,8 @@
classes:
wpi::sim::LinearSystemSim:
typealias:
- template <int S, int I, int O> using wpi::math::LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using wpi::math::Vectord = wpi::math::Vectord<I>
- template <int S, int I, int O> using LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using Vectord = wpi::math::Vectord<I>
template_params:
- int States
- int Inputs

View File

@@ -2,8 +2,8 @@ classes:
wpi::sim::SingleJointedArmSim:
typealias:
- wpi::math::DCMotor
- template <int S, int I, int O> using wpi::math::LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using wpi::math::Vectord = wpi::math::Vectord<I>
- template <int S, int I, int O> using LinearSystem = wpi::math::LinearSystem<S, I, O>
- template <int I> using Vectord = wpi::math::Vectord<I>
methods:
SingleJointedArmSim:
overloads:

View File

@@ -8,14 +8,14 @@ void ResetSmartDashboardInstance();
void ResetMotorSafety();
} // namespace wpi::impl
namespace wpi::impl {
namespace wpi::util::impl {
void ResetSendableRegistry();
} // namespace wpi::impl
void resetWpilibSimulationData() {
wpi::impl::ResetSmartDashboardInstance();
wpi::impl::ResetMotorSafety();
wpi::impl::ResetSendableRegistry();
wpi::util::impl::ResetSendableRegistry();
}
void resetMotorSafety() {

View File

@@ -271,7 +271,7 @@ public final class DataLogManager {
return filenameOverride;
}
Random rnd = new Random();
StringBuilder filename = new StringBuilder();
StringBuilder filename = new StringBuilder(18);
filename.append("FRC_TBD_");
for (int i = 0; i < 4; i++) {
filename.append(String.format("%04x", rnd.nextInt(0x10000)));

View File

@@ -87,7 +87,7 @@ using namespace wpi::units::torque;
using namespace wpi::units::velocity;
using namespace wpi::units::voltage;
using namespace wpi::units::volume;
using namespace units;
using namespace wpi::units;
#if !defined(_MSC_VER) || _MSC_VER > 1800
using namespace wpi::units::literals;

View File

@@ -13,7 +13,7 @@ def wpinet_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includ
header_file = "$(execpath :robotpy-native-wpinet.copy_headers)/wpi/net/PortForwarder.hpp",
tmpl_class_names = [],
trampolines = [
("wpi::PortForwarder", "wpi__PortForwarder.hpp"),
("wpi::net::PortForwarder", "wpi__net__PortForwarder.hpp"),
],
),
struct(
@@ -23,7 +23,7 @@ def wpinet_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includ
header_file = "$(execpath :robotpy-native-wpinet.copy_headers)/wpi/net/WebServer.hpp",
tmpl_class_names = [],
trampolines = [
("wpi::WebServer", "wpi__WebServer.hpp"),
("wpi::net::WebServer", "wpi__net__WebServer.hpp"),
],
),
]

View File

@@ -10,10 +10,11 @@
#include "wpi/util/Signal.h"
namespace wpi::net {
namespace wpi::util {
class Logger;
}
namespace wpi::net {
namespace uv {
class Loop;
class Tcp;

View File

@@ -12,9 +12,11 @@
#include "wpi/net/HttpParser.hpp"
#include "wpi/net/uv/Stream.hpp"
namespace wpi::net {
namespace wpi::util {
class raw_ostream;
}
namespace wpi::net {
class HttpServerConnection {
public:

View File

@@ -15,10 +15,11 @@
#include "wpi/net/uv/Timer.hpp"
namespace wpi::net {
namespace wpi::util {
class Logger;
}
namespace wpi::net {
namespace uv {
class GetAddrInfoReq;
class Loop;

View File

@@ -12,10 +12,11 @@
#include "wpi/util/SmallVector.hpp"
#include "wpi/util/mutex.hpp"
namespace wpi::net {
namespace wpi::util {
class Logger;
}
namespace wpi::net {
class UDPClient {
int m_lsd;
int m_port;

View File

@@ -8,10 +8,12 @@
#include <string>
#include <string_view>
namespace wpi::net {
namespace wpi::util {
template <typename T>
class SmallVectorImpl;
}
namespace wpi::net {
std::string GetHostname();
std::string_view GetHostname(wpi::util::SmallVectorImpl<char>& name);
} // namespace wpi::net

View File

@@ -18,7 +18,7 @@
#include "wpi/net/uv/Loop.hpp"
#include "wpi/util/Signal.h"
namespace wpi::net {
namespace wpi::util {
class Logger;
} // namespace wpi::net

View File

@@ -50,7 +50,7 @@ void ResolverThread::RemoveServiceRefInThread(DNSServiceRef serviceRef) {
WPI_EventHandle ResolverThread::RemoveServiceRefOutsideThread(
DNSServiceRef serviceRef) {
std::scoped_lock lock{serviceRefMutex};
WPI_EventHandle handle = CreateEvent(true);
WPI_EventHandle handle = wpi::util::CreateEvent(true);
serviceRefsToRemove.push_back({serviceRef, handle});
return handle;
}

View File

@@ -32,10 +32,11 @@
#include "wpi/net/NetworkAcceptor.hpp"
#include "wpi/net/TCPStream.h"
namespace wpi::net {
namespace wpi::util {
class Logger;
}
namespace wpi::net {
class TCPAcceptor : public NetworkAcceptor {
int m_lsd;
int m_port;

View File

@@ -30,10 +30,11 @@
#include "wpi/net/NetworkStream.hpp"
namespace wpi::net {
namespace wpi::util {
class Logger;
}
namespace wpi::net {
class TCPConnector {
public:
static std::unique_ptr<NetworkStream> connect(const char* server, int port,

View File

@@ -36,8 +36,8 @@ TEST(WorkerThreadTest, FutureVoid) {
}
TEST(WorkerThreadTest, Loop) {
mutex m;
condition_variable cv;
wpi::util::mutex m;
wpi::util::condition_variable cv;
int callbacks = 0;
WorkerThread<int(bool)> worker;
@@ -60,8 +60,8 @@ TEST(WorkerThreadTest, Loop) {
}
TEST(WorkerThreadTest, LoopVoid) {
mutex m;
condition_variable cv;
wpi::util::mutex m;
wpi::util::condition_variable cv;
int callbacks = 0;
WorkerThread<void(bool)> worker;

View File

@@ -38,7 +38,7 @@ def wpiutil_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], inclu
header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/sendable/Sendable.hpp",
tmpl_class_names = [],
trampolines = [
("wpi::Sendable", "wpi__Sendable.hpp"),
("wpi::util::Sendable", "wpi__util__Sendable.hpp"),
],
),
struct(
@@ -48,7 +48,7 @@ def wpiutil_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], inclu
header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/sendable/SendableBuilder.hpp",
tmpl_class_names = [],
trampolines = [
("wpi::SendableBuilder", "wpi__SendableBuilder.hpp"),
("wpi::util::SendableBuilder", "wpi__util__SendableBuilder.hpp"),
],
),
struct(
@@ -58,7 +58,7 @@ def wpiutil_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], inclu
header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/sendable/SendableRegistry.hpp",
tmpl_class_names = [],
trampolines = [
("wpi::SendableRegistry", "wpi__SendableRegistry.hpp"),
("wpi::util::SendableRegistry", "wpi__util__SendableRegistry.hpp"),
],
),
struct(

View File

@@ -6,7 +6,7 @@
#include <utility>
namespace wpi {
namespace wpi::util {
template <typename F>
class scope_exit {
@@ -34,4 +34,4 @@ class scope_exit {
bool m_active = true;
};
} // namespace wpi
} // namespace wpi::util

View File

@@ -81,7 +81,7 @@
#elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
#ifndef WPI_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
#define WPI_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
namespace wpi {
namespace wpi::util {
namespace detail_expected {
template <class T>
struct is_trivially_copy_constructible
@@ -91,11 +91,11 @@ template <class T, class A>
struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {};
#endif
} // namespace detail_expected
} // namespace wpi
} // namespace wpi::util
#endif
#define WPI_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
wpi::detail_expected::is_trivially_copy_constructible<T>
wpi::util::detail_expected::is_trivially_copy_constructible<T>
#define WPI_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable<T>
#define WPI_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \
@@ -126,7 +126,7 @@ struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {};
#define WPI_EXPECTED_11_CONSTEXPR constexpr
#endif
namespace wpi {
namespace wpi::util {
template <class T, class E> class expected;
#ifndef WPI_MONOSTATE_INPLACE_MUTEX
@@ -388,7 +388,7 @@ struct is_nothrow_swappable
#endif
#endif
// Trait for checking if a type is a wpi::expected
// Trait for checking if a type is a wpi::util::expected
template <class T> struct is_expected_impl : std::false_type {};
template <class T, class E>
struct is_expected_impl<expected<T, E>> : std::true_type {};
@@ -2439,6 +2439,6 @@ void swap(expected<T, E> &lhs,
expected<T, E> &rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}
} // namespace wpi
} // namespace wpi::util
#endif