From 8af6bd354ed0db3697082f11d7ceef2de3eb5a96 Mon Sep 17 00:00:00 2001 From: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:35:59 -0700 Subject: [PATCH] [ntcore] Fix up constants renames (#8693) Takes care of a few renames missed in #8676. --- .../main/java/GenericSubscriber.java.jinja | 2 +- .../main/java/NetworkTableEntry.java.jinja | 2 +- .../networktables/GenericSubscriber.java | 2 +- .../networktables/NetworkTableEntry.java | 2 +- .../networktables/NetworkTableEvent.java | 10 ++++---- .../wpilib/networktables/PubSubOptions.java | 4 +-- .../main/native/include/wpi/nt/UnitTopic.hpp | 2 +- ntcore/src/main/python/devtools/gen-pubsub.py | 25 +++++++++++-------- .../python/semiwrap/NetworkTableInstance.yml | 2 +- .../src/main/python/semiwrap/ntcore_cpp.yml | 2 -- ntcore/src/test/python/conftest.py | 2 +- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ntcore/src/generate/main/java/GenericSubscriber.java.jinja b/ntcore/src/generate/main/java/GenericSubscriber.java.jinja index 5c92c98dc7..182032217b 100644 --- a/ntcore/src/generate/main/java/GenericSubscriber.java.jinja +++ b/ntcore/src/generate/main/java/GenericSubscriber.java.jinja @@ -20,7 +20,7 @@ public interface GenericSubscriber extends Subscriber, Supplier - *
  • kConnected or kDisconnected: connInfo - *
  • kPublish, kUnpublish, or kProperties: topicInfo - *
  • kValueRemote, kValueLocal: valueData - *
  • kLogMessage: logMessage + *
  • CONNECTED or DISCONNECTED: connInfo + *
  • PUBLISH, UNPUBLISH, or PROPERTIES: topicInfo + *
  • VALUE_REMOTE, VALUE_LOCAL: valueData + *
  • LOG_MESSAGE: logMessage * * * @param kind Kind diff --git a/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java b/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java index 3aec699bc8..2bf16c7d75 100644 --- a/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java +++ b/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java @@ -57,7 +57,7 @@ public class PubSubOptions { } /** Default value of periodic. */ - public static final double kDefaultPeriodic = 0.1; + public static final double DEFAULT_PERIODIC = 0.1; /** * Polling storage size for a subscription. Specifies the maximum number of updates NetworkTables @@ -71,7 +71,7 @@ public class PubSubOptions { * frequently than this (e.g. use a combined minimum period for all values) or apply a restricted * range to this value. The default is 100 ms. */ - public double periodic = kDefaultPeriodic; + public double periodic = DEFAULT_PERIODIC; /** * For subscriptions, if non-zero, value updates for readQueue() are not queued for this diff --git a/ntcore/src/main/native/include/wpi/nt/UnitTopic.hpp b/ntcore/src/main/native/include/wpi/nt/UnitTopic.hpp index a8dad98142..2cd1c0f188 100644 --- a/ntcore/src/main/native/include/wpi/nt/UnitTopic.hpp +++ b/ntcore/src/main/native/include/wpi/nt/UnitTopic.hpp @@ -276,7 +276,7 @@ class UnitTopic final : public Topic { using ParamType = T; using TimestampedValueType = TimestampedUnit; /** The default type string for this topic type. */ - static constexpr std::string_view kTypeString = "double"; + static constexpr std::string_view TYPE_STRING = "double"; UnitTopic() = default; diff --git a/ntcore/src/main/python/devtools/gen-pubsub.py b/ntcore/src/main/python/devtools/gen-pubsub.py index 3a52551ef3..dff317d1c5 100755 --- a/ntcore/src/main/python/devtools/gen-pubsub.py +++ b/ntcore/src/main/python/devtools/gen-pubsub.py @@ -5,10 +5,10 @@ from cxxheaderparser.simple import parse_string from cxxheaderparser.tokfmt import tokfmt if __name__ == "__main__": - with open("ntcore/include/ntcore_cpp.h") as fp: + with open("ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp") as fp: data = parse_string(fp.read()) - for c in data.namespace.namespaces["nt"].classes: + for c in data.namespace.namespaces["wpi"].namespaces["nt"].classes: if c.class_decl.typename.format() == "struct PubSubOptions": params = [] docs = [] @@ -20,7 +20,7 @@ if __name__ == "__main__": if f.type.format() == "NT_Publisher": params.append( ( - "std::optional>", + "std::optional>", f.name, f"{f.name}.has_value() ? {f.name}.value()->GetHandle() : {f.value.format()}", "std::nullopt", @@ -28,8 +28,8 @@ if __name__ == "__main__": ) else: v = f.value.format() - if v == "kDefaultPeriodic": - v = f"nt::PubSubOptions::{v}" + if v == "DEFAULT_PERIODIC": + v = f"wpi::nt::PubSubOptions::{v}" params.append((f.type, f.name, f.name, v)) if f.doxygen: @@ -40,15 +40,16 @@ if __name__ == "__main__": options = ",\n ".join(f".{fn} = {n}" for _, fn, n, _ in params) doc = "\n ".join( - sphinxify.process_raw("\n".join(docs)).splitlines() + sphinxify.process_raw("\n".join(docs)).lstrip().splitlines() ) - print(f""" + print( + f""" // autogenerated by gen-pubsub.py .def(py::init([]( {paramstr} - ) -> nt::PubSubOptions {{ - return nt::PubSubOptions{{ + ) -> wpi::nt::PubSubOptions {{ + return wpi::nt::PubSubOptions{{ {options} }}; }}), @@ -58,5 +59,7 @@ if __name__ == "__main__": {doc} )" ) - - """) + """.removeprefix( + "\n" + ).rstrip() + ) diff --git a/ntcore/src/main/python/semiwrap/NetworkTableInstance.yml b/ntcore/src/main/python/semiwrap/NetworkTableInstance.yml index 58cb73e334..a516b37617 100644 --- a/ntcore/src/main/python/semiwrap/NetworkTableInstance.yml +++ b/ntcore/src/main/python/semiwrap/NetworkTableInstance.yml @@ -29,7 +29,7 @@ classes: NetworkMode: arithmetic: true inline_code: | - .value("kNetModeStarting", (wpi::nt::NetworkTableInstance::NetworkMode)NT_NET_MODE_STARTING) + .value("STARTING", (wpi::nt::NetworkTableInstance::NetworkMode)NT_NET_MODE_STARTING) LogLevel: value_prefix: LEVEL_ methods: diff --git a/ntcore/src/main/python/semiwrap/ntcore_cpp.yml b/ntcore/src/main/python/semiwrap/ntcore_cpp.yml index bb075d4b8d..d6f3197a48 100644 --- a/ntcore/src/main/python/semiwrap/ntcore_cpp.yml +++ b/ntcore/src/main/python/semiwrap/ntcore_cpp.yml @@ -250,8 +250,6 @@ classes: py::arg("excludeSelf") = false, py::arg("hidden") = false, R"( - - :param pollStorage: Polling storage size for a subscription. Specifies the maximum number of updates NetworkTables should store between calls to the subscriber's ReadQueue() function. If zero, defaults to 1 if sendAll is false, 20 if diff --git a/ntcore/src/test/python/conftest.py b/ntcore/src/test/python/conftest.py index d7136a7f8c..fac7a1e949 100644 --- a/ntcore/src/test/python/conftest.py +++ b/ntcore/src/test/python/conftest.py @@ -85,7 +85,7 @@ class NtTestBase: self.msub = MultiSubscriber(self._impl, [""]) self.vl = self._impl.addListener( - self.msub, EventFlags.kValueRemote, self._wait_cb + self.msub, EventFlags.VALUE_REMOTE, self._wait_cb ) def _wait_cb(self, evt: Event):