mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -9,7 +9,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
// Binary insertion into vector; std::log(n) efficiency.
|
||||
template <typename T>
|
||||
@@ -32,4 +32,4 @@ constexpr void for_each(F&& f, Ts&&... elems) {
|
||||
}(std::index_sequence_for<Ts...>{});
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
class raw_ostream;
|
||||
@@ -44,6 +44,6 @@ void Base64Encode(std::span<const uint8_t> plain, std::string* encoded);
|
||||
std::string_view Base64Encode(std::span<const uint8_t> plain,
|
||||
SmallVectorImpl<char>& buf);
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_BASE64_HPP_
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template <typename Callback>
|
||||
class CallbackListenerData {
|
||||
@@ -47,7 +47,7 @@ template <typename Derived, typename TUserInfo,
|
||||
typename TListenerData =
|
||||
CallbackListenerData<std::function<void(const TUserInfo& info)>>,
|
||||
typename TNotifierData = TUserInfo>
|
||||
class CallbackThread : public wpi::SafeThread {
|
||||
class CallbackThread : public wpi::util::SafeThread {
|
||||
public:
|
||||
using UserInfo = TUserInfo;
|
||||
using NotifierData = TNotifierData;
|
||||
@@ -67,10 +67,10 @@ class CallbackThread : public wpi::SafeThread {
|
||||
|
||||
void Main() override;
|
||||
|
||||
wpi::UidVector<ListenerData, 64> m_listeners;
|
||||
wpi::util::UidVector<ListenerData, 64> m_listeners;
|
||||
|
||||
std::queue<std::pair<unsigned int, NotifierData>> m_queue;
|
||||
wpi::condition_variable m_queue_empty;
|
||||
wpi::util::condition_variable m_queue_empty;
|
||||
|
||||
struct Poller {
|
||||
void Terminate() {
|
||||
@@ -81,12 +81,12 @@ class CallbackThread : public wpi::SafeThread {
|
||||
poll_cond.notify_all();
|
||||
}
|
||||
std::queue<NotifierData> poll_queue;
|
||||
wpi::mutex poll_mutex;
|
||||
wpi::condition_variable poll_cond;
|
||||
wpi::util::mutex poll_mutex;
|
||||
wpi::util::condition_variable poll_cond;
|
||||
bool terminating = false;
|
||||
bool canceling = false;
|
||||
};
|
||||
wpi::UidVector<std::shared_ptr<Poller>, 64> m_pollers;
|
||||
wpi::util::UidVector<std::shared_ptr<Poller>, 64> m_pollers;
|
||||
|
||||
std::function<void()> m_on_start;
|
||||
std::function<void()> m_on_exit;
|
||||
@@ -379,17 +379,17 @@ class CallbackManager {
|
||||
thr->m_cond.notify_one();
|
||||
}
|
||||
|
||||
typename wpi::SafeThreadOwner<Thread>::Proxy GetThread() const {
|
||||
typename wpi::util::SafeThreadOwner<Thread>::Proxy GetThread() const {
|
||||
return m_owner.GetThread();
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::SafeThreadOwner<Thread> m_owner;
|
||||
wpi::util::SafeThreadOwner<Thread> m_owner;
|
||||
|
||||
std::function<void()> m_on_start;
|
||||
std::function<void()> m_on_exit;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_CALLBACKMANAGER_HPP_
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template <class Derived, class Base>
|
||||
concept DecayedDerivedFrom =
|
||||
std::derived_from<std::decay_t<Derived>, std::decay_t<Base>> &&
|
||||
std::convertible_to<std::decay_t<Derived>*, std::decay_t<Base>*>;
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string_view>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Demangle a C++ symbol.
|
||||
@@ -28,6 +28,6 @@ std::string GetTypeName(const T& type) {
|
||||
return Demangle(typeid(type).name());
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_DEMANGLE_HPP_
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include "wpi/util/Synchronization.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
struct EventVector {
|
||||
wpi::mutex mutex;
|
||||
wpi::SmallVector<WPI_EventHandle, 4> events;
|
||||
wpi::util::mutex mutex;
|
||||
wpi::util::SmallVector<WPI_EventHandle, 4> events;
|
||||
|
||||
/**
|
||||
* Adds an event to the event vector.
|
||||
@@ -44,8 +44,8 @@ struct EventVector {
|
||||
void Wakeup() {
|
||||
std::scoped_lock lock{mutex};
|
||||
for (auto&& handle : events) {
|
||||
wpi::SetEvent(handle);
|
||||
wpi::util::SetEvent(handle);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
// Allocates memory sparingly, and only once if the original maximum size
|
||||
// estimate is never exceeded.
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template<typename T, size_t MAX_BLOCK_SIZE = 512>
|
||||
class FastQueue
|
||||
@@ -554,4 +554,4 @@ private:
|
||||
size_t largestBlockSize;
|
||||
};
|
||||
|
||||
} // end namespace wpi
|
||||
} // end namespace wpi::util
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
enum LogLevel {
|
||||
WPI_LOG_CRITICAL = 50,
|
||||
@@ -73,22 +73,22 @@ class Logger {
|
||||
}
|
||||
|
||||
#define WPI_ERROR(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_WARNING(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_INFO(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_DEBUG(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_DEBUG1(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_DEBUG2(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_DEBUG3(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define WPI_DEBUG4(inst, format, ...) \
|
||||
WPI_LOG(inst, ::wpi::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
WPI_LOG(inst, ::wpi::util::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_LOGGER_HPP_
|
||||
|
||||
@@ -18,7 +18,7 @@ using file_t = int;
|
||||
#endif
|
||||
} // namespace fs
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
class MappedFileRegion {
|
||||
public:
|
||||
@@ -83,4 +83,4 @@ class MappedFileRegion {
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
|
||||
// that is being deleted by someone else.
|
||||
@@ -13,4 +13,4 @@ struct NullDeleter {
|
||||
void operator()(T*) const noexcept {};
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -61,18 +61,18 @@ enum WPI_PixelFormat {
|
||||
};
|
||||
|
||||
/**
|
||||
* Timestamp metadata. Timebase is the same as wpi::Now
|
||||
* Timestamp metadata. Timebase is the same as wpi::util::Now
|
||||
*/
|
||||
enum WPI_TimestampSource {
|
||||
WPI_TIMESRC_UNKNOWN = 0, // unknown
|
||||
WPI_TIMESRC_FRAME_DEQUEUE, // wpi::Now when the new frame was dequeued by
|
||||
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::Now's timebase.
|
||||
// translated into wpi::util::Now's timebase.
|
||||
WPI_TIMESRC_V4L_SOE, // Start of Exposure. Same as
|
||||
// V4L2_BUF_FLAG_TSTAMP_SRC_SOE, translated into
|
||||
// wpi::Now's timebase.
|
||||
// wpi::util::Now's timebase.
|
||||
};
|
||||
|
||||
// Returns nonzero if the frame data was allocated/reallocated
|
||||
@@ -88,7 +88,7 @@ void WPI_SetRawFrameData(WPI_RawFrame* frame, void* data, size_t size,
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
struct RawFrame : public WPI_RawFrame {
|
||||
RawFrame() {
|
||||
data = nullptr;
|
||||
@@ -135,7 +135,7 @@ struct RawFrame : public WPI_RawFrame {
|
||||
};
|
||||
|
||||
#ifdef WPI_RAWFRAME_JNI
|
||||
template <std::same_as<wpi::RawFrame> T>
|
||||
template <std::same_as<wpi::util::RawFrame> T>
|
||||
void SetFrameData(JNIEnv* env, jclass rawFrameCls, jobject jframe,
|
||||
const T& frame, bool newData) {
|
||||
if (newData) {
|
||||
@@ -160,7 +160,7 @@ void SetFrameData(JNIEnv* env, jclass rawFrameCls, jobject jframe,
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
#endif
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_RAWFRAME_H_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/util/condition_variable.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Base class for SafeThreadOwner threads.
|
||||
@@ -25,7 +25,7 @@ class SafeThreadBase {
|
||||
virtual void Main() = 0;
|
||||
virtual void Stop() = 0;
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
std::atomic_bool m_active{true};
|
||||
std::thread::id m_threadId;
|
||||
};
|
||||
@@ -34,7 +34,7 @@ class SafeThread : public SafeThreadBase {
|
||||
public:
|
||||
void Stop() override;
|
||||
|
||||
wpi::condition_variable m_cond;
|
||||
wpi::util::condition_variable m_cond;
|
||||
};
|
||||
|
||||
class SafeThreadEvent : public SafeThreadBase {
|
||||
@@ -55,11 +55,11 @@ class SafeThreadProxyBase {
|
||||
public:
|
||||
explicit SafeThreadProxyBase(std::shared_ptr<SafeThreadBase> thr);
|
||||
explicit operator bool() const { return m_thread != nullptr; }
|
||||
std::unique_lock<wpi::mutex>& GetLock() { return m_lock; }
|
||||
std::unique_lock<wpi::util::mutex>& GetLock() { return m_lock; }
|
||||
|
||||
protected:
|
||||
std::shared_ptr<SafeThreadBase> m_thread;
|
||||
std::unique_lock<wpi::mutex> m_lock;
|
||||
std::unique_lock<wpi::util::mutex> m_lock;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ class SafeThreadOwnerBase {
|
||||
std::shared_ptr<SafeThreadBase> GetThreadSharedPtr() const;
|
||||
|
||||
private:
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
std::thread m_stdThread;
|
||||
std::weak_ptr<SafeThreadBase> m_thread;
|
||||
std::atomic_bool m_joinAtExit{true};
|
||||
@@ -140,6 +140,6 @@ class SafeThreadOwner : public detail::SafeThreadOwnerBase {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_SAFETHREAD_HPP_
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <cassert>
|
||||
#include <span>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/// Drop the first \p N elements of the array.
|
||||
template <typename T, size_t N>
|
||||
@@ -55,4 +55,4 @@ constexpr std::span<T> take_back(std::span<T, N> in,
|
||||
return drop_front(in, length - n);
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Get a stack trace, ignoring the first "offset" symbols.
|
||||
@@ -30,6 +30,6 @@ std::string GetStackTraceDefault(int offset);
|
||||
*/
|
||||
void SetGetStackTraceImpl(std::string (*func)(int offset));
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_STACKTRACE_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* StringMap is a sorted associative container that contains key-value pairs
|
||||
@@ -767,11 +767,11 @@ class StringMap : public std::map<std::string, T, std::less<>, Allocator> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace std {
|
||||
template <typename T>
|
||||
inline void swap(wpi::StringMap<T>& lhs, wpi::StringMap<T>& rhs) {
|
||||
inline void swap(wpi::util::StringMap<T>& lhs, wpi::util::StringMap<T>& rhs) {
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef WPI_Handle WPI_SemaphoreHandle; // NOLINT
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/** Constant representing an invalid handle. */
|
||||
constexpr unsigned int kInvalidHandle = 0;
|
||||
@@ -442,7 +442,7 @@ class SignalObject final {
|
||||
T m_handle;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
namespace impl {
|
||||
template <typename It>
|
||||
@@ -154,6 +154,6 @@ class UidVector {
|
||||
size_type m_active_count{0};
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_UIDVECTOR_HPP_
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
struct empty_array_t {};
|
||||
constexpr empty_array_t empty_array;
|
||||
@@ -59,42 +59,42 @@ class array : public std::array<T, N> {
|
||||
template <typename T, std::convertible_to<T>... Ts>
|
||||
array(T, Ts...) -> array<T, 1 + sizeof...(Ts)>;
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
template <size_t I, typename T, size_t N>
|
||||
requires(I < N)
|
||||
constexpr T& get(wpi::array<T, N>& arr) noexcept {
|
||||
constexpr T& get(wpi::util::array<T, N>& arr) noexcept {
|
||||
return std::get<I>(static_cast<std::array<T, N>>(arr));
|
||||
}
|
||||
|
||||
template <size_t I, typename T, size_t N>
|
||||
requires(I < N)
|
||||
constexpr T&& get(wpi::array<T, N>&& arr) noexcept {
|
||||
constexpr T&& get(wpi::util::array<T, N>&& arr) noexcept {
|
||||
return std::move(std::get<I>(arr));
|
||||
}
|
||||
|
||||
template <size_t I, typename T, size_t N>
|
||||
requires(I < N)
|
||||
constexpr const T& get(const wpi::array<T, N>& arr) noexcept {
|
||||
constexpr const T& get(const wpi::util::array<T, N>& arr) noexcept {
|
||||
return std::get<I>(static_cast<std::array<T, N>>(arr));
|
||||
}
|
||||
|
||||
template <size_t I, typename T, size_t N>
|
||||
requires(I < N)
|
||||
constexpr const T&& get(const wpi::array<T, N>&& arr) noexcept {
|
||||
constexpr const T&& get(const wpi::util::array<T, N>&& arr) noexcept {
|
||||
return std::move(std::get<I>(arr));
|
||||
}
|
||||
|
||||
// Enables structured bindings
|
||||
namespace std { // NOLINT
|
||||
// Partial specialization for wpi::array
|
||||
// Partial specialization for wpi::util::array
|
||||
template <typename T, size_t N>
|
||||
struct tuple_size<wpi::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::array
|
||||
// Partial specialization for wpi::util::array
|
||||
template <size_t I, typename T, size_t N>
|
||||
requires(I < N)
|
||||
struct tuple_element<I, wpi::array<T, N>> {
|
||||
struct tuple_element<I, wpi::util::array<T, N>> {
|
||||
using type = T;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* This is a simple circular buffer so we don't need to "bucket brigade" copy
|
||||
@@ -117,7 +117,7 @@ class circular_buffer {
|
||||
* Returns end iterator.
|
||||
*/
|
||||
constexpr iterator end() {
|
||||
return iterator(this, ::wpi::circular_buffer<T>::size());
|
||||
return iterator(this, ::wpi::util::circular_buffer<T>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ class circular_buffer {
|
||||
* Returns const end iterator.
|
||||
*/
|
||||
constexpr const_iterator end() const {
|
||||
return const_iterator(this, ::wpi::circular_buffer<T>::size());
|
||||
return const_iterator(this, ::wpi::util::circular_buffer<T>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +141,7 @@ class circular_buffer {
|
||||
* Returns const end iterator.
|
||||
*/
|
||||
constexpr const_iterator cend() const {
|
||||
return const_iterator(this, ::wpi::circular_buffer<T>::size());
|
||||
return const_iterator(this, ::wpi::util::circular_buffer<T>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,4 +431,4 @@ class circular_buffer {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/util/priority_mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
#if defined(__linux__) && defined(WPI_HAVE_PRIORITY_MUTEX)
|
||||
using condition_variable = ::std::condition_variable_any;
|
||||
@@ -16,4 +16,4 @@ using condition_variable = ::std::condition_variable_any;
|
||||
using condition_variable = ::std::condition_variable;
|
||||
#endif
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
// derived from:
|
||||
// https://codereview.stackexchange.com/questions/282514/string-literals-concatenation-with-support-for-dynamic-strings
|
||||
@@ -228,4 +228,4 @@ constexpr auto NumToCtString() {
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
inline void vprint(wpi::raw_ostream& os, fmt::string_view format_str,
|
||||
inline void vprint(wpi::util::raw_ostream& os, fmt::string_view format_str,
|
||||
fmt::format_args args) {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::detail::vformat_to(buffer, format_str, args);
|
||||
@@ -22,10 +22,10 @@ inline void vprint(wpi::raw_ostream& os, fmt::string_view format_str,
|
||||
* Prints formatted data to the stream *os*.
|
||||
*/
|
||||
template <typename S, typename... Args>
|
||||
void print(wpi::raw_ostream& os, const S& format_str, Args&&... args) {
|
||||
void print(wpi::util::raw_ostream& os, const S& format_str, Args&&... args) {
|
||||
vprint(os, format_str, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_FMT_RAW_OSTREAM_HPP_
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/condition_variable.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template <typename T>
|
||||
class PromiseFactory;
|
||||
@@ -39,16 +39,16 @@ class PromiseFactoryBase {
|
||||
|
||||
bool IsActive() const { return m_active; }
|
||||
|
||||
wpi::mutex& GetResultMutex() { return m_resultMutex; }
|
||||
wpi::util::mutex& GetResultMutex() { return m_resultMutex; }
|
||||
|
||||
void Notify() { m_resultCv.notify_all(); }
|
||||
|
||||
// must be called with locked lock == ResultMutex
|
||||
void Wait(std::unique_lock<wpi::mutex>& lock) { m_resultCv.wait(lock); }
|
||||
void Wait(std::unique_lock<wpi::util::mutex>& lock) { m_resultCv.wait(lock); }
|
||||
|
||||
// returns false if timeout reached
|
||||
template <class Clock, class Duration>
|
||||
bool WaitUntil(std::unique_lock<wpi::mutex>& lock,
|
||||
bool WaitUntil(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const std::chrono::time_point<Clock, Duration>& timeout_time) {
|
||||
return m_resultCv.wait_until(lock, timeout_time) ==
|
||||
std::cv_status::no_timeout;
|
||||
@@ -67,9 +67,9 @@ class PromiseFactoryBase {
|
||||
uint64_t CreateErasedRequest() { return ++m_uid; }
|
||||
|
||||
private:
|
||||
wpi::mutex m_resultMutex;
|
||||
wpi::util::mutex m_resultMutex;
|
||||
std::atomic_bool m_active{true};
|
||||
wpi::condition_variable m_resultCv;
|
||||
wpi::util::condition_variable m_resultCv;
|
||||
|
||||
uint64_t m_uid = 0;
|
||||
std::vector<uint64_t> m_requests;
|
||||
@@ -938,6 +938,6 @@ future<void> detail::FutureThen<void, void>::Create(
|
||||
return factory.CreateFuture(req);
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_FUTURE_HPP_
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Implements a table of key-value pairs with linear interpolation between
|
||||
@@ -84,4 +84,4 @@ class interpolating_map {
|
||||
std::map<Key, Value> m_container;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "wpi/util/string.h"
|
||||
|
||||
/** Java Native Interface (JNI) utility functions */
|
||||
namespace wpi::java {
|
||||
namespace wpi::util::java {
|
||||
|
||||
/**
|
||||
* Gets a Java stack trace.
|
||||
@@ -160,7 +160,7 @@ class JStringRef {
|
||||
env->ReleaseStringCritical(str, chars);
|
||||
}
|
||||
} else {
|
||||
wpi::print(stderr, "JStringRef was passed a null pointer at\n",
|
||||
wpi::util::print(stderr, "JStringRef was passed a null pointer at\n",
|
||||
GetJavaStackTrace(env));
|
||||
}
|
||||
// Ensure str is null-terminated.
|
||||
@@ -172,7 +172,7 @@ class JStringRef {
|
||||
std::string_view str() const { return m_str.str(); }
|
||||
const char* c_str() const { return m_str.data(); }
|
||||
size_t size() const { return m_str.size(); }
|
||||
WPI_String wpi_str() const { return wpi::make_string(str()); }
|
||||
WPI_String wpi_str() const { return wpi::util::make_string(str()); }
|
||||
|
||||
private:
|
||||
SmallString<128> m_str;
|
||||
@@ -284,7 +284,7 @@ class JSpanBase {
|
||||
m_elements{static_cast<std::remove_cv_t<T>*>(
|
||||
bb ? env->GetDirectBufferAddress(bb) : nullptr)} {
|
||||
if (!bb) {
|
||||
wpi::print(stderr, "JSpan was passed a null pointer at\n",
|
||||
wpi::util::print(stderr, "JSpan was passed a null pointer at\n",
|
||||
GetJavaStackTrace(env));
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ class JSpanBase {
|
||||
m_elements = ArrHelper::GetArrayElements(env, jarr);
|
||||
}
|
||||
} else {
|
||||
wpi::print(stderr, "JSpan was passed a null pointer at\n",
|
||||
wpi::util::print(stderr, "JSpan was passed a null pointer at\n",
|
||||
GetJavaStackTrace(env));
|
||||
}
|
||||
}
|
||||
@@ -845,7 +845,7 @@ inline std::string GetJavaStackTrace(JNIEnv* env, std::string_view skipPrefix) {
|
||||
// add a line to res
|
||||
JStringRef elem(env, stackElementString);
|
||||
if (!foundFirst) {
|
||||
if (wpi::starts_with(elem, skipPrefix)) {
|
||||
if (wpi::util::starts_with(elem, skipPrefix)) {
|
||||
continue;
|
||||
}
|
||||
foundFirst = true;
|
||||
@@ -928,7 +928,7 @@ inline std::string GetJavaStackTrace(JNIEnv* env, std::string* func,
|
||||
if (i == 1) {
|
||||
*func = elem.str();
|
||||
} else if (i > 1 && !haveLoc && !excludeFuncPrefix.empty() &&
|
||||
!wpi::starts_with(elem, excludeFuncPrefix)) {
|
||||
!wpi::util::starts_with(elem, excludeFuncPrefix)) {
|
||||
*func = elem.str();
|
||||
haveLoc = true;
|
||||
}
|
||||
@@ -975,6 +975,6 @@ struct JExceptionInit {
|
||||
JException* cls;
|
||||
};
|
||||
|
||||
} // namespace wpi::java
|
||||
} // namespace wpi::util::java
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_JNI_UTIL_HPP_
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/util/priority_mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
#ifdef WPI_HAVE_PRIORITY_MUTEX
|
||||
using mutex = priority_mutex;
|
||||
@@ -18,4 +18,4 @@ using mutex = ::std::mutex;
|
||||
using recursive_mutex = ::std::recursive_mutex;
|
||||
#endif
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <fmt/core.h>
|
||||
#endif
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Wrapper around fmt::print() that squelches write failure exceptions.
|
||||
@@ -60,4 +60,4 @@ inline void println(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
#if defined(__FRC_SYSTEMCORE__) && !defined(WPI_USE_PRIORITY_MUTEX)
|
||||
#define WPI_USE_PRIORITY_MUTEX
|
||||
@@ -75,4 +75,4 @@ class priority_mutex {
|
||||
|
||||
#endif // defined(WPI_USE_PRIORITY_MUTEX) && defined(__linux__)
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* This class is the same as std::priority_queue with two changes:
|
||||
@@ -111,6 +111,6 @@ class priority_queue {
|
||||
Compare comp;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_PRIORITY_QUEUE_HPP_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "wpi/util/array.hpp"
|
||||
#include "wpi/util/function_ref.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
@@ -36,7 +36,7 @@ template <typename T>
|
||||
struct Protobuf {};
|
||||
|
||||
namespace detail {
|
||||
using SmallVectorType = wpi::SmallVectorImpl<uint8_t>;
|
||||
using SmallVectorType = wpi::util::SmallVectorImpl<uint8_t>;
|
||||
using StdVectorType = std::vector<uint8_t>;
|
||||
bool WriteFromSmallVector(pb_ostream_t* stream, const pb_byte_t* buf,
|
||||
size_t count);
|
||||
@@ -232,25 +232,25 @@ class ProtoOutputStream {
|
||||
* values into a nanopb Stream and deserialization consists of
|
||||
* reading values from nanopb Stream.
|
||||
*
|
||||
* Implementations must define a template specialization for wpi::Protobuf with
|
||||
* 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::ProtoInputStream<T>&): function
|
||||
* - std::optional<T> Unpack(wpi::util::ProtoInputStream<T>&): function
|
||||
* for deserialization
|
||||
* - bool Pack(wpi::ProtoOutputStream<T>&, T&& value): function
|
||||
* - bool Pack(wpi::util::ProtoOutputStream<T>&, T&& value): function
|
||||
* for serialization
|
||||
*
|
||||
* As a suggestion, 2 extra type usings can be added to simplify the stream
|
||||
* definitions, however these are not required.
|
||||
* - using InputStream = wpi::ProtoInputStream<T>;
|
||||
* - using OutputStream = wpi::ProtoOutputStream<T>;
|
||||
* - using InputStream = wpi::util::ProtoInputStream<T>;
|
||||
* - using OutputStream = wpi::util::ProtoOutputStream<T>;
|
||||
*/
|
||||
template <typename T>
|
||||
concept ProtobufSerializable = requires(
|
||||
wpi::ProtoOutputStream<std::remove_cvref_t<T>>& ostream,
|
||||
wpi::ProtoInputStream<std::remove_cvref_t<T>>& istream, const T& value) {
|
||||
wpi::util::ProtoOutputStream<std::remove_cvref_t<T>>& ostream,
|
||||
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)
|
||||
@@ -274,14 +274,14 @@ concept ProtobufSerializable = requires(
|
||||
* Specifies that a type is capable of in-place protobuf deserialization.
|
||||
*
|
||||
* In addition to meeting ProtobufSerializable, implementations must define a
|
||||
* wpi::Protobuf<T> static member -
|
||||
* `bool UnpackInto(T*, wpi::ProtoInputStream<T>&)` to update the pointed-to T
|
||||
* 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.
|
||||
*/
|
||||
template <typename T>
|
||||
concept MutableProtobufSerializable =
|
||||
ProtobufSerializable<T> &&
|
||||
requires(T* out, wpi::ProtoInputStream<T>& istream) {
|
||||
requires(T* out, wpi::util::ProtoInputStream<T>& istream) {
|
||||
{
|
||||
Protobuf<typename std::remove_cvref_t<T>>::UnpackInto(out, istream)
|
||||
} -> std::same_as<bool>;
|
||||
@@ -345,7 +345,7 @@ class ProtobufMessage {
|
||||
* @param[in] value value
|
||||
* @return true if successful
|
||||
*/
|
||||
bool Pack(wpi::SmallVectorImpl<uint8_t>& out, const T& value) {
|
||||
bool Pack(wpi::util::SmallVectorImpl<uint8_t>& out, const T& value) {
|
||||
ProtoOutputStream<std::remove_cvref_t<T>> stream{out};
|
||||
return Protobuf<std::remove_cvref_t<T>>::Pack(stream, value);
|
||||
}
|
||||
@@ -391,4 +391,4 @@ class ProtobufMessage {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/array.hpp"
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* The behavior to use when more elements are in the message then expected when
|
||||
@@ -268,7 +268,7 @@ class DirectUnpackCallback {
|
||||
space.size());
|
||||
} else if constexpr (ProtobufSerializable<T>) {
|
||||
ProtoInputStream<T> istream{stream};
|
||||
auto decoded = wpi::Protobuf<T>::Unpack(istream);
|
||||
auto decoded = wpi::util::Protobuf<T>::Unpack(istream);
|
||||
if (decoded.has_value()) {
|
||||
m_storage.emplace_back(std::move(decoded.value()));
|
||||
return true;
|
||||
@@ -332,13 +332,13 @@ class DirectUnpackCallback {
|
||||
*/
|
||||
template <ProtoCallbackUnpackable T, size_t N = 1>
|
||||
class UnpackCallback
|
||||
: public DirectUnpackCallback<T, wpi::SmallVector<T, N>, N> {
|
||||
: public DirectUnpackCallback<T, wpi::util::SmallVector<T, N>, N> {
|
||||
public:
|
||||
/**
|
||||
* Constructs an UnpackCallback.
|
||||
*/
|
||||
UnpackCallback()
|
||||
: DirectUnpackCallback<T, wpi::SmallVector<T, N>, N>{m_storedBuffer} {
|
||||
: DirectUnpackCallback<T, wpi::util::SmallVector<T, N>, N>{m_storedBuffer} {
|
||||
this->SetLimits(DecodeLimits::Ignore);
|
||||
}
|
||||
|
||||
@@ -361,10 +361,10 @@ class UnpackCallback
|
||||
*
|
||||
* @return small vector reference
|
||||
*/
|
||||
wpi::SmallVector<T, N>& Vec() noexcept { return m_storedBuffer; }
|
||||
wpi::util::SmallVector<T, N>& Vec() noexcept { return m_storedBuffer; }
|
||||
|
||||
private:
|
||||
wpi::SmallVector<T, N> m_storedBuffer;
|
||||
wpi::util::SmallVector<T, N> m_storedBuffer;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -414,12 +414,12 @@ class StdVectorUnpackCallback
|
||||
};
|
||||
|
||||
/**
|
||||
* A wrapper around a wpi::array that lets us
|
||||
* A wrapper around a wpi::util::array that lets us
|
||||
* treat it as a limited sized vector.
|
||||
*/
|
||||
template <ProtoCallbackUnpackable T, size_t N>
|
||||
struct WpiArrayEmplaceWrapper {
|
||||
wpi::array<T, N> m_array{wpi::empty_array_t{}};
|
||||
wpi::util::array<T, N> m_array{wpi::util::empty_array_t{}};
|
||||
size_t m_currentIndex = 0;
|
||||
|
||||
size_t size() const { return m_currentIndex; }
|
||||
@@ -433,7 +433,7 @@ struct WpiArrayEmplaceWrapper {
|
||||
};
|
||||
|
||||
/**
|
||||
* A DirectUnpackCallback backed by a wpi::array<T, N>.
|
||||
* A DirectUnpackCallback backed by a wpi::util::array<T, N>.
|
||||
*
|
||||
* Any elements in the packed buffer past N will
|
||||
* be cause decoding to fail.
|
||||
@@ -471,7 +471,7 @@ struct WpiArrayUnpackCallback
|
||||
*
|
||||
* @return array reference
|
||||
*/
|
||||
wpi::array<T, N>& Array() noexcept { return m_array.m_array; }
|
||||
wpi::util::array<T, N>& Array() noexcept { return m_array.m_array; }
|
||||
|
||||
private:
|
||||
WpiArrayEmplaceWrapper<T, N> m_array;
|
||||
@@ -581,7 +581,7 @@ class PackCallback {
|
||||
reinterpret_cast<const pb_byte_t*>(view.data()),
|
||||
view.size());
|
||||
} else if constexpr (ProtobufSerializable<T>) {
|
||||
return wpi::Protobuf<T>::Pack(stream, value);
|
||||
return wpi::util::Protobuf<T>::Pack(stream, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,4 +667,4 @@ class PackCallback {
|
||||
pb_callback_t m_callback;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
class raw_istream {
|
||||
public:
|
||||
@@ -171,6 +171,6 @@ class raw_fd_istream : public raw_istream {
|
||||
bool m_shouldClose;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_RAW_ISTREAM_HPP_
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <span>
|
||||
#include <type_traits>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* This is a simple rotated span view. Indexed/iterated access provides a
|
||||
@@ -251,4 +251,4 @@ as_writable_bytes(rotated_span<Type, Extent> sp) noexcept {
|
||||
return {std::as_writable_bytes(sp.data()), sp.offset() * sizeof(Type)};
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
@@ -25,4 +25,4 @@ class WPILIB_DLLEXPORT Sendable {
|
||||
virtual void InitSendable(SendableBuilder& builder) = 0;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Helper class for building Sendable dashboard representations.
|
||||
@@ -277,7 +277,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
@@ -289,7 +289,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const int>(wpi::SmallVectorImpl<int>& buf)>
|
||||
std::function<std::span<const int>(wpi::util::SmallVectorImpl<int>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const int>)> setter) = 0;
|
||||
|
||||
@@ -303,7 +303,7 @@ class SendableBuilder {
|
||||
virtual void AddSmallIntegerArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
std::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
std::span<const int64_t>(wpi::util::SmallVectorImpl<int64_t>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const int64_t>)> setter) = 0;
|
||||
|
||||
@@ -316,7 +316,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallFloatArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const float>(wpi::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 +329,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallDoubleArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
std::function<std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const double>)> setter) = 0;
|
||||
|
||||
@@ -343,7 +343,7 @@ class SendableBuilder {
|
||||
virtual void AddSmallStringArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
std::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
std::span<const std::string>(wpi::util::SmallVectorImpl<std::string>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const std::string>)> setter) = 0;
|
||||
|
||||
@@ -357,7 +357,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<std::span<uint8_t>(wpi::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;
|
||||
|
||||
@@ -386,4 +386,4 @@ class SendableBuilder {
|
||||
virtual void ClearProperties() = 0;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* A helper class for use with objects that add themselves to SendableRegistry.
|
||||
@@ -59,4 +59,4 @@ class SendableHelper {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
class Sendable;
|
||||
class SendableBuilder;
|
||||
@@ -237,4 +237,4 @@ class SendableRegistry final {
|
||||
static void Update(UID sendableUid);
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
class raw_istream;
|
||||
@@ -47,6 +47,6 @@ class SHA1 {
|
||||
uint64_t transforms;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_SHA1_HPP_
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "wpi/util/Compiler.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* A spinlock mutex. Wraps std::atomic_flag in a std::mutex compatible way.
|
||||
@@ -141,4 +141,4 @@ using recursive_spinlock = recursive_spinlock2;
|
||||
using recursive_spinlock = recursive_spinlock1;
|
||||
#endif
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* This is a simple circular buffer so we don't need to "bucket brigade" copy
|
||||
@@ -108,7 +108,7 @@ class static_circular_buffer {
|
||||
* Returns end iterator.
|
||||
*/
|
||||
constexpr iterator end() {
|
||||
return iterator(this, ::wpi::static_circular_buffer<T, N>::size());
|
||||
return iterator(this, ::wpi::util::static_circular_buffer<T, N>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ class static_circular_buffer {
|
||||
* Returns const end iterator.
|
||||
*/
|
||||
constexpr const_iterator end() const {
|
||||
return const_iterator(this, ::wpi::static_circular_buffer<T, N>::size());
|
||||
return const_iterator(this, ::wpi::util::static_circular_buffer<T, N>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ class static_circular_buffer {
|
||||
* Returns const end iterator.
|
||||
*/
|
||||
constexpr const_iterator cend() const {
|
||||
return const_iterator(this, ::wpi::static_circular_buffer<T, N>::size());
|
||||
return const_iterator(this, ::wpi::util::static_circular_buffer<T, N>::size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,4 +348,4 @@ class static_circular_buffer {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -20,7 +20,7 @@ struct WPI_String {
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace wpi {
|
||||
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) {
|
||||
@@ -34,7 +34,7 @@ constexpr std::string_view to_string_view(const struct WPI_String* str) {
|
||||
constexpr WPI_String make_string(std::string_view view) {
|
||||
return WPI_String{view.data(), view.size()};
|
||||
}
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -109,7 +109,7 @@ void WPI_FreeStringArray(const struct WPI_String* wpiStringArray,
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace wpi {
|
||||
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) {
|
||||
@@ -126,5 +126,5 @@ inline WPI_String copy_wpi_string(const WPI_String& str) {
|
||||
}
|
||||
return alloc_wpi_string(to_string_view(&str));
|
||||
}
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
#include "wpi/util/bit.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
@@ -316,9 +316,9 @@ class StructDescriptor {
|
||||
|
||||
private:
|
||||
bool CheckCircular(
|
||||
wpi::SmallVectorImpl<const StructDescriptor*>& stack) const;
|
||||
wpi::util::SmallVectorImpl<const StructDescriptor*>& stack) const;
|
||||
std::string CalculateOffsets(
|
||||
wpi::SmallVectorImpl<const StructDescriptor*>& stack);
|
||||
wpi::util::SmallVectorImpl<const StructDescriptor*>& stack);
|
||||
|
||||
std::string m_name;
|
||||
std::string m_schema;
|
||||
@@ -696,4 +696,4 @@ class DynamicStructObject : private impl::DSOData, public MutableDynamicStruct {
|
||||
DynamicStructObject& operator=(DynamicStructObject&&) = delete;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wpi::structparser {
|
||||
namespace wpi::util::structparser {
|
||||
|
||||
/**
|
||||
* A lexed raw struct schema token.
|
||||
@@ -196,4 +196,4 @@ class Parser {
|
||||
std::string m_error;
|
||||
};
|
||||
|
||||
} // namespace wpi::structparser
|
||||
} // namespace wpi::util::structparser
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/type_traits.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* Struct serialization template. Unspecialized class has no members; only
|
||||
@@ -47,7 +47,7 @@ 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::Struct with
|
||||
* 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
|
||||
@@ -96,7 +96,7 @@ 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::Struct<T> static member `void UnpackInto(T*, std::span<const uint8_t>)`
|
||||
* 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>
|
||||
@@ -111,7 +111,7 @@ concept MutableStructSerializable =
|
||||
* Specifies that a struct type has nested struct declarations.
|
||||
*
|
||||
* In addition to meeting StructSerializable, implementations must define a
|
||||
* wpi::Struct<T> static member
|
||||
* wpi::util::Struct<T> static member
|
||||
* `void ForEachNested(std::invocable<std::string_view, std::string_view) auto
|
||||
* fn)` (or equivalent) and call ForEachStructSchema<Type> on each nested struct
|
||||
* type.
|
||||
@@ -169,17 +169,17 @@ inline T UnpackStruct(std::span<const uint8_t> data, const I&... info) {
|
||||
* @return Deserialized array
|
||||
*/
|
||||
template <StructSerializable T, size_t Offset, size_t N>
|
||||
inline wpi::array<T, N> UnpackStructArray(std::span<const uint8_t> data) {
|
||||
inline wpi::util::array<T, N> UnpackStructArray(std::span<const uint8_t> data) {
|
||||
if (is_constexpr([] { Struct<std::remove_cvref_t<T>>::GetSize(); })) {
|
||||
constexpr auto StructSize = Struct<std::remove_cvref_t<T>>::GetSize();
|
||||
wpi::array<T, N> arr(wpi::empty_array);
|
||||
wpi::util::array<T, N> arr(wpi::util::empty_array);
|
||||
[&]<size_t... Is>(std::index_sequence<Is...>) {
|
||||
((arr[Is] = UnpackStruct<T, Offset + Is * StructSize>(data)), ...);
|
||||
}(std::make_index_sequence<N>{});
|
||||
return arr;
|
||||
} else {
|
||||
auto size = Struct<std::remove_cvref_t<T>>::GetSize();
|
||||
wpi::array<T, N> arr(wpi::empty_array);
|
||||
wpi::util::array<T, N> arr(wpi::util::empty_array);
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
arr[i] = UnpackStruct<T>(data);
|
||||
data = data.subspan(size);
|
||||
@@ -232,7 +232,7 @@ inline void PackStruct(std::span<uint8_t> data, T&& value, const I&... info) {
|
||||
*/
|
||||
template <size_t Offset, size_t N, StructSerializable T>
|
||||
inline void PackStructArray(std::span<uint8_t> data,
|
||||
const wpi::array<T, N>& arr) {
|
||||
const wpi::util::array<T, N>& arr) {
|
||||
if (is_constexpr([] { Struct<std::remove_cvref_t<T>>::GetSize(); })) {
|
||||
constexpr auto StructSize = Struct<std::remove_cvref_t<T>>::GetSize();
|
||||
[&]<size_t... Is>(std::index_sequence<Is...>) {
|
||||
@@ -480,7 +480,7 @@ class StructArrayBuffer {
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::mutex m_mutex;
|
||||
wpi::util::mutex m_mutex;
|
||||
std::vector<uint8_t> m_buf;
|
||||
};
|
||||
|
||||
@@ -711,4 +711,4 @@ struct Struct<double> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
|
||||
@@ -51,7 +51,7 @@ uint64_t WPI_GetSystemTime(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
|
||||
/**
|
||||
* The default implementation used for Now().
|
||||
@@ -83,7 +83,7 @@ uint64_t Now();
|
||||
*/
|
||||
uint64_t GetSystemTime();
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::util
|
||||
#endif
|
||||
|
||||
#endif // WPIUTIL_WPI_UTIL_TIMESTAMP_H_
|
||||
|
||||
Reference in New Issue
Block a user