[wpiutil,hal] Move C++ Handle wrapper to wpiutil (#8935)

Also move WPI_Handle typedef to its own header (util/Handle.h).
This commit is contained in:
Peter Johnson
2026-06-01 13:57:25 -07:00
committed by GitHub
parent 3d982f81dd
commit 3f0d7bc2c4
24 changed files with 126 additions and 127 deletions

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include "wpi/util/Handle.h"
#include "wpi/util/string.h"
#ifdef __cplusplus
@@ -31,7 +32,7 @@ struct WPI_DataLog;
/** Typedefs */
typedef int NT_Bool;
typedef unsigned int NT_Handle;
typedef WPI_Handle NT_Handle;
typedef NT_Handle NT_ConnectionDataLogger;
typedef NT_Handle NT_DataLogger;
typedef NT_Handle NT_Entry;

View File

@@ -51,10 +51,10 @@ void ConnectionListenerTest::Connect(const char* address, unsigned int port4) {
TEST_F(ConnectionListenerTest, Polled) {
// set up the poller
NT_ListenerPoller poller = wpi::nt::CreateListenerPoller(server_inst);
ASSERT_NE(poller, 0u);
ASSERT_NE(poller, 0);
NT_Listener handle = wpi::nt::AddPolledListener(
poller, server_inst, wpi::nt::EventFlags::CONNECTION);
ASSERT_NE(handle, 0u);
ASSERT_NE(handle, 0);
// trigger a connect event
Connect("127.0.0.1", 10020);

View File

@@ -73,11 +73,11 @@ TEST_F(LocalStorageTest, GetTopic2) {
}
TEST_F(LocalStorageTest, GetTopicEmptyName) {
EXPECT_EQ(storage.GetTopic(""), 0u);
EXPECT_EQ(storage.GetTopic(""), 0);
}
TEST_F(LocalStorageTest, GetEntryEmptyName) {
EXPECT_EQ(storage.GetEntry(""), 0u);
EXPECT_EQ(storage.GetEntry(""), 0);
}
TEST_F(LocalStorageTest, GetEntryCached) {
@@ -538,11 +538,11 @@ TEST_F(LocalStorageTest, PublishUntyped) {
std::string_view{"cannot publish 'foo' with an unassigned "
"type or empty type string"}));
EXPECT_EQ(storage.Publish(fooTopic, NT_UNASSIGNED, "", {}, {}), 0u);
EXPECT_EQ(storage.Publish(fooTopic, NT_UNASSIGNED, "", {}, {}), 0);
}
TEST_F(LocalStorageTest, SetValueInvalidHandle) {
EXPECT_FALSE(storage.SetEntryValue(0u, {}));
EXPECT_FALSE(storage.SetEntryValue(0, {}));
}
class LocalStorageDuplicatesTest : public LocalStorageTest {