[ntcore] Fix up constants renames (#8693)

Takes care of a few renames missed in #8676.
This commit is contained in:
Joseph Eng
2026-03-19 23:35:59 -07:00
committed by GitHub
parent 0665aed66b
commit 8af6bd354e
11 changed files with 28 additions and 27 deletions

View File

@@ -20,7 +20,7 @@ public interface GenericSubscriber extends Subscriber, Supplier<NetworkTableValu
/**
* Get the last published value.
* If no value has been published, returns a value with type NetworkTableType.kUnassigned.
* If no value has been published, returns a value with type NetworkTableType.UNASSIGNED.
*
* @return value
*/

View File

@@ -117,7 +117,7 @@ public final class NetworkTableEntry implements Publisher, Subscriber {
}
/**
* Gets the entry's value. Returns a value with type NetworkTableType.kUnassigned if the value
* Gets the entry's value. Returns a value with type NetworkTableType.UNASSIGNED if the value
* does not exist.
*
* @return the entry's value

View File

@@ -20,7 +20,7 @@ public interface GenericSubscriber extends Subscriber, Supplier<NetworkTableValu
/**
* Get the last published value.
* If no value has been published, returns a value with type NetworkTableType.kUnassigned.
* If no value has been published, returns a value with type NetworkTableType.UNASSIGNED.
*
* @return value
*/

View File

@@ -117,7 +117,7 @@ public final class NetworkTableEntry implements Publisher, Subscriber {
}
/**
* Gets the entry's value. Returns a value with type NetworkTableType.kUnassigned if the value
* Gets the entry's value. Returns a value with type NetworkTableType.UNASSIGNED if the value
* does not exist.
*
* @return the entry's value

View File

@@ -79,14 +79,14 @@ public final class NetworkTableEvent {
public final int listener;
/**
* Determine if event is of a particular kind. For example, kPublish if the topic was not
* Determine if event is of a particular kind. For example, PUBLISH if the topic was not
* previously published. Also indicates the data included with the event:
*
* <ul>
* <li>kConnected or kDisconnected: connInfo
* <li>kPublish, kUnpublish, or kProperties: topicInfo
* <li>kValueRemote, kValueLocal: valueData
* <li>kLogMessage: logMessage
* <li>CONNECTED or DISCONNECTED: connInfo
* <li>PUBLISH, UNPUBLISH, or PROPERTIES: topicInfo
* <li>VALUE_REMOTE, VALUE_LOCAL: valueData
* <li>LOG_MESSAGE: logMessage
* </ul>
*
* @param kind Kind

View File

@@ -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

View File

@@ -276,7 +276,7 @@ class UnitTopic final : public Topic {
using ParamType = T;
using TimestampedValueType = TimestampedUnit<T>;
/** 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;

View File

@@ -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::shared_ptr<nt::Publisher>>",
"std::optional<std::shared_ptr<wpi::nt::Publisher>>",
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()
)

View File

@@ -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:

View File

@@ -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

View File

@@ -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):