diff --git a/apriltag/src/main/native/include/wpi/apriltag/AprilTag.hpp b/apriltag/src/main/native/include/wpi/apriltag/AprilTag.hpp index 5189c05be4..87384cef07 100644 --- a/apriltag/src/main/native/include/wpi/apriltag/AprilTag.hpp +++ b/apriltag/src/main/native/include/wpi/apriltag/AprilTag.hpp @@ -5,7 +5,7 @@ #pragma once #include "wpi/math/geometry/Pose3d.hpp" -#include "wpi/util/RawFrame.h" +#include "wpi/util/RawFrame.hpp" #include "wpi/util/SymbolExports.hpp" #include "wpi/util/json_fwd.hpp" diff --git a/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp b/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp index 2290f94a37..49c8abba6c 100644 --- a/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp +++ b/cscore/src/main/native/cpp/ConfigurableSourceImpl.cpp @@ -10,7 +10,8 @@ #include "Handle.hpp" #include "Instance.hpp" #include "Notifier.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/Handle.hpp b/cscore/src/main/native/cpp/Handle.hpp index 696609327d..1711b02390 100644 --- a/cscore/src/main/native/cpp/Handle.hpp +++ b/cscore/src/main/native/cpp/Handle.hpp @@ -5,7 +5,7 @@ #pragma once #include "wpi/cs/cscore_c.h" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" namespace wpi::cs { @@ -27,8 +27,8 @@ class Handle { }; enum { kIndexMax = 0xffff }; - Handle(CS_Handle handle) : m_handle(handle) {} // NOLINT - operator CS_Handle() const { return m_handle; } + Handle(CS_Handle handle) : m_handle(handle) {} // NOLINT + operator CS_Handle() const { return m_handle; } // NOLINT Handle(int index, Type type) { if (index < 0) { diff --git a/cscore/src/main/native/cpp/HttpCameraImpl.cpp b/cscore/src/main/native/cpp/HttpCameraImpl.cpp index 4b46a3a765..fb325141f2 100644 --- a/cscore/src/main/native/cpp/HttpCameraImpl.cpp +++ b/cscore/src/main/native/cpp/HttpCameraImpl.cpp @@ -18,9 +18,9 @@ #include "Telemetry.hpp" #include "c_util.hpp" #include "wpi/net/TCPConnector.h" -#include "wpi/util/MemAlloc.hpp" #include "wpi/util/StringExtras.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/MjpegServerImpl.cpp b/cscore/src/main/native/cpp/MjpegServerImpl.cpp index 5a9cecce03..bc6fb4feba 100644 --- a/cscore/src/main/native/cpp/MjpegServerImpl.cpp +++ b/cscore/src/main/native/cpp/MjpegServerImpl.cpp @@ -23,7 +23,7 @@ #include "wpi/util/SmallString.hpp" #include "wpi/util/StringExtras.hpp" #include "wpi/util/fmt/raw_ostream.hpp" -#include "wpi/util/print.hpp" +#include "wpi/util/string.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/RawSinkImpl.cpp b/cscore/src/main/native/cpp/RawSinkImpl.cpp index eaf205aa4e..9447714669 100644 --- a/cscore/src/main/native/cpp/RawSinkImpl.cpp +++ b/cscore/src/main/native/cpp/RawSinkImpl.cpp @@ -9,6 +9,7 @@ #include "Instance.hpp" #include "wpi/cs/cscore_raw.h" +#include "wpi/util/string.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/RawSourceImpl.cpp b/cscore/src/main/native/cpp/RawSourceImpl.cpp index b401c43f63..40ed58ec6c 100644 --- a/cscore/src/main/native/cpp/RawSourceImpl.cpp +++ b/cscore/src/main/native/cpp/RawSourceImpl.cpp @@ -9,7 +9,8 @@ #include "Instance.hpp" #include "Notifier.hpp" #include "wpi/cs/cscore_raw.h" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/SinkImpl.cpp b/cscore/src/main/native/cpp/SinkImpl.cpp index 132769c477..81be1818ae 100644 --- a/cscore/src/main/native/cpp/SinkImpl.cpp +++ b/cscore/src/main/native/cpp/SinkImpl.cpp @@ -12,6 +12,7 @@ #include "c_util.hpp" #include "wpi/util/SmallString.hpp" #include "wpi/util/json.hpp" +#include "wpi/util/string.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/SourceImpl.cpp b/cscore/src/main/native/cpp/SourceImpl.cpp index 467204df9e..8bcfc58f25 100644 --- a/cscore/src/main/native/cpp/SourceImpl.cpp +++ b/cscore/src/main/native/cpp/SourceImpl.cpp @@ -16,7 +16,7 @@ #include "Telemetry.hpp" #include "wpi/util/StringExtras.hpp" #include "wpi/util/json.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/UsbCameraImplCommon.cpp b/cscore/src/main/native/cpp/UsbCameraImplCommon.cpp index bd521e67fe..a17a5626f1 100644 --- a/cscore/src/main/native/cpp/UsbCameraImplCommon.cpp +++ b/cscore/src/main/native/cpp/UsbCameraImplCommon.cpp @@ -9,6 +9,7 @@ #include "c_util.hpp" #include "wpi/cs/cscore_cpp.hpp" #include "wpi/util/MemAlloc.hpp" +#include "wpi/util/string.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/cpp/cscore_c.cpp b/cscore/src/main/native/cpp/cscore_c.cpp index 814d01d159..5e9c34ada0 100644 --- a/cscore/src/main/native/cpp/cscore_c.cpp +++ b/cscore/src/main/native/cpp/cscore_c.cpp @@ -14,6 +14,7 @@ #include "wpi/cs/cscore_cpp.hpp" #include "wpi/util/MemAlloc.hpp" #include "wpi/util/SmallString.hpp" +#include "wpi/util/string.hpp" static CS_Event ConvertToC(const wpi::cs::RawEvent& rawEvent) { CS_Event event; diff --git a/cscore/src/main/native/include/wpi/cs/cscore_cv.hpp b/cscore/src/main/native/include/wpi/cs/cscore_cv.hpp index b1ee3b5d45..1a2b6a6eea 100644 --- a/cscore/src/main/native/include/wpi/cs/cscore_cv.hpp +++ b/cscore/src/main/native/include/wpi/cs/cscore_cv.hpp @@ -4,13 +4,11 @@ #pragma once -#include - #include #include "wpi/cs/cscore_oo.hpp" #include "wpi/cs/cscore_raw.h" -#include "wpi/util/RawFrame.h" +#include "wpi/util/RawFrame.hpp" namespace wpi::cs { /** diff --git a/cscore/src/main/native/include/wpi/cs/cscore_raw.h b/cscore/src/main/native/include/wpi/cs/cscore_raw.h index 5d4f0a48c4..cfeb840df0 100644 --- a/cscore/src/main/native/include/wpi/cs/cscore_raw.h +++ b/cscore/src/main/native/include/wpi/cs/cscore_raw.h @@ -11,6 +11,7 @@ // NOLINTBEGIN #ifdef __cplusplus #include "wpi/cs/cscore_oo.hpp" +#include "wpi/util/RawFrame.hpp" #endif #ifdef __cplusplus diff --git a/cscore/src/main/native/linux/RunLoopHelpers.cpp b/cscore/src/main/native/linux/RunLoopHelpers.cpp index 26f07e9661..6832efe0b2 100644 --- a/cscore/src/main/native/linux/RunLoopHelpers.cpp +++ b/cscore/src/main/native/linux/RunLoopHelpers.cpp @@ -3,7 +3,7 @@ // the WPILib BSD license file in the root directory of this project. #include "wpi/cs/cscore_runloop.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" static wpi::util::Event& GetInstance() { static wpi::util::Event event; diff --git a/cscore/src/main/native/linux/UsbCameraImpl.cpp b/cscore/src/main/native/linux/UsbCameraImpl.cpp index 657168c3e9..6e673c962e 100644 --- a/cscore/src/main/native/linux/UsbCameraImpl.cpp +++ b/cscore/src/main/native/linux/UsbCameraImpl.cpp @@ -34,12 +34,10 @@ #include "Telemetry.hpp" #include "UsbUtil.hpp" #include "wpi/cs/cscore_cpp.hpp" -#include "wpi/util/MemAlloc.hpp" #include "wpi/util/SmallString.hpp" #include "wpi/util/StringExtras.hpp" #include "wpi/util/fs.hpp" -#include "wpi/util/raw_ostream.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::cs; diff --git a/cscore/src/main/native/objcpp/UsbCameraDelegate.mm b/cscore/src/main/native/objcpp/UsbCameraDelegate.mm index 136698b6f5..c2544248cc 100644 --- a/cscore/src/main/native/objcpp/UsbCameraDelegate.mm +++ b/cscore/src/main/native/objcpp/UsbCameraDelegate.mm @@ -5,7 +5,7 @@ #import "UsbCameraDelegate.hpp" #include "UsbCameraImpl.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" @implementation UsbCameraDelegate diff --git a/cscore/src/main/native/objcpp/UsbCameraImpl.mm b/cscore/src/main/native/objcpp/UsbCameraImpl.mm index 95dafa45c7..3d87763fa3 100644 --- a/cscore/src/main/native/objcpp/UsbCameraImpl.mm +++ b/cscore/src/main/native/objcpp/UsbCameraImpl.mm @@ -9,7 +9,7 @@ #include #include -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" #pragma GCC diagnostic ignored "-Wunused-parameter" #include "Handle.hpp" diff --git a/cscore/src/main/native/windows/RunLoopHelpers.cpp b/cscore/src/main/native/windows/RunLoopHelpers.cpp index 26f07e9661..6832efe0b2 100644 --- a/cscore/src/main/native/windows/RunLoopHelpers.cpp +++ b/cscore/src/main/native/windows/RunLoopHelpers.cpp @@ -3,7 +3,7 @@ // the WPILib BSD license file in the root directory of this project. #include "wpi/cs/cscore_runloop.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" static wpi::util::Event& GetInstance() { static wpi::util::Event event; diff --git a/cscore/src/main/native/windows/UsbCameraImpl.cpp b/cscore/src/main/native/windows/UsbCameraImpl.cpp index 474af4830a..af6f7eaa3f 100644 --- a/cscore/src/main/native/windows/UsbCameraImpl.cpp +++ b/cscore/src/main/native/windows/UsbCameraImpl.cpp @@ -38,7 +38,7 @@ #include "wpi/util/MemAlloc.hpp" #include "wpi/util/SmallString.hpp" #include "wpi/util/StringExtras.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" #pragma comment(lib, "Mfplat.lib") #pragma comment(lib, "Mf.lib") diff --git a/datalog/src/main/native/cpp/DataLog.cpp b/datalog/src/main/native/cpp/DataLog.cpp index 9090beb8f9..589002b1b9 100644 --- a/datalog/src/main/native/cpp/DataLog.cpp +++ b/datalog/src/main/native/cpp/DataLog.cpp @@ -17,7 +17,8 @@ #include "wpi/util/Logger.hpp" #include "wpi/util/SmallString.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" using namespace wpi::log; diff --git a/datalog/src/main/native/cpp/DataLogBackgroundWriter.cpp b/datalog/src/main/native/cpp/DataLogBackgroundWriter.cpp index 811a0457aa..18825dd8d2 100644 --- a/datalog/src/main/native/cpp/DataLogBackgroundWriter.cpp +++ b/datalog/src/main/native/cpp/DataLogBackgroundWriter.cpp @@ -26,6 +26,7 @@ #include "wpi/util/Logger.hpp" #include "wpi/util/fs.hpp" +#include "wpi/util/string.hpp" using namespace wpi::log; diff --git a/datalog/src/main/native/cpp/DataLogWriter.cpp b/datalog/src/main/native/cpp/DataLogWriter.cpp index 53d4214e7c..a3f088e588 100644 --- a/datalog/src/main/native/cpp/DataLogWriter.cpp +++ b/datalog/src/main/native/cpp/DataLogWriter.cpp @@ -9,6 +9,7 @@ #include #include "wpi/util/raw_ostream.hpp" +#include "wpi/util/string.hpp" using namespace wpi::log; diff --git a/datalog/src/main/native/include/wpi/datalog/DataLog_c.h b/datalog/src/main/native/include/wpi/datalog/DataLog.h similarity index 100% rename from datalog/src/main/native/include/wpi/datalog/DataLog_c.h rename to datalog/src/main/native/include/wpi/datalog/DataLog.h diff --git a/datalog/src/main/native/include/wpi/datalog/DataLog.hpp b/datalog/src/main/native/include/wpi/datalog/DataLog.hpp index cf22d88a2b..339ba9f8ee 100644 --- a/datalog/src/main/native/include/wpi/datalog/DataLog.hpp +++ b/datalog/src/main/native/include/wpi/datalog/DataLog.hpp @@ -19,7 +19,6 @@ #include #include -#include "wpi/datalog/DataLog_c.h" #include "wpi/util/DenseMap.hpp" #include "wpi/util/SmallVector.hpp" #include "wpi/util/StringMap.hpp" @@ -27,7 +26,7 @@ #include "wpi/util/protobuf/Protobuf.hpp" #include "wpi/util/string.h" #include "wpi/util/struct/Struct.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" namespace wpi::util { class Logger; diff --git a/datalog/src/main/python/pyproject.toml b/datalog/src/main/python/pyproject.toml index bb4edd68c5..90a8e4e211 100644 --- a/datalog/src/main/python/pyproject.toml +++ b/datalog/src/main/python/pyproject.toml @@ -42,7 +42,7 @@ update_init = [ ] scan_headers_ignore = [ # wpi/datalog - "wpi/datalog/DataLog_c.h", + "wpi/datalog/DataLog.h", "wpi/datalog/DataLogReaderThread.hpp", "wpi/datalog/FileLogger.hpp", ] @@ -59,5 +59,5 @@ DataLogBackgroundWriter = "wpi/datalog/DataLogBackgroundWriter.hpp" DataLogReader = "wpi/datalog/DataLogReader.hpp" # DataLogReaderThread = "wpi/datalog/DataLogReaderThread.hpp" DataLogWriter = "wpi/datalog/DataLogWriter.hpp" -# DataLog_c = "wpi/datalog/DataLog_c.h" -# FileLogger = "wpi/datalog/FileLogger.hpp" \ No newline at end of file +# DataLog_c = "wpi/datalog/DataLog.h" +# FileLogger = "wpi/datalog/FileLogger.hpp" diff --git a/glass/src/lib/native/cpp/Context.cpp b/glass/src/lib/native/cpp/Context.cpp index 507f1e95e0..3988577f16 100644 --- a/glass/src/lib/native/cpp/Context.cpp +++ b/glass/src/lib/native/cpp/Context.cpp @@ -22,7 +22,7 @@ #include "wpi/util/fs.hpp" #include "wpi/util/json.hpp" #include "wpi/util/raw_ostream.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::glass; diff --git a/glass/src/lib/native/cpp/other/Plot.cpp b/glass/src/lib/native/cpp/other/Plot.cpp index e8de7f325a..e1db489aeb 100644 --- a/glass/src/lib/native/cpp/other/Plot.cpp +++ b/glass/src/lib/native/cpp/other/Plot.cpp @@ -35,9 +35,7 @@ #include "wpi/glass/support/EnumSetting.hpp" #include "wpi/glass/support/ExtraGuiWidgets.hpp" #include "wpi/util/Signal.h" -#include "wpi/util/SmallString.hpp" -#include "wpi/util/SmallVector.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::glass; diff --git a/hal/src/main/native/cpp/DashboardOpMode.cpp b/hal/src/main/native/cpp/DashboardOpMode.cpp index c793675a88..e17cf579da 100644 --- a/hal/src/main/native/cpp/DashboardOpMode.cpp +++ b/hal/src/main/native/cpp/DashboardOpMode.cpp @@ -18,7 +18,7 @@ #include "wpi/nt/ntcore_cpp.hpp" #include "wpi/util/StringMap.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" using namespace wpi; diff --git a/hal/src/main/native/cpp/jni/AlertJNI.cpp b/hal/src/main/native/cpp/jni/AlertJNI.cpp index 976589344d..68b619d505 100644 --- a/hal/src/main/native/cpp/jni/AlertJNI.cpp +++ b/hal/src/main/native/cpp/jni/AlertJNI.cpp @@ -11,7 +11,7 @@ #include "org_wpilib_hardware_hal_AlertJNI.h" #include "wpi/hal/Alert.h" #include "wpi/util/jni_util.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" using namespace wpi::hal; using namespace wpi::util::java; diff --git a/hal/src/main/native/include/wpi/hal/Notifier.hpp b/hal/src/main/native/include/wpi/hal/Notifier.hpp index 22a7e80603..f3f52148b0 100644 --- a/hal/src/main/native/include/wpi/hal/Notifier.hpp +++ b/hal/src/main/native/include/wpi/hal/Notifier.hpp @@ -7,6 +7,7 @@ #include #include "wpi/hal/Notifier.h" +#include "wpi/util/string.hpp" /** * Sets the name of a notifier. diff --git a/hal/src/main/native/include/wpi/hal/UsageReporting.hpp b/hal/src/main/native/include/wpi/hal/UsageReporting.hpp index b6707179b6..957ba516c1 100644 --- a/hal/src/main/native/include/wpi/hal/UsageReporting.hpp +++ b/hal/src/main/native/include/wpi/hal/UsageReporting.hpp @@ -7,6 +7,7 @@ #include #include "wpi/hal/UsageReporting.h" +#include "wpi/util/string.hpp" /** * Reports usage of a resource of interest. Repeated calls for the same diff --git a/hal/src/main/native/include/wpi/hal/handles/HandlesInternal.hpp b/hal/src/main/native/include/wpi/hal/handles/HandlesInternal.hpp index 2c95e759f7..35a721ed00 100644 --- a/hal/src/main/native/include/wpi/hal/handles/HandlesInternal.hpp +++ b/hal/src/main/native/include/wpi/hal/handles/HandlesInternal.hpp @@ -7,7 +7,7 @@ #include #include "wpi/hal/Types.h" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" /* General Handle Data Layout * Bits 0-15: Handle Index diff --git a/hal/src/main/native/sim/Alert.cpp b/hal/src/main/native/sim/Alert.cpp index b8dc00a079..da426cba2c 100644 --- a/hal/src/main/native/sim/Alert.cpp +++ b/hal/src/main/native/sim/Alert.cpp @@ -16,7 +16,7 @@ #include "wpi/hal/handles/UnlimitedHandleResource.hpp" #include "wpi/hal/simulation/AlertData.h" #include "wpi/util/mutex.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" namespace { struct Alert { diff --git a/hal/src/main/native/sim/CANAPI.cpp b/hal/src/main/native/sim/CANAPI.cpp index 0f5e4907f7..d04afcd816 100644 --- a/hal/src/main/native/sim/CANAPI.cpp +++ b/hal/src/main/native/sim/CANAPI.cpp @@ -14,7 +14,7 @@ #include "wpi/hal/handles/UnlimitedHandleResource.hpp" #include "wpi/util/DenseMap.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/sim/MockHooks.cpp b/hal/src/main/native/sim/MockHooks.cpp index 059f430932..f9908e73f6 100644 --- a/hal/src/main/native/sim/MockHooks.cpp +++ b/hal/src/main/native/sim/MockHooks.cpp @@ -14,7 +14,7 @@ #include "NotifierInternal.hpp" #include "wpi/hal/simulation/NotifierData.h" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" static std::atomic programStarted{false}; static std::atomic programState{0}; diff --git a/hal/src/main/native/sim/Notifier.cpp b/hal/src/main/native/sim/Notifier.cpp index 231f019dbe..c24a75cc7e 100644 --- a/hal/src/main/native/sim/Notifier.cpp +++ b/hal/src/main/native/sim/Notifier.cpp @@ -26,8 +26,9 @@ #include "wpi/util/SafeThread.hpp" #include "wpi/util/SmallVector.hpp" #include "wpi/util/StringExtras.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/priority_queue.hpp" +#include "wpi/util/string.hpp" namespace { struct Notifier { diff --git a/hal/src/main/native/sim/mockdata/DriverStationData.cpp b/hal/src/main/native/sim/mockdata/DriverStationData.cpp index bc7c79d6a4..a0c3162075 100644 --- a/hal/src/main/native/sim/mockdata/DriverStationData.cpp +++ b/hal/src/main/native/sim/mockdata/DriverStationData.cpp @@ -14,6 +14,7 @@ #include "DriverStationDataInternal.hpp" #include "wpi/hal/DashboardOpMode.hpp" #include "wpi/hal/DriverStationTypes.h" +#include "wpi/util/string.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/sim/mockdata/RoboRioData.cpp b/hal/src/main/native/sim/mockdata/RoboRioData.cpp index 7cd9200c9f..99eff2d661 100644 --- a/hal/src/main/native/sim/mockdata/RoboRioData.cpp +++ b/hal/src/main/native/sim/mockdata/RoboRioData.cpp @@ -5,6 +5,7 @@ #include #include "RoboRioDataInternal.hpp" +#include "wpi/util/string.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/systemcore/Alert.cpp b/hal/src/main/native/systemcore/Alert.cpp index af9446dc2c..4c70be6e34 100644 --- a/hal/src/main/native/systemcore/Alert.cpp +++ b/hal/src/main/native/systemcore/Alert.cpp @@ -16,7 +16,7 @@ #include "wpi/hal/handles/UnlimitedHandleResource.hpp" #include "wpi/hal/simulation/AlertData.h" #include "wpi/util/mutex.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" namespace { struct Alert { diff --git a/hal/src/main/native/systemcore/CAN.cpp b/hal/src/main/native/systemcore/CAN.cpp index 55e0f59978..e2cdd86d9d 100644 --- a/hal/src/main/native/systemcore/CAN.cpp +++ b/hal/src/main/native/systemcore/CAN.cpp @@ -28,7 +28,7 @@ #include "wpi/util/circular_buffer.hpp" #include "wpi/util/mutex.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/systemcore/CANAPI.cpp b/hal/src/main/native/systemcore/CANAPI.cpp index c38c6e428d..086088531d 100644 --- a/hal/src/main/native/systemcore/CANAPI.cpp +++ b/hal/src/main/native/systemcore/CANAPI.cpp @@ -14,7 +14,7 @@ #include "wpi/hal/handles/UnlimitedHandleResource.hpp" #include "wpi/util/DenseMap.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/systemcore/FRCDriverStation.cpp b/hal/src/main/native/systemcore/FRCDriverStation.cpp index ba8d90d0c4..811c8821bc 100644 --- a/hal/src/main/native/systemcore/FRCDriverStation.cpp +++ b/hal/src/main/native/systemcore/FRCDriverStation.cpp @@ -39,8 +39,8 @@ #include "wpi/util/SmallVector.hpp" #include "wpi/util/condition_variable.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/string.h" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" static_assert(sizeof(int32_t) >= sizeof(int), "WPILIB_NetworkComm status variable is larger than 32 bits"); diff --git a/hal/src/main/native/systemcore/HAL.cpp b/hal/src/main/native/systemcore/HAL.cpp index a3de238362..9e4d3347b4 100644 --- a/hal/src/main/native/systemcore/HAL.cpp +++ b/hal/src/main/native/systemcore/HAL.cpp @@ -12,25 +12,15 @@ #include #include #include -#include -#include -#include -#include #include "CANInternal.hpp" #include "HALInitializer.hpp" #include "HALInternal.hpp" #include "SystemServerInternal.hpp" -#include "wpi/hal/DriverStation.h" #include "wpi/hal/Errors.h" -#include "wpi/hal/Notifier.h" -#include "wpi/hal/handles/HandlesInternal.hpp" -#include "wpi/util/MemoryBuffer.hpp" #include "wpi/util/StringExtras.hpp" -#include "wpi/util/fs.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::hal; diff --git a/hal/src/main/native/systemcore/Notifier.cpp b/hal/src/main/native/systemcore/Notifier.cpp index be67ad16cc..1a3b46fa60 100644 --- a/hal/src/main/native/systemcore/Notifier.cpp +++ b/hal/src/main/native/systemcore/Notifier.cpp @@ -19,8 +19,9 @@ #include "wpi/hal/Types.h" #include "wpi/hal/handles/UnlimitedHandleResource.hpp" #include "wpi/util/SafeThread.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/priority_queue.hpp" +#include "wpi/util/string.hpp" namespace { struct Notifier { diff --git a/hal/src/main/native/systemcore/UsageReporting.cpp b/hal/src/main/native/systemcore/UsageReporting.cpp index f89083995a..dd23043835 100644 --- a/hal/src/main/native/systemcore/UsageReporting.cpp +++ b/hal/src/main/native/systemcore/UsageReporting.cpp @@ -12,7 +12,7 @@ #include "wpi/nt/NetworkTableInstance.hpp" #include "wpi/nt/StringTopic.hpp" #include "wpi/util/StringMap.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" namespace { struct SystemServerUsageReporting { diff --git a/ntcore/src/dev/native/cpp/main.cpp b/ntcore/src/dev/native/cpp/main.cpp index 536cfdd01a..9f90b133bf 100644 --- a/ntcore/src/dev/native/cpp/main.cpp +++ b/ntcore/src/dev/native/cpp/main.cpp @@ -19,12 +19,10 @@ #include "wpi/nt/DoubleArrayTopic.hpp" #include "wpi/nt/NetworkTableInstance.hpp" -#include "wpi/nt/ntcore.h" #include "wpi/nt/ntcore_c.h" #include "wpi/nt/ntcore_cpp.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" void bench(); void bench2(); diff --git a/ntcore/src/generate/main/native/cpp/ntcore_c_types.cpp.jinja b/ntcore/src/generate/main/native/cpp/ntcore_c_types.cpp.jinja index d03030a90d..ef3f8e4ded 100644 --- a/ntcore/src/generate/main/native/cpp/ntcore_c_types.cpp.jinja +++ b/ntcore/src/generate/main/native/cpp/ntcore_c_types.cpp.jinja @@ -8,6 +8,7 @@ #include "Value_internal.hpp" #include "wpi/nt/ntcore_cpp.hpp" +#include "wpi/util/string.hpp" using namespace wpi::nt; diff --git a/ntcore/src/generated/main/native/cpp/ntcore_c_types.cpp b/ntcore/src/generated/main/native/cpp/ntcore_c_types.cpp index 202f8b909c..3c26786a4c 100644 --- a/ntcore/src/generated/main/native/cpp/ntcore_c_types.cpp +++ b/ntcore/src/generated/main/native/cpp/ntcore_c_types.cpp @@ -8,6 +8,7 @@ #include "Value_internal.hpp" #include "wpi/nt/ntcore_cpp.hpp" +#include "wpi/util/string.hpp" using namespace wpi::nt; diff --git a/ntcore/src/main/native/cpp/Handle.hpp b/ntcore/src/main/native/cpp/Handle.hpp index 455cdd58c6..452403029c 100644 --- a/ntcore/src/main/native/cpp/Handle.hpp +++ b/ntcore/src/main/native/cpp/Handle.hpp @@ -5,7 +5,7 @@ #pragma once #include "wpi/nt/ntcore_c.h" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" namespace wpi::nt { @@ -33,7 +33,7 @@ class Handle { enum { kIndexMax = 0xfffff }; constexpr explicit Handle(NT_Handle handle) : m_handle(handle) {} - constexpr operator NT_Handle() const { return m_handle; } + constexpr operator NT_Handle() const { return m_handle; } // NOLINT constexpr NT_Handle handle() const { return m_handle; } diff --git a/ntcore/src/main/native/cpp/net/ClientImpl.cpp b/ntcore/src/main/native/cpp/net/ClientImpl.cpp index 345d16b76d..3f2aae1291 100644 --- a/ntcore/src/main/native/cpp/net/ClientImpl.cpp +++ b/ntcore/src/main/native/cpp/net/ClientImpl.cpp @@ -13,16 +13,13 @@ #include -#include "Handle.hpp" #include "Log.hpp" #include "Message.hpp" -#include "NetworkInterface.hpp" #include "WireConnection.hpp" #include "WireEncoder.hpp" #include "wpi/nt/NetworkTableValue.hpp" #include "wpi/util/Logger.hpp" -#include "wpi/util/raw_ostream.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::nt; using namespace wpi::nt::net; diff --git a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp index d92af20b49..2547c4f514 100644 --- a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp +++ b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp @@ -13,7 +13,7 @@ #include "wpi/util/Logger.hpp" #include "wpi/util/SpanExtras.hpp" #include "wpi/util/raw_ostream.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::nt; using namespace wpi::nt::net; diff --git a/ntcore/src/main/native/cpp/ntcore_c.cpp b/ntcore/src/main/native/cpp/ntcore_c.cpp index 920b244555..82edf1dfd9 100644 --- a/ntcore/src/main/native/cpp/ntcore_c.cpp +++ b/ntcore/src/main/native/cpp/ntcore_c.cpp @@ -10,16 +10,14 @@ #include #include #include -#include #include #include "Value_internal.hpp" -#include "wpi/nt/ntcore.h" #include "wpi/nt/ntcore_cpp.hpp" #include "wpi/util/MemAlloc.hpp" #include "wpi/util/SmallVector.hpp" #include "wpi/util/json.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" using namespace wpi::nt; diff --git a/ntcore/src/main/native/cpp/server/ServerClient4.cpp b/ntcore/src/main/native/cpp/server/ServerClient4.cpp index ed6ad86104..6179d5055d 100644 --- a/ntcore/src/main/native/cpp/server/ServerClient4.cpp +++ b/ntcore/src/main/native/cpp/server/ServerClient4.cpp @@ -10,7 +10,7 @@ #include "net/WireDecoder.hpp" #include "server/ServerStorage.hpp" #include "server/ServerTopic.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::nt::server; diff --git a/ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp b/ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp index 0726d70c7e..ff1a209859 100644 --- a/ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp +++ b/ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/ntcore/src/test/native/cpp/ConnectionListenerTest.cpp b/ntcore/src/test/native/cpp/ConnectionListenerTest.cpp index 56fa7da290..331c929d44 100644 --- a/ntcore/src/test/native/cpp/ConnectionListenerTest.cpp +++ b/ntcore/src/test/native/cpp/ConnectionListenerTest.cpp @@ -10,7 +10,7 @@ #include "TestPrinters.hpp" #include "wpi/nt/ntcore_cpp.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/mutex.hpp" class ConnectionListenerTest : public ::testing::Test { diff --git a/ntcore/src/test/native/cpp/TopicListenerTest.cpp b/ntcore/src/test/native/cpp/TopicListenerTest.cpp index bfeb332d34..85af6902a7 100644 --- a/ntcore/src/test/native/cpp/TopicListenerTest.cpp +++ b/ntcore/src/test/native/cpp/TopicListenerTest.cpp @@ -13,8 +13,7 @@ #include "ValueMatcher.hpp" #include "wpi/nt/ntcore_c.h" #include "wpi/nt/ntcore_cpp.hpp" -#include "wpi/util/Synchronization.h" -#include "wpi/util/json.hpp" +#include "wpi/util/Synchronization.hpp" class TopicListenerTest : public ::testing::Test { public: diff --git a/ntcore/src/test/native/cpp/ValueListenerTest.cpp b/ntcore/src/test/native/cpp/ValueListenerTest.cpp index 91d51de0e2..235a4a57e0 100644 --- a/ntcore/src/test/native/cpp/ValueListenerTest.cpp +++ b/ntcore/src/test/native/cpp/ValueListenerTest.cpp @@ -8,8 +8,7 @@ #include "ValueMatcher.hpp" #include "wpi/nt/ntcore_c.h" #include "wpi/nt/ntcore_cpp.hpp" -#include "wpi/util/StringExtras.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" using ::testing::_; using ::testing::AnyNumber; diff --git a/ntcore/src/test/native/cpp/ValueTest.cpp b/ntcore/src/test/native/cpp/ValueTest.cpp index 480356c236..c8faab3578 100644 --- a/ntcore/src/test/native/cpp/ValueTest.cpp +++ b/ntcore/src/test/native/cpp/ValueTest.cpp @@ -13,6 +13,7 @@ #include "TestPrinters.hpp" #include "Value_internal.hpp" #include "wpi/nt/NetworkTableValue.hpp" +#include "wpi/util/string.hpp" using namespace std::string_view_literals; diff --git a/ntcoreffi/src/main/native/cpp/DataLogManager.cpp b/ntcoreffi/src/main/native/cpp/DataLogManager.cpp index 9cfd23552f..c49be76b4c 100644 --- a/ntcoreffi/src/main/native/cpp/DataLogManager.cpp +++ b/ntcoreffi/src/main/native/cpp/DataLogManager.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,7 @@ #include "wpi/util/StringExtras.hpp" #include "wpi/util/fs.hpp" #include "wpi/util/print.hpp" +#include "wpi/util/string.hpp" using namespace wpi; diff --git a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp index 3c20051d6a..fd1d16e205 100644 --- a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp @@ -32,6 +32,7 @@ #include "wpi/halsim/gui/HALSimGui.hpp" #include "wpi/util/SmallVector.hpp" #include "wpi/util/StringExtras.hpp" +#include "wpi/util/string.hpp" using namespace halsimgui; diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp index 97cd0350e5..51b1d7222a 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp @@ -8,11 +8,9 @@ #include #include -#include "wpi/hal/DriverStation.h" #include "wpi/hal/Extensions.h" -#include "wpi/hal/Ports.h" #include "wpi/hal/simulation/DriverStationData.h" -#include "wpi/util/raw_ostream.hpp" +#include "wpi/util/string.hpp" #define REGISTER(halsim, jsonid, ctype, haltype) \ HALSIM_RegisterDriverStation##halsim##Callback( \ diff --git a/wpilibc/src/main/native/cpp/driverstation/Alert.cpp b/wpilibc/src/main/native/cpp/driverstation/Alert.cpp index 9c784886fa..b8b140bee9 100644 --- a/wpilibc/src/main/native/cpp/driverstation/Alert.cpp +++ b/wpilibc/src/main/native/cpp/driverstation/Alert.cpp @@ -8,7 +8,7 @@ #include -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" using namespace wpi; diff --git a/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp b/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp index 31117cfe9d..bca903fd9b 100644 --- a/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp @@ -34,12 +34,10 @@ #include "wpi/util/DenseMap.hpp" #include "wpi/util/EventVector.hpp" #include "wpi/util/StringExtras.hpp" -#include "wpi/util/condition_variable.hpp" #include "wpi/util/json.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/string.h" -#include "wpi/util/struct/Struct.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/string.hpp" +#include "wpi/util/timestamp.hpp" using namespace wpi; diff --git a/wpilibc/src/main/native/cpp/hardware/led/LEDPattern.cpp b/wpilibc/src/main/native/cpp/hardware/led/LEDPattern.cpp index 45a519ad93..3d427609dc 100644 --- a/wpilibc/src/main/native/cpp/hardware/led/LEDPattern.cpp +++ b/wpilibc/src/main/native/cpp/hardware/led/LEDPattern.cpp @@ -14,7 +14,7 @@ #include "wpi/hal/UsageReporting.hpp" #include "wpi/math/util/MathUtil.hpp" #include "wpi/util/MathExtras.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi; diff --git a/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp b/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp index b5ce68b45a..7f28ee25ec 100644 --- a/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp +++ b/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp @@ -6,7 +6,7 @@ #include "wpi/driverstation/DriverStation.hpp" #include "wpi/hal/DriverStation.h" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" using namespace wpi::internal; diff --git a/wpilibc/src/main/native/cpp/simulation/AlertSim.cpp b/wpilibc/src/main/native/cpp/simulation/AlertSim.cpp index 4267c8b549..0a1ba556e7 100644 --- a/wpilibc/src/main/native/cpp/simulation/AlertSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/AlertSim.cpp @@ -8,7 +8,7 @@ #include #include "wpi/hal/simulation/AlertData.h" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" using namespace wpi; using namespace wpi::sim; diff --git a/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp b/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp index ae3b01251c..b3e12dd883 100644 --- a/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp @@ -10,6 +10,8 @@ #include "wpi/hal/DriverStation.h" #include "wpi/hal/simulation/DriverStationData.h" #include "wpi/hal/simulation/MockHooks.h" +#include "wpi/util/Synchronization.hpp" +#include "wpi/util/string.hpp" using namespace wpi; using namespace wpi::sim; diff --git a/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp index 0cc5a49dba..d387af9dba 100644 --- a/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp @@ -8,6 +8,7 @@ #include #include "wpi/hal/simulation/RoboRioData.h" +#include "wpi/util/string.hpp" using namespace wpi; using namespace wpi::sim; diff --git a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp index 04aee9c038..06492d1601 100644 --- a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp +++ b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp @@ -17,7 +17,7 @@ #include "wpi/datalog/FileLogger.hpp" #include "wpi/driverstation/DriverStation.hpp" #include "wpi/framework/RobotBase.hpp" -#include "wpi/hal/UsageReporting.h" +#include "wpi/hal/UsageReporting.hpp" #include "wpi/nt/NetworkTableInstance.hpp" #include "wpi/system/Errors.hpp" #include "wpi/system/Filesystem.hpp" @@ -26,7 +26,7 @@ #include "wpi/util/StringExtras.hpp" #include "wpi/util/fs.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi; diff --git a/wpilibc/src/main/native/cpp/system/RobotController.cpp b/wpilibc/src/main/native/cpp/system/RobotController.cpp index ceb3a5c533..86847b8381 100644 --- a/wpilibc/src/main/native/cpp/system/RobotController.cpp +++ b/wpilibc/src/main/native/cpp/system/RobotController.cpp @@ -11,6 +11,7 @@ #include "wpi/hal/HALBase.h" #include "wpi/hal/Power.h" #include "wpi/system/Errors.hpp" +#include "wpi/util/string.hpp" using namespace wpi; diff --git a/wpilibc/src/main/native/cppcs/RobotBase.cpp b/wpilibc/src/main/native/cppcs/RobotBase.cpp index ab96a24274..c889a1c582 100644 --- a/wpilibc/src/main/native/cppcs/RobotBase.cpp +++ b/wpilibc/src/main/native/cppcs/RobotBase.cpp @@ -27,7 +27,7 @@ #include "wpi/system/Notifier.hpp" #include "wpi/system/WPILibVersion.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" static_assert(wpi::RuntimeType::kRoboRIO == static_cast(HAL_Runtime_RoboRIO)); diff --git a/wpilibc/src/main/native/include/wpi/internal/DriverStationModeThread.hpp b/wpilibc/src/main/native/include/wpi/internal/DriverStationModeThread.hpp index 438fa8aba7..1247b32b9d 100644 --- a/wpilibc/src/main/native/include/wpi/internal/DriverStationModeThread.hpp +++ b/wpilibc/src/main/native/include/wpi/internal/DriverStationModeThread.hpp @@ -8,7 +8,7 @@ #include #include "wpi/hal/DriverStationTypes.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" namespace wpi::internal { /** diff --git a/wpilibc/src/test/native/cpp/OpModeRobotTest.cpp b/wpilibc/src/test/native/cpp/OpModeRobotTest.cpp index a5c798b0b1..c01371bcd3 100644 --- a/wpilibc/src/test/native/cpp/OpModeRobotTest.cpp +++ b/wpilibc/src/test/native/cpp/OpModeRobotTest.cpp @@ -11,6 +11,7 @@ #include "wpi/simulation/DriverStationSim.hpp" #include "wpi/simulation/SimHooks.hpp" #include "wpi/util/Color.hpp" +#include "wpi/util/string.hpp" namespace { class OpModeRobotTest : public ::testing::Test { diff --git a/wpimath/src/main/native/cpp/util/MathShared.cpp b/wpimath/src/main/native/cpp/util/MathShared.cpp index d93afcdd2e..82b87953dc 100644 --- a/wpimath/src/main/native/cpp/util/MathShared.cpp +++ b/wpimath/src/main/native/cpp/util/MathShared.cpp @@ -9,7 +9,7 @@ #include "wpi/units/time.hpp" #include "wpi/util/mutex.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::math; diff --git a/wpinet/src/main/native/include/wpi/net/MulticastServiceResolver.h b/wpinet/src/main/native/include/wpi/net/MulticastServiceResolver.h index 6faf4a7ce9..c93d82f29b 100644 --- a/wpinet/src/main/native/include/wpi/net/MulticastServiceResolver.h +++ b/wpinet/src/main/native/include/wpi/net/MulticastServiceResolver.h @@ -4,7 +4,7 @@ #pragma once -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #ifdef __cplusplus diff --git a/wpinet/src/netconsoleServer/native/cpp/main.cpp b/wpinet/src/netconsoleServer/native/cpp/main.cpp index 954897a6eb..ebd6ec7cbd 100644 --- a/wpinet/src/netconsoleServer/native/cpp/main.cpp +++ b/wpinet/src/netconsoleServer/native/cpp/main.cpp @@ -27,7 +27,7 @@ #include "wpi/util/SmallVector.hpp" #include "wpi/util/StringExtras.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" namespace uv = wpi::net::uv; diff --git a/wpinet/src/netconsoleTee/native/cpp/main.cpp b/wpinet/src/netconsoleTee/native/cpp/main.cpp index 48680a6b16..44f94ed30e 100644 --- a/wpinet/src/netconsoleTee/native/cpp/main.cpp +++ b/wpinet/src/netconsoleTee/native/cpp/main.cpp @@ -18,7 +18,7 @@ #include "wpi/util/SmallVector.hpp" #include "wpi/util/StringExtras.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" namespace uv = wpi::net::uv; diff --git a/wpiutil/robotpy_pybind_build_info.bzl b/wpiutil/robotpy_pybind_build_info.bzl index 15af0fa32f..2205879cce 100644 --- a/wpiutil/robotpy_pybind_build_info.bzl +++ b/wpiutil/robotpy_pybind_build_info.bzl @@ -40,7 +40,15 @@ def wpiutil_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], inclu class_name = "Synchronization", yml_file = "semiwrap/Synchronization.yml", header_root = "$(execpath :robotpy-native-wpiutil.copy_headers)", - header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/Synchronization.h", + header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/Synchronization.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "RawFrame_c", + yml_file = "semiwrap/RawFrame_c.yml", + header_root = "$(execpath :robotpy-native-wpiutil.copy_headers)", + header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/RawFrame.h", tmpl_class_names = [], trampolines = [], ), @@ -48,7 +56,7 @@ def wpiutil_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], inclu class_name = "RawFrame", yml_file = "semiwrap/RawFrame.yml", header_root = "$(execpath :robotpy-native-wpiutil.copy_headers)", - header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/RawFrame.h", + header_file = "$(execpath :robotpy-native-wpiutil.copy_headers)/wpi/util/RawFrame.hpp", tmpl_class_names = [], trampolines = [], ), diff --git a/wpiutil/src/main/native/cpp/Synchronization.cpp b/wpiutil/src/main/native/cpp/Synchronization.cpp index b8bc929a30..44b1a0afb4 100644 --- a/wpiutil/src/main/native/cpp/Synchronization.cpp +++ b/wpiutil/src/main/native/cpp/Synchronization.cpp @@ -2,7 +2,7 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include #include diff --git a/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp b/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp index cdd4c741c1..fef2aae484 100644 --- a/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp +++ b/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp @@ -7,12 +7,12 @@ #include #include "org_wpilib_util_WPIUtilJNI.h" -#include "wpi/util/RawFrame.h" +#include "wpi/util/RawFrame.hpp" #include "wpi/util/RuntimeCheck.h" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/jni_util.hpp" #include "wpi/util/print.hpp" -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" using namespace wpi::util::java; diff --git a/wpiutil/src/main/native/cpp/timestamp.cpp b/wpiutil/src/main/native/cpp/timestamp.cpp index 3ec3acf98f..8c23b8879a 100644 --- a/wpiutil/src/main/native/cpp/timestamp.cpp +++ b/wpiutil/src/main/native/cpp/timestamp.cpp @@ -2,11 +2,9 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include "wpi/util/timestamp.h" +#include "wpi/util/timestamp.hpp" #include -#include -#include #ifdef _WIN32 #include @@ -19,8 +17,6 @@ #include -#include "wpi/util/print.hpp" - // offset in microseconds static uint64_t time_since_epoch() noexcept { #ifdef _WIN32 diff --git a/wpiutil/src/main/native/include/wpi/util/EventVector.hpp b/wpiutil/src/main/native/include/wpi/util/EventVector.hpp index d9c4014e25..9d7db4bb1b 100644 --- a/wpiutil/src/main/native/include/wpi/util/EventVector.hpp +++ b/wpiutil/src/main/native/include/wpi/util/EventVector.hpp @@ -5,7 +5,7 @@ #pragma once #include "wpi/util/SmallVector.hpp" -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/mutex.hpp" namespace wpi::util { diff --git a/wpiutil/src/main/native/include/wpi/util/RawFrame.h b/wpiutil/src/main/native/include/wpi/util/RawFrame.h index d5d3d1b2e5..b8f9298421 100644 --- a/wpiutil/src/main/native/include/wpi/util/RawFrame.h +++ b/wpiutil/src/main/native/include/wpi/util/RawFrame.h @@ -4,22 +4,8 @@ #pragma once -#include - -#ifdef __cplusplus -#include -#include -#else - #include // NOLINT - -#endif - -#ifdef WPI_RAWFRAME_JNI -#include "wpi/util/jni_util.hpp" -#endif - -// NOLINT +#include #ifdef __cplusplus extern "C" { @@ -85,79 +71,3 @@ void WPI_SetRawFrameData(WPI_RawFrame* frame, void* data, size_t size, #ifdef __cplusplus } // extern "C" #endif - -#ifdef __cplusplus -namespace wpi::util { -struct RawFrame : public WPI_RawFrame { - RawFrame() { - data = nullptr; - freeFunc = nullptr; - freeCbData = nullptr; - capacity = 0; - size = 0; - pixelFormat = WPI_PIXFMT_UNKNOWN; - width = 0; - height = 0; - timestamp = 0; - timestampSrc = WPI_TIMESRC_UNKNOWN; - } - RawFrame(const RawFrame&) = delete; - RawFrame& operator=(const RawFrame&) = delete; - RawFrame(RawFrame&& rhs) noexcept : WPI_RawFrame{rhs} { - rhs.data = nullptr; - rhs.freeFunc = nullptr; - rhs.freeCbData = nullptr; - rhs.capacity = 0; - rhs.size = 0; - } - RawFrame& operator=(RawFrame&& rhs) noexcept { - *static_cast(this) = rhs; - rhs.data = nullptr; - rhs.freeFunc = nullptr; - rhs.freeCbData = nullptr; - rhs.capacity = 0; - rhs.size = 0; - return *this; - } - - void SetData(void* data, size_t size, size_t capacity, void* cbdata, - void (*freeFunc)(void* cbdata, void* data, size_t capacity)) { - WPI_SetRawFrameData(this, data, size, capacity, cbdata, freeFunc); - } - - // returns true if the frame data was allocated/reallocated - bool Reserve(size_t size) { - return WPI_AllocateRawFrameData(this, size) != 0; - } - - ~RawFrame() { WPI_FreeRawFrameData(this); } -}; - -#ifdef WPI_RAWFRAME_JNI -template T> -void SetFrameData(JNIEnv* env, jclass rawFrameCls, jobject jframe, - const T& frame, bool newData) { - if (newData) { - static jmethodID setData = env->GetMethodID( - rawFrameCls, "setDataJNI", "(Ljava/nio/ByteBuffer;IIIIJI)V"); - env->CallVoidMethod( - jframe, setData, env->NewDirectByteBuffer(frame.data, frame.size), - static_cast(frame.width), static_cast(frame.height), - static_cast(frame.stride), static_cast(frame.pixelFormat), - static_cast(frame.timestamp), - static_cast(frame.timestampSrc)); - } else { - static jmethodID setInfo = - env->GetMethodID(rawFrameCls, "setInfoJNI", "(IIIIJI)V"); - env->CallVoidMethod(jframe, setInfo, static_cast(frame.width), - static_cast(frame.height), - static_cast(frame.stride), - static_cast(frame.pixelFormat), - static_cast(frame.timestamp), - static_cast(frame.timestampSrc)); - } -} -#endif - -} // namespace wpi::util -#endif diff --git a/wpiutil/src/main/native/include/wpi/util/RawFrame.hpp b/wpiutil/src/main/native/include/wpi/util/RawFrame.hpp new file mode 100644 index 0000000000..4fad0c9ee5 --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/util/RawFrame.hpp @@ -0,0 +1,90 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include "wpi/util/RawFrame.h" + +#ifdef WPI_RAWFRAME_JNI +#include +#endif +#include + +#ifdef WPI_RAWFRAME_JNI +#include "wpi/util/jni_util.hpp" +#endif + +namespace wpi::util { +struct RawFrame : public WPI_RawFrame { + RawFrame() { + data = nullptr; + freeFunc = nullptr; + freeCbData = nullptr; + capacity = 0; + size = 0; + pixelFormat = WPI_PIXFMT_UNKNOWN; + width = 0; + height = 0; + timestamp = 0; + timestampSrc = WPI_TIMESRC_UNKNOWN; + } + RawFrame(const RawFrame&) = delete; + RawFrame& operator=(const RawFrame&) = delete; + RawFrame(RawFrame&& rhs) noexcept : WPI_RawFrame{rhs} { + rhs.data = nullptr; + rhs.freeFunc = nullptr; + rhs.freeCbData = nullptr; + rhs.capacity = 0; + rhs.size = 0; + } + RawFrame& operator=(RawFrame&& rhs) noexcept { + *static_cast(this) = rhs; + rhs.data = nullptr; + rhs.freeFunc = nullptr; + rhs.freeCbData = nullptr; + rhs.capacity = 0; + rhs.size = 0; + return *this; + } + + void SetData(void* data, size_t size, size_t capacity, void* cbdata, + void (*freeFunc)(void* cbdata, void* data, size_t capacity)) { + WPI_SetRawFrameData(this, data, size, capacity, cbdata, freeFunc); + } + + // returns true if the frame data was allocated/reallocated + bool Reserve(size_t size) { + return WPI_AllocateRawFrameData(this, size) != 0; + } + + ~RawFrame() { WPI_FreeRawFrameData(this); } +}; + +#ifdef WPI_RAWFRAME_JNI +template T> +void SetFrameData(JNIEnv* env, jclass rawFrameCls, jobject jframe, + const T& frame, bool newData) { + if (newData) { + static jmethodID setData = env->GetMethodID( + rawFrameCls, "setDataJNI", "(Ljava/nio/ByteBuffer;IIIIJI)V"); + env->CallVoidMethod( + jframe, setData, env->NewDirectByteBuffer(frame.data, frame.size), + static_cast(frame.width), static_cast(frame.height), + static_cast(frame.stride), static_cast(frame.pixelFormat), + static_cast(frame.timestamp), + static_cast(frame.timestampSrc)); + } else { + static jmethodID setInfo = + env->GetMethodID(rawFrameCls, "setInfoJNI", "(IIIIJI)V"); + env->CallVoidMethod(jframe, setInfo, static_cast(frame.width), + static_cast(frame.height), + static_cast(frame.stride), + static_cast(frame.pixelFormat), + static_cast(frame.timestamp), + static_cast(frame.timestampSrc)); + } +} +#endif + +} // namespace wpi::util diff --git a/wpiutil/src/main/native/include/wpi/util/SafeThread.hpp b/wpiutil/src/main/native/include/wpi/util/SafeThread.hpp index 6b7f8c80bd..6260d2b463 100644 --- a/wpiutil/src/main/native/include/wpi/util/SafeThread.hpp +++ b/wpiutil/src/main/native/include/wpi/util/SafeThread.hpp @@ -9,7 +9,7 @@ #include #include -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include "wpi/util/condition_variable.hpp" #include "wpi/util/mutex.hpp" diff --git a/wpiutil/src/main/native/include/wpi/util/Synchronization.h b/wpiutil/src/main/native/include/wpi/util/Synchronization.h index 7759110507..51a7dc2cb0 100644 --- a/wpiutil/src/main/native/include/wpi/util/Synchronization.h +++ b/wpiutil/src/main/native/include/wpi/util/Synchronization.h @@ -4,12 +4,6 @@ #pragma once -#ifdef __cplusplus -#include -#include -#include -#endif - /** * Generic handle for all WPI handle-based interfaces. * @@ -27,425 +21,8 @@ typedef WPI_Handle WPI_EventHandle; // NOLINT typedef WPI_Handle WPI_SemaphoreHandle; // NOLINT #ifdef __cplusplus - -namespace wpi::util { - -/** Constant representing an invalid handle. */ -constexpr unsigned int kInvalidHandle = 0; - -/** - * Standard types for handles. - * @{ - */ -constexpr int kHandleTypeEvent = 1; -constexpr int kHandleTypeSemaphore = 2; -constexpr int kHandleTypeCSBase = 3; -constexpr int kHandleTypeNTBase = 16; -constexpr int kHandleTypeHALBase = 48; -constexpr int kHandleTypeUserBase = 80; -/** @} */ - -/** - * Creates an event. Events have binary state (signaled or not signaled) and - * may be either automatically reset or manually reset. Automatic-reset events - * go to non-signaled state when a WaitForObject is woken up by the event; - * manual-reset events require ResetEvent() to be called to set the event to - * non-signaled state; if ResetEvent() is not called, any waiter on that event - * will immediately wake when called. - * - * @param manualReset true for manual reset, false for automatic reset - * @param initialState true to make the event initially in signaled state - * @return Event handle - */ -WPI_EventHandle CreateEvent(bool manualReset = false, - bool initialState = false); - -/** - * Destroys an event. Destruction wakes up any waiters. - * - * @param handle event handle - */ -void DestroyEvent(WPI_EventHandle handle); - -/** - * Sets an event to signaled state. - * - * @param handle event handle - */ -void SetEvent(WPI_EventHandle handle); - -/** - * Sets an event to non-signaled state. - * - * @param handle event handle - */ -void ResetEvent(WPI_EventHandle handle); - -/** - * Creates a semaphore. Semaphores keep an internal counter. Releasing the - * semaphore increases the count. A semaphore with a non-zero count is - * considered signaled. When a waiter wakes up it atomically decrements the - * count by 1. This is generally useful in a single-supplier, - * multiple-consumer scenario. - * - * @param initialCount initial value for the semaphore's internal counter - * @param maximumCount maximum value for the semaphore's internal counter - * @return Semaphore handle - */ -WPI_SemaphoreHandle CreateSemaphore(int initialCount = 0, - int maximumCount = INT_MAX); - -/** - * Destroys a semaphore. Destruction wakes up any waiters. - * - * @param handle semaphore handle - */ -void DestroySemaphore(WPI_SemaphoreHandle handle); - -/** - * Releases N counts of a semaphore. - * - * @param handle semaphore handle - * @param releaseCount amount to add to semaphore's internal counter; - * must be positive - * @param prevCount if non-null, previous count (output parameter) - * @return True on successful release, false on failure (e.g. release count - * would exceed maximum value, or handle invalid) - */ -bool ReleaseSemaphore(WPI_SemaphoreHandle handle, int releaseCount = 1, - int* prevCount = nullptr); - -/** - * Waits for an handle to be signaled. - * - * @param handle handle to wait on - * @return True if handle was signaled, false otherwise (e.g. object was - * destroyed) - */ -bool WaitForObject(WPI_Handle handle); - -/** - * Waits for an handle to be signaled, with timeout. - * - * @param handle handle to wait on - * @param timeout timeout in seconds - * @param timedOut if non-null, set to true if timeout reached without handle - * being signaled; set to false otherwise (output) - * @return True if handle was signaled, false otherwise (e.g. object was - * destroyed or timed out) - */ -bool WaitForObject(WPI_Handle handle, double timeout, bool* timedOut); - -/** - * Waits for one or more handles to be signaled. - * - * Invalid handles are treated as signaled; the returned array will have the - * handle error bit set for any invalid handles. - * - * @param handles array of handles to wait on - * @param signaled output array for storage of signaled handles; must be at - * least the size of the handles input array - * @return array of signaled handles (points into signaled array) - */ -std::span WaitForObjects(std::span handles, - std::span signaled); - -/** - * Waits for one or more handles to be signaled. - * - * Invalid handles are treated as signaled; the returned array will have the - * handle error bit set for any invalid handles. - * - * @param handles array of handles to wait on - * @param signaled output array for storage of signaled handles; must be at - * least the size of the handles input array - * @return array of signaled handles (points into signaled array) - */ -inline std::span WaitForObjects( - std::initializer_list handles, std::span signaled) { - return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled); -} - -/** - * Waits for one or more handles to be signaled, with timeout. - * - * Invalid handles are treated as signaled; the returned array will have the - * handle error bit set for any invalid handles. - * - * @param handles array of handles to wait on - * @param signaled output array for storage of signaled handles; must be at - * least the size of the handles input array - * @param timeout timeout in seconds - * @param timedOut if non-null, set to true if timeout reached without any - * handle being signaled; set to false otherwise (output) - * @return array of signaled handles (points into signaled array) - */ -std::span WaitForObjects(std::span handles, - std::span signaled, - double timeout, bool* timedOut); -/** - * Waits for one or more handles to be signaled, with timeout. - * - * Invalid handles are treated as signaled; the returned array will have the - * handle error bit set for any invalid handles. - * - * @param handles array of handles to wait on - * @param signaled output array for storage of signaled handles; must be at - * least the size of the handles input array - * @param timeout timeout in seconds - * @param timedOut if non-null, set to true if timeout reached without any - * handle being signaled; set to false otherwise (output) - * @return array of signaled handles (points into signaled array) - */ -inline std::span WaitForObjects( - std::initializer_list handles, std::span signaled, - double timeout, bool* timedOut) { - return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled, - timeout, timedOut); -} - -/** - * Sets up signaling for an arbitrary handle. With this function, any handle - * can operate like an event handle. - * - * @param handle Event handle - * @param manualReset true for manual reset, false for automatic reset - * @param initialState true to make the handle initially in signaled state - */ -void CreateSignalObject(WPI_Handle handle, bool manualReset = false, - bool initialState = false); - -/** - * Sets a handle to signaled state. - * - * @param handle handle - */ -void SetSignalObject(WPI_Handle handle); - -/** - * Sets a handle to non-signaled state. - * - * @param handle handle - */ -void ResetSignalObject(WPI_Handle handle); - -/** - * Cleans up signaling for a handle. Destruction wakes up any waiters. - * - * @param handle handle - */ -void DestroySignalObject(WPI_Handle handle); - -/** - * An atomic signaling event for synchronization. - * - * Events have binary state (signaled or not signaled) and may be either - * automatically reset or manually reset. Automatic-reset events go to - * non-signaled state when a WaitForObject is woken up by the event; - * manual-reset events require Reset() to be called to set the event to - * non-signaled state; if Reset() is not called, any waiter on that event - * will immediately wake when called. - */ -class Event final { - public: - /** - * Constructor. - * - * @param manualReset true for manual reset, false for automatic reset - * @param initialState true to make the event initially in signaled state - */ - explicit Event(bool manualReset = false, bool initialState = false) - : m_handle{CreateEvent(manualReset, initialState)} {} - ~Event() { - if (m_handle != 0) { - DestroyEvent(m_handle); - } - } - - Event(const Event&) = delete; - Event& operator=(const Event&) = delete; - - Event(Event&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; } - Event& operator=(Event&& rhs) { - if (m_handle != 0) { - DestroyEvent(m_handle); - } - m_handle = rhs.m_handle; - rhs.m_handle = 0; - return *this; - } - - /** - * Gets the event handle (e.g. for WaitForObject). - * - * @return handle - */ - explicit operator WPI_Handle() const { return m_handle; } - - /** - * Gets the event handle (e.g. for WaitForObject). - * - * @return handle - */ - WPI_EventHandle GetHandle() const { return m_handle; } - - /** - * Sets the event to signaled state. - */ - void Set() { SetEvent(m_handle); } - - /** - * Sets the event to non-signaled state. - */ - void Reset() { ResetEvent(m_handle); } - - private: - WPI_EventHandle m_handle; -}; - -/** - * A semaphore for synchronization. - * - * Semaphores keep an internal counter. Releasing the semaphore increases - * the count. A semaphore with a non-zero count is considered signaled. - * When a waiter wakes up it atomically decrements the count by 1. This - * is generally useful in a single-supplier, multiple-consumer scenario. - */ -class Semaphore final { - public: - /** - * Constructor. - * - * @param initialCount initial value for the semaphore's internal counter - * @param maximumCount maximum value for the semaphore's internal counter - */ - explicit Semaphore(int initialCount = 0, int maximumCount = INT_MAX) - : m_handle{CreateSemaphore(initialCount, maximumCount)} {} - ~Semaphore() { - if (m_handle != 0) { - DestroySemaphore(m_handle); - } - } - - Semaphore(const Semaphore&) = delete; - Semaphore& operator=(const Semaphore&) = delete; - - Semaphore(Semaphore&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; } - Semaphore& operator=(Semaphore&& rhs) { - if (m_handle != 0) { - DestroySemaphore(m_handle); - } - m_handle = rhs.m_handle; - rhs.m_handle = 0; - return *this; - } - - /** - * Gets the semaphore handle (e.g. for WaitForObject). - * - * @return handle - */ - explicit operator WPI_Handle() const { return m_handle; } - - /** - * Gets the semaphore handle (e.g. for WaitForObject). - * - * @return handle - */ - WPI_SemaphoreHandle GetHandle() const { return m_handle; } - - /** - * Releases N counts of the semaphore. - * - * @param releaseCount amount to add to semaphore's internal counter; - * must be positive - * @param prevCount if non-null, previous count (output parameter) - * @return True on successful release, false on failure (e.g. release count - * would exceed maximum value, or handle invalid) - */ - bool Release(int releaseCount = 1, int* prevCount = nullptr) { - return ReleaseSemaphore(m_handle, releaseCount, prevCount); - } - - private: - WPI_SemaphoreHandle m_handle; -}; - -/** - * RAII wrapper for signaling handles. - * - * Sets up signaling for an arbitrary handle. This enables any handle - * to operate like an event handle. - */ -template -class SignalObject final { - public: - /** - * Constructor. - * - * @param handle handle - * @param manualReset true for manual reset, false for automatic reset - * @param initialState true to make the handle initially in signaled state - */ - explicit SignalObject(T handle = 0, bool manualReset = false, - bool initialState = false) - : m_handle{handle} { - CreateSignalObject(handle, manualReset, initialState); - } - ~SignalObject() { - if (m_handle != 0) { - DestroySignalObject(m_handle); - } - } - - SignalObject(const SignalObject&) = delete; - SignalObject& operator=(const SignalObject&) = delete; - - SignalObject(SignalObject&& rhs) : m_handle{rhs.m_handle} { - rhs.m_handle = 0; - } - SignalObject& operator=(SignalObject&& rhs) { - if (m_handle != 0) { - DestroySignalObject(m_handle); - } - m_handle = rhs.m_handle; - rhs.m_handle = 0; - return *this; - } - - /** - * Gets the handle. - * - * @return handle - */ - /*implicit*/ operator T() const { return m_handle; } // NOLINT - - /** - * Gets the handle (e.g. for WaitForObject). - * - * @return handle - */ - T GetHandle() const { return m_handle; } - - /** - * Sets the handle to signaled state. - */ - void Set() { SetSignalObject(m_handle); } - - /** - * Sets the handle to non-signaled state. - */ - void Reset() { ResetSignalObject(m_handle); } - - private: - T m_handle; -}; - -} // namespace wpi::util - extern "C" { - -#endif // __cplusplus +#endif /** * Creates an event. Events have binary state (signaled or not signaled) and diff --git a/wpiutil/src/main/native/include/wpi/util/Synchronization.hpp b/wpiutil/src/main/native/include/wpi/util/Synchronization.hpp new file mode 100644 index 0000000000..eb6607176a --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/util/Synchronization.hpp @@ -0,0 +1,426 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include +#include +#include + +#include "wpi/util/Synchronization.h" + +namespace wpi::util { + +/** Constant representing an invalid handle. */ +constexpr unsigned int kInvalidHandle = 0; + +/** + * Standard types for handles. + * @{ + */ +constexpr int kHandleTypeEvent = 1; +constexpr int kHandleTypeSemaphore = 2; +constexpr int kHandleTypeCSBase = 3; +constexpr int kHandleTypeNTBase = 16; +constexpr int kHandleTypeHALBase = 48; +constexpr int kHandleTypeUserBase = 80; +/** @} */ + +/** + * Creates an event. Events have binary state (signaled or not signaled) and + * may be either automatically reset or manually reset. Automatic-reset events + * go to non-signaled state when a WaitForObject is woken up by the event; + * manual-reset events require ResetEvent() to be called to set the event to + * non-signaled state; if ResetEvent() is not called, any waiter on that event + * will immediately wake when called. + * + * @param manualReset true for manual reset, false for automatic reset + * @param initialState true to make the event initially in signaled state + * @return Event handle + */ +WPI_EventHandle CreateEvent(bool manualReset = false, + bool initialState = false); + +/** + * Destroys an event. Destruction wakes up any waiters. + * + * @param handle event handle + */ +void DestroyEvent(WPI_EventHandle handle); + +/** + * Sets an event to signaled state. + * + * @param handle event handle + */ +void SetEvent(WPI_EventHandle handle); + +/** + * Sets an event to non-signaled state. + * + * @param handle event handle + */ +void ResetEvent(WPI_EventHandle handle); + +/** + * Creates a semaphore. Semaphores keep an internal counter. Releasing the + * semaphore increases the count. A semaphore with a non-zero count is + * considered signaled. When a waiter wakes up it atomically decrements the + * count by 1. This is generally useful in a single-supplier, + * multiple-consumer scenario. + * + * @param initialCount initial value for the semaphore's internal counter + * @param maximumCount maximum value for the semaphore's internal counter + * @return Semaphore handle + */ +WPI_SemaphoreHandle CreateSemaphore(int initialCount = 0, + int maximumCount = INT_MAX); + +/** + * Destroys a semaphore. Destruction wakes up any waiters. + * + * @param handle semaphore handle + */ +void DestroySemaphore(WPI_SemaphoreHandle handle); + +/** + * Releases N counts of a semaphore. + * + * @param handle semaphore handle + * @param releaseCount amount to add to semaphore's internal counter; + * must be positive + * @param prevCount if non-null, previous count (output parameter) + * @return True on successful release, false on failure (e.g. release count + * would exceed maximum value, or handle invalid) + */ +bool ReleaseSemaphore(WPI_SemaphoreHandle handle, int releaseCount = 1, + int* prevCount = nullptr); + +/** + * Waits for an handle to be signaled. + * + * @param handle handle to wait on + * @return True if handle was signaled, false otherwise (e.g. object was + * destroyed) + */ +bool WaitForObject(WPI_Handle handle); + +/** + * Waits for an handle to be signaled, with timeout. + * + * @param handle handle to wait on + * @param timeout timeout in seconds + * @param timedOut if non-null, set to true if timeout reached without handle + * being signaled; set to false otherwise (output) + * @return True if handle was signaled, false otherwise (e.g. object was + * destroyed or timed out) + */ +bool WaitForObject(WPI_Handle handle, double timeout, bool* timedOut); + +/** + * Waits for one or more handles to be signaled. + * + * Invalid handles are treated as signaled; the returned array will have the + * handle error bit set for any invalid handles. + * + * @param handles array of handles to wait on + * @param signaled output array for storage of signaled handles; must be at + * least the size of the handles input array + * @return array of signaled handles (points into signaled array) + */ +std::span WaitForObjects(std::span handles, + std::span signaled); + +/** + * Waits for one or more handles to be signaled. + * + * Invalid handles are treated as signaled; the returned array will have the + * handle error bit set for any invalid handles. + * + * @param handles array of handles to wait on + * @param signaled output array for storage of signaled handles; must be at + * least the size of the handles input array + * @return array of signaled handles (points into signaled array) + */ +inline std::span WaitForObjects( + std::initializer_list handles, std::span signaled) { + return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled); +} + +/** + * Waits for one or more handles to be signaled, with timeout. + * + * Invalid handles are treated as signaled; the returned array will have the + * handle error bit set for any invalid handles. + * + * @param handles array of handles to wait on + * @param signaled output array for storage of signaled handles; must be at + * least the size of the handles input array + * @param timeout timeout in seconds + * @param timedOut if non-null, set to true if timeout reached without any + * handle being signaled; set to false otherwise (output) + * @return array of signaled handles (points into signaled array) + */ +std::span WaitForObjects(std::span handles, + std::span signaled, + double timeout, bool* timedOut); +/** + * Waits for one or more handles to be signaled, with timeout. + * + * Invalid handles are treated as signaled; the returned array will have the + * handle error bit set for any invalid handles. + * + * @param handles array of handles to wait on + * @param signaled output array for storage of signaled handles; must be at + * least the size of the handles input array + * @param timeout timeout in seconds + * @param timedOut if non-null, set to true if timeout reached without any + * handle being signaled; set to false otherwise (output) + * @return array of signaled handles (points into signaled array) + */ +inline std::span WaitForObjects( + std::initializer_list handles, std::span signaled, + double timeout, bool* timedOut) { + return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled, + timeout, timedOut); +} + +/** + * Sets up signaling for an arbitrary handle. With this function, any handle + * can operate like an event handle. + * + * @param handle Event handle + * @param manualReset true for manual reset, false for automatic reset + * @param initialState true to make the handle initially in signaled state + */ +void CreateSignalObject(WPI_Handle handle, bool manualReset = false, + bool initialState = false); + +/** + * Sets a handle to signaled state. + * + * @param handle handle + */ +void SetSignalObject(WPI_Handle handle); + +/** + * Sets a handle to non-signaled state. + * + * @param handle handle + */ +void ResetSignalObject(WPI_Handle handle); + +/** + * Cleans up signaling for a handle. Destruction wakes up any waiters. + * + * @param handle handle + */ +void DestroySignalObject(WPI_Handle handle); + +/** + * An atomic signaling event for synchronization. + * + * Events have binary state (signaled or not signaled) and may be either + * automatically reset or manually reset. Automatic-reset events go to + * non-signaled state when a WaitForObject is woken up by the event; + * manual-reset events require Reset() to be called to set the event to + * non-signaled state; if Reset() is not called, any waiter on that event + * will immediately wake when called. + */ +class Event final { + public: + /** + * Constructor. + * + * @param manualReset true for manual reset, false for automatic reset + * @param initialState true to make the event initially in signaled state + */ + explicit Event(bool manualReset = false, bool initialState = false) + : m_handle{CreateEvent(manualReset, initialState)} {} + ~Event() { + if (m_handle != 0) { + DestroyEvent(m_handle); + } + } + + Event(const Event&) = delete; + Event& operator=(const Event&) = delete; + + Event(Event&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; } + Event& operator=(Event&& rhs) { + if (m_handle != 0) { + DestroyEvent(m_handle); + } + m_handle = rhs.m_handle; + rhs.m_handle = 0; + return *this; + } + + /** + * Gets the event handle (e.g. for WaitForObject). + * + * @return handle + */ + explicit operator WPI_Handle() const { return m_handle; } + + /** + * Gets the event handle (e.g. for WaitForObject). + * + * @return handle + */ + WPI_EventHandle GetHandle() const { return m_handle; } + + /** + * Sets the event to signaled state. + */ + void Set() { SetEvent(m_handle); } + + /** + * Sets the event to non-signaled state. + */ + void Reset() { ResetEvent(m_handle); } + + private: + WPI_EventHandle m_handle; +}; + +/** + * A semaphore for synchronization. + * + * Semaphores keep an internal counter. Releasing the semaphore increases + * the count. A semaphore with a non-zero count is considered signaled. + * When a waiter wakes up it atomically decrements the count by 1. This + * is generally useful in a single-supplier, multiple-consumer scenario. + */ +class Semaphore final { + public: + /** + * Constructor. + * + * @param initialCount initial value for the semaphore's internal counter + * @param maximumCount maximum value for the semaphore's internal counter + */ + explicit Semaphore(int initialCount = 0, int maximumCount = INT_MAX) + : m_handle{CreateSemaphore(initialCount, maximumCount)} {} + ~Semaphore() { + if (m_handle != 0) { + DestroySemaphore(m_handle); + } + } + + Semaphore(const Semaphore&) = delete; + Semaphore& operator=(const Semaphore&) = delete; + + Semaphore(Semaphore&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; } + Semaphore& operator=(Semaphore&& rhs) { + if (m_handle != 0) { + DestroySemaphore(m_handle); + } + m_handle = rhs.m_handle; + rhs.m_handle = 0; + return *this; + } + + /** + * Gets the semaphore handle (e.g. for WaitForObject). + * + * @return handle + */ + explicit operator WPI_Handle() const { return m_handle; } + + /** + * Gets the semaphore handle (e.g. for WaitForObject). + * + * @return handle + */ + WPI_SemaphoreHandle GetHandle() const { return m_handle; } + + /** + * Releases N counts of the semaphore. + * + * @param releaseCount amount to add to semaphore's internal counter; + * must be positive + * @param prevCount if non-null, previous count (output parameter) + * @return True on successful release, false on failure (e.g. release count + * would exceed maximum value, or handle invalid) + */ + bool Release(int releaseCount = 1, int* prevCount = nullptr) { + return ReleaseSemaphore(m_handle, releaseCount, prevCount); + } + + private: + WPI_SemaphoreHandle m_handle; +}; + +/** + * RAII wrapper for signaling handles. + * + * Sets up signaling for an arbitrary handle. This enables any handle + * to operate like an event handle. + */ +template +class SignalObject final { + public: + /** + * Constructor. + * + * @param handle handle + * @param manualReset true for manual reset, false for automatic reset + * @param initialState true to make the handle initially in signaled state + */ + explicit SignalObject(T handle = 0, bool manualReset = false, + bool initialState = false) + : m_handle{handle} { + CreateSignalObject(handle, manualReset, initialState); + } + ~SignalObject() { + if (m_handle != 0) { + DestroySignalObject(m_handle); + } + } + + SignalObject(const SignalObject&) = delete; + SignalObject& operator=(const SignalObject&) = delete; + + SignalObject(SignalObject&& rhs) : m_handle{rhs.m_handle} { + rhs.m_handle = 0; + } + SignalObject& operator=(SignalObject&& rhs) { + if (m_handle != 0) { + DestroySignalObject(m_handle); + } + m_handle = rhs.m_handle; + rhs.m_handle = 0; + return *this; + } + + /** + * Gets the handle. + * + * @return handle + */ + /*implicit*/ operator T() const { return m_handle; } // NOLINT + + /** + * Gets the handle (e.g. for WaitForObject). + * + * @return handle + */ + T GetHandle() const { return m_handle; } + + /** + * Sets the handle to signaled state. + */ + void Set() { SetSignalObject(m_handle); } + + /** + * Sets the handle to non-signaled state. + */ + void Reset() { ResetSignalObject(m_handle); } + + private: + T m_handle; +}; + +} // namespace wpi::util diff --git a/wpiutil/src/main/native/include/wpi/util/jni_util.hpp b/wpiutil/src/main/native/include/wpi/util/jni_util.hpp index 9f2e5c5d2a..1fd32eb593 100644 --- a/wpiutil/src/main/native/include/wpi/util/jni_util.hpp +++ b/wpiutil/src/main/native/include/wpi/util/jni_util.hpp @@ -22,7 +22,7 @@ #include "wpi/util/mutex.hpp" #include "wpi/util/print.hpp" #include "wpi/util/raw_ostream.hpp" -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" /** Java Native Interface (JNI) utility functions */ namespace wpi::util::java { diff --git a/wpiutil/src/main/native/include/wpi/util/string.h b/wpiutil/src/main/native/include/wpi/util/string.h index 006af17ad0..59eccba43c 100644 --- a/wpiutil/src/main/native/include/wpi/util/string.h +++ b/wpiutil/src/main/native/include/wpi/util/string.h @@ -4,10 +4,7 @@ #pragma once -#ifdef __cplusplus -#include -#include -#endif +#include // NOLINT /** * A const UTF8 string. @@ -19,27 +16,9 @@ struct WPI_String { size_t len; }; -#ifdef __cplusplus -namespace wpi::util { -/** Converts a WPI_String to a string_view */ -constexpr std::string_view to_string_view(const struct WPI_String* str) { - if (str) { - return {str->str, str->len}; - } else { - return ""; - } -} - -/** Converts a string_view to a WPI_String */ -constexpr WPI_String make_string(std::string_view view) { - return WPI_String{view.data(), view.size()}; -} -} // namespace wpi::util -#endif // __cplusplus - #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif /** * Initializes a WPI_String from a null terminated UTF-8 string. @@ -106,25 +85,4 @@ void WPI_FreeStringArray(const struct WPI_String* wpiStringArray, #ifdef __cplusplus } // extern "C" -#endif // __cplusplus - -#ifdef __cplusplus -namespace wpi::util { - -/** Allocates a copy of a string_view and stores the result into a WPI_String */ -inline WPI_String alloc_wpi_string(std::string_view view) { - WPI_String out; - size_t len = view.size(); - std::memcpy(WPI_AllocateString(&out, len), view.data(), len); - return out; -} - -/** Allocates a copy of a WPI_String */ -inline WPI_String copy_wpi_string(const WPI_String& str) { - if (str.str == nullptr || str.len == 0) { - return WPI_String{nullptr, 0}; - } - return alloc_wpi_string(to_string_view(&str)); -} -} // namespace wpi::util #endif diff --git a/wpiutil/src/main/native/include/wpi/util/string.hpp b/wpiutil/src/main/native/include/wpi/util/string.hpp new file mode 100644 index 0000000000..eedb3d05ef --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/util/string.hpp @@ -0,0 +1,44 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include +#include + +#include "wpi/util/string.h" + +namespace wpi::util { + +/** Converts a WPI_String to a string_view */ +constexpr std::string_view to_string_view(const struct WPI_String* str) { + if (str) { + return {str->str, str->len}; + } else { + return ""; + } +} + +/** Converts a string_view to a WPI_String */ +constexpr WPI_String make_string(std::string_view view) { + return WPI_String{view.data(), view.size()}; +} + +/** Allocates a copy of a string_view and stores the result into a WPI_String */ +inline WPI_String alloc_wpi_string(std::string_view view) { + WPI_String out; + size_t len = view.size(); + std::memcpy(WPI_AllocateString(&out, len), view.data(), len); + return out; +} + +/** Allocates a copy of a WPI_String */ +inline WPI_String copy_wpi_string(const WPI_String& str) { + if (str.str == nullptr || str.len == 0) { + return WPI_String{nullptr, 0}; + } + return alloc_wpi_string(to_string_view(&str)); +} + +} // namespace wpi::util diff --git a/wpiutil/src/main/native/include/wpi/util/timestamp.h b/wpiutil/src/main/native/include/wpi/util/timestamp.h index 5bbea915f8..df974415d8 100644 --- a/wpiutil/src/main/native/include/wpi/util/timestamp.h +++ b/wpiutil/src/main/native/include/wpi/util/timestamp.h @@ -6,11 +6,6 @@ #include -#ifdef __cplusplus -#include // NOLINT - -#endif - #ifdef __cplusplus extern "C" { #endif @@ -48,39 +43,3 @@ uint64_t WPI_GetSystemTime(void); #ifdef __cplusplus } // extern "C" #endif - -#ifdef __cplusplus -namespace wpi::util { - -/** - * The default implementation used for Now(). - * In general this is the time returned by the operating system. - * @return Time in microseconds. - */ -uint64_t NowDefault(); - -/** - * Set the implementation used by Now(). - * The implementation must return monotonic time in microseconds to maintain - * the contract of Now(). - * @param func Function called by Now() to return the time. - */ -void SetNowImpl(uint64_t (*func)()); - -/** - * Return a value representing the current time in microseconds. - * This is a monotonic clock with an undefined epoch. - * @return Time in microseconds. - */ -uint64_t Now(); - -/** - * Return the current system time in microseconds since the Unix epoch - * (January 1st, 1970 00:00 UTC). - * - * @return Time in microseconds. - */ -uint64_t GetSystemTime(); - -} // namespace wpi::util -#endif diff --git a/wpiutil/src/main/native/include/wpi/util/timestamp.hpp b/wpiutil/src/main/native/include/wpi/util/timestamp.hpp new file mode 100644 index 0000000000..433e487d30 --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/util/timestamp.hpp @@ -0,0 +1,41 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace wpi::util { + +/** + * The default implementation used for Now(). + * In general this is the time returned by the operating system. + * @return Time in microseconds. + */ +uint64_t NowDefault(); + +/** + * Set the implementation used by Now(). + * The implementation must return monotonic time in microseconds to maintain + * the contract of Now(). + * @param func Function called by Now() to return the time. + */ +void SetNowImpl(uint64_t (*func)()); + +/** + * Return a value representing the current time in microseconds. + * This is a monotonic clock with an undefined epoch. + * @return Time in microseconds. + */ +uint64_t Now(); + +/** + * Return the current system time in microseconds since the Unix epoch + * (January 1st, 1970 00:00 UTC). + * + * @return Time in microseconds. + */ +uint64_t GetSystemTime(); + +} // namespace wpi::util diff --git a/wpiutil/src/main/python/pyproject.toml b/wpiutil/src/main/python/pyproject.toml index 53f4b7d6ed..33e7e93045 100644 --- a/wpiutil/src/main/python/pyproject.toml +++ b/wpiutil/src/main/python/pyproject.toml @@ -70,8 +70,9 @@ depends = ["wpiutil-casters"] Color = "wpi/util/Color.hpp" Color8Bit = "wpi/util/Color8Bit.hpp" StackTrace = "wpi/util/StackTrace.hpp" -Synchronization = "wpi/util/Synchronization.h" -RawFrame = "wpi/util/RawFrame.h" +Synchronization = "wpi/util/Synchronization.hpp" +RawFrame_c = "wpi/util/RawFrame.h" +RawFrame = "wpi/util/RawFrame.hpp" # wpi/sendable Sendable = "wpi/util/sendable/Sendable.hpp" diff --git a/wpiutil/src/main/python/semiwrap/RawFrame.yml b/wpiutil/src/main/python/semiwrap/RawFrame.yml index 71b74c2843..43649627ee 100644 --- a/wpiutil/src/main/python/semiwrap/RawFrame.yml +++ b/wpiutil/src/main/python/semiwrap/RawFrame.yml @@ -1,7 +1,3 @@ defaults: ignore: true -enums: - WPI_TimestampSource: - value_prefix: WPI_TIMESRC - rename: TimestampSource diff --git a/wpiutil/src/main/python/semiwrap/RawFrame_c.yml b/wpiutil/src/main/python/semiwrap/RawFrame_c.yml new file mode 100644 index 0000000000..71b74c2843 --- /dev/null +++ b/wpiutil/src/main/python/semiwrap/RawFrame_c.yml @@ -0,0 +1,7 @@ +defaults: + ignore: true + +enums: + WPI_TimestampSource: + value_prefix: WPI_TIMESRC + rename: TimestampSource diff --git a/wpiutil/src/main/python/wpiutil/src/type_casters/wpi_string_type_caster.h b/wpiutil/src/main/python/wpiutil/src/type_casters/wpi_string_type_caster.h index ba0c26dea8..eec0c30b6b 100644 --- a/wpiutil/src/main/python/wpiutil/src/type_casters/wpi_string_type_caster.h +++ b/wpiutil/src/main/python/wpiutil/src/type_casters/wpi_string_type_caster.h @@ -1,6 +1,6 @@ #include -#include "wpi/util/string.h" +#include "wpi/util/string.hpp" namespace pybind11::detail { @@ -31,4 +31,4 @@ public: } }; -} // namespace pybind11::detail \ No newline at end of file +} // namespace pybind11::detail diff --git a/wpiutil/src/test/native/cpp/SynchronizationTest.cpp b/wpiutil/src/test/native/cpp/SynchronizationTest.cpp index 49c3301cce..c610f662ff 100644 --- a/wpiutil/src/test/native/cpp/SynchronizationTest.cpp +++ b/wpiutil/src/test/native/cpp/SynchronizationTest.cpp @@ -2,7 +2,7 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include "wpi/util/Synchronization.h" +#include "wpi/util/Synchronization.hpp" #include