SCRIPT: wpiformat

This commit is contained in:
PJ Reiniger
2025-11-07 20:01:58 -05:00
committed by Peter Johnson
parent ae6bdc9d25
commit 2109161534
749 changed files with 5504 additions and 3936 deletions

View File

@@ -147,7 +147,8 @@ void wpi::util::ResetEvent(WPI_EventHandle handle) {
ResetSignalObject(handle);
}
WPI_SemaphoreHandle wpi::util::CreateSemaphore(int initialCount, int maximumCount) {
WPI_SemaphoreHandle wpi::util::CreateSemaphore(int initialCount,
int maximumCount) {
ManagerGuard guard;
if (!guard) {
return {};
@@ -183,7 +184,7 @@ void wpi::util::DestroySemaphore(WPI_SemaphoreHandle handle) {
}
bool wpi::util::ReleaseSemaphore(WPI_SemaphoreHandle handle, int releaseCount,
int* prevCount) {
int* prevCount) {
if ((handle >> 24) != kHandleTypeSemaphore) {
return false;
}
@@ -221,7 +222,8 @@ bool wpi::util::WaitForObject(WPI_Handle handle) {
return WaitForObject(handle, -1, nullptr);
}
bool wpi::util::WaitForObject(WPI_Handle handle, double timeout, bool* timedOut) {
bool wpi::util::WaitForObject(WPI_Handle handle, double timeout,
bool* timedOut) {
WPI_Handle signaledValue;
auto signaled = WaitForObjects(
std::span(&handle, 1), std::span(&signaledValue, 1), timeout, timedOut);
@@ -231,14 +233,14 @@ bool wpi::util::WaitForObject(WPI_Handle handle, double timeout, bool* timedOut)
return (signaled[0] & 0x80000000ul) == 0;
}
std::span<WPI_Handle> wpi::util::WaitForObjects(std::span<const WPI_Handle> handles,
std::span<WPI_Handle> signaled) {
std::span<WPI_Handle> wpi::util::WaitForObjects(
std::span<const WPI_Handle> handles, std::span<WPI_Handle> signaled) {
return WaitForObjects(handles, signaled, -1, nullptr);
}
std::span<WPI_Handle> wpi::util::WaitForObjects(std::span<const WPI_Handle> handles,
std::span<WPI_Handle> signaled,
double timeout, bool* timedOut) {
std::span<WPI_Handle> wpi::util::WaitForObjects(
std::span<const WPI_Handle> handles, std::span<WPI_Handle> signaled,
double timeout, bool* timedOut) {
ManagerGuard guard;
if (!guard) {
if (timedOut) {
@@ -337,7 +339,7 @@ std::span<WPI_Handle> wpi::util::WaitForObjects(std::span<const WPI_Handle> hand
}
void wpi::util::CreateSignalObject(WPI_Handle handle, bool manualReset,
bool initialState) {
bool initialState) {
ManagerGuard guard;
if (!guard) {
return;
@@ -448,7 +450,7 @@ int WPI_WaitForObjectTimeout(WPI_Handle handle, double timeout,
int WPI_WaitForObjects(const WPI_Handle* handles, int handles_count,
WPI_Handle* signaled) {
return wpi::util::WaitForObjects(std::span(handles, handles_count),
std::span(signaled, handles_count))
std::span(signaled, handles_count))
.size();
}
@@ -456,9 +458,9 @@ int WPI_WaitForObjectsTimeout(const WPI_Handle* handles, int handles_count,
WPI_Handle* signaled, double timeout,
int* timed_out) {
bool timedOutBool;
auto signaledResult = wpi::util::WaitForObjects(std::span(handles, handles_count),
std::span(signaled, handles_count),
timeout, &timedOutBool);
auto signaledResult = wpi::util::WaitForObjects(
std::span(handles, handles_count), std::span(signaled, handles_count),
timeout, &timedOutBool);
*timed_out = timedOutBool ? 1 : 0;
return signaledResult.size();
}

View File

@@ -34,7 +34,8 @@ static const JExceptionInit exceptions[] = {
{"java/lang/NullPointerException", &nullPointerEx},
{"org/wpilib/util/runtime/MsvcRuntimeException", &msvcRuntimeEx}};
void wpi::util::ThrowIllegalArgumentException(JNIEnv* env, std::string_view msg) {
void wpi::util::ThrowIllegalArgumentException(JNIEnv* env,
std::string_view msg) {
illegalArgEx.Throw(env, msg);
}
@@ -98,7 +99,8 @@ Java_org_wpilib_util_WPIUtilJNI_checkMsvcRuntime
&expectedMinor, &runtimePath)) {
static jmethodID ctor =
env->GetMethodID(msvcRuntimeEx, "<init>", "(IIIILjava/lang/String;)V");
jstring jmsvcruntime = MakeJString(env, wpi::util::to_string_view(&runtimePath));
jstring jmsvcruntime =
MakeJString(env, wpi::util::to_string_view(&runtimePath));
jobject exception =
env->NewObject(msvcRuntimeEx, ctor, foundMajor, foundMinor,
expectedMajor, expectedMinor, jmsvcruntime);
@@ -129,7 +131,8 @@ Java_org_wpilib_util_WPIUtilJNI_enableMockTime
(JNIEnv*, jclass)
{
#ifdef __FRC_SYSTEMCORE__
wpi::util::print(stderr, "WPIUtil: Mocking time is not available on systemcore\n");
wpi::util::print(stderr,
"WPIUtil: Mocking time is not available on systemcore\n");
#else
mockTimeEnabled = true;
wpi::util::SetNowImpl([] { return mockNow; });

View File

@@ -65,8 +65,8 @@ enum WPI_PixelFormat {
*/
enum WPI_TimestampSource {
WPI_TIMESRC_UNKNOWN = 0, // unknown
WPI_TIMESRC_FRAME_DEQUEUE, // wpi::util::Now when the new frame was dequeued by
// CSCore. Does not account for camera exposure
WPI_TIMESRC_FRAME_DEQUEUE, // wpi::util::Now when the new frame was dequeued
// by CSCore. Does not account for camera exposure
// time or V4L latency.
WPI_TIMESRC_V4L_EOF, // End of Frame. Same as V4L2_BUF_FLAG_TSTAMP_SRC_EOF,
// translated into wpi::util::Now's timebase.

View File

@@ -89,7 +89,8 @@ constexpr const T&& get(const wpi::util::array<T, N>&& arr) noexcept {
namespace std { // NOLINT
// Partial specialization for wpi::util::array
template <typename T, size_t N>
struct tuple_size<wpi::util::array<T, N>> : public integral_constant<size_t, N> {};
struct tuple_size<wpi::util::array<T, N>>
: public integral_constant<size_t, N> {};
// Partial specialization for wpi::util::array
template <size_t I, typename T, size_t N>

View File

@@ -161,7 +161,7 @@ class JStringRef {
}
} else {
wpi::util::print(stderr, "JStringRef was passed a null pointer at\n",
GetJavaStackTrace(env));
GetJavaStackTrace(env));
}
// Ensure str is null-terminated.
m_str.push_back('\0');
@@ -285,7 +285,7 @@ class JSpanBase {
bb ? env->GetDirectBufferAddress(bb) : nullptr)} {
if (!bb) {
wpi::util::print(stderr, "JSpan was passed a null pointer at\n",
GetJavaStackTrace(env));
GetJavaStackTrace(env));
}
}
@@ -304,7 +304,7 @@ class JSpanBase {
}
} else {
wpi::util::print(stderr, "JSpan was passed a null pointer at\n",
GetJavaStackTrace(env));
GetJavaStackTrace(env));
}
}

View File

@@ -232,9 +232,9 @@ class ProtoOutputStream {
* values into a nanopb Stream and deserialization consists of
* reading values from nanopb Stream.
*
* Implementations must define a template specialization for wpi::util::Protobuf with
* T being the type that is being serialized/deserialized, with the following
* static members (as enforced by this concept):
* Implementations must define a template specialization for wpi::util::Protobuf
* with T being the type that is being serialized/deserialized, with the
* following static members (as enforced by this concept):
* - using MessageStruct = nanopb_message_struct_here: typedef to the wpilib
* modified nanopb message struct
* - std::optional<T> Unpack(wpi::util::ProtoInputStream<T>&): function
@@ -250,7 +250,8 @@ class ProtoOutputStream {
template <typename T>
concept ProtobufSerializable = requires(
wpi::util::ProtoOutputStream<std::remove_cvref_t<T>>& ostream,
wpi::util::ProtoInputStream<std::remove_cvref_t<T>>& istream, const T& value) {
wpi::util::ProtoInputStream<std::remove_cvref_t<T>>& istream,
const T& value) {
typename Protobuf<typename std::remove_cvref_t<T>>;
{
Protobuf<typename std::remove_cvref_t<T>>::Unpack(istream)
@@ -275,8 +276,8 @@ concept ProtobufSerializable = requires(
*
* In addition to meeting ProtobufSerializable, implementations must define a
* wpi::util::Protobuf<T> static member -
* `bool UnpackInto(T*, wpi::util::ProtoInputStream<T>&)` to update the pointed-to T
* with the contents of the message.
* `bool UnpackInto(T*, wpi::util::ProtoInputStream<T>&)` to update the
* pointed-to T with the contents of the message.
*/
template <typename T>
concept MutableProtobufSerializable =

View File

@@ -338,7 +338,8 @@ class UnpackCallback
* Constructs an UnpackCallback.
*/
UnpackCallback()
: DirectUnpackCallback<T, wpi::util::SmallVector<T, N>, N>{m_storedBuffer} {
: DirectUnpackCallback<T, wpi::util::SmallVector<T, N>, N>{
m_storedBuffer} {
this->SetLimits(DecodeLimits::Ignore);
}

View File

@@ -277,7 +277,8 @@ class SendableBuilder {
*/
virtual void AddSmallStringProperty(
std::string_view key,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)> getter,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)>
getter,
std::function<void(std::string_view)> setter) = 0;
/**
@@ -316,7 +317,8 @@ class SendableBuilder {
*/
virtual void AddSmallFloatArrayProperty(
std::string_view key,
std::function<std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
std::function<
std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
getter,
std::function<void(std::span<const float>)> setter) = 0;
@@ -329,7 +331,8 @@ class SendableBuilder {
*/
virtual void AddSmallDoubleArrayProperty(
std::string_view key,
std::function<std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
std::function<
std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
getter,
std::function<void(std::span<const double>)> setter) = 0;
@@ -342,8 +345,8 @@ class SendableBuilder {
*/
virtual void AddSmallStringArrayProperty(
std::string_view key,
std::function<
std::span<const std::string>(wpi::util::SmallVectorImpl<std::string>& buf)>
std::function<std::span<const std::string>(
wpi::util::SmallVectorImpl<std::string>& buf)>
getter,
std::function<void(std::span<const std::string>)> setter) = 0;
@@ -357,7 +360,8 @@ class SendableBuilder {
*/
virtual void AddSmallRawProperty(
std::string_view key, std::string_view typeString,
std::function<std::span<uint8_t>(wpi::util::SmallVectorImpl<uint8_t>& buf)>
std::function<
std::span<uint8_t>(wpi::util::SmallVectorImpl<uint8_t>& buf)>
getter,
std::function<void(std::span<const uint8_t>)> setter) = 0;

View File

@@ -120,7 +120,8 @@ class static_circular_buffer {
* Returns const end iterator.
*/
constexpr const_iterator end() const {
return const_iterator(this, ::wpi::util::static_circular_buffer<T, N>::size());
return const_iterator(this,
::wpi::util::static_circular_buffer<T, N>::size());
}
/**
@@ -132,7 +133,8 @@ class static_circular_buffer {
* Returns const end iterator.
*/
constexpr const_iterator cend() const {
return const_iterator(this, ::wpi::util::static_circular_buffer<T, N>::size());
return const_iterator(this,
::wpi::util::static_circular_buffer<T, N>::size());
}
/**

View File

@@ -47,9 +47,9 @@ struct Struct {};
* values into a mutable std::span and deserialization consists of reading
* values from an immutable std::span.
*
* Implementations must define a template specialization for wpi::util::Struct with
* T being the type that is being serialized/deserialized, with the following
* static members (as enforced by this concept):
* Implementations must define a template specialization for wpi::util::Struct
* with T being the type that is being serialized/deserialized, with the
* following static members (as enforced by this concept):
* - std::string_view GetTypeName(): function that returns the type name
* - size_t GetSize(): function that returns the structure size in bytes
* - std::string_view GetSchema(): function that returns the struct schema
@@ -96,8 +96,8 @@ concept StructSerializable = requires(std::span<const uint8_t> in,
* Specifies that a type is capable of in-place raw struct deserialization.
*
* In addition to meeting StructSerializable, implementations must define a
* wpi::util::Struct<T> static member `void UnpackInto(T*, std::span<const uint8_t>)`
* to update the pointed-to T with the contents of the span.
* wpi::util::Struct<T> static member `void UnpackInto(T*, std::span<const
* uint8_t>)` to update the pointed-to T with the contents of the span.
*/
template <typename T, typename... I>
concept MutableStructSerializable =