diff --git a/cameraserver/src/main/native/cpp/CameraServer.cpp b/cameraserver/src/main/native/cpp/CameraServer.cpp index eebe8504fa..4fa779e80e 100644 --- a/cameraserver/src/main/native/cpp/CameraServer.cpp +++ b/cameraserver/src/main/native/cpp/CameraServer.cpp @@ -7,9 +7,9 @@ #include "CameraServer.h" -#include -#include #include +#include +#include #include "CameraServerShared.h" #include "ntcore_cpp.h" @@ -21,14 +21,14 @@ CameraServer* CameraServer::GetInstance() { return &instance; } -static llvm::StringRef MakeSourceValue(CS_Source source, - llvm::SmallVectorImpl& buf) { +static wpi::StringRef MakeSourceValue(CS_Source source, + wpi::SmallVectorImpl& buf) { CS_Status status = 0; buf.clear(); switch (cs::GetSourceKind(source, &status)) { #ifdef __linux__ case cs::VideoSource::kUsb: { - llvm::StringRef prefix{"usb:"}; + wpi::StringRef prefix{"usb:"}; buf.append(prefix.begin(), prefix.end()); auto path = cs::GetUsbCameraPath(source, &status); buf.append(path.begin(), path.end()); @@ -36,7 +36,7 @@ static llvm::StringRef MakeSourceValue(CS_Source source, } #endif case cs::VideoSource::kHttp: { - llvm::StringRef prefix{"ip:"}; + wpi::StringRef prefix{"ip:"}; buf.append(prefix.begin(), prefix.end()); auto urls = cs::GetHttpCameraUrls(source, &status); if (!urls.empty()) buf.append(urls[0].begin(), urls[0].end()); @@ -50,12 +50,12 @@ static llvm::StringRef MakeSourceValue(CS_Source source, return "unknown:"; } - return llvm::StringRef{buf.begin(), buf.size()}; + return wpi::StringRef{buf.begin(), buf.size()}; } -static std::string MakeStreamValue(llvm::StringRef address, int port) { +static std::string MakeStreamValue(wpi::StringRef address, int port) { std::string rv; - llvm::raw_string_ostream stream(rv); + wpi::raw_string_ostream stream(rv); stream << "mjpg:http://" << address << ':' << port << "/?action=stream"; stream.flush(); return rv; @@ -178,7 +178,7 @@ static std::string PixelFormatToString(int pixelFormat) { static std::string VideoModeToString(const cs::VideoMode& mode) { std::string rv; - llvm::raw_string_ostream oss{rv}; + wpi::raw_string_ostream oss{rv}; oss << mode.width << "x" << mode.height; oss << " " << PixelFormatToString(mode.pixelFormat) << " "; oss << mode.fps << " fps"; @@ -193,20 +193,20 @@ static std::vector GetSourceModeValues(int source) { return rv; } -static inline llvm::StringRef Concatenate(llvm::StringRef lhs, - llvm::StringRef rhs, - llvm::SmallVectorImpl& buf) { +static inline wpi::StringRef Concatenate(wpi::StringRef lhs, + wpi::StringRef rhs, + wpi::SmallVectorImpl& buf) { buf.clear(); - llvm::raw_svector_ostream oss{buf}; + wpi::raw_svector_ostream oss{buf}; oss << lhs << rhs; return oss.str(); } static void PutSourcePropertyValue(nt::NetworkTable* table, const cs::VideoEvent& event, bool isNew) { - llvm::SmallString<64> name; - llvm::SmallString<64> infoName; - if (llvm::StringRef{event.name}.startswith("raw_")) { + wpi::SmallString<64> name; + wpi::SmallString<64> infoName; + if (wpi::StringRef{event.name}.startswith("raw_")) { name = "RawProperty/"; name += event.name; infoName = "RawPropertyInfo/"; @@ -218,7 +218,7 @@ static void PutSourcePropertyValue(nt::NetworkTable* table, infoName += event.name; } - llvm::SmallString<64> buf; + wpi::SmallString<64> buf; CS_Status status = 0; nt::NetworkTableEntry entry = table->GetEntry(name); switch (event.propertyKind) { @@ -282,10 +282,10 @@ CameraServer::CameraServer() std::lock_guard lock(m_mutex); m_tables.insert(std::make_pair(event.sourceHandle, table)); } - llvm::SmallString<64> buf; + wpi::SmallString<64> buf; table->GetEntry("source").SetString( MakeSourceValue(event.sourceHandle, buf)); - llvm::SmallString<64> descBuf; + wpi::SmallString<64> descBuf; table->GetEntry("description") .SetString(cs::GetSourceDescription(event.sourceHandle, descBuf, &status)); @@ -314,7 +314,7 @@ CameraServer::CameraServer() auto table = GetSourceTable(event.sourceHandle); if (table) { // update the description too (as it may have changed) - llvm::SmallString<64> descBuf; + wpi::SmallString<64> descBuf; table->GetEntry("description") .SetString(cs::GetSourceDescription(event.sourceHandle, descBuf, &status)); @@ -353,7 +353,7 @@ CameraServer::CameraServer() case cs::VideoEvent::kSourcePropertyChoicesUpdated: { auto table = GetSourceTable(event.sourceHandle); if (table) { - llvm::SmallString<64> name{"PropertyInfo/"}; + wpi::SmallString<64> name{"PropertyInfo/"}; name += event.name; name += "/choices"; auto choices = @@ -380,17 +380,17 @@ CameraServer::CameraServer() // We don't currently support changing settings via NT due to // synchronization issues, so just update to current setting if someone // else tries to change it. - llvm::SmallString<64> buf; + wpi::SmallString<64> buf; m_tableListener = nt::NetworkTableInstance::GetDefault().AddEntryListener( Concatenate(kPublishName, "/", buf), [=](const nt::EntryNotification& event) { - llvm::StringRef relativeKey = - event.name.substr(llvm::StringRef(kPublishName).size() + 1); + wpi::StringRef relativeKey = + event.name.substr(wpi::StringRef(kPublishName).size() + 1); // get source (sourceName/...) auto subKeyIndex = relativeKey.find('/'); - if (subKeyIndex == llvm::StringRef::npos) return; - llvm::StringRef sourceName = relativeKey.slice(0, subKeyIndex); + if (subKeyIndex == wpi::StringRef::npos) return; + wpi::StringRef sourceName = relativeKey.slice(0, subKeyIndex); auto sourceIt = m_sources.find(sourceName); if (sourceIt == m_sources.end()) return; @@ -398,7 +398,7 @@ CameraServer::CameraServer() relativeKey = relativeKey.substr(subKeyIndex + 1); // handle standard names - llvm::StringRef propName; + wpi::StringRef propName; nt::NetworkTableEntry entry{event.entry}; if (relativeKey == "mode") { // reset to current mode @@ -442,8 +442,8 @@ cs::UsbCamera CameraServer::StartAutomaticCapture() { } cs::UsbCamera CameraServer::StartAutomaticCapture(int dev) { - llvm::SmallString<64> buf; - llvm::raw_svector_ostream name{buf}; + wpi::SmallString<64> buf; + wpi::raw_svector_ostream name{buf}; name << "USB Camera " << dev; cs::UsbCamera camera{name.str(), dev}; @@ -453,7 +453,7 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(int dev) { return camera; } -cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name, +cs::UsbCamera CameraServer::StartAutomaticCapture(wpi::StringRef name, int dev) { cs::UsbCamera camera{name, dev}; StartAutomaticCapture(camera); @@ -462,8 +462,8 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name, return camera; } -cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name, - llvm::StringRef path) { +cs::UsbCamera CameraServer::StartAutomaticCapture(wpi::StringRef name, + wpi::StringRef path) { cs::UsbCamera camera{name, path}; StartAutomaticCapture(camera); auto csShared = GetCameraServerShared(); @@ -472,7 +472,7 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name, } #endif -cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef host) { +cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef host) { return AddAxisCamera("Axis Camera", host); } @@ -484,12 +484,12 @@ cs::AxisCamera CameraServer::AddAxisCamera(const std::string& host) { return AddAxisCamera("Axis Camera", host); } -cs::AxisCamera CameraServer::AddAxisCamera(llvm::ArrayRef hosts) { +cs::AxisCamera CameraServer::AddAxisCamera(wpi::ArrayRef hosts) { return AddAxisCamera("Axis Camera", hosts); } -cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, - llvm::StringRef host) { +cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name, + wpi::StringRef host) { cs::AxisCamera camera{name, host}; StartAutomaticCapture(camera); auto csShared = GetCameraServerShared(); @@ -497,7 +497,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, return camera; } -cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, +cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name, const char* host) { cs::AxisCamera camera{name, host}; StartAutomaticCapture(camera); @@ -506,7 +506,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, return camera; } -cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, +cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name, const std::string& host) { cs::AxisCamera camera{name, host}; StartAutomaticCapture(camera); @@ -515,8 +515,8 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, return camera; } -cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, - llvm::ArrayRef hosts) { +cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name, + wpi::ArrayRef hosts) { cs::AxisCamera camera{name, hosts}; StartAutomaticCapture(camera); auto csShared = GetCameraServerShared(); @@ -525,7 +525,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name, } void CameraServer::StartAutomaticCapture(const cs::VideoSource& camera) { - llvm::SmallString<64> name{"serve_"}; + wpi::SmallString<64> name{"serve_"}; name += camera.GetName(); AddCamera(camera); @@ -553,7 +553,7 @@ cs::CvSink CameraServer::GetVideo() { } cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) { - llvm::SmallString<64> name{"opencv_"}; + wpi::SmallString<64> name{"opencv_"}; name += camera.GetName(); { @@ -562,8 +562,8 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) { if (it != m_sinks.end()) { auto kind = it->second.GetKind(); if (kind != cs::VideoSink::kCv) { - llvm::SmallString<64> buf; - llvm::raw_svector_ostream err{buf}; + wpi::SmallString<64> buf; + wpi::raw_svector_ostream err{buf}; err << "expected OpenCV sink, but got " << kind; auto csShared = GetCameraServerShared(); csShared->SetCameraServerError(err.str()); @@ -579,14 +579,14 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) { return newsink; } -cs::CvSink CameraServer::GetVideo(llvm::StringRef name) { +cs::CvSink CameraServer::GetVideo(wpi::StringRef name) { cs::VideoSource source; { std::lock_guard lock(m_mutex); auto it = m_sources.find(name); if (it == m_sources.end()) { - llvm::SmallString<64> buf; - llvm::raw_svector_ostream err{buf}; + wpi::SmallString<64> buf; + wpi::raw_svector_ostream err{buf}; err << "could not find camera " << name; auto csShared = GetCameraServerShared(); csShared->SetCameraServerError(err.str()); @@ -597,14 +597,14 @@ cs::CvSink CameraServer::GetVideo(llvm::StringRef name) { return GetVideo(source); } -cs::CvSource CameraServer::PutVideo(llvm::StringRef name, int width, +cs::CvSource CameraServer::PutVideo(wpi::StringRef name, int width, int height) { cs::CvSource source{name, cs::VideoMode::kMJPEG, width, height, 30}; StartAutomaticCapture(source); return source; } -cs::MjpegServer CameraServer::AddServer(llvm::StringRef name) { +cs::MjpegServer CameraServer::AddServer(wpi::StringRef name) { int port; { std::lock_guard lock(m_mutex); @@ -613,7 +613,7 @@ cs::MjpegServer CameraServer::AddServer(llvm::StringRef name) { return AddServer(name, port); } -cs::MjpegServer CameraServer::AddServer(llvm::StringRef name, int port) { +cs::MjpegServer CameraServer::AddServer(wpi::StringRef name, int port) { cs::MjpegServer server{name, port}; AddServer(server); return server; @@ -624,13 +624,13 @@ void CameraServer::AddServer(const cs::VideoSink& server) { m_sinks.emplace_second(server.GetName(), server); } -void CameraServer::RemoveServer(llvm::StringRef name) { +void CameraServer::RemoveServer(wpi::StringRef name) { std::lock_guard lock(m_mutex); m_sinks.erase(name); } cs::VideoSink CameraServer::GetServer() { - llvm::SmallString<64> name; + wpi::SmallString<64> name; { std::lock_guard lock(m_mutex); if (m_primarySourceName.empty()) { @@ -644,12 +644,12 @@ cs::VideoSink CameraServer::GetServer() { return GetServer(name); } -cs::VideoSink CameraServer::GetServer(llvm::StringRef name) { +cs::VideoSink CameraServer::GetServer(wpi::StringRef name) { std::lock_guard lock(m_mutex); auto it = m_sinks.find(name); if (it == m_sinks.end()) { - llvm::SmallString<64> buf; - llvm::raw_svector_ostream err{buf}; + wpi::SmallString<64> buf; + wpi::raw_svector_ostream err{buf}; err << "could not find server " << name; auto csShared = GetCameraServerShared(); csShared->SetCameraServerError(err.str()); @@ -665,7 +665,7 @@ void CameraServer::AddCamera(const cs::VideoSource& camera) { m_sources.emplace_second(name, camera); } -void CameraServer::RemoveCamera(llvm::StringRef name) { +void CameraServer::RemoveCamera(wpi::StringRef name) { std::lock_guard lock(m_mutex); m_sources.erase(name); } diff --git a/cameraserver/src/main/native/cpp/CameraServerShared.cpp b/cameraserver/src/main/native/cpp/CameraServerShared.cpp index 7a9b8d8674..d00a5b5cc7 100644 --- a/cameraserver/src/main/native/cpp/CameraServerShared.cpp +++ b/cameraserver/src/main/native/cpp/CameraServerShared.cpp @@ -7,7 +7,7 @@ #include "CameraServerShared.h" -#include +#include namespace { class DefaultCameraServerShared : public frc::CameraServerShared { @@ -15,9 +15,9 @@ class DefaultCameraServerShared : public frc::CameraServerShared { void ReportUsbCamera(int id) override {} void ReportAxisCamera(int id) override {} void ReportVideoServer(int id) override {} - void SetCameraServerError(llvm::StringRef error) override {} - void SetVisionRunnerError(llvm::StringRef error) override {} - void ReportDriverStationError(llvm::StringRef error) override {} + void SetCameraServerError(wpi::StringRef error) override {} + void SetVisionRunnerError(wpi::StringRef error) override {} + void ReportDriverStationError(wpi::StringRef error) override {} std::pair GetRobotMainThreadId() const override { return std::make_pair(std::thread::id(), false); } diff --git a/cameraserver/src/main/native/include/CameraServer.h b/cameraserver/src/main/native/include/CameraServer.h index ca401d67eb..32a2b04319 100644 --- a/cameraserver/src/main/native/include/CameraServer.h +++ b/cameraserver/src/main/native/include/CameraServer.h @@ -14,11 +14,11 @@ #include #include -#include -#include -#include #include -#include +#include +#include +#include +#include #include "cscore.h" @@ -72,7 +72,7 @@ class CameraServer { * @param name The name to give the camera * @param dev The device number of the camera interface */ - cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, int dev); + cs::UsbCamera StartAutomaticCapture(wpi::StringRef name, int dev); /** * Start automatically capturing images to send to the dashboard. @@ -80,8 +80,8 @@ class CameraServer { * @param name The name to give the camera * @param path The device path (e.g. "/dev/video0") of the camera */ - cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, - llvm::StringRef path); + cs::UsbCamera StartAutomaticCapture(wpi::StringRef name, + wpi::StringRef path); #endif /** @@ -99,7 +99,7 @@ class CameraServer { * * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ - cs::AxisCamera AddAxisCamera(llvm::StringRef host); + cs::AxisCamera AddAxisCamera(wpi::StringRef host); /** * Adds an Axis IP camera. @@ -126,7 +126,7 @@ class CameraServer { * * @param hosts Array of Camera host IPs/DNS names */ - cs::AxisCamera AddAxisCamera(llvm::ArrayRef hosts); + cs::AxisCamera AddAxisCamera(wpi::ArrayRef hosts); /** * Adds an Axis IP camera. @@ -144,7 +144,7 @@ class CameraServer { * @param name The name to give the camera * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ - cs::AxisCamera AddAxisCamera(llvm::StringRef name, llvm::StringRef host); + cs::AxisCamera AddAxisCamera(wpi::StringRef name, wpi::StringRef host); /** * Adds an Axis IP camera. @@ -152,7 +152,7 @@ class CameraServer { * @param name The name to give the camera * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ - cs::AxisCamera AddAxisCamera(llvm::StringRef name, const char* host); + cs::AxisCamera AddAxisCamera(wpi::StringRef name, const char* host); /** * Adds an Axis IP camera. @@ -160,7 +160,7 @@ class CameraServer { * @param name The name to give the camera * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ - cs::AxisCamera AddAxisCamera(llvm::StringRef name, const std::string& host); + cs::AxisCamera AddAxisCamera(wpi::StringRef name, const std::string& host); /** * Adds an Axis IP camera. @@ -168,8 +168,8 @@ class CameraServer { * @param name The name to give the camera * @param hosts Array of Camera host IPs/DNS names */ - cs::AxisCamera AddAxisCamera(llvm::StringRef name, - llvm::ArrayRef hosts); + cs::AxisCamera AddAxisCamera(wpi::StringRef name, + wpi::ArrayRef hosts); /** * Adds an Axis IP camera. @@ -178,7 +178,7 @@ class CameraServer { * @param hosts Array of Camera host IPs/DNS names */ template - cs::AxisCamera AddAxisCamera(llvm::StringRef name, + cs::AxisCamera AddAxisCamera(wpi::StringRef name, std::initializer_list hosts); /** @@ -204,7 +204,7 @@ class CameraServer { * * @param name Camera name */ - cs::CvSink GetVideo(llvm::StringRef name); + cs::CvSink GetVideo(wpi::StringRef name); /** * Create a MJPEG stream with OpenCV input. This can be called to pass custom @@ -214,21 +214,21 @@ class CameraServer { * @param width Width of the image being sent * @param height Height of the image being sent */ - cs::CvSource PutVideo(llvm::StringRef name, int width, int height); + cs::CvSource PutVideo(wpi::StringRef name, int width, int height); /** * Adds a MJPEG server at the next available port. * * @param name Server name */ - cs::MjpegServer AddServer(llvm::StringRef name); + cs::MjpegServer AddServer(wpi::StringRef name); /** * Adds a MJPEG server. * * @param name Server name */ - cs::MjpegServer AddServer(llvm::StringRef name, int port); + cs::MjpegServer AddServer(wpi::StringRef name, int port); /** * Adds an already created server. @@ -242,7 +242,7 @@ class CameraServer { * * @param name Server name */ - void RemoveServer(llvm::StringRef name); + void RemoveServer(wpi::StringRef name); /** * Get server for the primary camera feed. @@ -257,7 +257,7 @@ class CameraServer { * * @param name Server name */ - cs::VideoSink GetServer(llvm::StringRef name); + cs::VideoSink GetServer(wpi::StringRef name); /** * Adds an already created camera. @@ -271,7 +271,7 @@ class CameraServer { * * @param name Camera name */ - void RemoveCamera(llvm::StringRef name); + void RemoveCamera(wpi::StringRef name); /** * Sets the size of the image to use. Use the public kSize constants to set @@ -297,9 +297,9 @@ class CameraServer { wpi::mutex m_mutex; std::atomic m_defaultUsbDevice; std::string m_primarySourceName; - llvm::StringMap m_sources; - llvm::StringMap m_sinks; - llvm::DenseMap> m_tables; + wpi::StringMap m_sources; + wpi::StringMap m_sinks; + wpi::DenseMap> m_tables; std::shared_ptr m_publishTable; cs::VideoListener m_videoListener; int m_tableListener; diff --git a/cameraserver/src/main/native/include/CameraServer.inc b/cameraserver/src/main/native/include/CameraServer.inc index 9922fc4585..bf3272e841 100644 --- a/cameraserver/src/main/native/include/CameraServer.inc +++ b/cameraserver/src/main/native/include/CameraServer.inc @@ -20,7 +20,7 @@ inline cs::AxisCamera CameraServer::AddAxisCamera( template inline cs::AxisCamera CameraServer::AddAxisCamera( - llvm::StringRef name, std::initializer_list hosts) { + wpi::StringRef name, std::initializer_list hosts) { std::vector vec; vec.reserve(hosts.size()); for (const auto& host : hosts) vec.emplace_back(host); diff --git a/cameraserver/src/main/native/include/CameraServerShared.h b/cameraserver/src/main/native/include/CameraServerShared.h index f0553d7087..ff0ceac771 100644 --- a/cameraserver/src/main/native/include/CameraServerShared.h +++ b/cameraserver/src/main/native/include/CameraServerShared.h @@ -11,7 +11,7 @@ #include #include -#include +#include namespace frc { class CameraServerShared { @@ -19,9 +19,9 @@ class CameraServerShared { virtual void ReportUsbCamera(int id) = 0; virtual void ReportAxisCamera(int id) = 0; virtual void ReportVideoServer(int id) = 0; - virtual void SetCameraServerError(llvm::StringRef error) = 0; - virtual void SetVisionRunnerError(llvm::StringRef error) = 0; - virtual void ReportDriverStationError(llvm::StringRef error) = 0; + virtual void SetCameraServerError(wpi::StringRef error) = 0; + virtual void SetVisionRunnerError(wpi::StringRef error) = 0; + virtual void ReportDriverStationError(wpi::StringRef error) = 0; virtual std::pair GetRobotMainThreadId() const = 0; }; diff --git a/cscore/src/main/java/edu/wpi/cscore/CvSink.java b/cscore/src/main/java/edu/wpi/cscore/CvSink.java index 807313afd6..0e157890a5 100644 --- a/cscore/src/main/java/edu/wpi/cscore/CvSink.java +++ b/cscore/src/main/java/edu/wpi/cscore/CvSink.java @@ -31,7 +31,7 @@ public class CvSink extends VideoSink { /// time=0 if an error occurred. processFrame should call GetImage() /// or GetError() as needed, but should not call (except in very /// unusual circumstances) WaitForImage(). - //public CvSink(llvm::StringRef name, + //public CvSink(wpi::StringRef name, // std::function processFrame) { // super(CameraServerJNI.createCvSinkCallback(name, processFrame)); //} diff --git a/cscore/src/main/native/cpp/CvSinkImpl.cpp b/cscore/src/main/native/cpp/CvSinkImpl.cpp index e31b097866..2e95c00553 100644 --- a/cscore/src/main/native/cpp/CvSinkImpl.cpp +++ b/cscore/src/main/native/cpp/CvSinkImpl.cpp @@ -7,10 +7,10 @@ #include "CvSinkImpl.h" -#include #include #include #include +#include #include "Handle.h" #include "Log.h" @@ -20,12 +20,12 @@ using namespace cs; -CvSinkImpl::CvSinkImpl(llvm::StringRef name) : SinkImpl{name} { +CvSinkImpl::CvSinkImpl(wpi::StringRef name) : SinkImpl{name} { m_active = true; // m_thread = std::thread(&CvSinkImpl::ThreadMain, this); } -CvSinkImpl::CvSinkImpl(llvm::StringRef name, +CvSinkImpl::CvSinkImpl(wpi::StringRef name, std::function processFrame) : SinkImpl{name} {} @@ -118,14 +118,14 @@ void CvSinkImpl::ThreadMain() { namespace cs { -CS_Sink CreateCvSink(llvm::StringRef name, CS_Status* status) { +CS_Sink CreateCvSink(wpi::StringRef name, CS_Status* status) { auto sink = std::make_shared(name); auto handle = Sinks::GetInstance().Allocate(CS_SINK_CV, sink); Notifier::GetInstance().NotifySink(name, handle, CS_SINK_CREATED); return handle; } -CS_Sink CreateCvSinkCallback(llvm::StringRef name, +CS_Sink CreateCvSinkCallback(wpi::StringRef name, std::function processFrame, CS_Status* status) { auto sink = std::make_shared(name, processFrame); @@ -134,7 +134,7 @@ CS_Sink CreateCvSinkCallback(llvm::StringRef name, return handle; } -void SetSinkDescription(CS_Sink sink, llvm::StringRef description, +void SetSinkDescription(CS_Sink sink, wpi::StringRef description, CS_Status* status) { auto data = Sinks::GetInstance().Get(sink); if (!data || data->kind != CS_SINK_CV) { @@ -172,12 +172,12 @@ std::string GetSinkError(CS_Sink sink, CS_Status* status) { return static_cast(*data->sink).GetError(); } -llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl& buf, +wpi::StringRef GetSinkError(CS_Sink sink, wpi::SmallVectorImpl& buf, CS_Status* status) { auto data = Sinks::GetInstance().Get(sink); if (!data || data->kind != CS_SINK_CV) { *status = CS_INVALID_HANDLE; - return llvm::StringRef{}; + return wpi::StringRef{}; } return static_cast(*data->sink).GetError(buf); } @@ -233,7 +233,7 @@ uint64_t CS_GrabSinkFrameTimeoutCpp(CS_Sink sink, cv::Mat* image, } char* CS_GetSinkError(CS_Sink sink, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkError(sink, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); diff --git a/cscore/src/main/native/cpp/CvSinkImpl.h b/cscore/src/main/native/cpp/CvSinkImpl.h index 11f896975d..7ef764baea 100644 --- a/cscore/src/main/native/cpp/CvSinkImpl.h +++ b/cscore/src/main/native/cpp/CvSinkImpl.h @@ -13,13 +13,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "SinkImpl.h" @@ -29,8 +29,8 @@ class SourceImpl; class CvSinkImpl : public SinkImpl { public: - explicit CvSinkImpl(llvm::StringRef name); - CvSinkImpl(llvm::StringRef name, + explicit CvSinkImpl(wpi::StringRef name); + CvSinkImpl(wpi::StringRef name, std::function processFrame); ~CvSinkImpl() override; diff --git a/cscore/src/main/native/cpp/CvSourceImpl.cpp b/cscore/src/main/native/cpp/CvSourceImpl.cpp index 0de9046cb7..622ecb45f8 100644 --- a/cscore/src/main/native/cpp/CvSourceImpl.cpp +++ b/cscore/src/main/native/cpp/CvSourceImpl.cpp @@ -7,11 +7,11 @@ #include "CvSourceImpl.h" -#include #include #include #include -#include +#include +#include #include "Handle.h" #include "Log.h" @@ -21,7 +21,7 @@ using namespace cs; -CvSourceImpl::CvSourceImpl(llvm::StringRef name, const VideoMode& mode) +CvSourceImpl::CvSourceImpl(wpi::StringRef name, const VideoMode& mode) : SourceImpl{name} { m_mode = mode; m_videoModes.push_back(m_mode); @@ -32,8 +32,8 @@ CvSourceImpl::~CvSourceImpl() {} void CvSourceImpl::Start() {} std::unique_ptr CvSourceImpl::CreateEmptyProperty( - llvm::StringRef name) const { - return llvm::make_unique(name); + wpi::StringRef name) const { + return wpi::make_unique(name); } bool CvSourceImpl::CacheProperties(CS_Status* status) const { @@ -59,10 +59,10 @@ void CvSourceImpl::SetProperty(int property, int value, CS_Status* status) { return; } - UpdatePropertyValue(property, false, value, llvm::StringRef{}); + UpdatePropertyValue(property, false, value, wpi::StringRef{}); } -void CvSourceImpl::SetStringProperty(int property, llvm::StringRef value, +void CvSourceImpl::SetStringProperty(int property, wpi::StringRef value, CS_Status* status) { std::lock_guard lock(m_mutex); auto prop = static_cast(GetProperty(property)); @@ -168,11 +168,11 @@ void CvSourceImpl::PutFrame(cv::Mat& image) { SourceImpl::PutFrame(std::move(dest), wpi::Now()); } -void CvSourceImpl::NotifyError(llvm::StringRef msg) { +void CvSourceImpl::NotifyError(wpi::StringRef msg) { PutError(msg, wpi::Now()); } -int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind, +int CvSourceImpl::CreateProperty(wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value) { std::lock_guard lock(m_mutex); @@ -180,7 +180,7 @@ int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind, if (ndx == 0) { // create a new index ndx = m_propertyData.size() + 1; - m_propertyData.emplace_back(llvm::make_unique( + m_propertyData.emplace_back(wpi::make_unique( name, kind, minimum, maximum, step, defaultValue, value)); } else { // update all but value @@ -194,12 +194,12 @@ int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind, } Notifier::GetInstance().NotifySourceProperty( *this, CS_SOURCE_PROPERTY_CREATED, name, ndx, kind, value, - llvm::StringRef{}); + wpi::StringRef{}); return ndx; } int CvSourceImpl::CreateProperty( - llvm::StringRef name, CS_PropertyKind kind, int minimum, int maximum, + wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, std::function onChange) { // TODO @@ -207,7 +207,7 @@ int CvSourceImpl::CreateProperty( } void CvSourceImpl::SetEnumPropertyChoices(int property, - llvm::ArrayRef choices, + wpi::ArrayRef choices, CS_Status* status) { std::lock_guard lock(m_mutex); auto prop = GetProperty(property); @@ -222,12 +222,12 @@ void CvSourceImpl::SetEnumPropertyChoices(int property, prop->enumChoices = choices; Notifier::GetInstance().NotifySourceProperty( *this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, prop->name, property, - CS_PROP_ENUM, prop->value, llvm::StringRef{}); + CS_PROP_ENUM, prop->value, wpi::StringRef{}); } namespace cs { -CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode, +CS_Source CreateCvSource(wpi::StringRef name, const VideoMode& mode, CS_Status* status) { auto source = std::make_shared(name, mode); auto handle = Sources::GetInstance().Allocate(CS_SOURCE_CV, source); @@ -250,7 +250,7 @@ void PutSourceFrame(CS_Source source, cv::Mat& image, CS_Status* status) { static_cast(*data->source).PutFrame(image); } -void NotifySourceError(CS_Source source, llvm::StringRef msg, +void NotifySourceError(CS_Source source, wpi::StringRef msg, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data || data->kind != CS_SOURCE_CV) { @@ -269,7 +269,7 @@ void SetSourceConnected(CS_Source source, bool connected, CS_Status* status) { static_cast(*data->source).SetConnected(connected); } -void SetSourceDescription(CS_Source source, llvm::StringRef description, +void SetSourceDescription(CS_Source source, wpi::StringRef description, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data || data->kind != CS_SOURCE_CV) { @@ -279,7 +279,7 @@ void SetSourceDescription(CS_Source source, llvm::StringRef description, static_cast(*data->source).SetDescription(description); } -CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name, +CS_Property CreateSourceProperty(CS_Source source, wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, CS_Status* status) { @@ -295,7 +295,7 @@ CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name, } CS_Property CreateSourcePropertyCallback( - CS_Source source, llvm::StringRef name, CS_PropertyKind kind, int minimum, + CS_Source source, wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, std::function onChange, CS_Status* status) { auto data = Sources::GetInstance().Get(source); @@ -310,7 +310,7 @@ CS_Property CreateSourcePropertyCallback( } void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property, - llvm::ArrayRef choices, + wpi::ArrayRef choices, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data || data->kind != CS_SOURCE_CV) { @@ -390,7 +390,7 @@ CS_Property CS_CreateSourcePropertyCallback( void CS_SetSourceEnumPropertyChoices(CS_Source source, CS_Property property, const char** choices, int count, CS_Status* status) { - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(count); for (int i = 0; i < count; ++i) vec.push_back(choices[i]); return cs::SetSourceEnumPropertyChoices(source, property, vec, status); diff --git a/cscore/src/main/native/cpp/CvSourceImpl.h b/cscore/src/main/native/cpp/CvSourceImpl.h index 95752e917f..91d0c6925c 100644 --- a/cscore/src/main/native/cpp/CvSourceImpl.h +++ b/cscore/src/main/native/cpp/CvSourceImpl.h @@ -20,14 +20,14 @@ namespace cs { class CvSourceImpl : public SourceImpl { public: - CvSourceImpl(llvm::StringRef name, const VideoMode& mode); + CvSourceImpl(wpi::StringRef name, const VideoMode& mode); ~CvSourceImpl() override; void Start(); // Property functions void SetProperty(int property, int value, CS_Status* status) override; - void SetStringProperty(int property, llvm::StringRef value, + void SetStringProperty(int property, wpi::StringRef value, CS_Status* status) override; // Standard common camera properties @@ -47,21 +47,21 @@ class CvSourceImpl : public SourceImpl { // OpenCV-specific functions void PutFrame(cv::Mat& image); - void NotifyError(llvm::StringRef msg); - int CreateProperty(llvm::StringRef name, CS_PropertyKind kind, int minimum, + void NotifyError(wpi::StringRef msg); + int CreateProperty(wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value); - int CreateProperty(llvm::StringRef name, CS_PropertyKind kind, int minimum, + int CreateProperty(wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, std::function onChange); - void SetEnumPropertyChoices(int property, llvm::ArrayRef choices, + void SetEnumPropertyChoices(int property, wpi::ArrayRef choices, CS_Status* status); // Property data class PropertyData : public PropertyImpl { public: PropertyData() = default; - explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {} - PropertyData(llvm::StringRef name_, CS_PropertyKind kind_, int minimum_, + explicit PropertyData(wpi::StringRef name_) : PropertyImpl{name_} {} + PropertyData(wpi::StringRef name_, CS_PropertyKind kind_, int minimum_, int maximum_, int step_, int defaultValue_, int value_) : PropertyImpl{name_, kind_, step_, defaultValue_, value_} { hasMinimum = true; @@ -76,7 +76,7 @@ class CvSourceImpl : public SourceImpl { protected: std::unique_ptr CreateEmptyProperty( - llvm::StringRef name) const override; + wpi::StringRef name) const override; bool CacheProperties(CS_Status* status) const override; diff --git a/cscore/src/main/native/cpp/Frame.cpp b/cscore/src/main/native/cpp/Frame.cpp index 700e4e1072..98b458a8e1 100644 --- a/cscore/src/main/native/cpp/Frame.cpp +++ b/cscore/src/main/native/cpp/Frame.cpp @@ -16,7 +16,7 @@ using namespace cs; -Frame::Frame(SourceImpl& source, llvm::StringRef error, Time time) +Frame::Frame(SourceImpl& source, wpi::StringRef error, Time time) : m_impl{source.AllocFrameImpl().release()} { m_impl->refcount = 1; m_impl->error = error; diff --git a/cscore/src/main/native/cpp/Frame.h b/cscore/src/main/native/cpp/Frame.h index 6b0bd6225f..9d447b8ac8 100644 --- a/cscore/src/main/native/cpp/Frame.h +++ b/cscore/src/main/native/cpp/Frame.h @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include #include "Image.h" #include "cscore_cpp.h" @@ -39,14 +39,14 @@ class Frame { Time time{0}; SourceImpl& source; std::string error; - llvm::SmallVector images; + wpi::SmallVector images; std::vector compressionParams; }; public: Frame() noexcept : m_impl{nullptr} {} - Frame(SourceImpl& source, llvm::StringRef error, Time time); + Frame(SourceImpl& source, wpi::StringRef error, Time time); Frame(SourceImpl& source, std::unique_ptr image, Time time); @@ -72,8 +72,8 @@ class Frame { Time GetTime() const { return m_impl ? m_impl->time : 0; } - llvm::StringRef GetError() const { - if (!m_impl) return llvm::StringRef{}; + wpi::StringRef GetError() const { + if (!m_impl) return wpi::StringRef{}; return m_impl->error; } diff --git a/cscore/src/main/native/cpp/Handle.h b/cscore/src/main/native/cpp/Handle.h index 8d868166f4..45aa0e9afe 100644 --- a/cscore/src/main/native/cpp/Handle.h +++ b/cscore/src/main/native/cpp/Handle.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "UnlimitedHandleResource.h" #include "cscore_c.h" diff --git a/cscore/src/main/native/cpp/HttpCameraImpl.cpp b/cscore/src/main/native/cpp/HttpCameraImpl.cpp index 52f2719024..4ffc7f15dd 100644 --- a/cscore/src/main/native/cpp/HttpCameraImpl.cpp +++ b/cscore/src/main/native/cpp/HttpCameraImpl.cpp @@ -7,9 +7,9 @@ #include "HttpCameraImpl.h" -#include -#include -#include +#include +#include +#include #include "Handle.h" #include "JpegUtil.h" @@ -20,7 +20,7 @@ using namespace cs; -HttpCameraImpl::HttpCameraImpl(llvm::StringRef name, CS_HttpCameraKind kind) +HttpCameraImpl::HttpCameraImpl(wpi::StringRef name, CS_HttpCameraKind kind) : SourceImpl{name}, m_kind{kind} {} HttpCameraImpl::~HttpCameraImpl() { @@ -79,7 +79,7 @@ void HttpCameraImpl::StreamThreadMain() { } // connect - llvm::SmallString<64> boundary; + wpi::SmallString<64> boundary; wpi::HttpConnection* conn = DeviceStreamConnect(boundary); if (!m_active) break; @@ -99,7 +99,7 @@ void HttpCameraImpl::StreamThreadMain() { } wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect( - llvm::SmallVectorImpl& boundary) { + wpi::SmallVectorImpl& boundary) { // Build the request wpi::HttpRequest req; { @@ -120,7 +120,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect( if (!m_active || !stream) return nullptr; - auto connPtr = llvm::make_unique(std::move(stream), 1); + auto connPtr = wpi::make_unique(std::move(stream), 1); wpi::HttpConnection* conn = connPtr.get(); // update m_streamConn @@ -138,7 +138,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect( } // Parse Content-Type header to get the boundary - llvm::StringRef mediaType, contentType; + wpi::StringRef mediaType, contentType; std::tie(mediaType, contentType) = conn->contentType.str().split(';'); mediaType = mediaType.trim(); if (mediaType != "multipart/x-mixed-replace") { @@ -152,10 +152,10 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect( // media parameters boundary.clear(); while (!contentType.empty()) { - llvm::StringRef keyvalue; + wpi::StringRef keyvalue; std::tie(keyvalue, contentType) = contentType.split(';'); contentType = contentType.ltrim(); - llvm::StringRef key, value; + wpi::StringRef key, value; std::tie(key, value) = keyvalue.split('='); if (key.trim() == "boundary") { value = value.trim().trim('"'); // value may be quoted @@ -175,7 +175,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect( } void HttpCameraImpl::DeviceStream(wpi::raw_istream& is, - llvm::StringRef boundary) { + wpi::StringRef boundary) { // Stored here so we reuse it from frame to frame std::string imageBuf; @@ -205,8 +205,8 @@ void HttpCameraImpl::DeviceStream(wpi::raw_istream& is, bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is, std::string& imageBuf) { // Read the headers - llvm::SmallString<64> contentTypeBuf; - llvm::SmallString<64> contentLengthBuf; + wpi::SmallString<64> contentTypeBuf; + wpi::SmallString<64> contentLengthBuf; if (!ParseHttpHeaders(is, &contentTypeBuf, &contentLengthBuf)) { SWARNING("disconnected during headers"); PutError("disconnected during headers", wpi::Now()); @@ -216,8 +216,8 @@ bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is, // Check the content type (if present) if (!contentTypeBuf.str().empty() && !contentTypeBuf.str().startswith("image/jpeg")) { - llvm::SmallString<64> errBuf; - llvm::raw_svector_ostream errMsg{errBuf}; + wpi::SmallString<64> errBuf; + wpi::raw_svector_ostream errMsg{errBuf}; errMsg << "received unknown Content-Type \"" << contentTypeBuf << "\""; SWARNING(errMsg.str()); PutError(errMsg.str(), wpi::Now()); @@ -282,7 +282,7 @@ void HttpCameraImpl::DeviceSendSettings(wpi::HttpRequest& req) { if (!m_active || !stream) return; - auto connPtr = llvm::make_unique(std::move(stream), 1); + auto connPtr = wpi::make_unique(std::move(stream), 1); wpi::HttpConnection* conn = connPtr.get(); // update m_settingsConn @@ -303,7 +303,7 @@ CS_HttpCameraKind HttpCameraImpl::GetKind() const { return m_kind; } -bool HttpCameraImpl::SetUrls(llvm::ArrayRef urls, +bool HttpCameraImpl::SetUrls(wpi::ArrayRef urls, CS_Status* status) { std::vector locations; for (const auto& url : urls) { @@ -331,27 +331,27 @@ std::vector HttpCameraImpl::GetUrls() const { return urls; } -void HttpCameraImpl::CreateProperty(llvm::StringRef name, - llvm::StringRef httpParam, bool viaSettings, +void HttpCameraImpl::CreateProperty(wpi::StringRef name, + wpi::StringRef httpParam, bool viaSettings, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value) const { std::lock_guard lock(m_mutex); - m_propertyData.emplace_back(llvm::make_unique( + m_propertyData.emplace_back(wpi::make_unique( name, httpParam, viaSettings, kind, minimum, maximum, step, defaultValue, value)); Notifier::GetInstance().NotifySourceProperty( *this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1, kind, - value, llvm::StringRef{}); + value, wpi::StringRef{}); } template void HttpCameraImpl::CreateEnumProperty( - llvm::StringRef name, llvm::StringRef httpParam, bool viaSettings, + wpi::StringRef name, wpi::StringRef httpParam, bool viaSettings, int defaultValue, int value, std::initializer_list choices) const { std::lock_guard lock(m_mutex); - m_propertyData.emplace_back(llvm::make_unique( + m_propertyData.emplace_back(wpi::make_unique( name, httpParam, viaSettings, CS_PROP_ENUM, 0, choices.size() - 1, 1, defaultValue, value)); @@ -361,15 +361,15 @@ void HttpCameraImpl::CreateEnumProperty( Notifier::GetInstance().NotifySourceProperty( *this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1, - CS_PROP_ENUM, value, llvm::StringRef{}); + CS_PROP_ENUM, value, wpi::StringRef{}); Notifier::GetInstance().NotifySourceProperty( *this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, name, - m_propertyData.size() + 1, CS_PROP_ENUM, value, llvm::StringRef{}); + m_propertyData.size() + 1, CS_PROP_ENUM, value, wpi::StringRef{}); } std::unique_ptr HttpCameraImpl::CreateEmptyProperty( - llvm::StringRef name) const { - return llvm::make_unique(name); + wpi::StringRef name) const { + return wpi::make_unique(name); } bool HttpCameraImpl::CacheProperties(CS_Status* status) const { @@ -389,7 +389,7 @@ void HttpCameraImpl::SetProperty(int property, int value, CS_Status* status) { // TODO } -void HttpCameraImpl::SetStringProperty(int property, llvm::StringRef value, +void HttpCameraImpl::SetStringProperty(int property, wpi::StringRef value, CS_Status* status) { // TODO } @@ -473,7 +473,7 @@ bool AxisCameraImpl::CacheProperties(CS_Status* status) const { namespace cs { -CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url, +CS_Source CreateHttpCamera(wpi::StringRef name, wpi::StringRef url, CS_HttpCameraKind kind, CS_Status* status) { std::shared_ptr source; switch (kind) { @@ -493,8 +493,8 @@ CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url, return handle; } -CS_Source CreateHttpCamera(llvm::StringRef name, - llvm::ArrayRef urls, +CS_Source CreateHttpCamera(wpi::StringRef name, + wpi::ArrayRef urls, CS_HttpCameraKind kind, CS_Status* status) { if (urls.empty()) { *status = CS_EMPTY_VALUE; @@ -518,7 +518,7 @@ CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status) { return static_cast(*data->source).GetKind(); } -void SetHttpCameraUrls(CS_Source source, llvm::ArrayRef urls, +void SetHttpCameraUrls(CS_Source source, wpi::ArrayRef urls, CS_Status* status) { if (urls.empty()) { *status = CS_EMPTY_VALUE; @@ -554,7 +554,7 @@ CS_Source CS_CreateHttpCamera(const char* name, const char* url, CS_Source CS_CreateHttpCameraMulti(const char* name, const char** urls, int count, CS_HttpCameraKind kind, CS_Status* status) { - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(count); for (int i = 0; i < count; ++i) vec.push_back(urls[i]); return cs::CreateHttpCamera(name, vec, kind, status); @@ -566,7 +566,7 @@ CS_HttpCameraKind CS_GetHttpCameraKind(CS_Source source, CS_Status* status) { void CS_SetHttpCameraUrls(CS_Source source, const char** urls, int count, CS_Status* status) { - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(count); for (int i = 0; i < count; ++i) vec.push_back(urls[i]); cs::SetHttpCameraUrls(source, vec, status); diff --git a/cscore/src/main/native/cpp/HttpCameraImpl.h b/cscore/src/main/native/cpp/HttpCameraImpl.h index 35956b2424..2f666d4d2b 100644 --- a/cscore/src/main/native/cpp/HttpCameraImpl.h +++ b/cscore/src/main/native/cpp/HttpCameraImpl.h @@ -16,11 +16,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "SourceImpl.h" #include "cscore_cpp.h" @@ -29,14 +29,14 @@ namespace cs { class HttpCameraImpl : public SourceImpl { public: - HttpCameraImpl(llvm::StringRef name, CS_HttpCameraKind kind); + HttpCameraImpl(wpi::StringRef name, CS_HttpCameraKind kind); ~HttpCameraImpl() override; void Start(); // Property functions void SetProperty(int property, int value, CS_Status* status) override; - void SetStringProperty(int property, llvm::StringRef value, + void SetStringProperty(int property, wpi::StringRef value, CS_Status* status) override; // Standard common camera properties @@ -55,15 +55,15 @@ class HttpCameraImpl : public SourceImpl { void NumSinksEnabledChanged() override; CS_HttpCameraKind GetKind() const; - bool SetUrls(llvm::ArrayRef urls, CS_Status* status); + bool SetUrls(wpi::ArrayRef urls, CS_Status* status); std::vector GetUrls() const; // Property data class PropertyData : public PropertyImpl { public: PropertyData() = default; - explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {} - PropertyData(llvm::StringRef name_, llvm::StringRef httpParam_, + explicit PropertyData(wpi::StringRef name_) : PropertyImpl{name_} {} + PropertyData(wpi::StringRef name_, wpi::StringRef httpParam_, bool viaSettings_, CS_PropertyKind kind_, int minimum_, int maximum_, int step_, int defaultValue_, int value_) : PropertyImpl(name_, kind_, step_, defaultValue_, value_), @@ -82,16 +82,16 @@ class HttpCameraImpl : public SourceImpl { protected: std::unique_ptr CreateEmptyProperty( - llvm::StringRef name) const override; + wpi::StringRef name) const override; bool CacheProperties(CS_Status* status) const override; - void CreateProperty(llvm::StringRef name, llvm::StringRef httpParam, + void CreateProperty(wpi::StringRef name, wpi::StringRef httpParam, bool viaSettings, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value) const; template - void CreateEnumProperty(llvm::StringRef name, llvm::StringRef httpParam, + void CreateEnumProperty(wpi::StringRef name, wpi::StringRef httpParam, bool viaSettings, int defaultValue, int value, std::initializer_list choices) const; @@ -101,8 +101,8 @@ class HttpCameraImpl : public SourceImpl { // Functions used by StreamThreadMain() wpi::HttpConnection* DeviceStreamConnect( - llvm::SmallVectorImpl& boundary); - void DeviceStream(wpi::raw_istream& is, llvm::StringRef boundary); + wpi::SmallVectorImpl& boundary); + void DeviceStream(wpi::raw_istream& is, wpi::StringRef boundary); bool DeviceStreamFrame(wpi::raw_istream& is, std::string& imageBuf); // The camera settings thread @@ -130,20 +130,20 @@ class HttpCameraImpl : public SourceImpl { wpi::condition_variable m_sinkEnabledCond; - llvm::StringMap> m_settings; + wpi::StringMap> m_settings; wpi::condition_variable m_settingsCond; - llvm::StringMap> m_streamSettings; + wpi::StringMap> m_streamSettings; std::atomic_bool m_streamSettingsUpdated{false}; }; class AxisCameraImpl : public HttpCameraImpl { public: - explicit AxisCameraImpl(llvm::StringRef name) + explicit AxisCameraImpl(wpi::StringRef name) : HttpCameraImpl{name, CS_HTTP_AXIS} {} #if 0 void SetProperty(int property, int value, CS_Status* status) override; - void SetStringProperty(int property, llvm::StringRef value, + void SetStringProperty(int property, wpi::StringRef value, CS_Status* status) override; #endif protected: diff --git a/cscore/src/main/native/cpp/Image.h b/cscore/src/main/native/cpp/Image.h index 64a355019a..604d05cf8c 100644 --- a/cscore/src/main/native/cpp/Image.h +++ b/cscore/src/main/native/cpp/Image.h @@ -10,8 +10,8 @@ #include -#include #include +#include #include "cscore_cpp.h" #include "default_init_allocator.h" @@ -37,8 +37,8 @@ class Image { Image& operator=(const Image&) = delete; // Getters - operator llvm::StringRef() const { return str(); } - llvm::StringRef str() const { return llvm::StringRef(data(), size()); } + operator wpi::StringRef() const { return str(); } + wpi::StringRef str() const { return wpi::StringRef(data(), size()); } size_t capacity() const { return m_data.capacity(); } const char* data() const { return reinterpret_cast(m_data.data()); diff --git a/cscore/src/main/native/cpp/JpegUtil.cpp b/cscore/src/main/native/cpp/JpegUtil.cpp index f80cf8ce62..357aaf56eb 100644 --- a/cscore/src/main/native/cpp/JpegUtil.cpp +++ b/cscore/src/main/native/cpp/JpegUtil.cpp @@ -7,7 +7,7 @@ #include "JpegUtil.h" -#include +#include namespace cs { @@ -49,7 +49,7 @@ static const unsigned char dhtData[] = { 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa}; -bool IsJpeg(llvm::StringRef data) { +bool IsJpeg(wpi::StringRef data) { if (data.size() < 11) return false; // Check for valid SOI @@ -58,7 +58,7 @@ bool IsJpeg(llvm::StringRef data) { return true; } -bool GetJpegSize(llvm::StringRef data, int* width, int* height) { +bool GetJpegSize(wpi::StringRef data, int* width, int* height) { if (!IsJpeg(data)) return false; data = data.substr(2); // Get to the first block @@ -82,7 +82,7 @@ bool GetJpegSize(llvm::StringRef data, int* width, int* height) { } bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) { - llvm::StringRef sdata(data, *size); + wpi::StringRef sdata(data, *size); if (!IsJpeg(sdata)) return false; *locSOF = *size; @@ -109,8 +109,8 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) { return false; } -llvm::StringRef JpegGetDHT() { - return llvm::StringRef(reinterpret_cast(dhtData), +wpi::StringRef JpegGetDHT() { + return wpi::StringRef(reinterpret_cast(dhtData), sizeof(dhtData)); } diff --git a/cscore/src/main/native/cpp/JpegUtil.h b/cscore/src/main/native/cpp/JpegUtil.h index 9bb3934efd..082fdc40a8 100644 --- a/cscore/src/main/native/cpp/JpegUtil.h +++ b/cscore/src/main/native/cpp/JpegUtil.h @@ -10,7 +10,7 @@ #include -#include +#include namespace wpi { class raw_istream; @@ -18,13 +18,13 @@ class raw_istream; namespace cs { -bool IsJpeg(llvm::StringRef data); +bool IsJpeg(wpi::StringRef data); -bool GetJpegSize(llvm::StringRef data, int* width, int* height); +bool GetJpegSize(wpi::StringRef data, int* width, int* height); bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF); -llvm::StringRef JpegGetDHT(); +wpi::StringRef JpegGetDHT(); bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height); diff --git a/cscore/src/main/native/cpp/Log.cpp b/cscore/src/main/native/cpp/Log.cpp index 9a6dd10b1d..06bdfbb758 100644 --- a/cscore/src/main/native/cpp/Log.cpp +++ b/cscore/src/main/native/cpp/Log.cpp @@ -7,24 +7,24 @@ #include "Log.h" -#include -#include -#include -#include +#include +#include +#include +#include using namespace cs; static void def_log_func(unsigned int level, const char* file, unsigned int line, const char* msg) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream oss(buf); if (level == 20) { oss << "CS: " << msg << '\n'; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); return; } - llvm::StringRef levelmsg; + wpi::StringRef levelmsg; if (level >= 50) levelmsg = "CRITICAL: "; else if (level >= 40) @@ -33,9 +33,9 @@ static void def_log_func(unsigned int level, const char* file, levelmsg = "WARNING: "; else return; - oss << "CS: " << levelmsg << msg << " (" << llvm::sys::path::filename(file) + oss << "CS: " << levelmsg << msg << " (" << wpi::sys::path::filename(file) << ':' << line << ")\n"; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); } Logger::Logger() { SetDefaultLogger(); } diff --git a/cscore/src/main/native/cpp/Log.h b/cscore/src/main/native/cpp/Log.h index 9d2fb7452d..3cf76b403b 100644 --- a/cscore/src/main/native/cpp/Log.h +++ b/cscore/src/main/native/cpp/Log.h @@ -8,7 +8,7 @@ #ifndef CSCORE_LOG_H_ #define CSCORE_LOG_H_ -#include +#include namespace cs { diff --git a/cscore/src/main/native/cpp/MjpegServerImpl.cpp b/cscore/src/main/native/cpp/MjpegServerImpl.cpp index 3fc6dc9dce..d8a5a0bc7e 100644 --- a/cscore/src/main/native/cpp/MjpegServerImpl.cpp +++ b/cscore/src/main/native/cpp/MjpegServerImpl.cpp @@ -9,11 +9,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "Handle.h" #include "JpegUtil.h" @@ -73,15 +73,15 @@ static const char* endRootPage = ""; class MjpegServerImpl::ConnThread : public wpi::SafeThread { public: - explicit ConnThread(llvm::StringRef name) : m_name(name) {} + explicit ConnThread(wpi::StringRef name) : m_name(name) {} void Main(); - bool ProcessCommand(llvm::raw_ostream& os, SourceImpl& source, - llvm::StringRef parameters, bool respond); - void SendJSON(llvm::raw_ostream& os, SourceImpl& source, bool header); - void SendHTMLHeadTitle(llvm::raw_ostream& os) const; - void SendHTML(llvm::raw_ostream& os, SourceImpl& source, bool header); + bool ProcessCommand(wpi::raw_ostream& os, SourceImpl& source, + wpi::StringRef parameters, bool respond); + void SendJSON(wpi::raw_ostream& os, SourceImpl& source, bool header); + void SendHTMLHeadTitle(wpi::raw_ostream& os) const; + void SendHTML(wpi::raw_ostream& os, SourceImpl& source, bool header); void SendStream(wpi::raw_socket_ostream& os); void ProcessRequest(); @@ -93,7 +93,7 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread { private: std::string m_name; - llvm::StringRef GetName() { return m_name; } + wpi::StringRef GetName() { return m_name; } std::shared_ptr GetSource() { std::lock_guard lock(m_mutex); @@ -124,9 +124,9 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread { // A browser should connect for each file and not serve files from its cache. // Using cached pictures would lead to showing old/outdated pictures. // Many browsers seem to ignore, or at least not always obey, those headers. -static void SendHeader(llvm::raw_ostream& os, int code, - llvm::StringRef codeText, llvm::StringRef contentType, - llvm::StringRef extra = llvm::StringRef{}) { +static void SendHeader(wpi::raw_ostream& os, int code, + wpi::StringRef codeText, wpi::StringRef contentType, + wpi::StringRef extra = wpi::StringRef{}) { os << "HTTP/1.0 " << code << ' ' << codeText << "\r\n"; os << "Connection: close\r\n" "Server: CameraServer/1.0\r\n" @@ -143,9 +143,9 @@ static void SendHeader(llvm::raw_ostream& os, int code, // Send error header and message // @param code HTTP error code (e.g. 404) // @param message Additional message text -static void SendError(llvm::raw_ostream& os, int code, - llvm::StringRef message) { - llvm::StringRef codeText, extra, baseMessage; +static void SendError(wpi::raw_ostream& os, int code, + wpi::StringRef message) { + wpi::StringRef codeText, extra, baseMessage; switch (code) { case 401: codeText = "Unauthorized"; @@ -183,16 +183,16 @@ static void SendError(llvm::raw_ostream& os, int code, } // Perform a command specified by HTTP GET parameters. -bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os, +bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os, SourceImpl& source, - llvm::StringRef parameters, + wpi::StringRef parameters, bool respond) { - llvm::SmallString<256> responseBuf; - llvm::raw_svector_ostream response{responseBuf}; + wpi::SmallString<256> responseBuf; + wpi::raw_svector_ostream response{responseBuf}; // command format: param1=value1¶m2=value2... while (!parameters.empty()) { // split out next param and value - llvm::StringRef rawParam, rawValue; + wpi::StringRef rawParam, rawValue; std::tie(rawParam, parameters) = parameters.split('&'); if (rawParam.empty()) continue; // ignore "&&" std::tie(rawParam, rawValue) = rawParam.split('='); @@ -202,11 +202,11 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os, // unescape param bool error = false; - llvm::SmallString<64> paramBuf; - llvm::StringRef param = wpi::UnescapeURI(rawParam, paramBuf, &error); + wpi::SmallString<64> paramBuf; + wpi::StringRef param = wpi::UnescapeURI(rawParam, paramBuf, &error); if (error) { - llvm::SmallString<128> error; - llvm::raw_svector_ostream oss{error}; + wpi::SmallString<128> error; + wpi::raw_svector_ostream oss{error}; oss << "could not unescape parameter \"" << rawParam << "\""; SendError(os, 500, error.str()); SDEBUG(error.str()); @@ -214,11 +214,11 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os, } // unescape value - llvm::SmallString<64> valueBuf; - llvm::StringRef value = wpi::UnescapeURI(rawValue, valueBuf, &error); + wpi::SmallString<64> valueBuf; + wpi::StringRef value = wpi::UnescapeURI(rawValue, valueBuf, &error); if (error) { - llvm::SmallString<128> error; - llvm::raw_svector_ostream oss{error}; + wpi::SmallString<128> error; + wpi::raw_svector_ostream oss{error}; oss << "could not unescape value \"" << rawValue << "\""; SendError(os, 500, error.str()); SDEBUG(error.str()); @@ -228,7 +228,7 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os, // Handle resolution, compression, and FPS. These are handled locally // rather than passed to the source. if (param == "resolution") { - llvm::StringRef widthStr, heightStr; + wpi::StringRef widthStr, heightStr; std::tie(widthStr, heightStr) = value.split('x'); int width, height; if (widthStr.getAsInteger(10, width)) { @@ -327,21 +327,21 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os, } void MjpegServerImpl::ConnThread::SendHTMLHeadTitle( - llvm::raw_ostream& os) const { + wpi::raw_ostream& os) const { os << "" << m_name << " CameraServer"; } // Send the root html file with controls for all the settable properties. -void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os, +void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os, SourceImpl& source, bool header) { if (header) SendHeader(os, 200, "OK", "application/x-javascript"); SendHTMLHeadTitle(os); os << startRootPage; - llvm::SmallVector properties_vec; + wpi::SmallVector properties_vec; CS_Status status = 0; for (auto prop : source.EnumerateProperties(properties_vec, &status)) { - llvm::SmallString<128> name_buf; + wpi::SmallString<128> name_buf; auto name = source.GetPropertyName(prop, name_buf, &status); if (name.startswith("raw_")) continue; auto kind = source.GetPropertyKind(prop); @@ -378,7 +378,7 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os, ++j, ++choice) { if (choice->empty()) continue; // skip empty choices // replace any non-printable characters in name with spaces - llvm::SmallString<128> ch_name; + wpi::SmallString<128> ch_name; for (char ch : *choice) ch_name.push_back(std::isprint(ch) ? ch : ' '); os << " strval_buf; + wpi::SmallString<128> strval_buf; os << "\n"; @@ -445,12 +445,12 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os, } // Send a JSON file which is contains information about the source parameters. -void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os, +void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os, SourceImpl& source, bool header) { if (header) SendHeader(os, 200, "OK", "application/x-javascript"); os << "{\n\"controls\": [\n"; - llvm::SmallVector properties_vec; + wpi::SmallVector properties_vec; bool first = true; CS_Status status = 0; for (auto prop : source.EnumerateProperties(properties_vec, &status)) { @@ -459,7 +459,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os, else os << ",\n"; os << '{'; - llvm::SmallString<128> name_buf; + wpi::SmallString<128> name_buf; auto name = source.GetPropertyName(prop, name_buf, &status); auto kind = source.GetPropertyKind(prop); os << "\n\"name\": \"" << name << '"'; @@ -478,7 +478,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os, os << source.GetProperty(prop, &status); break; case CS_PROP_STRING: { - llvm::SmallString<128> strval_buf; + wpi::SmallString<128> strval_buf; os << source.GetStringProperty(prop, strval_buf, &status); break; } @@ -499,7 +499,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os, ++j, ++choice) { if (j != 0) os << ", "; // replace any non-printable characters in name with spaces - llvm::SmallString<128> ch_name; + wpi::SmallString<128> ch_name; for (char ch : *choice) ch_name.push_back(std::isprint(ch) ? ch : ' '); os << '"' << j << "\": \"" << ch_name << '"'; } @@ -545,8 +545,8 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os, os.flush(); } -MjpegServerImpl::MjpegServerImpl(llvm::StringRef name, - llvm::StringRef listenAddress, int port, +MjpegServerImpl::MjpegServerImpl(wpi::StringRef name, + wpi::StringRef listenAddress, int port, std::unique_ptr acceptor) : SinkImpl{name}, m_listenAddress(listenAddress), @@ -554,8 +554,8 @@ MjpegServerImpl::MjpegServerImpl(llvm::StringRef name, m_acceptor{std::move(acceptor)} { m_active = true; - llvm::SmallString<128> descBuf; - llvm::raw_svector_ostream desc{descBuf}; + wpi::SmallString<128> descBuf; + wpi::raw_svector_ostream desc{descBuf}; desc << "HTTP Server on port " << port; SetDescription(desc.str()); @@ -595,8 +595,8 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) { os.SetUnbuffered(); - llvm::SmallString<256> header; - llvm::raw_svector_ostream oss{header}; + wpi::SmallString<256> header; + wpi::raw_svector_ostream oss{header}; SendHeader(oss, 200, "OK", "multipart/x-mixed-replace;boundary=" BOUNDARY); os << oss.str(); @@ -678,11 +678,11 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) { os << oss.str(); if (addDHT) { // Insert DHT data immediately before SOF - os << llvm::StringRef(data, locSOF); + os << wpi::StringRef(data, locSOF); os << JpegGetDHT(); - os << llvm::StringRef(data + locSOF, image->size() - locSOF); + os << wpi::StringRef(data + locSOF, image->size() - locSOF); } else { - os << llvm::StringRef(data, size); + os << wpi::StringRef(data, size); } // os.flush(); } @@ -700,44 +700,44 @@ void MjpegServerImpl::ConnThread::ProcessRequest() { m_fps = 0; // Read the request string from the stream - llvm::SmallString<128> reqBuf; - llvm::StringRef req = is.getline(reqBuf, 4096); + wpi::SmallString<128> reqBuf; + wpi::StringRef req = is.getline(reqBuf, 4096); if (is.has_error()) { SDEBUG("error getting request string"); return; } enum { kCommand, kStream, kGetSettings, kRootPage } kind; - llvm::StringRef parameters; + wpi::StringRef parameters; size_t pos; SDEBUG("HTTP request: '" << req << "'\n"); // Determine request kind. Most of these are for mjpgstreamer // compatibility, others are for Axis camera compatibility. - if ((pos = req.find("POST /stream")) != llvm::StringRef::npos) { + if ((pos = req.find("POST /stream")) != wpi::StringRef::npos) { kind = kStream; parameters = req.substr(req.find('?', pos + 12)).substr(1); - } else if ((pos = req.find("GET /?action=stream")) != llvm::StringRef::npos) { + } else if ((pos = req.find("GET /?action=stream")) != wpi::StringRef::npos) { kind = kStream; parameters = req.substr(req.find('&', pos + 19)).substr(1); - } else if ((pos = req.find("GET /stream.mjpg")) != llvm::StringRef::npos) { + } else if ((pos = req.find("GET /stream.mjpg")) != wpi::StringRef::npos) { kind = kStream; parameters = req.substr(req.find('?', pos + 16)).substr(1); - } else if (req.find("GET /settings") != llvm::StringRef::npos && - req.find(".json") != llvm::StringRef::npos) { + } else if (req.find("GET /settings") != wpi::StringRef::npos && + req.find(".json") != wpi::StringRef::npos) { kind = kGetSettings; - } else if (req.find("GET /input") != llvm::StringRef::npos && - req.find(".json") != llvm::StringRef::npos) { + } else if (req.find("GET /input") != wpi::StringRef::npos && + req.find(".json") != wpi::StringRef::npos) { kind = kGetSettings; - } else if (req.find("GET /output") != llvm::StringRef::npos && - req.find(".json") != llvm::StringRef::npos) { + } else if (req.find("GET /output") != wpi::StringRef::npos && + req.find(".json") != wpi::StringRef::npos) { kind = kGetSettings; } else if ((pos = req.find("GET /?action=command")) != - llvm::StringRef::npos) { + wpi::StringRef::npos) { kind = kCommand; parameters = req.substr(req.find('&', pos + 20)).substr(1); - } else if (req.find("GET / ") != llvm::StringRef::npos || req == "GET /\n") { + } else if (req.find("GET / ") != wpi::StringRef::npos || req == "GET /\n") { kind = kRootPage; } else { SDEBUG("HTTP request resource not found"); @@ -754,7 +754,7 @@ void MjpegServerImpl::ConnThread::ProcessRequest() { // Read the rest of the HTTP request. // The end of the request is marked by a single, empty line - llvm::SmallString<128> lineBuf; + wpi::SmallString<128> lineBuf; for (;;) { if (is.getline(lineBuf, 4096).startswith("\n")) break; if (is.has_error()) return; @@ -888,9 +888,9 @@ void MjpegServerImpl::SetSourceImpl(std::shared_ptr source) { namespace cs { -CS_Sink CreateMjpegServer(llvm::StringRef name, llvm::StringRef listenAddress, +CS_Sink CreateMjpegServer(wpi::StringRef name, wpi::StringRef listenAddress, int port, CS_Status* status) { - llvm::SmallString<128> str{listenAddress}; + wpi::SmallString<128> str{listenAddress}; auto sink = std::make_shared( name, listenAddress, port, std::unique_ptr( diff --git a/cscore/src/main/native/cpp/MjpegServerImpl.h b/cscore/src/main/native/cpp/MjpegServerImpl.h index cc898b41f2..312ba768b8 100644 --- a/cscore/src/main/native/cpp/MjpegServerImpl.h +++ b/cscore/src/main/native/cpp/MjpegServerImpl.h @@ -14,14 +14,14 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "SinkImpl.h" @@ -31,7 +31,7 @@ class SourceImpl; class MjpegServerImpl : public SinkImpl { public: - MjpegServerImpl(llvm::StringRef name, llvm::StringRef listenAddress, int port, + MjpegServerImpl(wpi::StringRef name, wpi::StringRef listenAddress, int port, std::unique_ptr acceptor); ~MjpegServerImpl() override; diff --git a/cscore/src/main/native/cpp/NetworkListener.h b/cscore/src/main/native/cpp/NetworkListener.h index 5f8567d581..c6d4c597ea 100644 --- a/cscore/src/main/native/cpp/NetworkListener.h +++ b/cscore/src/main/native/cpp/NetworkListener.h @@ -8,7 +8,7 @@ #ifndef CSCORE_NETWORKLISTENER_H_ #define CSCORE_NETWORKLISTENER_H_ -#include +#include namespace cs { diff --git a/cscore/src/main/native/cpp/Notifier.cpp b/cscore/src/main/native/cpp/Notifier.cpp index 48e03a52e2..b4f0047771 100644 --- a/cscore/src/main/native/cpp/Notifier.cpp +++ b/cscore/src/main/native/cpp/Notifier.cpp @@ -151,7 +151,7 @@ void Notifier::RemoveListener(int uid) { thr->m_listeners.erase(uid); } -void Notifier::NotifySource(llvm::StringRef name, CS_Source source, +void Notifier::NotifySource(wpi::StringRef name, CS_Source source, CS_EventKind kind) { auto thr = m_owner.GetThread(); if (!thr) return; @@ -176,9 +176,9 @@ void Notifier::NotifySourceVideoMode(const SourceImpl& source, } void Notifier::NotifySourceProperty(const SourceImpl& source, CS_EventKind kind, - llvm::StringRef propertyName, int property, + wpi::StringRef propertyName, int property, CS_PropertyKind propertyKind, int value, - llvm::StringRef valueStr) { + wpi::StringRef valueStr) { auto thr = m_owner.GetThread(); if (!thr) return; @@ -191,7 +191,7 @@ void Notifier::NotifySourceProperty(const SourceImpl& source, CS_EventKind kind, thr->m_cond.notify_one(); } -void Notifier::NotifySink(llvm::StringRef name, CS_Sink sink, +void Notifier::NotifySink(wpi::StringRef name, CS_Sink sink, CS_EventKind kind) { auto thr = m_owner.GetThread(); if (!thr) return; @@ -205,7 +205,7 @@ void Notifier::NotifySink(const SinkImpl& sink, CS_EventKind kind) { NotifySink(sink.GetName(), handleData.first, kind); } -void Notifier::NotifySinkSourceChanged(llvm::StringRef name, CS_Sink sink, +void Notifier::NotifySinkSourceChanged(wpi::StringRef name, CS_Sink sink, CS_Source source) { auto thr = m_owner.GetThread(); if (!thr) return; diff --git a/cscore/src/main/native/cpp/Notifier.h b/cscore/src/main/native/cpp/Notifier.h index 98da430e5c..05714ccf59 100644 --- a/cscore/src/main/native/cpp/Notifier.h +++ b/cscore/src/main/native/cpp/Notifier.h @@ -10,7 +10,7 @@ #include -#include +#include #include "cscore_cpp.h" @@ -42,16 +42,16 @@ class Notifier { void RemoveListener(int uid); // Notification events - void NotifySource(llvm::StringRef name, CS_Source source, CS_EventKind kind); + void NotifySource(wpi::StringRef name, CS_Source source, CS_EventKind kind); void NotifySource(const SourceImpl& source, CS_EventKind kind); void NotifySourceVideoMode(const SourceImpl& source, const VideoMode& mode); void NotifySourceProperty(const SourceImpl& source, CS_EventKind kind, - llvm::StringRef propertyName, int property, + wpi::StringRef propertyName, int property, CS_PropertyKind propertyKind, int value, - llvm::StringRef valueStr); - void NotifySink(llvm::StringRef name, CS_Sink sink, CS_EventKind kind); + wpi::StringRef valueStr); + void NotifySink(wpi::StringRef name, CS_Sink sink, CS_EventKind kind); void NotifySink(const SinkImpl& sink, CS_EventKind kind); - void NotifySinkSourceChanged(llvm::StringRef name, CS_Sink sink, + void NotifySinkSourceChanged(wpi::StringRef name, CS_Sink sink, CS_Source source); void NotifyNetworkInterfacesChanged(); void NotifyTelemetryUpdated(); diff --git a/cscore/src/main/native/cpp/PropertyImpl.h b/cscore/src/main/native/cpp/PropertyImpl.h index 6e6e7fbed8..f2051339a1 100644 --- a/cscore/src/main/native/cpp/PropertyImpl.h +++ b/cscore/src/main/native/cpp/PropertyImpl.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "cscore_c.h" @@ -21,8 +21,8 @@ namespace cs { class PropertyImpl { public: PropertyImpl() = default; - explicit PropertyImpl(llvm::StringRef name_) : name{name_} {} - PropertyImpl(llvm::StringRef name_, CS_PropertyKind kind_, int step_, + explicit PropertyImpl(wpi::StringRef name_) : name{name_} {} + PropertyImpl(wpi::StringRef name_, CS_PropertyKind kind_, int step_, int defaultValue_, int value_) : name{name_}, propKind{kind_}, @@ -43,7 +43,7 @@ class PropertyImpl { valueSet = true; } - void SetValue(llvm::StringRef v) { + void SetValue(wpi::StringRef v) { valueStr = v; valueSet = true; } diff --git a/cscore/src/main/native/cpp/SinkImpl.cpp b/cscore/src/main/native/cpp/SinkImpl.cpp index e830efebbd..15a75bf79a 100644 --- a/cscore/src/main/native/cpp/SinkImpl.cpp +++ b/cscore/src/main/native/cpp/SinkImpl.cpp @@ -12,7 +12,7 @@ using namespace cs; -SinkImpl::SinkImpl(llvm::StringRef name) : m_name{name} {} +SinkImpl::SinkImpl(wpi::StringRef name) : m_name{name} {} SinkImpl::~SinkImpl() { if (m_source) { @@ -21,16 +21,16 @@ SinkImpl::~SinkImpl() { } } -void SinkImpl::SetDescription(llvm::StringRef description) { +void SinkImpl::SetDescription(wpi::StringRef description) { std::lock_guard lock(m_mutex); m_description = description; } -llvm::StringRef SinkImpl::GetDescription( - llvm::SmallVectorImpl& buf) const { +wpi::StringRef SinkImpl::GetDescription( + wpi::SmallVectorImpl& buf) const { std::lock_guard lock(m_mutex); buf.append(m_description.begin(), m_description.end()); - return llvm::StringRef{buf.data(), buf.size()}; + return wpi::StringRef{buf.data(), buf.size()}; } void SinkImpl::Enable() { @@ -87,14 +87,14 @@ std::string SinkImpl::GetError() const { return m_source->GetCurFrame().GetError(); } -llvm::StringRef SinkImpl::GetError(llvm::SmallVectorImpl& buf) const { +wpi::StringRef SinkImpl::GetError(wpi::SmallVectorImpl& buf) const { std::lock_guard lock(m_mutex); if (!m_source) return "no source connected"; // Make a copy as it's shared data - llvm::StringRef error = m_source->GetCurFrame().GetError(); + wpi::StringRef error = m_source->GetCurFrame().GetError(); buf.clear(); buf.append(error.data(), error.data() + error.size()); - return llvm::StringRef{buf.data(), buf.size()}; + return wpi::StringRef{buf.data(), buf.size()}; } void SinkImpl::SetSourceImpl(std::shared_ptr source) {} diff --git a/cscore/src/main/native/cpp/SinkImpl.h b/cscore/src/main/native/cpp/SinkImpl.h index a855b2c4fe..8eef4d3f12 100644 --- a/cscore/src/main/native/cpp/SinkImpl.h +++ b/cscore/src/main/native/cpp/SinkImpl.h @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include "SourceImpl.h" @@ -22,15 +22,15 @@ class Frame; class SinkImpl { public: - explicit SinkImpl(llvm::StringRef name); + explicit SinkImpl(wpi::StringRef name); virtual ~SinkImpl(); SinkImpl(const SinkImpl& queue) = delete; SinkImpl& operator=(const SinkImpl& queue) = delete; - llvm::StringRef GetName() const { return m_name; } + wpi::StringRef GetName() const { return m_name; } - void SetDescription(llvm::StringRef description); - llvm::StringRef GetDescription(llvm::SmallVectorImpl& buf) const; + void SetDescription(wpi::StringRef description); + wpi::StringRef GetDescription(wpi::SmallVectorImpl& buf) const; void Enable(); void Disable(); @@ -44,7 +44,7 @@ class SinkImpl { } std::string GetError() const; - llvm::StringRef GetError(llvm::SmallVectorImpl& buf) const; + wpi::StringRef GetError(wpi::SmallVectorImpl& buf) const; protected: virtual void SetSourceImpl(std::shared_ptr source); diff --git a/cscore/src/main/native/cpp/SourceImpl.cpp b/cscore/src/main/native/cpp/SourceImpl.cpp index 59971de231..730b3c0203 100644 --- a/cscore/src/main/native/cpp/SourceImpl.cpp +++ b/cscore/src/main/native/cpp/SourceImpl.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "Log.h" #include "Notifier.h" @@ -21,8 +21,8 @@ using namespace cs; static constexpr size_t kMaxImagesAvail = 32; -SourceImpl::SourceImpl(llvm::StringRef name) : m_name{name} { - m_frame = Frame{*this, llvm::StringRef{}, 0}; +SourceImpl::SourceImpl(wpi::StringRef name) : m_name{name} { + m_frame = Frame{*this, wpi::StringRef{}, 0}; } SourceImpl::~SourceImpl() { @@ -38,16 +38,16 @@ SourceImpl::~SourceImpl() { // Everything else can clean up itself. } -void SourceImpl::SetDescription(llvm::StringRef description) { +void SourceImpl::SetDescription(wpi::StringRef description) { std::lock_guard lock(m_mutex); m_description = description; } -llvm::StringRef SourceImpl::GetDescription( - llvm::SmallVectorImpl& buf) const { +wpi::StringRef SourceImpl::GetDescription( + wpi::SmallVectorImpl& buf) const { std::lock_guard lock(m_mutex); buf.append(m_description.begin(), m_description.end()); - return llvm::StringRef{buf.data(), buf.size()}; + return wpi::StringRef{buf.data(), buf.size()}; } void SourceImpl::SetConnected(bool connected) { @@ -89,12 +89,12 @@ Frame SourceImpl::GetNextFrame(double timeout) { void SourceImpl::Wakeup() { { std::lock_guard lock{m_frameMutex}; - m_frame = Frame{*this, llvm::StringRef{}, 0}; + m_frame = Frame{*this, wpi::StringRef{}, 0}; } m_frameCv.notify_all(); } -int SourceImpl::GetPropertyIndex(llvm::StringRef name) const { +int SourceImpl::GetPropertyIndex(wpi::StringRef name) const { // We can't fail, so instead we create a new index if caching fails. CS_Status status = 0; if (!m_properties_cached) CacheProperties(&status); @@ -108,10 +108,10 @@ int SourceImpl::GetPropertyIndex(llvm::StringRef name) const { return ndx; } -llvm::ArrayRef SourceImpl::EnumerateProperties( - llvm::SmallVectorImpl& vec, CS_Status* status) const { +wpi::ArrayRef SourceImpl::EnumerateProperties( + wpi::SmallVectorImpl& vec, CS_Status* status) const { if (!m_properties_cached && !CacheProperties(status)) - return llvm::ArrayRef{}; + return wpi::ArrayRef{}; std::lock_guard lock(m_mutex); for (int i = 0; i < static_cast(m_propertyData.size()); ++i) { if (m_propertyData[i]) vec.push_back(i + 1); @@ -128,16 +128,16 @@ CS_PropertyKind SourceImpl::GetPropertyKind(int property) const { return prop->propKind; } -llvm::StringRef SourceImpl::GetPropertyName(int property, - llvm::SmallVectorImpl& buf, - CS_Status* status) const { +wpi::StringRef SourceImpl::GetPropertyName(int property, + wpi::SmallVectorImpl& buf, + CS_Status* status) const { if (!m_properties_cached && !CacheProperties(status)) - return llvm::StringRef{}; + return wpi::StringRef{}; std::lock_guard lock(m_mutex); auto prop = GetProperty(property); if (!prop) { *status = CS_INVALID_PROPERTY; - return llvm::StringRef{}; + return wpi::StringRef{}; } // safe to not copy because we never modify it after caching return prop->name; @@ -203,24 +203,24 @@ int SourceImpl::GetPropertyDefault(int property, CS_Status* status) const { return prop->defaultValue; } -llvm::StringRef SourceImpl::GetStringProperty(int property, - llvm::SmallVectorImpl& buf, - CS_Status* status) const { +wpi::StringRef SourceImpl::GetStringProperty(int property, + wpi::SmallVectorImpl& buf, + CS_Status* status) const { if (!m_properties_cached && !CacheProperties(status)) - return llvm::StringRef{}; + return wpi::StringRef{}; std::lock_guard lock(m_mutex); auto prop = GetProperty(property); if (!prop) { *status = CS_INVALID_PROPERTY; - return llvm::StringRef{}; + return wpi::StringRef{}; } if (prop->propKind != CS_PROP_STRING) { *status = CS_WRONG_PROPERTY_TYPE; - return llvm::StringRef{}; + return wpi::StringRef{}; } buf.clear(); buf.append(prop->valueStr.begin(), prop->valueStr.end()); - return llvm::StringRef(buf.data(), buf.size()); + return wpi::StringRef(buf.data(), buf.size()); } std::vector SourceImpl::GetEnumPropertyChoices( @@ -313,7 +313,7 @@ std::unique_ptr SourceImpl::AllocImage( } void SourceImpl::PutFrame(VideoMode::PixelFormat pixelFormat, int width, - int height, llvm::StringRef data, Frame::Time time) { + int height, wpi::StringRef data, Frame::Time time) { auto image = AllocImage(pixelFormat, width, height, data.size()); // Copy in image data @@ -342,7 +342,7 @@ void SourceImpl::PutFrame(std::unique_ptr image, Frame::Time time) { m_frameCv.notify_all(); } -void SourceImpl::PutError(llvm::StringRef msg, Frame::Time time) { +void SourceImpl::PutError(wpi::StringRef msg, Frame::Time time) { // Update frame { std::lock_guard lock{m_frameMutex}; @@ -362,11 +362,11 @@ void SourceImpl::NotifyPropertyCreated(int propIndex, PropertyImpl& prop) { if (prop.propKind == CS_PROP_ENUM) notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, prop.name, propIndex, prop.propKind, - prop.value, llvm::StringRef{}); + prop.value, wpi::StringRef{}); } void SourceImpl::UpdatePropertyValue(int property, bool setString, int value, - llvm::StringRef valueStr) { + wpi::StringRef valueStr) { auto prop = GetProperty(property); if (!prop) return; @@ -407,7 +407,7 @@ void SourceImpl::ReleaseImage(std::unique_ptr image) { std::unique_ptr SourceImpl::AllocFrameImpl() { std::lock_guard lock{m_poolMutex}; - if (m_framesAvail.empty()) return llvm::make_unique(*this); + if (m_framesAvail.empty()) return wpi::make_unique(*this); auto impl = std::move(m_framesAvail.back()); m_framesAvail.pop_back(); diff --git a/cscore/src/main/native/cpp/SourceImpl.h b/cscore/src/main/native/cpp/SourceImpl.h index fa8036df6c..dd98041bf8 100644 --- a/cscore/src/main/native/cpp/SourceImpl.h +++ b/cscore/src/main/native/cpp/SourceImpl.h @@ -14,11 +14,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "Frame.h" #include "Image.h" @@ -31,15 +31,15 @@ class SourceImpl { friend class Frame; public: - explicit SourceImpl(llvm::StringRef name); + explicit SourceImpl(wpi::StringRef name); virtual ~SourceImpl(); SourceImpl(const SourceImpl& oth) = delete; SourceImpl& operator=(const SourceImpl& oth) = delete; - llvm::StringRef GetName() const { return m_name; } + wpi::StringRef GetName() const { return m_name; } - void SetDescription(llvm::StringRef description); - llvm::StringRef GetDescription(llvm::SmallVectorImpl& buf) const; + void SetDescription(wpi::StringRef description); + wpi::StringRef GetDescription(wpi::SmallVectorImpl& buf) const; void SetConnected(bool connected); bool IsConnected() const { return m_connected; } @@ -90,23 +90,23 @@ class SourceImpl { void Wakeup(); // Property functions - int GetPropertyIndex(llvm::StringRef name) const; - llvm::ArrayRef EnumerateProperties(llvm::SmallVectorImpl& vec, - CS_Status* status) const; + int GetPropertyIndex(wpi::StringRef name) const; + wpi::ArrayRef EnumerateProperties(wpi::SmallVectorImpl& vec, + CS_Status* status) const; CS_PropertyKind GetPropertyKind(int property) const; - llvm::StringRef GetPropertyName(int property, - llvm::SmallVectorImpl& buf, - CS_Status* status) const; + wpi::StringRef GetPropertyName(int property, + wpi::SmallVectorImpl& buf, + CS_Status* status) const; int GetProperty(int property, CS_Status* status) const; virtual void SetProperty(int property, int value, CS_Status* status) = 0; int GetPropertyMin(int property, CS_Status* status) const; int GetPropertyMax(int property, CS_Status* status) const; int GetPropertyStep(int property, CS_Status* status) const; int GetPropertyDefault(int property, CS_Status* status) const; - llvm::StringRef GetStringProperty(int property, - llvm::SmallVectorImpl& buf, - CS_Status* status) const; - virtual void SetStringProperty(int property, llvm::StringRef value, + wpi::StringRef GetStringProperty(int property, + wpi::SmallVectorImpl& buf, + CS_Status* status) const; + virtual void SetStringProperty(int property, wpi::StringRef value, CS_Status* status) = 0; std::vector GetEnumPropertyChoices(int property, CS_Status* status) const; @@ -139,9 +139,9 @@ class SourceImpl { protected: void PutFrame(VideoMode::PixelFormat pixelFormat, int width, int height, - llvm::StringRef data, Frame::Time time); + wpi::StringRef data, Frame::Time time); void PutFrame(std::unique_ptr image, Frame::Time time); - void PutError(llvm::StringRef msg, Frame::Time time); + void PutError(wpi::StringRef msg, Frame::Time time); // Notification functions for corresponding atomics virtual void NumSinksChanged() = 0; @@ -167,7 +167,7 @@ class SourceImpl { // properties that don't exist (as GetPropertyIndex can't fail). // Note: called with m_mutex held. virtual std::unique_ptr CreateEmptyProperty( - llvm::StringRef name) const = 0; + wpi::StringRef name) const = 0; // Cache properties. Implementations must return false and set status to // CS_SOURCE_IS_DISCONNECTED if not possible to cache. @@ -177,11 +177,11 @@ class SourceImpl { // Update property value; must be called with m_mutex held. void UpdatePropertyValue(int property, bool setString, int value, - llvm::StringRef valueStr); + wpi::StringRef valueStr); // Cached properties and video modes (protected with m_mutex) mutable std::vector> m_propertyData; - mutable llvm::StringMap m_properties; + mutable wpi::StringMap m_properties; mutable std::vector m_videoModes; // Current video mode mutable VideoMode m_mode; diff --git a/cscore/src/main/native/cpp/Telemetry.cpp b/cscore/src/main/native/cpp/Telemetry.cpp index 04dd7d9ff4..63885e8538 100644 --- a/cscore/src/main/native/cpp/Telemetry.cpp +++ b/cscore/src/main/native/cpp/Telemetry.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "Handle.h" #include "Notifier.h" @@ -23,8 +23,8 @@ class Telemetry::Thread : public wpi::SafeThread { public: void Main(); - llvm::DenseMap, int64_t> m_user; - llvm::DenseMap, int64_t> m_current; + wpi::DenseMap, int64_t> m_user; + wpi::DenseMap, int64_t> m_current; double m_period = 0.0; double m_elapsed = 0.0; bool m_updated = false; diff --git a/cscore/src/main/native/cpp/Telemetry.h b/cscore/src/main/native/cpp/Telemetry.h index 8995dce6bc..2c869e8dc6 100644 --- a/cscore/src/main/native/cpp/Telemetry.h +++ b/cscore/src/main/native/cpp/Telemetry.h @@ -8,7 +8,7 @@ #ifndef CSCORE_TELEMETRY_H_ #define CSCORE_TELEMETRY_H_ -#include +#include #include "cscore_cpp.h" diff --git a/cscore/src/main/native/cpp/UnlimitedHandleResource.h b/cscore/src/main/native/cpp/UnlimitedHandleResource.h index 59a9eca6f2..a235bdd38a 100644 --- a/cscore/src/main/native/cpp/UnlimitedHandleResource.h +++ b/cscore/src/main/native/cpp/UnlimitedHandleResource.h @@ -12,9 +12,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace cs { @@ -53,7 +53,7 @@ class UnlimitedHandleResource { void Free(THandle handle); template - llvm::ArrayRef GetAll(llvm::SmallVectorImpl& vec); + wpi::ArrayRef GetAll(wpi::SmallVectorImpl& vec); // @param func functor with (THandle, const TStruct&) parameters template @@ -133,9 +133,9 @@ inline void UnlimitedHandleResource::Free( template template -inline llvm::ArrayRef +inline wpi::ArrayRef UnlimitedHandleResource::GetAll( - llvm::SmallVectorImpl& vec) { + wpi::SmallVectorImpl& vec) { ForEach([&](THandle handle, const TStruct& data) { vec.push_back(handle); }); return vec; } diff --git a/cscore/src/main/native/cpp/UsbCameraImpl.cpp b/cscore/src/main/native/cpp/UsbCameraImpl.cpp index e2aa8f3f2a..d53f2560c6 100644 --- a/cscore/src/main/native/cpp/UsbCameraImpl.cpp +++ b/cscore/src/main/native/cpp/UsbCameraImpl.cpp @@ -27,9 +27,9 @@ #include -#include -#include -#include +#include +#include +#include #include "Handle.h" #include "Log.h" @@ -97,7 +97,7 @@ static __u32 FromPixelFormat(VideoMode::PixelFormat pixelFormat) { } } -static bool IsPercentageProperty(llvm::StringRef name) { +static bool IsPercentageProperty(wpi::StringRef name) { if (name.startswith("raw_")) name = name.substr(4); return name == "brightness" || name == "contrast" || name == "saturation" || name == "hue" || name == "sharpness" || name == "gain" || @@ -112,7 +112,7 @@ int UsbCameraImpl::RawToPercentage(const UsbCameraProperty& rawProp, // LifeCam exposure setting quirk if (m_lifecam_exposure && rawProp.name == "raw_exposure_absolute" && rawProp.minimum == 5 && rawProp.maximum == 20000) { - int nelems = llvm::array_lengthof(quirkLifeCamHd3000); + int nelems = wpi::array_lengthof(quirkLifeCamHd3000); for (int i = 0; i < nelems; ++i) { if (rawValue < quirkLifeCamHd3000[i]) return 100.0 * i / nelems; } @@ -127,7 +127,7 @@ int UsbCameraImpl::PercentageToRaw(const UsbCameraProperty& rawProp, // LifeCam exposure setting quirk if (m_lifecam_exposure && rawProp.name == "raw_exposure_absolute" && rawProp.minimum == 5 && rawProp.maximum == 20000) { - int nelems = llvm::array_lengthof(quirkLifeCamHd3000); + int nelems = wpi::array_lengthof(quirkLifeCamHd3000); int ndx = nelems * percentValue / 100.0; if (ndx < 0) ndx = 0; if (ndx >= nelems) ndx = nelems - 1; @@ -137,8 +137,8 @@ int UsbCameraImpl::PercentageToRaw(const UsbCameraProperty& rawProp, (rawProp.maximum - rawProp.minimum) * (percentValue / 100.0); } -static bool GetDescriptionSysV4L(llvm::StringRef path, std::string* desc) { - llvm::SmallString<64> ifpath{"/sys/class/video4linux/"}; +static bool GetDescriptionSysV4L(wpi::StringRef path, std::string* desc) { + wpi::SmallString<64> ifpath{"/sys/class/video4linux/"}; ifpath += path.substr(5); ifpath += "/device/interface"; @@ -151,7 +151,7 @@ static bool GetDescriptionSysV4L(llvm::StringRef path, std::string* desc) { if (n <= 0) return false; - *desc = llvm::StringRef(readBuf, n).rtrim(); + *desc = wpi::StringRef(readBuf, n).rtrim(); return true; } @@ -167,15 +167,15 @@ static bool GetDescriptionIoctl(const char* cpath, std::string* desc) { } close(fd); - llvm::StringRef card{reinterpret_cast(vcap.card)}; + wpi::StringRef card{reinterpret_cast(vcap.card)}; // try to convert "UVC Camera (0000:0000)" into a better name int vendor = 0; int product = 0; if (card.startswith("UVC Camera (") && !card.substr(12, 4).getAsInteger(16, vendor) && !card.substr(17, 4).getAsInteger(16, product)) { - llvm::SmallString<64> card2Buf; - llvm::StringRef card2 = GetUsbNameFromId(vendor, product, card2Buf); + wpi::SmallString<64> card2Buf; + wpi::StringRef card2 = GetUsbNameFromId(vendor, product, card2Buf); if (!card2.empty()) { *desc = card2; return true; @@ -187,17 +187,17 @@ static bool GetDescriptionIoctl(const char* cpath, std::string* desc) { } static std::string GetDescriptionImpl(const char* cpath) { - llvm::StringRef path{cpath}; + wpi::StringRef path{cpath}; char pathBuf[128]; std::string rv; // If trying to get by id or path, follow symlink if (path.startswith("/dev/v4l/by-id/")) { ssize_t n = readlink(cpath, pathBuf, sizeof(pathBuf)); - if (n > 0) path = llvm::StringRef(pathBuf, n); + if (n > 0) path = wpi::StringRef(pathBuf, n); } else if (path.startswith("/dev/v4l/by-path/")) { ssize_t n = readlink(cpath, pathBuf, sizeof(pathBuf)); - if (n > 0) path = llvm::StringRef(pathBuf, n); + if (n > 0) path = wpi::StringRef(pathBuf, n); } if (path.startswith("/dev/video")) { @@ -211,7 +211,7 @@ static std::string GetDescriptionImpl(const char* cpath) { return std::string{}; } -UsbCameraImpl::UsbCameraImpl(llvm::StringRef name, llvm::StringRef path) +UsbCameraImpl::UsbCameraImpl(wpi::StringRef name, wpi::StringRef path) : SourceImpl{name}, m_path{path}, m_fd{-1}, @@ -258,7 +258,7 @@ void UsbCameraImpl::CameraThreadMain() { int notify_fd = inotify_init(); if (notify_fd >= 0) { // need to make a copy as dirname can modify it - llvm::SmallString<64> pathCopy{m_path}; + wpi::SmallString<64> pathCopy{m_path}; pathCopy.push_back('\0'); if (inotify_add_watch(notify_fd, dirname(pathCopy.data()), IN_CREATE | IN_DELETE) < 0) { @@ -272,9 +272,9 @@ void UsbCameraImpl::CameraThreadMain() { bool notified = (notify_fd < 0); // treat as always notified if cannot notify // Get the basename for later notify use - llvm::SmallString<64> pathCopy{m_path}; + wpi::SmallString<64> pathCopy{m_path}; pathCopy.push_back('\0'); - llvm::SmallString<64> base{basename(pathCopy.data())}; + wpi::SmallString<64> base{basename(pathCopy.data())}; // Used to restart streaming on reconnect bool wasStreaming = false; @@ -341,11 +341,11 @@ void UsbCameraImpl::CameraThreadMain() { // Read the event structure notify_is->read(&event, sizeof(event)); // Read the event name - llvm::SmallString<64> raw_name; + wpi::SmallString<64> raw_name; raw_name.resize(event.len); notify_is->read(raw_name.data(), event.len); // If the name is what we expect... - llvm::StringRef name{raw_name.c_str()}; + wpi::StringRef name{raw_name.c_str()}; SDEBUG4("got event on '" << name << "' (" << name.size() << ") compare to '" << base << "' (" << base.size() << ") mask " << event.mask); @@ -401,7 +401,7 @@ void UsbCameraImpl::CameraThreadMain() { PutFrame(static_cast(m_mode.pixelFormat), m_mode.width, m_mode.height, - llvm::StringRef( + wpi::StringRef( static_cast(m_buffers[buf.index].m_data), static_cast(buf.bytesused)), wpi::Now()); // TODO: time @@ -649,7 +649,7 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty( bool setString = (msg.kind == Message::kCmdSetPropertyStr); int property = msg.data[0]; int value = msg.data[1]; - llvm::StringRef valueStr = msg.dataStr; + wpi::StringRef valueStr = msg.dataStr; // Look up auto prop = static_cast(GetProperty(property)); @@ -885,7 +885,7 @@ void UsbCameraImpl::DeviceCacheProperty( std::unique_ptr perProp; if (IsPercentageProperty(rawProp->name)) { perProp = - llvm::make_unique(rawProp->name, 0, *rawProp, 0, 0); + wpi::make_unique(rawProp->name, 0, *rawProp, 0, 0); rawProp->name = "raw_" + perProp->name; } @@ -1107,8 +1107,8 @@ void UsbCameraImpl::Send(Message&& msg) const { } std::unique_ptr UsbCameraImpl::CreateEmptyProperty( - llvm::StringRef name) const { - return llvm::make_unique(name); + wpi::StringRef name) const { + return wpi::make_unique(name); } bool UsbCameraImpl::CacheProperties(CS_Status* status) const { @@ -1123,8 +1123,8 @@ bool UsbCameraImpl::CacheProperties(CS_Status* status) const { } void UsbCameraImpl::SetQuirks() { - llvm::SmallString<128> descbuf; - llvm::StringRef desc = GetDescription(descbuf); + wpi::SmallString<128> descbuf; + wpi::StringRef desc = GetDescription(descbuf); m_lifecam_exposure = desc.endswith("LifeCam HD-3000") || desc.endswith("LifeCam Cinema (TM)"); } @@ -1136,7 +1136,7 @@ void UsbCameraImpl::SetProperty(int property, int value, CS_Status* status) { *status = SendAndWait(std::move(msg)); } -void UsbCameraImpl::SetStringProperty(int property, llvm::StringRef value, +void UsbCameraImpl::SetStringProperty(int property, wpi::StringRef value, CS_Status* status) { Message msg{Message::kCmdSetPropertyStr}; msg.data[0] = property; @@ -1232,14 +1232,14 @@ void UsbCameraImpl::NumSinksEnabledChanged() { namespace cs { -CS_Source CreateUsbCameraDev(llvm::StringRef name, int dev, CS_Status* status) { - llvm::SmallString<32> path; - llvm::raw_svector_ostream oss{path}; +CS_Source CreateUsbCameraDev(wpi::StringRef name, int dev, CS_Status* status) { + wpi::SmallString<32> path; + wpi::raw_svector_ostream oss{path}; oss << "/dev/video" << dev; return CreateUsbCameraPath(name, oss.str(), status); } -CS_Source CreateUsbCameraPath(llvm::StringRef name, llvm::StringRef path, +CS_Source CreateUsbCameraPath(wpi::StringRef name, wpi::StringRef path, CS_Status* status) { auto source = std::make_shared(name, path); auto handle = Sources::GetInstance().Allocate(CS_SOURCE_USB, source); @@ -1264,13 +1264,13 @@ std::vector EnumerateUsbCameras(CS_Status* status) { if (DIR* dp = opendir("/dev")) { while (struct dirent* ep = readdir(dp)) { - llvm::StringRef fname{ep->d_name}; + wpi::StringRef fname{ep->d_name}; if (!fname.startswith("video")) continue; UsbCameraInfo info; info.dev = -1; fname.substr(5).getAsInteger(10, info.dev); - llvm::SmallString<32> path{"/dev/"}; + wpi::SmallString<32> path{"/dev/"}; path += fname; info.path = path.str(); diff --git a/cscore/src/main/native/cpp/UsbCameraImpl.h b/cscore/src/main/native/cpp/UsbCameraImpl.h index 0e55561699..de449b5e47 100644 --- a/cscore/src/main/native/cpp/UsbCameraImpl.h +++ b/cscore/src/main/native/cpp/UsbCameraImpl.h @@ -19,12 +19,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "SourceImpl.h" #include "UsbCameraBuffer.h" @@ -34,14 +34,14 @@ namespace cs { class UsbCameraImpl : public SourceImpl { public: - UsbCameraImpl(llvm::StringRef name, llvm::StringRef path); + UsbCameraImpl(wpi::StringRef name, wpi::StringRef path); ~UsbCameraImpl() override; void Start(); // Property functions void SetProperty(int property, int value, CS_Status* status) override; - void SetStringProperty(int property, llvm::StringRef value, + void SetStringProperty(int property, wpi::StringRef value, CS_Status* status) override; // Standard common camera properties @@ -93,7 +93,7 @@ class UsbCameraImpl : public SourceImpl { protected: std::unique_ptr CreateEmptyProperty( - llvm::StringRef name) const override; + wpi::StringRef name) const override; // Cache properties. Immediately successful if properties are already cached. // If they are not, tries to connect to the camera to do so; returns false and diff --git a/cscore/src/main/native/cpp/UsbCameraProperty.cpp b/cscore/src/main/native/cpp/UsbCameraProperty.cpp index cc772de7fa..99d91af894 100644 --- a/cscore/src/main/native/cpp/UsbCameraProperty.cpp +++ b/cscore/src/main/native/cpp/UsbCameraProperty.cpp @@ -7,8 +7,8 @@ #include "UsbCameraProperty.h" -#include -#include +#include +#include #include "UsbUtil.h" @@ -92,8 +92,8 @@ static int GetStringCtrlIoctl(int fd, int id, int maximum, std::string* value) { } static int SetStringCtrlIoctl(int fd, int id, int maximum, - llvm::StringRef value) { - llvm::SmallString<64> str{ + wpi::StringRef value) { + wpi::SmallString<64> str{ value.substr(0, std::min(value.size(), static_cast(maximum)))}; struct v4l2_ext_control ctrl; @@ -111,8 +111,8 @@ static int SetStringCtrlIoctl(int fd, int id, int maximum, // Removes non-alphanumeric characters and replaces spaces with underscores. // e.g. "Zoom, Absolute" -> "zoom_absolute", "Pan (Absolute)" -> "pan_absolute" -static llvm::StringRef NormalizeName(llvm::StringRef name, - llvm::SmallVectorImpl& buf) { +static wpi::StringRef NormalizeName(wpi::StringRef name, + wpi::SmallVectorImpl& buf) { bool newWord = false; for (auto ch : name) { if (std::isalnum(ch)) { @@ -123,12 +123,12 @@ static llvm::StringRef NormalizeName(llvm::StringRef name, newWord = true; } } - return llvm::StringRef(buf.data(), buf.size()); + return wpi::StringRef(buf.data(), buf.size()); } #ifdef VIDIOC_QUERY_EXT_CTRL UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl) - : PropertyImpl(llvm::StringRef{}, CS_PROP_NONE, ctrl.step, + : PropertyImpl(wpi::StringRef{}, CS_PROP_NONE, ctrl.step, ctrl.default_value, 0), id(ctrl.id & V4L2_CTRL_ID_MASK), type(ctrl.type) { @@ -160,13 +160,13 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl) // name size_t len = 0; while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len; - llvm::SmallString<64> name_buf; - name = NormalizeName(llvm::StringRef(ctrl.name, len), name_buf); + wpi::SmallString<64> name_buf; + name = NormalizeName(wpi::StringRef(ctrl.name, len), name_buf); } #endif UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl) - : PropertyImpl(llvm::StringRef{}, CS_PROP_NONE, ctrl.step, + : PropertyImpl(wpi::StringRef{}, CS_PROP_NONE, ctrl.step, ctrl.default_value, 0), id(ctrl.id & V4L2_CTRL_ID_MASK), type(ctrl.type) { @@ -198,9 +198,9 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl) // name size_t len = 0; while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len; - llvm::SmallString<64> name_buf; + wpi::SmallString<64> name_buf; name = NormalizeName( - llvm::StringRef(reinterpret_cast(ctrl.name), len), name_buf); + wpi::StringRef(reinterpret_cast(ctrl.name), len), name_buf); } std::unique_ptr UsbCameraProperty::DeviceQuery(int fd, @@ -216,7 +216,7 @@ std::unique_ptr UsbCameraProperty::DeviceQuery(int fd, *id = qc_ext.id; // copy back // We don't support array types if (qc_ext.elems > 1 || qc_ext.nr_of_dims > 0) return nullptr; - prop = llvm::make_unique(qc_ext); + prop = wpi::make_unique(qc_ext); } #endif if (!prop) { @@ -227,7 +227,7 @@ std::unique_ptr UsbCameraProperty::DeviceQuery(int fd, rc = TryIoctl(fd, VIDIOC_QUERYCTRL, &qc); *id = qc.id; // copy back if (rc != 0) return nullptr; - prop = llvm::make_unique(qc); + prop = wpi::make_unique(qc); } // Cache enum property choices @@ -282,13 +282,13 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock& lock, int fd) { bool UsbCameraProperty::DeviceSet(std::unique_lock& lock, int fd) const { // Make a copy of the string as we're about to release the lock - llvm::SmallString<128> valueStrCopy{valueStr}; + wpi::SmallString<128> valueStrCopy{valueStr}; return DeviceSet(lock, fd, value, valueStrCopy); } bool UsbCameraProperty::DeviceSet(std::unique_lock& lock, int fd, int newValue, - llvm::StringRef newValueStr) const { + wpi::StringRef newValueStr) const { if (fd < 0) return true; unsigned idCopy = id; int rv = 0; diff --git a/cscore/src/main/native/cpp/UsbCameraProperty.h b/cscore/src/main/native/cpp/UsbCameraProperty.h index 8f9d966fca..8c774aee23 100644 --- a/cscore/src/main/native/cpp/UsbCameraProperty.h +++ b/cscore/src/main/native/cpp/UsbCameraProperty.h @@ -14,7 +14,7 @@ #include -#include +#include #include "PropertyImpl.h" @@ -24,10 +24,10 @@ namespace cs { class UsbCameraProperty : public PropertyImpl { public: UsbCameraProperty() = default; - explicit UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {} + explicit UsbCameraProperty(wpi::StringRef name_) : PropertyImpl{name_} {} // Normalized property constructor - UsbCameraProperty(llvm::StringRef name_, int rawIndex_, + UsbCameraProperty(wpi::StringRef name_, int rawIndex_, const UsbCameraProperty& rawProp, int defaultValue_, int value_) : PropertyImpl(name_, rawProp.propKind, 1, defaultValue_, value_), @@ -52,7 +52,7 @@ class UsbCameraProperty : public PropertyImpl { bool DeviceGet(std::unique_lock& lock, int fd); bool DeviceSet(std::unique_lock& lock, int fd) const; bool DeviceSet(std::unique_lock& lock, int fd, int newValue, - llvm::StringRef newValueStr) const; + wpi::StringRef newValueStr) const; #endif // If this is a percentage (rather than raw) property diff --git a/cscore/src/main/native/cpp/UsbUtil.cpp b/cscore/src/main/native/cpp/UsbUtil.cpp index 1c6a045434..07b8eddf29 100644 --- a/cscore/src/main/native/cpp/UsbUtil.cpp +++ b/cscore/src/main/native/cpp/UsbUtil.cpp @@ -14,10 +14,10 @@ #include #endif -#include -#include -#include -#include +#include +#include +#include +#include #include "Log.h" @@ -25,22 +25,22 @@ namespace cs { #ifdef __linux__ -static llvm::StringRef GetUsbNameFromFile(int vendor, int product, - llvm::SmallVectorImpl& buf) { +static wpi::StringRef GetUsbNameFromFile(int vendor, int product, + wpi::SmallVectorImpl& buf) { int fd = open("/var/lib/usbutils/usb.ids", O_RDONLY); - if (fd < 0) return llvm::StringRef{}; + if (fd < 0) return wpi::StringRef{}; - llvm::raw_svector_ostream os{buf}; + wpi::raw_svector_ostream os{buf}; wpi::raw_fd_istream is{fd, true}; // build vendor and product 4-char hex strings - llvm::SmallString<16> vendorStr, productStr; - llvm::raw_svector_ostream vendorOs{vendorStr}, productOs{productStr}; - vendorOs << llvm::format_hex_no_prefix(vendor, 4); - productOs << llvm::format_hex_no_prefix(product, 4); + wpi::SmallString<16> vendorStr, productStr; + wpi::raw_svector_ostream vendorOs{vendorStr}, productOs{productStr}; + vendorOs << wpi::format_hex_no_prefix(vendor, 4); + productOs << wpi::format_hex_no_prefix(product, 4); // scan file - llvm::SmallString<128> lineBuf; + wpi::SmallString<128> lineBuf; bool foundVendor = false; for (;;) { auto line = is.getline(lineBuf, 4096); @@ -70,17 +70,17 @@ static llvm::StringRef GetUsbNameFromFile(int vendor, int product, } } - return llvm::StringRef{}; + return wpi::StringRef{}; } -llvm::StringRef GetUsbNameFromId(int vendor, int product, - llvm::SmallVectorImpl& buf) { +wpi::StringRef GetUsbNameFromId(int vendor, int product, + wpi::SmallVectorImpl& buf) { // try reading usb.ids - llvm::StringRef rv = GetUsbNameFromFile(vendor, product, buf); + wpi::StringRef rv = GetUsbNameFromFile(vendor, product, buf); if (!rv.empty()) return rv; // Fall back to internal database - llvm::raw_svector_ostream os{buf}; + wpi::raw_svector_ostream os{buf}; switch (vendor) { case 0x046d: os << "Logitech, Inc. "; @@ -153,7 +153,7 @@ int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int) const char* name, const char* file, int line, bool quiet) { int retval = ioctl(fd, req, data); if (!quiet && retval < 0) { - llvm::SmallString<64> localfile{file}; + wpi::SmallString<64> localfile{file}; localfile.push_back('\0'); ERROR("ioctl " << name << " failed at " << basename(localfile.data()) << ":" << line << ": " << std::strerror(errno)); diff --git a/cscore/src/main/native/cpp/UsbUtil.h b/cscore/src/main/native/cpp/UsbUtil.h index 695fbd5abc..6ecb0a8afa 100644 --- a/cscore/src/main/native/cpp/UsbUtil.h +++ b/cscore/src/main/native/cpp/UsbUtil.h @@ -10,15 +10,15 @@ #include -#include -#include +#include +#include namespace cs { #ifdef __linux__ -llvm::StringRef GetUsbNameFromId(int vendor, int product, - llvm::SmallVectorImpl& buf); +wpi::StringRef GetUsbNameFromId(int vendor, int product, + wpi::SmallVectorImpl& buf); int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int) const char* name, const char* file, int line, bool quiet); diff --git a/cscore/src/main/native/cpp/c_util.h b/cscore/src/main/native/cpp/c_util.h index d8d7e0d4ba..8e2b0349bc 100644 --- a/cscore/src/main/native/cpp/c_util.h +++ b/cscore/src/main/native/cpp/c_util.h @@ -11,11 +11,11 @@ #include #include -#include +#include namespace cs { -inline char* ConvertToC(llvm::StringRef in) { +inline char* ConvertToC(wpi::StringRef in) { char* out = static_cast(std::malloc(in.size() + 1)); std::memmove(out, in.data(), in.size()); out[in.size()] = '\0'; diff --git a/cscore/src/main/native/cpp/cscore_c.cpp b/cscore/src/main/native/cpp/cscore_c.cpp index aea42fb34b..335e7b142e 100644 --- a/cscore/src/main/native/cpp/cscore_c.cpp +++ b/cscore/src/main/native/cpp/cscore_c.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include "c_util.h" #include "cscore_cpp.h" @@ -23,7 +23,7 @@ CS_PropertyKind CS_GetPropertyKind(CS_Property property, CS_Status* status) { } char* CS_GetPropertyName(CS_Property property, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetPropertyName(property, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); @@ -54,7 +54,7 @@ int CS_GetPropertyDefault(CS_Property property, CS_Status* status) { } char* CS_GetStringProperty(CS_Property property, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetStringProperty(property, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); @@ -80,14 +80,14 @@ CS_SourceKind CS_GetSourceKind(CS_Source source, CS_Status* status) { } char* CS_GetSourceName(CS_Source source, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSourceName(source, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); } char* CS_GetSourceDescription(CS_Source source, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSourceDescription(source, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); @@ -108,7 +108,7 @@ CS_Property CS_GetSourceProperty(CS_Source source, const char* name, CS_Property* CS_EnumerateSourceProperties(CS_Source source, int* count, CS_Status* status) { - llvm::SmallVector buf; + wpi::SmallVector buf; auto vec = cs::EnumerateSourceProperties(source, buf, status); CS_Property* out = static_cast(std::malloc(vec.size() * sizeof(CS_Property))); @@ -170,7 +170,7 @@ CS_VideoMode* CS_EnumerateSourceVideoModes(CS_Source source, int* count, CS_Sink* CS_EnumerateSourceSinks(CS_Source source, int* count, CS_Status* status) { - llvm::SmallVector buf; + wpi::SmallVector buf; auto handles = cs::EnumerateSourceSinks(source, buf, status); CS_Sink* sinks = static_cast(std::malloc(handles.size() * sizeof(CS_Sink))); @@ -227,14 +227,14 @@ CS_SinkKind CS_GetSinkKind(CS_Sink sink, CS_Status* status) { } char* CS_GetSinkName(CS_Sink sink, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkName(sink, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); } char* CS_GetSinkDescription(CS_Sink sink, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkDescription(sink, buf, status); if (*status != 0) return nullptr; return cs::ConvertToC(str); @@ -321,7 +321,7 @@ void CS_SetDefaultLogger(unsigned int min_level) { } CS_Source* CS_EnumerateSources(int* count, CS_Status* status) { - llvm::SmallVector buf; + wpi::SmallVector buf; auto handles = cs::EnumerateSourceHandles(buf, status); CS_Source* sources = static_cast(std::malloc(handles.size() * sizeof(CS_Source))); @@ -340,7 +340,7 @@ void CS_ReleaseEnumeratedSources(CS_Source* sources, int count) { } CS_Sink* CS_EnumerateSinks(int* count, CS_Status* status) { - llvm::SmallVector buf; + wpi::SmallVector buf; auto handles = cs::EnumerateSinkHandles(buf, status); CS_Sink* sinks = static_cast(std::malloc(handles.size() * sizeof(CS_Sink))); diff --git a/cscore/src/main/native/cpp/cscore_cpp.cpp b/cscore/src/main/native/cpp/cscore_cpp.cpp index b4a532a6db..fb5abfec4b 100644 --- a/cscore/src/main/native/cpp/cscore_cpp.cpp +++ b/cscore/src/main/native/cpp/cscore_cpp.cpp @@ -14,7 +14,7 @@ #include #endif -#include +#include #include "Handle.h" #include "Log.h" @@ -58,19 +58,19 @@ CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status) { } std::string GetPropertyName(CS_Property property, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; int propertyIndex; auto source = GetPropertySource(property, &propertyIndex, status); if (!source) return std::string{}; return source->GetPropertyName(propertyIndex, buf, status); } -llvm::StringRef GetPropertyName(CS_Property property, - llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetPropertyName(CS_Property property, + wpi::SmallVectorImpl& buf, + CS_Status* status) { int propertyIndex; auto source = GetPropertySource(property, &propertyIndex, status); - if (!source) return llvm::StringRef{}; + if (!source) return wpi::StringRef{}; return source->GetPropertyName(propertyIndex, buf, status); } @@ -117,23 +117,23 @@ int GetPropertyDefault(CS_Property property, CS_Status* status) { } std::string GetStringProperty(CS_Property property, CS_Status* status) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; int propertyIndex; auto source = GetPropertySource(property, &propertyIndex, status); if (!source) return std::string{}; return source->GetStringProperty(propertyIndex, buf, status); } -llvm::StringRef GetStringProperty(CS_Property property, - llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetStringProperty(CS_Property property, + wpi::SmallVectorImpl& buf, + CS_Status* status) { int propertyIndex; auto source = GetPropertySource(property, &propertyIndex, status); - if (!source) return llvm::StringRef{}; + if (!source) return wpi::StringRef{}; return source->GetStringProperty(propertyIndex, buf, status); } -void SetStringProperty(CS_Property property, llvm::StringRef value, +void SetStringProperty(CS_Property property, wpi::StringRef value, CS_Status* status) { int propertyIndex; auto source = GetPropertySource(property, &propertyIndex, status); @@ -171,13 +171,13 @@ std::string GetSourceName(CS_Source source, CS_Status* status) { return data->source->GetName(); } -llvm::StringRef GetSourceName(CS_Source source, - llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetSourceName(CS_Source source, + wpi::SmallVectorImpl& buf, + CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { *status = CS_INVALID_HANDLE; - return llvm::StringRef{}; + return wpi::StringRef{}; } return data->source->GetName(); } @@ -188,17 +188,17 @@ std::string GetSourceDescription(CS_Source source, CS_Status* status) { *status = CS_INVALID_HANDLE; return std::string{}; } - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; return data->source->GetDescription(buf); } -llvm::StringRef GetSourceDescription(CS_Source source, - llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetSourceDescription(CS_Source source, + wpi::SmallVectorImpl& buf, + CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { *status = CS_INVALID_HANDLE; - return llvm::StringRef{}; + return wpi::StringRef{}; } return data->source->GetDescription(buf); } @@ -221,7 +221,7 @@ bool IsSourceConnected(CS_Source source, CS_Status* status) { return data->source->IsConnected(); } -CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name, +CS_Property GetSourceProperty(CS_Source source, wpi::StringRef name, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { @@ -236,15 +236,15 @@ CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name, return Handle{source, property, Handle::kProperty}; } -llvm::ArrayRef EnumerateSourceProperties( - CS_Source source, llvm::SmallVectorImpl& vec, +wpi::ArrayRef EnumerateSourceProperties( + CS_Source source, wpi::SmallVectorImpl& vec, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { *status = CS_INVALID_HANDLE; return 0; } - llvm::SmallVector properties_buf; + wpi::SmallVector properties_buf; for (auto property : data->source->EnumerateProperties(properties_buf, status)) vec.push_back(Handle{source, property, Handle::kProperty}); @@ -309,12 +309,12 @@ std::vector EnumerateSourceVideoModes(CS_Source source, return data->source->EnumerateVideoModes(status); } -llvm::ArrayRef EnumerateSourceSinks( - CS_Source source, llvm::SmallVectorImpl& vec, CS_Status* status) { +wpi::ArrayRef EnumerateSourceSinks( + CS_Source source, wpi::SmallVectorImpl& vec, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { *status = CS_INVALID_HANDLE; - return llvm::ArrayRef{}; + return wpi::ArrayRef{}; } vec.clear(); Sinks::GetInstance().ForEach([&](CS_Sink sinkHandle, const SinkData& data) { @@ -448,12 +448,12 @@ std::string GetSinkName(CS_Sink sink, CS_Status* status) { return data->sink->GetName(); } -llvm::StringRef GetSinkName(CS_Sink sink, llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetSinkName(CS_Sink sink, wpi::SmallVectorImpl& buf, + CS_Status* status) { auto data = Sinks::GetInstance().Get(sink); if (!data) { *status = CS_INVALID_HANDLE; - return llvm::StringRef{}; + return wpi::StringRef{}; } return data->sink->GetName(); } @@ -464,17 +464,17 @@ std::string GetSinkDescription(CS_Sink sink, CS_Status* status) { *status = CS_INVALID_HANDLE; return std::string{}; } - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; return data->sink->GetDescription(buf); } -llvm::StringRef GetSinkDescription(CS_Sink sink, - llvm::SmallVectorImpl& buf, - CS_Status* status) { +wpi::StringRef GetSinkDescription(CS_Sink sink, + wpi::SmallVectorImpl& buf, + CS_Status* status) { auto data = Sinks::GetInstance().Get(sink); if (!data) { *status = CS_INVALID_HANDLE; - return llvm::StringRef{}; + return wpi::StringRef{}; } return data->sink->GetDescription(buf); } @@ -509,7 +509,7 @@ CS_Source GetSinkSource(CS_Sink sink, CS_Status* status) { return data->sourceHandle.load(); } -CS_Property GetSinkSourceProperty(CS_Sink sink, llvm::StringRef name, +CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name, CS_Status* status) { auto data = Sinks::GetInstance().Get(sink); if (!data) { @@ -625,13 +625,13 @@ void SetDefaultLogger(unsigned int min_level) { // Utility Functions // -llvm::ArrayRef EnumerateSourceHandles( - llvm::SmallVectorImpl& vec, CS_Status* status) { +wpi::ArrayRef EnumerateSourceHandles( + wpi::SmallVectorImpl& vec, CS_Status* status) { return Sources::GetInstance().GetAll(vec); } -llvm::ArrayRef EnumerateSinkHandles( - llvm::SmallVectorImpl& vec, CS_Status* status) { +wpi::ArrayRef EnumerateSinkHandles( + wpi::SmallVectorImpl& vec, CS_Status* status) { return Sinks::GetInstance().GetAll(vec); } diff --git a/cscore/src/main/native/cpp/cscore_oo.cpp b/cscore/src/main/native/cpp/cscore_oo.cpp index d4a01cd924..29213130fb 100644 --- a/cscore/src/main/native/cpp/cscore_oo.cpp +++ b/cscore/src/main/native/cpp/cscore_oo.cpp @@ -10,7 +10,7 @@ using namespace cs; std::vector VideoSource::EnumerateProperties() const { - llvm::SmallVector handles_buf; + wpi::SmallVector handles_buf; CS_Status status = 0; auto handles = EnumerateSourceProperties(m_handle, handles_buf, &status); @@ -22,7 +22,7 @@ std::vector VideoSource::EnumerateProperties() const { } std::vector VideoSource::EnumerateSinks() { - llvm::SmallVector handles_buf; + wpi::SmallVector handles_buf; CS_Status status = 0; auto handles = EnumerateSourceSinks(m_handle, handles_buf, &status); @@ -33,7 +33,7 @@ std::vector VideoSource::EnumerateSinks() { } std::vector VideoSource::EnumerateSources() { - llvm::SmallVector handles_buf; + wpi::SmallVector handles_buf; CS_Status status = 0; auto handles = ::cs::EnumerateSourceHandles(handles_buf, &status); @@ -44,7 +44,7 @@ std::vector VideoSource::EnumerateSources() { } std::vector VideoSink::EnumerateSinks() { - llvm::SmallVector handles_buf; + wpi::SmallVector handles_buf; CS_Status status = 0; auto handles = ::cs::EnumerateSinkHandles(handles_buf, &status); diff --git a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp index 38962cebc7..b5b5f77f2d 100644 --- a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp +++ b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp @@ -5,9 +5,9 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include -#include -#include +#include +#include +#include #include "cscore_cpp.h" #include "edu_wpi_cscore_CameraServerJNI.h" @@ -132,7 +132,7 @@ class JCSGlobal { static void ReportError(JNIEnv* env, CS_Status status) { if (status == CS_OK) return; - llvm::SmallString<64> msg; + wpi::SmallString<64> msg; switch (status) { case CS_PROPERTY_WRITE_FAILED: msg = "property write failed"; @@ -165,7 +165,7 @@ static void ReportError(JNIEnv* env, CS_Status status) { msg = "telemetry not enabled"; break; default: { - llvm::raw_svector_ostream oss{msg}; + wpi::raw_svector_ostream oss{msg}; oss << "unknown error code=" << status; break; } @@ -248,7 +248,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyName (JNIEnv* env, jclass, jint property) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetPropertyName(property, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -346,7 +346,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getStringProperty (JNIEnv* env, jclass, jint property) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetStringProperty(property, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -475,7 +475,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti return 0; } size_t len = env->GetArrayLength(urls); - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(len); for (size_t i = 0; i < len; ++i) { JLocal elem{ @@ -541,7 +541,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceName (JNIEnv* env, jclass, jint source) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSourceName(source, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -556,7 +556,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceDescripti (JNIEnv* env, jclass, jint source) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSourceDescription(source, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -617,7 +617,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceP (JNIEnv* env, jclass, jint source) { CS_Status status = 0; - llvm::SmallVector buf; + wpi::SmallVector buf; auto arr = cs::EnumerateSourceProperties(source, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJIntArray(env, arr); @@ -728,7 +728,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceS (JNIEnv* env, jclass, jint source) { CS_Status status = 0; - llvm::SmallVector buf; + wpi::SmallVector buf; auto arr = cs::EnumerateSourceSinks(source, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJIntArray(env, arr); @@ -912,7 +912,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls return; } size_t len = env->GetArrayLength(urls); - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(len); for (size_t i = 0; i < len; ++i) { JLocal elem{ @@ -1033,7 +1033,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumProperty return; } size_t len = env->GetArrayLength(choices); - llvm::SmallVector vec; + wpi::SmallVector vec; vec.reserve(len); for (size_t i = 0; i < len; ++i) { JLocal elem{ @@ -1113,7 +1113,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkName (JNIEnv* env, jclass, jint sink) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkName(sink, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -1128,7 +1128,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription (JNIEnv* env, jclass, jint sink) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkDescription(sink, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -1290,7 +1290,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkError (JNIEnv* env, jclass, jint sink) { CS_Status status = 0; - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; auto str = cs::GetSinkError(sink, buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJString(env, str); @@ -1464,7 +1464,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSources (JNIEnv* env, jclass) { CS_Status status = 0; - llvm::SmallVector buf; + wpi::SmallVector buf; auto arr = cs::EnumerateSourceHandles(buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJIntArray(env, arr); @@ -1479,7 +1479,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks (JNIEnv* env, jclass) { CS_Status status = 0; - llvm::SmallVector buf; + wpi::SmallVector buf; auto arr = cs::EnumerateSinkHandles(buf, &status); if (!CheckStatus(env, status)) return nullptr; return MakeJIntArray(env, arr); diff --git a/cscore/src/main/native/include/cscore_cpp.h b/cscore/src/main/native/include/cscore_cpp.h index 99e847ba4a..5cba871b6f 100644 --- a/cscore/src/main/native/include/cscore_cpp.h +++ b/cscore/src/main/native/include/cscore_cpp.h @@ -14,9 +14,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "cscore_c.h" @@ -90,7 +90,7 @@ struct RawEvent { RawEvent() = default; explicit RawEvent(RawEvent::Kind kind_) : kind{kind_} {} - RawEvent(llvm::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_) + RawEvent(wpi::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_) : kind{kind_}, name{name_} { if (kind_ == kSinkCreated || kind_ == kSinkDestroyed || kind_ == kSinkEnabled || kind_ == kSinkDisabled) @@ -98,14 +98,14 @@ struct RawEvent { else sourceHandle = handle_; } - RawEvent(llvm::StringRef name_, CS_Source source_, const VideoMode& mode_) + RawEvent(wpi::StringRef name_, CS_Source source_, const VideoMode& mode_) : kind{kSourceVideoModeChanged}, sourceHandle{source_}, name{name_}, mode{mode_} {} - RawEvent(llvm::StringRef name_, CS_Source source_, RawEvent::Kind kind_, + RawEvent(wpi::StringRef name_, CS_Source source_, RawEvent::Kind kind_, CS_Property property_, CS_PropertyKind propertyKind_, int value_, - llvm::StringRef valueStr_) + wpi::StringRef valueStr_) : kind{kind_}, sourceHandle{source_}, name{name_}, @@ -138,9 +138,9 @@ struct RawEvent { // CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status); std::string GetPropertyName(CS_Property property, CS_Status* status); -llvm::StringRef GetPropertyName(CS_Property property, - llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetPropertyName(CS_Property property, + wpi::SmallVectorImpl& buf, + CS_Status* status); int GetProperty(CS_Property property, CS_Status* status); void SetProperty(CS_Property property, int value, CS_Status* status); int GetPropertyMin(CS_Property property, CS_Status* status); @@ -148,10 +148,10 @@ int GetPropertyMax(CS_Property property, CS_Status* status); int GetPropertyStep(CS_Property property, CS_Status* status); int GetPropertyDefault(CS_Property property, CS_Status* status); std::string GetStringProperty(CS_Property property, CS_Status* status); -llvm::StringRef GetStringProperty(CS_Property property, - llvm::SmallVectorImpl& buf, - CS_Status* status); -void SetStringProperty(CS_Property property, llvm::StringRef value, +wpi::StringRef GetStringProperty(CS_Property property, + wpi::SmallVectorImpl& buf, + CS_Status* status); +void SetStringProperty(CS_Property property, wpi::StringRef value, CS_Status* status); std::vector GetEnumPropertyChoices(CS_Property property, CS_Status* status); @@ -159,15 +159,15 @@ std::vector GetEnumPropertyChoices(CS_Property property, // // Source Creation Functions // -CS_Source CreateUsbCameraDev(llvm::StringRef name, int dev, CS_Status* status); -CS_Source CreateUsbCameraPath(llvm::StringRef name, llvm::StringRef path, +CS_Source CreateUsbCameraDev(wpi::StringRef name, int dev, CS_Status* status); +CS_Source CreateUsbCameraPath(wpi::StringRef name, wpi::StringRef path, CS_Status* status); -CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url, +CS_Source CreateHttpCamera(wpi::StringRef name, wpi::StringRef url, CS_HttpCameraKind kind, CS_Status* status); -CS_Source CreateHttpCamera(llvm::StringRef name, - llvm::ArrayRef urls, +CS_Source CreateHttpCamera(wpi::StringRef name, + wpi::ArrayRef urls, CS_HttpCameraKind kind, CS_Status* status); -CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode, +CS_Source CreateCvSource(wpi::StringRef name, const VideoMode& mode, CS_Status* status); // @@ -175,19 +175,19 @@ CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode, // CS_SourceKind GetSourceKind(CS_Source source, CS_Status* status); std::string GetSourceName(CS_Source source, CS_Status* status); -llvm::StringRef GetSourceName(CS_Source source, - llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetSourceName(CS_Source source, + wpi::SmallVectorImpl& buf, + CS_Status* status); std::string GetSourceDescription(CS_Source source, CS_Status* status); -llvm::StringRef GetSourceDescription(CS_Source source, - llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetSourceDescription(CS_Source source, + wpi::SmallVectorImpl& buf, + CS_Status* status); uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status); bool IsSourceConnected(CS_Source source, CS_Status* status); -CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name, +CS_Property GetSourceProperty(CS_Source source, wpi::StringRef name, CS_Status* status); -llvm::ArrayRef EnumerateSourceProperties( - CS_Source source, llvm::SmallVectorImpl& vec, +wpi::ArrayRef EnumerateSourceProperties( + CS_Source source, wpi::SmallVectorImpl& vec, CS_Status* status); VideoMode GetSourceVideoMode(CS_Source source, CS_Status* status); bool SetSourceVideoMode(CS_Source source, const VideoMode& mode, @@ -199,8 +199,8 @@ bool SetSourceResolution(CS_Source source, int width, int height, bool SetSourceFPS(CS_Source source, int fps, CS_Status* status); std::vector EnumerateSourceVideoModes(CS_Source source, CS_Status* status); -llvm::ArrayRef EnumerateSourceSinks( - CS_Source source, llvm::SmallVectorImpl& vec, CS_Status* status); +wpi::ArrayRef EnumerateSourceSinks( + CS_Source source, wpi::SmallVectorImpl& vec, CS_Status* status); CS_Source CopySource(CS_Source source, CS_Status* status); void ReleaseSource(CS_Source source, CS_Status* status); @@ -226,7 +226,7 @@ std::string GetUsbCameraPath(CS_Source source, CS_Status* status); // HttpCamera Source Functions // CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status); -void SetHttpCameraUrls(CS_Source source, llvm::ArrayRef urls, +void SetHttpCameraUrls(CS_Source source, wpi::ArrayRef urls, CS_Status* status); std::vector GetHttpCameraUrls(CS_Source source, CS_Status* status); @@ -234,26 +234,26 @@ std::vector GetHttpCameraUrls(CS_Source source, CS_Status* status); // OpenCV Source Functions // void PutSourceFrame(CS_Source source, cv::Mat& image, CS_Status* status); -void NotifySourceError(CS_Source source, llvm::StringRef msg, +void NotifySourceError(CS_Source source, wpi::StringRef msg, CS_Status* status); void SetSourceConnected(CS_Source source, bool connected, CS_Status* status); -void SetSourceDescription(CS_Source source, llvm::StringRef description, +void SetSourceDescription(CS_Source source, wpi::StringRef description, CS_Status* status); -CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name, +CS_Property CreateSourceProperty(CS_Source source, wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, CS_Status* status); void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property, - llvm::ArrayRef choices, + wpi::ArrayRef choices, CS_Status* status); // // Sink Creation Functions // -CS_Sink CreateMjpegServer(llvm::StringRef name, llvm::StringRef listenAddress, +CS_Sink CreateMjpegServer(wpi::StringRef name, wpi::StringRef listenAddress, int port, CS_Status* status); -CS_Sink CreateCvSink(llvm::StringRef name, CS_Status* status); -CS_Sink CreateCvSinkCallback(llvm::StringRef name, +CS_Sink CreateCvSink(wpi::StringRef name, CS_Status* status); +CS_Sink CreateCvSinkCallback(wpi::StringRef name, std::function processFrame, CS_Status* status); @@ -262,14 +262,14 @@ CS_Sink CreateCvSinkCallback(llvm::StringRef name, // CS_SinkKind GetSinkKind(CS_Sink sink, CS_Status* status); std::string GetSinkName(CS_Sink sink, CS_Status* status); -llvm::StringRef GetSinkName(CS_Sink sink, llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetSinkName(CS_Sink sink, wpi::SmallVectorImpl& buf, + CS_Status* status); std::string GetSinkDescription(CS_Sink sink, CS_Status* status); -llvm::StringRef GetSinkDescription(CS_Sink sink, - llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetSinkDescription(CS_Sink sink, + wpi::SmallVectorImpl& buf, + CS_Status* status); void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status); -CS_Property GetSinkSourceProperty(CS_Sink sink, llvm::StringRef name, +CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name, CS_Status* status); CS_Source GetSinkSource(CS_Sink sink, CS_Status* status); CS_Sink CopySink(CS_Sink sink, CS_Status* status); @@ -284,14 +284,14 @@ int GetMjpegServerPort(CS_Sink sink, CS_Status* status); // // OpenCV Sink Functions // -void SetSinkDescription(CS_Sink sink, llvm::StringRef description, +void SetSinkDescription(CS_Sink sink, wpi::StringRef description, CS_Status* status); uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat& image, CS_Status* status); uint64_t GrabSinkFrameTimeout(CS_Sink sink, cv::Mat& image, double timeout, CS_Status* status); std::string GetSinkError(CS_Sink sink, CS_Status* status); -llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl& buf, - CS_Status* status); +wpi::StringRef GetSinkError(CS_Sink sink, wpi::SmallVectorImpl& buf, + CS_Status* status); void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status* status); // @@ -331,10 +331,10 @@ void SetDefaultLogger(unsigned int min_level); // std::vector EnumerateUsbCameras(CS_Status* status); -llvm::ArrayRef EnumerateSourceHandles( - llvm::SmallVectorImpl& vec, CS_Status* status); -llvm::ArrayRef EnumerateSinkHandles( - llvm::SmallVectorImpl& vec, CS_Status* status); +wpi::ArrayRef EnumerateSourceHandles( + wpi::SmallVectorImpl& vec, CS_Status* status); +wpi::ArrayRef EnumerateSinkHandles( + wpi::SmallVectorImpl& vec, CS_Status* status); std::string GetHostname(); diff --git a/cscore/src/main/native/include/cscore_oo.h b/cscore/src/main/native/include/cscore_oo.h index 7fc0d7fb91..34858f6ccd 100644 --- a/cscore/src/main/native/include/cscore_oo.h +++ b/cscore/src/main/native/include/cscore_oo.h @@ -65,8 +65,8 @@ class VideoProperty { // String-specific functions std::string GetString() const; - llvm::StringRef GetString(llvm::SmallVectorImpl& buf) const; - void SetString(llvm::StringRef value); + wpi::StringRef GetString(wpi::SmallVectorImpl& buf) const; + void SetString(wpi::StringRef value); // Enum-specific functions std::vector GetChoices() const; @@ -133,7 +133,7 @@ class VideoSource { /// @param name Property name /// @return Property contents (of kind Property::kNone if no property with /// the given name exists) - VideoProperty GetProperty(llvm::StringRef name); + VideoProperty GetProperty(wpi::StringRef name); /// Enumerate all properties of this source. std::vector EnumerateProperties() const; @@ -255,12 +255,12 @@ class UsbCamera : public VideoCamera { /// Create a source for a USB camera based on device number. /// @param name Source name (arbitrary unique identifier) /// @param dev Device number (e.g. 0 for /dev/video0) - UsbCamera(llvm::StringRef name, int dev); + UsbCamera(wpi::StringRef name, int dev); /// Create a source for a USB camera based on device path. /// @param name Source name (arbitrary unique identifier) /// @param path Path to device (e.g. "/dev/video0" on Linux) - UsbCamera(llvm::StringRef name, llvm::StringRef path); + UsbCamera(wpi::StringRef name, wpi::StringRef path); /// Enumerate USB cameras on the local system. /// @return Vector of USB camera information (one for each camera) @@ -284,28 +284,28 @@ class HttpCamera : public VideoCamera { /// @param name Source name (arbitrary unique identifier) /// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg") /// @param kind Camera kind (e.g. kAxis) - HttpCamera(llvm::StringRef name, llvm::StringRef url, + HttpCamera(wpi::StringRef name, wpi::StringRef url, HttpCameraKind kind = kUnknown); /// Create a source for a MJPEG-over-HTTP (IP) camera. /// @param name Source name (arbitrary unique identifier) /// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg") /// @param kind Camera kind (e.g. kAxis) - HttpCamera(llvm::StringRef name, const char* url, + HttpCamera(wpi::StringRef name, const char* url, HttpCameraKind kind = kUnknown); /// Create a source for a MJPEG-over-HTTP (IP) camera. /// @param name Source name (arbitrary unique identifier) /// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg") /// @param kind Camera kind (e.g. kAxis) - HttpCamera(llvm::StringRef name, const std::string& url, + HttpCamera(wpi::StringRef name, const std::string& url, HttpCameraKind kind = kUnknown); /// Create a source for a MJPEG-over-HTTP (IP) camera. /// @param name Source name (arbitrary unique identifier) /// @param urls Array of Camera URLs /// @param kind Camera kind (e.g. kAxis) - HttpCamera(llvm::StringRef name, llvm::ArrayRef urls, + HttpCamera(wpi::StringRef name, wpi::ArrayRef urls, HttpCameraKind kind = kUnknown); /// Create a source for a MJPEG-over-HTTP (IP) camera. @@ -313,7 +313,7 @@ class HttpCamera : public VideoCamera { /// @param urls Array of Camera URLs /// @param kind Camera kind (e.g. kAxis) template - HttpCamera(llvm::StringRef name, std::initializer_list urls, + HttpCamera(wpi::StringRef name, std::initializer_list urls, HttpCameraKind kind = kUnknown); /// Get the kind of HTTP camera. @@ -322,7 +322,7 @@ class HttpCamera : public VideoCamera { HttpCameraKind GetHttpCameraKind() const; /// Change the URLs used to connect to the camera. - void SetUrls(llvm::ArrayRef urls); + void SetUrls(wpi::ArrayRef urls); /// Change the URLs used to connect to the camera. template @@ -334,8 +334,8 @@ class HttpCamera : public VideoCamera { /// A source that represents an Axis IP camera. class AxisCamera : public HttpCamera { - static std::string HostToUrl(llvm::StringRef host); - static std::vector HostToUrl(llvm::ArrayRef hosts); + static std::string HostToUrl(wpi::StringRef host); + static std::vector HostToUrl(wpi::ArrayRef hosts); template static std::vector HostToUrl(std::initializer_list hosts); @@ -344,32 +344,32 @@ class AxisCamera : public HttpCamera { /// @param name Source name (arbitrary unique identifier) /// @param host Camera host IP or DNS name (e.g. "10.x.y.11") /// @param kind Camera kind (e.g. kAxis) - AxisCamera(llvm::StringRef name, llvm::StringRef host); + AxisCamera(wpi::StringRef name, wpi::StringRef host); /// Create a source for an Axis IP camera. /// @param name Source name (arbitrary unique identifier) /// @param host Camera host IP or DNS name (e.g. "10.x.y.11") /// @param kind Camera kind (e.g. kAxis) - AxisCamera(llvm::StringRef name, const char* host); + AxisCamera(wpi::StringRef name, const char* host); /// Create a source for an Axis IP camera. /// @param name Source name (arbitrary unique identifier) /// @param host Camera host IP or DNS name (e.g. "10.x.y.11") /// @param kind Camera kind (e.g. kAxis) - AxisCamera(llvm::StringRef name, const std::string& host); + AxisCamera(wpi::StringRef name, const std::string& host); /// Create a source for an Axis IP camera. /// @param name Source name (arbitrary unique identifier) /// @param hosts Array of Camera host IPs/DNS names /// @param kind Camera kind (e.g. kAxis) - AxisCamera(llvm::StringRef name, llvm::ArrayRef hosts); + AxisCamera(wpi::StringRef name, wpi::ArrayRef hosts); /// Create a source for an Axis IP camera. /// @param name Source name (arbitrary unique identifier) /// @param hosts Array of Camera host IPs/DNS names /// @param kind Camera kind (e.g. kAxis) template - AxisCamera(llvm::StringRef name, std::initializer_list hosts); + AxisCamera(wpi::StringRef name, std::initializer_list hosts); }; /// A source for user code to provide OpenCV images as video frames. @@ -380,7 +380,7 @@ class CvSource : public VideoSource { /// Create an OpenCV source. /// @param name Source name (arbitrary unique identifier) /// @param mode Video mode being generated - CvSource(llvm::StringRef name, const VideoMode& mode); + CvSource(wpi::StringRef name, const VideoMode& mode); /// Create an OpenCV source. /// @param name Source name (arbitrary unique identifier) @@ -388,7 +388,7 @@ class CvSource : public VideoSource { /// @param width width /// @param height height /// @param fps fps - CvSource(llvm::StringRef name, VideoMode::PixelFormat pixelFormat, int width, + CvSource(wpi::StringRef name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps); /// Put an OpenCV image and notify sinks. @@ -400,7 +400,7 @@ class CvSource : public VideoSource { /// Signal sinks that an error has occurred. This should be called instead /// of NotifyFrame when an error occurs. - void NotifyError(llvm::StringRef msg); + void NotifyError(wpi::StringRef msg); /// Set source connection status. Defaults to true. /// @param connected True for connected, false for disconnected @@ -408,7 +408,7 @@ class CvSource : public VideoSource { /// Set source description. /// @param description Description - void SetDescription(llvm::StringRef description); + void SetDescription(wpi::StringRef description); /// Create a property. /// @param name Property name @@ -419,7 +419,7 @@ class CvSource : public VideoSource { /// @param defaultValue Default value /// @param value Current value /// @return Property - VideoProperty CreateProperty(llvm::StringRef name, VideoProperty::Kind kind, + VideoProperty CreateProperty(wpi::StringRef name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value); @@ -431,7 +431,7 @@ class CvSource : public VideoSource { /// @param defaultValue Default value /// @param value Current value /// @return Property - VideoProperty CreateIntegerProperty(llvm::StringRef name, int minimum, + VideoProperty CreateIntegerProperty(wpi::StringRef name, int minimum, int maximum, int step, int defaultValue, int value); @@ -440,7 +440,7 @@ class CvSource : public VideoSource { /// @param defaultValue Default value /// @param value Current value /// @return Property - VideoProperty CreateBooleanProperty(llvm::StringRef name, bool defaultValue, + VideoProperty CreateBooleanProperty(wpi::StringRef name, bool defaultValue, bool value); /// Create a string property. @@ -448,14 +448,14 @@ class CvSource : public VideoSource { /// @param defaultValue Default value /// @param value Current value /// @return Property - VideoProperty CreateStringProperty(llvm::StringRef name, - llvm::StringRef value); + VideoProperty CreateStringProperty(wpi::StringRef name, + wpi::StringRef value); /// Configure enum property choices. /// @param property Property /// @param choices Choices void SetEnumPropertyChoices(const VideoProperty& property, - llvm::ArrayRef choices); + wpi::ArrayRef choices); /// Configure enum property choices. /// @param property Property @@ -517,7 +517,7 @@ class VideoSink { /// @param name Property name /// @return Property (kind Property::kNone if no property with /// the given name exists or no source connected) - VideoProperty GetSourceProperty(llvm::StringRef name); + VideoProperty GetSourceProperty(wpi::StringRef name); CS_Status GetLastStatus() const { return m_status; } @@ -547,12 +547,12 @@ class MjpegServer : public VideoSink { /// @param name Sink name (arbitrary unique identifier) /// @param listenAddress TCP listen address (empty string for all addresses) /// @param port TCP port number - MjpegServer(llvm::StringRef name, llvm::StringRef listenAddress, int port); + MjpegServer(wpi::StringRef name, wpi::StringRef listenAddress, int port); /// Create a MJPEG-over-HTTP server sink. /// @param name Sink name (arbitrary unique identifier) /// @param port TCP port number - MjpegServer(llvm::StringRef name, int port) : MjpegServer(name, "", port) {} + MjpegServer(wpi::StringRef name, int port) : MjpegServer(name, "", port) {} /// Get the listen address of the server. std::string GetListenAddress() const; @@ -570,7 +570,7 @@ class CvSink : public VideoSink { /// WaitForFrame() must be called on the created sink to get each new /// image. /// @param name Source name (arbitrary unique identifier) - explicit CvSink(llvm::StringRef name); + explicit CvSink(wpi::StringRef name); /// Create a sink for accepting OpenCV images in a separate thread. /// A thread will be created that calls WaitForFrame() and calls the @@ -580,11 +580,11 @@ class CvSink : public VideoSink { /// time=0 if an error occurred. processFrame should call GetImage() /// or GetError() as needed, but should not call (except in very /// unusual circumstances) WaitForImage(). - CvSink(llvm::StringRef name, std::function processFrame); + CvSink(wpi::StringRef name, std::function processFrame); /// Set sink description. /// @param description Description - void SetDescription(llvm::StringRef description); + void SetDescription(wpi::StringRef description); /// Wait for the next frame and get the image. /// Times out (returning 0) after timeout seconds. diff --git a/cscore/src/main/native/include/cscore_oo.inl b/cscore/src/main/native/include/cscore_oo.inl index d4181c6854..8c7fe7a104 100644 --- a/cscore/src/main/native/include/cscore_oo.inl +++ b/cscore/src/main/native/include/cscore_oo.inl @@ -50,13 +50,13 @@ inline std::string VideoProperty::GetString() const { return GetStringProperty(m_handle, &m_status); } -inline llvm::StringRef VideoProperty::GetString( - llvm::SmallVectorImpl& buf) const { +inline wpi::StringRef VideoProperty::GetString( + wpi::SmallVectorImpl& buf) const { m_status = 0; return GetStringProperty(m_handle, buf, &m_status); } -inline void VideoProperty::SetString(llvm::StringRef value) { +inline void VideoProperty::SetString(wpi::StringRef value) { m_status = 0; SetStringProperty(m_handle, value, &m_status); } @@ -121,7 +121,7 @@ inline bool VideoSource::IsConnected() const { return IsSourceConnected(m_handle, &m_status); } -inline VideoProperty VideoSource::GetProperty(llvm::StringRef name) { +inline VideoProperty VideoSource::GetProperty(wpi::StringRef name) { m_status = 0; return VideoProperty{GetSourceProperty(m_handle, name, &m_status)}; } @@ -215,11 +215,11 @@ inline void VideoCamera::SetExposureManual(int value) { SetCameraExposureManual(m_handle, value, &m_status); } -inline UsbCamera::UsbCamera(llvm::StringRef name, int dev) { +inline UsbCamera::UsbCamera(wpi::StringRef name, int dev) { m_handle = CreateUsbCameraDev(name, dev, &m_status); } -inline UsbCamera::UsbCamera(llvm::StringRef name, llvm::StringRef path) { +inline UsbCamera::UsbCamera(wpi::StringRef name, wpi::StringRef path) { m_handle = CreateUsbCameraPath(name, path, &m_status); } @@ -233,26 +233,26 @@ inline std::string UsbCamera::GetPath() const { return ::cs::GetUsbCameraPath(m_handle, &m_status); } -inline HttpCamera::HttpCamera(llvm::StringRef name, llvm::StringRef url, +inline HttpCamera::HttpCamera(wpi::StringRef name, wpi::StringRef url, HttpCameraKind kind) { m_handle = CreateHttpCamera( name, url, static_cast(static_cast(kind)), &m_status); } -inline HttpCamera::HttpCamera(llvm::StringRef name, const char* url, +inline HttpCamera::HttpCamera(wpi::StringRef name, const char* url, HttpCameraKind kind) { m_handle = CreateHttpCamera( name, url, static_cast(static_cast(kind)), &m_status); } -inline HttpCamera::HttpCamera(llvm::StringRef name, const std::string& url, +inline HttpCamera::HttpCamera(wpi::StringRef name, const std::string& url, HttpCameraKind kind) - : HttpCamera(name, llvm::StringRef{url}, kind) {} + : HttpCamera(name, wpi::StringRef{url}, kind) {} -inline HttpCamera::HttpCamera(llvm::StringRef name, - llvm::ArrayRef urls, +inline HttpCamera::HttpCamera(wpi::StringRef name, + wpi::ArrayRef urls, HttpCameraKind kind) { m_handle = CreateHttpCamera( name, urls, static_cast(static_cast(kind)), @@ -260,7 +260,7 @@ inline HttpCamera::HttpCamera(llvm::StringRef name, } template -inline HttpCamera::HttpCamera(llvm::StringRef name, +inline HttpCamera::HttpCamera(wpi::StringRef name, std::initializer_list urls, HttpCameraKind kind) { std::vector vec; @@ -277,7 +277,7 @@ inline HttpCamera::HttpCameraKind HttpCamera::GetHttpCameraKind() const { static_cast(::cs::GetHttpCameraKind(m_handle, &m_status))); } -inline void HttpCamera::SetUrls(llvm::ArrayRef urls) { +inline void HttpCamera::SetUrls(wpi::ArrayRef urls) { m_status = 0; ::cs::SetHttpCameraUrls(m_handle, urls, &m_status); } @@ -296,7 +296,7 @@ inline std::vector HttpCamera::GetUrls() const { return ::cs::GetHttpCameraUrls(m_handle, &m_status); } -inline std::string AxisCamera::HostToUrl(llvm::StringRef host) { +inline std::string AxisCamera::HostToUrl(wpi::StringRef host) { std::string rv{"http://"}; rv += host; rv += "/mjpg/video.mjpg"; @@ -304,11 +304,11 @@ inline std::string AxisCamera::HostToUrl(llvm::StringRef host) { } inline std::vector AxisCamera::HostToUrl( - llvm::ArrayRef hosts) { + wpi::ArrayRef hosts) { std::vector rv; rv.reserve(hosts.size()); for (const auto& host : hosts) - rv.emplace_back(HostToUrl(llvm::StringRef{host})); + rv.emplace_back(HostToUrl(wpi::StringRef{host})); return rv; } @@ -318,33 +318,33 @@ inline std::vector AxisCamera::HostToUrl( std::vector rv; rv.reserve(hosts.size()); for (const auto& host : hosts) - rv.emplace_back(HostToUrl(llvm::StringRef{host})); + rv.emplace_back(HostToUrl(wpi::StringRef{host})); return rv; } -inline AxisCamera::AxisCamera(llvm::StringRef name, llvm::StringRef host) +inline AxisCamera::AxisCamera(wpi::StringRef name, wpi::StringRef host) : HttpCamera(name, HostToUrl(host), kAxis) {} -inline AxisCamera::AxisCamera(llvm::StringRef name, const char* host) +inline AxisCamera::AxisCamera(wpi::StringRef name, const char* host) : HttpCamera(name, HostToUrl(host), kAxis) {} -inline AxisCamera::AxisCamera(llvm::StringRef name, const std::string& host) - : HttpCamera(name, HostToUrl(llvm::StringRef{host}), kAxis) {} +inline AxisCamera::AxisCamera(wpi::StringRef name, const std::string& host) + : HttpCamera(name, HostToUrl(wpi::StringRef{host}), kAxis) {} -inline AxisCamera::AxisCamera(llvm::StringRef name, - llvm::ArrayRef hosts) +inline AxisCamera::AxisCamera(wpi::StringRef name, + wpi::ArrayRef hosts) : HttpCamera(name, HostToUrl(hosts), kAxis) {} template -inline AxisCamera::AxisCamera(llvm::StringRef name, +inline AxisCamera::AxisCamera(wpi::StringRef name, std::initializer_list hosts) : HttpCamera(name, HostToUrl(hosts), kAxis) {} -inline CvSource::CvSource(llvm::StringRef name, const VideoMode& mode) { +inline CvSource::CvSource(wpi::StringRef name, const VideoMode& mode) { m_handle = CreateCvSource(name, mode, &m_status); } -inline CvSource::CvSource(llvm::StringRef name, VideoMode::PixelFormat format, +inline CvSource::CvSource(wpi::StringRef name, VideoMode::PixelFormat format, int width, int height, int fps) { m_handle = CreateCvSource(name, VideoMode{format, width, height, fps}, &m_status); @@ -355,7 +355,7 @@ inline void CvSource::PutFrame(cv::Mat& image) { PutSourceFrame(m_handle, image, &m_status); } -inline void CvSource::NotifyError(llvm::StringRef msg) { +inline void CvSource::NotifyError(wpi::StringRef msg) { m_status = 0; NotifySourceError(m_handle, msg, &m_status); } @@ -365,12 +365,12 @@ inline void CvSource::SetConnected(bool connected) { SetSourceConnected(m_handle, connected, &m_status); } -inline void CvSource::SetDescription(llvm::StringRef description) { +inline void CvSource::SetDescription(wpi::StringRef description) { m_status = 0; SetSourceDescription(m_handle, description, &m_status); } -inline VideoProperty CvSource::CreateProperty(llvm::StringRef name, +inline VideoProperty CvSource::CreateProperty(wpi::StringRef name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, @@ -381,7 +381,7 @@ inline VideoProperty CvSource::CreateProperty(llvm::StringRef name, minimum, maximum, step, defaultValue, value, &m_status)}; } -inline VideoProperty CvSource::CreateIntegerProperty(llvm::StringRef name, +inline VideoProperty CvSource::CreateIntegerProperty(wpi::StringRef name, int minimum, int maximum, int step, int defaultValue, int value) { @@ -391,7 +391,7 @@ inline VideoProperty CvSource::CreateIntegerProperty(llvm::StringRef name, minimum, maximum, step, defaultValue, value, &m_status)}; } -inline VideoProperty CvSource::CreateBooleanProperty(llvm::StringRef name, +inline VideoProperty CvSource::CreateBooleanProperty(wpi::StringRef name, bool defaultValue, bool value) { m_status = 0; @@ -400,8 +400,8 @@ inline VideoProperty CvSource::CreateBooleanProperty(llvm::StringRef name, 0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0, &m_status)}; } -inline VideoProperty CvSource::CreateStringProperty(llvm::StringRef name, - llvm::StringRef value) { +inline VideoProperty CvSource::CreateStringProperty(wpi::StringRef name, + wpi::StringRef value) { m_status = 0; auto prop = VideoProperty{CreateSourceProperty( m_handle, name, static_cast(static_cast(VideoProperty::Kind::kString)), @@ -412,7 +412,7 @@ inline VideoProperty CvSource::CreateStringProperty(llvm::StringRef name, inline void CvSource::SetEnumPropertyChoices( - const VideoProperty& property, llvm::ArrayRef choices) { + const VideoProperty& property, wpi::ArrayRef choices) { m_status = 0; SetSourceEnumPropertyChoices(m_handle, property.m_handle, choices, &m_status); } @@ -473,13 +473,13 @@ inline VideoSource VideoSink::GetSource() const { return VideoSource{handle == 0 ? 0 : CopySource(handle, &m_status)}; } -inline VideoProperty VideoSink::GetSourceProperty(llvm::StringRef name) { +inline VideoProperty VideoSink::GetSourceProperty(wpi::StringRef name) { m_status = 0; return VideoProperty{GetSinkSourceProperty(m_handle, name, &m_status)}; } -inline MjpegServer::MjpegServer(llvm::StringRef name, - llvm::StringRef listenAddress, int port) { +inline MjpegServer::MjpegServer(wpi::StringRef name, + wpi::StringRef listenAddress, int port) { m_handle = CreateMjpegServer(name, listenAddress, port, &m_status); } @@ -493,16 +493,16 @@ inline int MjpegServer::GetPort() const { return cs::GetMjpegServerPort(m_handle, &m_status); } -inline CvSink::CvSink(llvm::StringRef name) { +inline CvSink::CvSink(wpi::StringRef name) { m_handle = CreateCvSink(name, &m_status); } -inline CvSink::CvSink(llvm::StringRef name, +inline CvSink::CvSink(wpi::StringRef name, std::function processFrame) { m_handle = CreateCvSinkCallback(name, processFrame, &m_status); } -inline void CvSink::SetDescription(llvm::StringRef description) { +inline void CvSink::SetDescription(wpi::StringRef description) { m_status = 0; SetSinkDescription(m_handle, description, &m_status); } diff --git a/hal/src/main/native/athena/AnalogInput.cpp b/hal/src/main/native/athena/AnalogInput.cpp index e307eb17a7..140671a0a6 100644 --- a/hal/src/main/native/athena/AnalogInput.cpp +++ b/hal/src/main/native/athena/AnalogInput.cpp @@ -8,7 +8,7 @@ #include "HAL/AnalogInput.h" #include -#include +#include #include "AnalogInternal.h" #include "HAL/AnalogAccumulator.h" diff --git a/hal/src/main/native/athena/AnalogInternal.cpp b/hal/src/main/native/athena/AnalogInternal.cpp index e219f94066..0bb97d7add 100644 --- a/hal/src/main/native/athena/AnalogInternal.cpp +++ b/hal/src/main/native/athena/AnalogInternal.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include "HAL/AnalogInput.h" #include "HAL/ChipObject.h" diff --git a/hal/src/main/native/athena/AnalogInternal.h b/hal/src/main/native/athena/AnalogInternal.h index 5c3a8631c8..14d64610f2 100644 --- a/hal/src/main/native/athena/AnalogInternal.h +++ b/hal/src/main/native/athena/AnalogInternal.h @@ -11,7 +11,7 @@ #include -#include +#include #include "HAL/ChipObject.h" #include "HAL/Ports.h" diff --git a/hal/src/main/native/athena/DigitalInternal.cpp b/hal/src/main/native/athena/DigitalInternal.cpp index 2305ce2812..e562e29323 100644 --- a/hal/src/main/native/athena/DigitalInternal.cpp +++ b/hal/src/main/native/athena/DigitalInternal.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "ConstantsInternal.h" #include "HAL/AnalogTrigger.h" diff --git a/hal/src/main/native/athena/DigitalInternal.h b/hal/src/main/native/athena/DigitalInternal.h index 6ef8e29c6c..57bbb6414f 100644 --- a/hal/src/main/native/athena/DigitalInternal.h +++ b/hal/src/main/native/athena/DigitalInternal.h @@ -11,7 +11,7 @@ #include -#include +#include #include "HAL/AnalogTrigger.h" #include "HAL/ChipObject.h" diff --git a/hal/src/main/native/athena/FRCDriverStation.cpp b/hal/src/main/native/athena/FRCDriverStation.cpp index 32d29b9758..62081e8c28 100644 --- a/hal/src/main/native/athena/FRCDriverStation.cpp +++ b/hal/src/main/native/athena/FRCDriverStation.cpp @@ -13,9 +13,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "HAL/DriverStation.h" @@ -73,12 +73,12 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode, details, location, callStack); if (printMsg) { if (location && location[0] != '\0') { - llvm::errs() << (isError ? "Error" : "Warning") << " at " << location - << ": "; + wpi::errs() << (isError ? "Error" : "Warning") << " at " << location + << ": "; } - llvm::errs() << details << "\n"; + wpi::errs() << details << "\n"; if (callStack && callStack[0] != '\0') { - llvm::errs() << callStack << "\n"; + wpi::errs() << callStack << "\n"; } } if (i == KEEP_MSGS) { diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp index 258edc0d52..558c54bca1 100644 --- a/hal/src/main/native/athena/HAL.cpp +++ b/hal/src/main/native/athena/HAL.cpp @@ -18,9 +18,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "HAL/ChipObject.h" #include "HAL/DriverStation.h" @@ -329,20 +329,20 @@ static bool killExistingProgram(int timeout, int mode) { // see if the pid is around, but we don't want to mess with init id=1, or // ourselves if (pid >= 2 && kill(pid, 0) == 0 && pid != getpid()) { - llvm::outs() << "Killing previously running FRC program...\n"; + wpi::outs() << "Killing previously running FRC program...\n"; kill(pid, SIGTERM); // try to kill it std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); if (kill(pid, 0) == 0) { // still not successfull if (mode == 0) { - llvm::outs() << "FRC pid " << pid << " did not die within " << timeout - << "ms. Aborting\n"; + wpi::outs() << "FRC pid " << pid << " did not die within " << timeout + << "ms. Aborting\n"; return 0; // just fail } else if (mode == 1) { // kill -9 it kill(pid, SIGKILL); } else { - llvm::outs() << "WARNING: FRC pid " << pid << " did not die within " - << timeout << "ms.\n"; + wpi::outs() << "WARNING: FRC pid " << pid << " did not die within " + << timeout << "ms.\n"; } } } @@ -374,7 +374,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) { setlinebuf(stdin); setlinebuf(stdout); - llvm::outs().SetUnbuffered(); + wpi::outs().SetUnbuffered(); prctl(PR_SET_PDEATHSIG, SIGTERM); @@ -401,10 +401,10 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) { int32_t status = 0; uint64_t rv = HAL_GetFPGATime(&status); if (status != 0) { - llvm::errs() + wpi::errs() << "Call to HAL_GetFPGATime failed." << "Initialization might have failed. Time will not be correct\n"; - llvm::errs().flush(); + wpi::errs().flush(); return 0u; } return rv; diff --git a/hal/src/main/native/athena/Interrupts.cpp b/hal/src/main/native/athena/Interrupts.cpp index afc6ec0b4e..049fc3e541 100644 --- a/hal/src/main/native/athena/Interrupts.cpp +++ b/hal/src/main/native/athena/Interrupts.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include "DigitalInternal.h" #include "HAL/ChipObject.h" diff --git a/hal/src/main/native/athena/Notifier.cpp b/hal/src/main/native/athena/Notifier.cpp index 6a3c1acdc2..4831f2cadf 100644 --- a/hal/src/main/native/athena/Notifier.cpp +++ b/hal/src/main/native/athena/Notifier.cpp @@ -11,8 +11,8 @@ #include // For std::atexit() #include -#include -#include +#include +#include #include "HAL/ChipObject.h" #include "HAL/Errors.h" diff --git a/hal/src/main/native/athena/OSSerialPort.cpp b/hal/src/main/native/athena/OSSerialPort.cpp index ccb49fd26f..177d7cc612 100644 --- a/hal/src/main/native/athena/OSSerialPort.cpp +++ b/hal/src/main/native/athena/OSSerialPort.cpp @@ -217,9 +217,9 @@ int32_t HAL_ReadOSSerial(HAL_SerialPort port, char* buffer, int32_t count, std::memcpy(&buffer[bytesRead], buf, rx); bytesRead += rx; if (bytesRead >= count) break; - llvm::StringRef tmp(buffer, bytesRead); + wpi::StringRef tmp(buffer, bytesRead); auto loc = tmp.find('\n'); - if (loc != llvm::StringRef::npos) { + if (loc != wpi::StringRef::npos) { bytesRead = loc; break; } diff --git a/hal/src/main/native/athena/SPI.cpp b/hal/src/main/native/athena/SPI.cpp index d8b2485a73..6c89419fa8 100644 --- a/hal/src/main/native/athena/SPI.cpp +++ b/hal/src/main/native/athena/SPI.cpp @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include #include "DigitalInternal.h" #include "HAL/DIO.h" @@ -196,20 +196,20 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) { if ((digitalHandles[5] = HAL_InitializeDIOPort(createPortHandleForSPI(14), false, status)) == HAL_kInvalidHandle) { - llvm::outs() << "Failed to allocate DIO 14\n"; + wpi::outs() << "Failed to allocate DIO 14\n"; return; } if ((digitalHandles[6] = HAL_InitializeDIOPort(createPortHandleForSPI(15), false, status)) == HAL_kInvalidHandle) { - llvm::outs() << "Failed to allocate DIO 15\n"; + wpi::outs() << "Failed to allocate DIO 15\n"; HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated return; } if ((digitalHandles[7] = HAL_InitializeDIOPort(createPortHandleForSPI(16), false, status)) == HAL_kInvalidHandle) { - llvm::outs() << "Failed to allocate DIO 16\n"; + wpi::outs() << "Failed to allocate DIO 16\n"; HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated return; @@ -217,7 +217,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) { if ((digitalHandles[8] = HAL_InitializeDIOPort(createPortHandleForSPI(17), false, status)) == HAL_kInvalidHandle) { - llvm::outs() << "Failed to allocate DIO 17\n"; + wpi::outs() << "Failed to allocate DIO 17\n"; HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated HAL_FreeDIOPort(digitalHandles[7]); // free the third port allocated diff --git a/hal/src/main/native/athena/cpp/SerialHelper.cpp b/hal/src/main/native/athena/cpp/SerialHelper.cpp index c990c334cd..b6cffd04bb 100644 --- a/hal/src/main/native/athena/cpp/SerialHelper.cpp +++ b/hal/src/main/native/athena/cpp/SerialHelper.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include "../visa/visa.h" #include "HAL/Errors.h" @@ -137,22 +137,22 @@ void SerialHelper::SortHubPathVector() { m_sortedHubPath.clear(); m_sortedHubPath = m_unsortedHubPath; std::sort(m_sortedHubPath.begin(), m_sortedHubPath.end(), - [](const llvm::SmallVectorImpl& lhs, - const llvm::SmallVectorImpl& rhs) -> int { - llvm::StringRef lhsRef(lhs.begin(), lhs.size()); - llvm::StringRef rhsRef(rhs.begin(), rhs.size()); + [](const wpi::SmallVectorImpl& lhs, + const wpi::SmallVectorImpl& rhs) -> int { + wpi::StringRef lhsRef(lhs.begin(), lhs.size()); + wpi::StringRef rhsRef(rhs.begin(), rhs.size()); return lhsRef.compare(rhsRef); }); } void SerialHelper::CoiteratedSort( - llvm::SmallVectorImpl>& vec) { - llvm::SmallVector, 4> sortedVec; + wpi::SmallVectorImpl>& vec) { + wpi::SmallVector, 4> sortedVec; for (auto& str : m_sortedHubPath) { for (size_t i = 0; i < m_unsortedHubPath.size(); i++) { - if (llvm::StringRef{m_unsortedHubPath[i].begin(), + if (wpi::StringRef{m_unsortedHubPath[i].begin(), m_unsortedHubPath[i].size()} - .equals(llvm::StringRef{str.begin(), str.size()})) { + .equals(wpi::StringRef{str.begin(), str.size()})) { sortedVec.push_back(vec[i]); break; } @@ -206,26 +206,26 @@ void SerialHelper::QueryHubPaths(int32_t* status) { *status = 0; // split until (/dev/ - llvm::StringRef devNameRef = llvm::StringRef{osName}.split("(/dev/").second; + wpi::StringRef devNameRef = wpi::StringRef{osName}.split("(/dev/").second; // String not found, continue if (devNameRef.equals("")) continue; // Split at ) - llvm::StringRef matchString = devNameRef.split(')').first; + wpi::StringRef matchString = devNameRef.split(')').first; if (matchString.equals(devNameRef)) continue; // Search directories to get a list of system accessors std::error_code ec; - for (auto p = llvm::sys::fs::recursive_directory_iterator( + for (auto p = wpi::sys::fs::recursive_directory_iterator( "/sys/devices/soc0", ec); - p != llvm::sys::fs::recursive_directory_iterator(); p.increment(ec)) { + p != wpi::sys::fs::recursive_directory_iterator(); p.increment(ec)) { if (ec) break; - llvm::StringRef path{p->path()}; - if (path.find("amba") == llvm::StringRef::npos) continue; - if (path.find("usb") == llvm::StringRef::npos) continue; - if (path.find(matchString) == llvm::StringRef::npos) continue; + wpi::StringRef path{p->path()}; + if (path.find("amba") == wpi::StringRef::npos) continue; + if (path.find("usb") == wpi::StringRef::npos) continue; + if (path.find(matchString) == wpi::StringRef::npos) continue; - llvm::SmallVector pathSplitVec; + wpi::SmallVector pathSplitVec; // Split path into individual directories path.split(pathSplitVec, '/', -1, false); @@ -255,10 +255,10 @@ void SerialHelper::QueryHubPaths(int32_t* status) { // Add our devices to our list m_unsortedHubPath.emplace_back( - llvm::StringRef{pathSplitVec[hubIndex - 2]}); + wpi::StringRef{pathSplitVec[hubIndex - 2]}); m_visaResource.emplace_back(desc); m_osResource.emplace_back( - llvm::StringRef{osName}.split("(").second.split(")").first); + wpi::StringRef{osName}.split("(").second.split(")").first); break; } } @@ -277,7 +277,7 @@ int32_t SerialHelper::GetIndexForPort(HAL_SerialPort port, int32_t* status) { std::string portString = m_usbNames[port - 2]; - llvm::SmallVector indices; + wpi::SmallVector indices; // If port has not been assigned, find the one to assign if (portString.empty()) { diff --git a/hal/src/main/native/athena/ctre/CtreCanNode.h b/hal/src/main/native/athena/ctre/CtreCanNode.h index 6bba37e857..f00060d4f3 100644 --- a/hal/src/main/native/athena/ctre/CtreCanNode.h +++ b/hal/src/main/native/athena/ctre/CtreCanNode.h @@ -4,7 +4,7 @@ #include #include // memcpy #include -#include +#include class CtreCanNode { public: diff --git a/hal/src/main/native/cpp/cpp/fpga_clock.cpp b/hal/src/main/native/cpp/cpp/fpga_clock.cpp index bf1ffe1dce..5ab2fcaac5 100644 --- a/hal/src/main/native/cpp/cpp/fpga_clock.cpp +++ b/hal/src/main/native/cpp/cpp/fpga_clock.cpp @@ -7,7 +7,7 @@ #include "HAL/cpp/fpga_clock.h" -#include +#include #include "HAL/HAL.h" @@ -20,10 +20,10 @@ fpga_clock::time_point fpga_clock::now() noexcept { int32_t status = 0; uint64_t currentTime = HAL_GetFPGATime(&status); if (status != 0) { - llvm::errs() + wpi::errs() << "Call to HAL_GetFPGATime failed." << "Initialization might have failed. Time will not be correct\n"; - llvm::errs().flush(); + wpi::errs().flush(); return epoch(); } return time_point(std::chrono::microseconds(currentTime)); diff --git a/hal/src/main/native/cpp/handles/HandlesInternal.cpp b/hal/src/main/native/cpp/handles/HandlesInternal.cpp index 6d829b88fc..f72b7f0b41 100644 --- a/hal/src/main/native/cpp/handles/HandlesInternal.cpp +++ b/hal/src/main/native/cpp/handles/HandlesInternal.cpp @@ -9,14 +9,14 @@ #include -#include -#include +#include +#include namespace hal { -static llvm::SmallVector* globalHandles = nullptr; +static wpi::SmallVector* globalHandles = nullptr; static wpi::mutex globalHandleMutex; HandleBase::HandleBase() { - static llvm::SmallVector gH; + static wpi::SmallVector gH; std::lock_guard lock(globalHandleMutex); if (!globalHandles) { globalHandles = &gH; diff --git a/hal/src/main/native/cpp/jni/CANJNI.cpp b/hal/src/main/native/cpp/jni/CANJNI.cpp index 8b2ec9e67f..5d46b284df 100644 --- a/hal/src/main/native/cpp/jni/CANJNI.cpp +++ b/hal/src/main/native/cpp/jni/CANJNI.cpp @@ -12,9 +12,9 @@ #include "HAL/CAN.h" #include "HALUtil.h" #include "edu_wpi_first_wpilibj_can_CANJNI.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" -#include "support/jni_util.h" +#include "wpi/SmallString.h" +#include "wpi/jni_util.h" +#include "wpi/raw_ostream.h" using namespace frc; using namespace wpi::java; @@ -53,8 +53,8 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxSendMessage( if (logDEBUG <= canJNILogLevel) { if (dataBuffer) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream str(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream str(buf); for (int32_t i = 0; i < dataSize; i++) { str.write_hex(dataBuffer[i]) << ' '; } @@ -102,8 +102,8 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage( CANJNI_LOG(logDEBUG).write_hex(*messageIDPtr); if (logDEBUG <= canJNILogLevel) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream str(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream str(buf); for (int32_t i = 0; i < dataSize; i++) { // Pad one-digit data with a zero @@ -121,7 +121,7 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage( CANJNI_LOG(logDEBUG) << "Status: " << status; if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr; - return MakeJByteArray(env, llvm::StringRef{reinterpret_cast(buffer), + return MakeJByteArray(env, wpi::StringRef{reinterpret_cast(buffer), static_cast(dataSize)}); } diff --git a/hal/src/main/native/cpp/jni/HAL.cpp b/hal/src/main/native/cpp/jni/HAL.cpp index 3e518fb527..ac02ab9975 100644 --- a/hal/src/main/native/cpp/jni/HAL.cpp +++ b/hal/src/main/native/cpp/jni/HAL.cpp @@ -15,7 +15,7 @@ #include "HAL/DriverStation.h" #include "edu_wpi_first_wpilibj_hal_HAL.h" #include "HALUtil.h" -#include "support/jni_util.h" +#include "wpi/jni_util.h" using namespace frc; using namespace wpi::java; diff --git a/hal/src/main/native/cpp/jni/HALUtil.cpp b/hal/src/main/native/cpp/jni/HALUtil.cpp index 3c6efb4939..fb458e7be4 100644 --- a/hal/src/main/native/cpp/jni/HALUtil.cpp +++ b/hal/src/main/native/cpp/jni/HALUtil.cpp @@ -21,9 +21,9 @@ #include "HAL/Errors.h" #include "HAL/cpp/Log.h" #include "edu_wpi_first_wpilibj_hal_HALUtil.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" -#include "support/jni_util.h" +#include "wpi/SmallString.h" +#include "wpi/jni_util.h" +#include "wpi/raw_ostream.h" using namespace wpi::java; @@ -64,8 +64,8 @@ namespace frc { void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange, int32_t requestedValue, int32_t status) { const char *message = HAL_GetErrorMessage(status); - llvm::SmallString<1024> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<1024> buf; + wpi::raw_svector_ostream oss(buf); oss << " Code: " << status << ". " << message << ", Minimum Value: " << minRange << ", Maximum Value: " << maxRange << ", Requested Value: " << requestedValue; @@ -75,8 +75,8 @@ void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange, void ThrowHalHandleException(JNIEnv *env, int32_t status) { const char *message = HAL_GetErrorMessage(status); - llvm::SmallString<1024> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<1024> buf; + wpi::raw_svector_ostream oss(buf); oss << " Code: " << status << ". " << message; halHandleExCls.Throw(env, buf.c_str()); } @@ -88,8 +88,8 @@ void ReportError(JNIEnv *env, int32_t status, bool doThrow) { } const char *message = HAL_GetErrorMessage(status); if (doThrow && status < 0) { - llvm::SmallString<1024> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<1024> buf; + wpi::raw_svector_ostream oss(buf); oss << " Code: " << status << ". " << message; runtimeExCls.Throw(env, buf.c_str()); } else { @@ -111,8 +111,8 @@ void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange, ThrowHalHandleException(env, status); } const char *message = HAL_GetErrorMessage(status); - llvm::SmallString<1024> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<1024> buf; + wpi::raw_svector_ostream oss(buf); oss << " Code: " << status << ". " << message; runtimeExCls.Throw(env, buf.c_str()); } @@ -147,8 +147,8 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { } case HAL_ERR_CANSessionMux_NotAllowed: case kRIOStatusFeatureNotSupported: { - llvm::SmallString<100> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<100> buf; + wpi::raw_svector_ostream oss(buf); oss << "MessageID = " << message_id; canMessageNotAllowedExCls.Throw(env, buf.c_str()); break; @@ -165,8 +165,8 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) { break; } default: { - llvm::SmallString<100> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<100> buf; + wpi::raw_svector_ostream oss(buf); oss << "Fatal status code detected: " << status; uncleanStatusExCls.Throw(env, buf.c_str()); break; diff --git a/hal/src/main/native/cpp/jni/I2CJNI.cpp b/hal/src/main/native/cpp/jni/I2CJNI.cpp index 771f9e4001..65d9b76728 100644 --- a/hal/src/main/native/cpp/jni/I2CJNI.cpp +++ b/hal/src/main/native/cpp/jni/I2CJNI.cpp @@ -13,7 +13,7 @@ #include "HAL/I2C.h" #include "HALUtil.h" -#include "support/jni_util.h" +#include "wpi/jni_util.h" using namespace frc; using namespace wpi::java; @@ -83,7 +83,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransactionB( I2CJNI_LOG(logDEBUG) << "Port = " << port; I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address; I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)sendSize; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(receiveSize); I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << (jint)receiveSize; jint returnValue = @@ -173,7 +173,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CReadB( I2CJNI_LOG(logDEBUG) << "Port = " << port; I2CJNI_LOG(logDEBUG) << "Address = " << address; I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << receiveSize; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(receiveSize); jint returnValue = HAL_ReadI2C(static_cast(port), address, recvBuf.data(), receiveSize); env->SetByteArrayRegion(dataReceived, 0, receiveSize, diff --git a/hal/src/main/native/cpp/jni/InterruptJNI.cpp b/hal/src/main/native/cpp/jni/InterruptJNI.cpp index 04af196c47..c4a1b111d4 100644 --- a/hal/src/main/native/cpp/jni/InterruptJNI.cpp +++ b/hal/src/main/native/cpp/jni/InterruptJNI.cpp @@ -10,14 +10,14 @@ #include #include -#include +#include +#include #include "HAL/cpp/Log.h" #include "HAL/Interrupts.h" #include "HALUtil.h" #include "edu_wpi_first_wpilibj_hal_InterruptJNI.h" -#include "support/SafeThread.h" using namespace frc; diff --git a/hal/src/main/native/cpp/jni/OSSerialPortJNI.cpp b/hal/src/main/native/cpp/jni/OSSerialPortJNI.cpp index 375e5bceb0..7a6c9a5d3e 100644 --- a/hal/src/main/native/cpp/jni/OSSerialPortJNI.cpp +++ b/hal/src/main/native/cpp/jni/OSSerialPortJNI.cpp @@ -13,7 +13,7 @@ #include "HAL/OSSerialPort.h" #include "HALUtil.h" -#include "support/jni_util.h" +#include "wpi/jni_util.h" using namespace frc; using namespace wpi::java; @@ -244,7 +244,7 @@ Java_edu_wpi_first_wpilibj_hal_OSSerialPortJNI_serialGetBytesReceived( JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_OSSerialPortJNI_serialRead( JNIEnv* env, jclass, jbyte port, jbyteArray dataReceived, jint size) { SERIALJNI_LOG(logDEBUG) << "Serial Read"; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(size); int32_t status = 0; jint retVal = HAL_ReadOSSerial(static_cast(port), recvBuf.data(), diff --git a/hal/src/main/native/cpp/jni/SPIJNI.cpp b/hal/src/main/native/cpp/jni/SPIJNI.cpp index e9d21e4b20..919e8ab4ea 100644 --- a/hal/src/main/native/cpp/jni/SPIJNI.cpp +++ b/hal/src/main/native/cpp/jni/SPIJNI.cpp @@ -13,7 +13,7 @@ #include "HAL/SPI.h" #include "HALUtil.h" -#include "support/jni_util.h" +#include "wpi/jni_util.h" using namespace frc; using namespace wpi::java; @@ -79,7 +79,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransactionB"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(size); jint retVal = HAL_TransactionSPI(static_cast(port), @@ -146,7 +146,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead( SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr; jint retVal; if (initiate) { - llvm::SmallVector sendBuf; + wpi::SmallVector sendBuf; sendBuf.resize(size); retVal = HAL_TransactionSPI(static_cast(port), sendBuf.data(), dataReceivedPtr, size); } else { @@ -168,10 +168,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB( SPIJNI_LOG(logDEBUG) << "Initiate = " << (jboolean)initiate; SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size; jint retVal; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(size); if (initiate) { - llvm::SmallVector sendBuf; + wpi::SmallVector sendBuf; sendBuf.resize(size); retVal = HAL_TransactionSPI(static_cast(port), sendBuf.data(), recvBuf.data(), size); } else { @@ -404,7 +404,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceived SPIJNI_LOG(logDEBUG) << "Port = " << port; SPIJNI_LOG(logDEBUG) << "NumToRead = " << numToRead; SPIJNI_LOG(logDEBUG) << "Timeout = " << timeout; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(numToRead); int32_t status = 0; jint retval = HAL_ReadSPIAutoReceivedData(static_cast(port), recvBuf.data(), numToRead, timeout, &status); diff --git a/hal/src/main/native/cpp/jni/SerialPortJNI.cpp b/hal/src/main/native/cpp/jni/SerialPortJNI.cpp index 5634b0ed91..33e6358e34 100644 --- a/hal/src/main/native/cpp/jni/SerialPortJNI.cpp +++ b/hal/src/main/native/cpp/jni/SerialPortJNI.cpp @@ -13,7 +13,7 @@ #include "HAL/SerialPort.h" #include "HALUtil.h" -#include "support/jni_util.h" +#include "wpi/jni_util.h" using namespace frc; using namespace wpi::java; @@ -263,7 +263,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetBytesReceived( JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead( JNIEnv* env, jclass, jbyte port, jbyteArray dataReceived, jint size) { SERIALJNI_LOG(logDEBUG) << "Serial Read"; - llvm::SmallVector recvBuf; + wpi::SmallVector recvBuf; recvBuf.resize(size); int32_t status = 0; jint retVal = HAL_ReadSerial(static_cast(port), recvBuf.data(), diff --git a/hal/src/main/native/include/HAL/cpp/Log.h b/hal/src/main/native/include/HAL/cpp/Log.h index e57974e467..1fabae6afe 100644 --- a/hal/src/main/native/include/HAL/cpp/Log.h +++ b/hal/src/main/native/include/HAL/cpp/Log.h @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include inline std::string NowTime(); @@ -31,7 +31,7 @@ class Log { public: Log(); virtual ~Log(); - llvm::raw_ostream& Get(TLogLevel level = logINFO); + wpi::raw_ostream& Get(TLogLevel level = logINFO); public: static TLogLevel& ReportingLevel(); @@ -39,8 +39,8 @@ class Log { static TLogLevel FromString(const std::string& level); protected: - llvm::SmallString<128> buf; - llvm::raw_svector_ostream oss{buf}; + wpi::SmallString<128> buf; + wpi::raw_svector_ostream oss{buf}; private: Log(const Log&); @@ -49,7 +49,7 @@ class Log { inline Log::Log() {} -inline llvm::raw_ostream& Log::Get(TLogLevel level) { +inline wpi::raw_ostream& Log::Get(TLogLevel level) { oss << "- " << NowTime(); oss << " " << ToString(level) << ": "; if (level > logDEBUG) { @@ -60,7 +60,7 @@ inline llvm::raw_ostream& Log::Get(TLogLevel level) { inline Log::~Log() { oss << "\n"; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); } inline TLogLevel& Log::ReportingLevel() { @@ -99,8 +99,8 @@ typedef Log FILELog; Log().Get(level) inline std::string NowTime() { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream oss(buf); using std::chrono::duration_cast; diff --git a/hal/src/main/native/include/HAL/cpp/SerialHelper.h b/hal/src/main/native/include/HAL/cpp/SerialHelper.h index 3b978b86b6..df8b0417bb 100644 --- a/hal/src/main/native/include/HAL/cpp/SerialHelper.h +++ b/hal/src/main/native/include/HAL/cpp/SerialHelper.h @@ -12,9 +12,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "HAL/SerialPort.h" @@ -31,7 +31,7 @@ class SerialHelper { private: void SortHubPathVector(); - void CoiteratedSort(llvm::SmallVectorImpl>& vec); + void CoiteratedSort(wpi::SmallVectorImpl>& vec); void QueryHubPaths(int32_t* status); int32_t GetIndexForPort(HAL_SerialPort port, int32_t* status); @@ -39,10 +39,10 @@ class SerialHelper { // Vectors to hold data before sorting. // Note we will most likely have at max 2 instances, and the longest string // is around 12, so these should never touch the heap; - llvm::SmallVector, 4> m_visaResource; - llvm::SmallVector, 4> m_osResource; - llvm::SmallVector, 4> m_unsortedHubPath; - llvm::SmallVector, 4> m_sortedHubPath; + wpi::SmallVector, 4> m_visaResource; + wpi::SmallVector, 4> m_osResource; + wpi::SmallVector, 4> m_unsortedHubPath; + wpi::SmallVector, 4> m_sortedHubPath; int32_t m_resourceHandle; diff --git a/hal/src/main/native/include/HAL/cpp/UnsafeDIO.h b/hal/src/main/native/include/HAL/cpp/UnsafeDIO.h index 5d951005fb..caf1ab135e 100644 --- a/hal/src/main/native/include/HAL/cpp/UnsafeDIO.h +++ b/hal/src/main/native/include/HAL/cpp/UnsafeDIO.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "HAL/ChipObject.h" #include "HAL/Types.h" diff --git a/hal/src/main/native/include/HAL/handles/DigitalHandleResource.h b/hal/src/main/native/include/HAL/handles/DigitalHandleResource.h index 6473d90f66..58d64dd3d7 100644 --- a/hal/src/main/native/include/HAL/handles/DigitalHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/DigitalHandleResource.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "HAL/Errors.h" #include "HAL/Types.h" diff --git a/hal/src/main/native/include/HAL/handles/IndexedClassedHandleResource.h b/hal/src/main/native/include/HAL/handles/IndexedClassedHandleResource.h index c13fb2a94b..d3b495bc6d 100644 --- a/hal/src/main/native/include/HAL/handles/IndexedClassedHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/IndexedClassedHandleResource.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include "HAL/Errors.h" #include "HAL/Types.h" diff --git a/hal/src/main/native/include/HAL/handles/IndexedHandleResource.h b/hal/src/main/native/include/HAL/handles/IndexedHandleResource.h index 1d5ea8623a..79f78fd5a3 100644 --- a/hal/src/main/native/include/HAL/handles/IndexedHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/IndexedHandleResource.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "HAL/Errors.h" #include "HAL/Types.h" diff --git a/hal/src/main/native/include/HAL/handles/LimitedClassedHandleResource.h b/hal/src/main/native/include/HAL/handles/LimitedClassedHandleResource.h index 57b15a20a7..cee698d561 100644 --- a/hal/src/main/native/include/HAL/handles/LimitedClassedHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/LimitedClassedHandleResource.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "HAL/Types.h" #include "HAL/cpp/make_unique.h" diff --git a/hal/src/main/native/include/HAL/handles/LimitedHandleResource.h b/hal/src/main/native/include/HAL/handles/LimitedHandleResource.h index afab748461..b6c6e4bc06 100644 --- a/hal/src/main/native/include/HAL/handles/LimitedHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/LimitedHandleResource.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "HAL/Types.h" #include "HAL/cpp/make_unique.h" diff --git a/hal/src/main/native/include/HAL/handles/UnlimitedHandleResource.h b/hal/src/main/native/include/HAL/handles/UnlimitedHandleResource.h index 5941628bc9..15d343be70 100644 --- a/hal/src/main/native/include/HAL/handles/UnlimitedHandleResource.h +++ b/hal/src/main/native/include/HAL/handles/UnlimitedHandleResource.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include "HAL/Types.h" #include "HAL/handles/HandlesInternal.h" diff --git a/hal/src/main/native/sim/DriverStation.cpp b/hal/src/main/native/sim/DriverStation.cpp index d2e2f9e057..53e312b735 100644 --- a/hal/src/main/native/sim/DriverStation.cpp +++ b/hal/src/main/native/sim/DriverStation.cpp @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include #include "MockData/DriverStationDataInternal.h" #include "MockData/MockHooks.h" diff --git a/hal/src/main/native/sim/Extensions.cpp b/hal/src/main/native/sim/Extensions.cpp index f289b43d88..6aeaeafe1c 100644 --- a/hal/src/main/native/sim/Extensions.cpp +++ b/hal/src/main/native/sim/Extensions.cpp @@ -7,8 +7,8 @@ #include "HAL/Extensions.h" -#include -#include +#include +#include #include "HAL/HAL.h" @@ -46,7 +46,7 @@ int HAL_LoadOneExtension(const char* library) { HTYPE handle = DLOPEN(library); #if !defined(WIN32) && !defined(_WIN32) if (!handle) { - llvm::SmallString<128> libraryName("lib"); + wpi::SmallString<128> libraryName("lib"); libraryName += library; #if defined(__APPLE__) libraryName += ".dylib"; @@ -73,13 +73,13 @@ int HAL_LoadOneExtension(const char* library) { */ int HAL_LoadExtensions(void) { int rc = 1; - llvm::SmallVector libraries; + wpi::SmallVector libraries; const char* e = std::getenv("HALSIM_EXTENSIONS"); if (!e) return rc; - llvm::StringRef env{e}; + wpi::StringRef env{e}; env.split(libraries, DELIM, -1, false); for (auto& libref : libraries) { - llvm::SmallString<128> library(libref); + wpi::SmallString<128> library(libref); rc = HAL_LoadOneExtension(library.c_str()); if (rc < 0) break; } diff --git a/hal/src/main/native/sim/HAL.cpp b/hal/src/main/native/sim/HAL.cpp index 74125b19a1..4a87ea166b 100644 --- a/hal/src/main/native/sim/HAL.cpp +++ b/hal/src/main/native/sim/HAL.cpp @@ -7,7 +7,7 @@ #include "HAL/HAL.h" -#include +#include #include "ErrorsInternal.h" #include "HAL/DriverStation.h" @@ -263,7 +263,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) { hal::init::InitializeHAL(); - llvm::outs().SetUnbuffered(); + wpi::outs().SetUnbuffered(); if (HAL_LoadExtensions() < 0) return false; hal::RestartTiming(); HAL_InitializeDriverStation(); diff --git a/hal/src/main/native/sim/Interrupts.cpp b/hal/src/main/native/sim/Interrupts.cpp index 27dab1e04d..1336104e0f 100644 --- a/hal/src/main/native/sim/Interrupts.cpp +++ b/hal/src/main/native/sim/Interrupts.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include "AnalogInternal.h" #include "DigitalInternal.h" diff --git a/hal/src/main/native/sim/MockData/AccelerometerDataInternal.h b/hal/src/main/native/sim/MockData/AccelerometerDataInternal.h index 08efbc6e49..5d0a8f1dba 100644 --- a/hal/src/main/native/sim/MockData/AccelerometerDataInternal.h +++ b/hal/src/main/native/sim/MockData/AccelerometerDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/AccelerometerData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/AnalogGyroDataInternal.h b/hal/src/main/native/sim/MockData/AnalogGyroDataInternal.h index 180d7ef7d2..177c21ad9a 100644 --- a/hal/src/main/native/sim/MockData/AnalogGyroDataInternal.h +++ b/hal/src/main/native/sim/MockData/AnalogGyroDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/AnalogGyroData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/AnalogInDataInternal.h b/hal/src/main/native/sim/MockData/AnalogInDataInternal.h index 5000e1623f..035205adb1 100644 --- a/hal/src/main/native/sim/MockData/AnalogInDataInternal.h +++ b/hal/src/main/native/sim/MockData/AnalogInDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/AnalogInData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/AnalogOutDataInternal.h b/hal/src/main/native/sim/MockData/AnalogOutDataInternal.h index c65e7f735e..822e5d648b 100644 --- a/hal/src/main/native/sim/MockData/AnalogOutDataInternal.h +++ b/hal/src/main/native/sim/MockData/AnalogOutDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/AnalogOutData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/AnalogTriggerDataInternal.h b/hal/src/main/native/sim/MockData/AnalogTriggerDataInternal.h index abb632b352..39f81bde93 100644 --- a/hal/src/main/native/sim/MockData/AnalogTriggerDataInternal.h +++ b/hal/src/main/native/sim/MockData/AnalogTriggerDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/AnalogTriggerData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/CanDataInternal.h b/hal/src/main/native/sim/MockData/CanDataInternal.h index 2e64d789b5..a90b5154e6 100644 --- a/hal/src/main/native/sim/MockData/CanDataInternal.h +++ b/hal/src/main/native/sim/MockData/CanDataInternal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "MockData/CanData.h" #include "MockData/NotifyCallbackHelpers.h" diff --git a/hal/src/main/native/sim/MockData/DIODataInternal.h b/hal/src/main/native/sim/MockData/DIODataInternal.h index 3f51a8d3ce..a3051f4d99 100644 --- a/hal/src/main/native/sim/MockData/DIODataInternal.h +++ b/hal/src/main/native/sim/MockData/DIODataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/DIOData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/DigitalPWMDataInternal.h b/hal/src/main/native/sim/MockData/DigitalPWMDataInternal.h index 3ea5c24e08..41eaa6404a 100644 --- a/hal/src/main/native/sim/MockData/DigitalPWMDataInternal.h +++ b/hal/src/main/native/sim/MockData/DigitalPWMDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/DigitalPWMData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/DriverStationDataInternal.h b/hal/src/main/native/sim/MockData/DriverStationDataInternal.h index 16614c268a..2bbdd257c3 100644 --- a/hal/src/main/native/sim/MockData/DriverStationDataInternal.h +++ b/hal/src/main/native/sim/MockData/DriverStationDataInternal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "MockData/DriverStationData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/EncoderDataInternal.h b/hal/src/main/native/sim/MockData/EncoderDataInternal.h index df86ec6230..b5d18c0a4b 100644 --- a/hal/src/main/native/sim/MockData/EncoderDataInternal.h +++ b/hal/src/main/native/sim/MockData/EncoderDataInternal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "MockData/EncoderData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/HALValueInternal.h b/hal/src/main/native/sim/MockData/HALValueInternal.h index 05d59a1f0d..b48052ca6c 100644 --- a/hal/src/main/native/sim/MockData/HALValueInternal.h +++ b/hal/src/main/native/sim/MockData/HALValueInternal.h @@ -11,7 +11,7 @@ #include #include "MockData/HALValue.h" -#include "MockData/llvm/StringRef.h" +#include "MockData/wpi/StringRef.h" namespace hal { @@ -19,9 +19,9 @@ class Value; void ConvertToC(const Value& in, HAL_Value* out); std::shared_ptr ConvertFromC(const HAL_Value& value); -void ConvertToC(llvm::StringRef in, HALString* out); -inline llvm::StringRef ConvertFromC(const HALString& str) { - return llvm::StringRef(str.str, str.len); +void ConvertToC(wpi::StringRef in, HALString* out); +inline wpi::StringRef ConvertFromC(const HALString& str) { + return wpi::StringRef(str.str, str.len); } } // namespace hal diff --git a/hal/src/main/native/sim/MockData/I2CDataInternal.h b/hal/src/main/native/sim/MockData/I2CDataInternal.h index 3b53b252c3..8e05f4e1d4 100644 --- a/hal/src/main/native/sim/MockData/I2CDataInternal.h +++ b/hal/src/main/native/sim/MockData/I2CDataInternal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "MockData/I2CData.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/PCMDataInternal.h b/hal/src/main/native/sim/MockData/PCMDataInternal.h index 69b83cf707..e7d2bbc62a 100644 --- a/hal/src/main/native/sim/MockData/PCMDataInternal.h +++ b/hal/src/main/native/sim/MockData/PCMDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "../PortsInternal.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/PDPDataInternal.h b/hal/src/main/native/sim/MockData/PDPDataInternal.h index aaa8104071..4e1b5ab51d 100644 --- a/hal/src/main/native/sim/MockData/PDPDataInternal.h +++ b/hal/src/main/native/sim/MockData/PDPDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "../PortsInternal.h" #include "MockData/NotifyListenerVector.h" diff --git a/hal/src/main/native/sim/MockData/PWMDataInternal.h b/hal/src/main/native/sim/MockData/PWMDataInternal.h index 76cd13a77b..229a8a4226 100644 --- a/hal/src/main/native/sim/MockData/PWMDataInternal.h +++ b/hal/src/main/native/sim/MockData/PWMDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" #include "MockData/PWMData.h" diff --git a/hal/src/main/native/sim/MockData/RelayDataInternal.h b/hal/src/main/native/sim/MockData/RelayDataInternal.h index ee32eb2d5e..f9a46f306a 100644 --- a/hal/src/main/native/sim/MockData/RelayDataInternal.h +++ b/hal/src/main/native/sim/MockData/RelayDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" #include "MockData/RelayData.h" diff --git a/hal/src/main/native/sim/MockData/RoboRioDataInternal.h b/hal/src/main/native/sim/MockData/RoboRioDataInternal.h index 01cf245cdc..1980c6dd8b 100644 --- a/hal/src/main/native/sim/MockData/RoboRioDataInternal.h +++ b/hal/src/main/native/sim/MockData/RoboRioDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" #include "MockData/RoboRioData.h" diff --git a/hal/src/main/native/sim/MockData/SPIAccelerometerDataInternal.h b/hal/src/main/native/sim/MockData/SPIAccelerometerDataInternal.h index c0df5bae0c..228d047b6f 100644 --- a/hal/src/main/native/sim/MockData/SPIAccelerometerDataInternal.h +++ b/hal/src/main/native/sim/MockData/SPIAccelerometerDataInternal.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" #include "MockData/SPIAccelerometerData.h" diff --git a/hal/src/main/native/sim/MockData/SPIDataInternal.h b/hal/src/main/native/sim/MockData/SPIDataInternal.h index 8f0180be06..65eafd08ba 100644 --- a/hal/src/main/native/sim/MockData/SPIDataInternal.h +++ b/hal/src/main/native/sim/MockData/SPIDataInternal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" #include "MockData/SPIData.h" diff --git a/hal/src/main/native/sim/MockHooks.cpp b/hal/src/main/native/sim/MockHooks.cpp index 06ecce4061..62e2dcdccb 100644 --- a/hal/src/main/native/sim/MockHooks.cpp +++ b/hal/src/main/native/sim/MockHooks.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockHooksInternal.h" diff --git a/hal/src/main/native/sim/Notifier.cpp b/hal/src/main/native/sim/Notifier.cpp index 264352d492..59cd8c384a 100644 --- a/hal/src/main/native/sim/Notifier.cpp +++ b/hal/src/main/native/sim/Notifier.cpp @@ -9,9 +9,9 @@ #include -#include -#include -#include +#include +#include +#include #include "HAL/HAL.h" #include "HAL/cpp/fpga_clock.h" diff --git a/ntcore/src/main/native/cpp/CallbackManager.h b/ntcore/src/main/native/cpp/CallbackManager.h index cf43dbcc2b..44ca46b180 100644 --- a/ntcore/src/main/native/cpp/CallbackManager.h +++ b/ntcore/src/main/native/cpp/CallbackManager.h @@ -16,11 +16,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace nt { diff --git a/ntcore/src/main/native/cpp/Dispatcher.cpp b/ntcore/src/main/native/cpp/Dispatcher.cpp index cb734312fb..c7268b9abe 100644 --- a/ntcore/src/main/native/cpp/Dispatcher.cpp +++ b/ntcore/src/main/native/cpp/Dispatcher.cpp @@ -10,12 +10,13 @@ #include #include +#include +#include + #include "IConnectionNotifier.h" #include "IStorage.h" #include "Log.h" #include "NetworkConnection.h" -#include "tcpsockets/TCPAcceptor.h" -#include "tcpsockets/TCPConnector.h" using namespace nt; @@ -37,13 +38,13 @@ void Dispatcher::SetServer(const char* server_name, unsigned int port) { void Dispatcher::SetServer( ArrayRef> servers) { - llvm::SmallVector, 16> servers_copy; + wpi::SmallVector, 16> servers_copy; for (const auto& server : servers) servers_copy.emplace_back(std::string{server.first}, static_cast(server.second)); SetConnector([=]() -> std::unique_ptr { - llvm::SmallVector, 16> servers_copy2; + wpi::SmallVector, 16> servers_copy2; for (const auto& server : servers_copy) servers_copy2.emplace_back(server.first.c_str(), server.second); return wpi::TCPConnector::connect_parallel(servers_copy2, m_logger, 1); @@ -54,9 +55,9 @@ void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) { std::pair servers[5]; // 10.te.am.2 - llvm::SmallString<32> fixed; + wpi::SmallString<32> fixed; { - llvm::raw_svector_ostream oss{fixed}; + wpi::raw_svector_ostream oss{fixed}; oss << "10." << static_cast(team / 100) << '.' << static_cast(team % 100) << ".2"; servers[0] = std::make_pair(oss.str(), port); @@ -66,25 +67,25 @@ void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) { servers[1] = std::make_pair("172.22.11.2", port); // roboRIO--FRC.local - llvm::SmallString<32> mdns; + wpi::SmallString<32> mdns; { - llvm::raw_svector_ostream oss{mdns}; + wpi::raw_svector_ostream oss{mdns}; oss << "roboRIO-" << team << "-FRC.local"; servers[2] = std::make_pair(oss.str(), port); } // roboRIO--FRC.lan - llvm::SmallString<32> mdns_lan; + wpi::SmallString<32> mdns_lan; { - llvm::raw_svector_ostream oss{mdns_lan}; + wpi::raw_svector_ostream oss{mdns_lan}; oss << "roboRIO-" << team << "-FRC.lan"; servers[3] = std::make_pair(oss.str(), port); } // roboRIO--FRC.frc-field.local - llvm::SmallString<64> field_local; + wpi::SmallString<64> field_local; { - llvm::raw_svector_ostream oss{field_local}; + wpi::raw_svector_ostream oss{field_local}; oss << "roboRIO-" << team << "-FRC.frc-field.local"; servers[4] = std::make_pair(oss.str(), port); } @@ -463,7 +464,7 @@ void DispatcherBase::ClientThreadMain() { bool DispatcherBase::ClientHandshake( NetworkConnection& conn, std::function()> get_msg, - std::function>)> send_msgs) { + std::function>)> send_msgs) { // get identity std::string self_id; { @@ -543,7 +544,7 @@ bool DispatcherBase::ClientHandshake( bool DispatcherBase::ServerHandshake( NetworkConnection& conn, std::function()> get_msg, - std::function>)> send_msgs) { + std::function>)> send_msgs) { // Wait for the client to send us a hello. auto msg = get_msg(); if (!msg) { diff --git a/ntcore/src/main/native/cpp/Dispatcher.h b/ntcore/src/main/native/cpp/Dispatcher.h index 8a5d6e9f61..e96b4a6b31 100644 --- a/ntcore/src/main/native/cpp/Dispatcher.h +++ b/ntcore/src/main/native/cpp/Dispatcher.h @@ -17,10 +17,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "IDispatcher.h" #include "INetworkConnection.h" @@ -81,11 +81,11 @@ class DispatcherBase : public IDispatcher { bool ClientHandshake( NetworkConnection& conn, std::function()> get_msg, - std::function>)> send_msgs); + std::function>)> send_msgs); bool ServerHandshake( NetworkConnection& conn, std::function()> get_msg, - std::function>)> send_msgs); + std::function>)> send_msgs); void ClientReconnect(unsigned int proto_rev = 0x0300); diff --git a/ntcore/src/main/native/cpp/DsClient.cpp b/ntcore/src/main/native/cpp/DsClient.cpp index 563ce4e589..38992b096c 100644 --- a/ntcore/src/main/native/cpp/DsClient.cpp +++ b/ntcore/src/main/native/cpp/DsClient.cpp @@ -7,13 +7,13 @@ #include "DsClient.h" -#include -#include -#include +#include +#include +#include +#include #include "Dispatcher.h" #include "Log.h" -#include "tcpsockets/TCPConnector.h" using namespace nt; @@ -80,7 +80,7 @@ void DsClient::Thread::Main() { while (m_active && !is.has_error()) { // Read JSON "{...}". This is very limited, does not handle quoted "}" or // nested {}, but is sufficient for this purpose. - llvm::SmallString<128> json; + wpi::SmallString<128> json; char ch; // Throw away characters until { @@ -112,10 +112,10 @@ void DsClient::Thread::Main() { // Look for "robotIP":12345, and get 12345 portion size_t pos = json.find("\"robotIP\""); - if (pos == llvm::StringRef::npos) continue; // could not find? + if (pos == wpi::StringRef::npos) continue; // could not find? pos += 9; pos = json.find(':', pos); - if (pos == llvm::StringRef::npos) continue; // could not find? + if (pos == wpi::StringRef::npos) continue; // could not find? size_t endpos = json.find_first_not_of("0123456789", pos + 1); DEBUG3("found robotIP=" << json.slice(pos + 1, endpos)); @@ -136,7 +136,7 @@ void DsClient::Thread::Main() { // Convert number into dotted quad json.clear(); - llvm::raw_svector_ostream os{json}; + wpi::raw_svector_ostream os{json}; os << ((ip >> 24) & 0xff) << "." << ((ip >> 16) & 0xff) << "." << ((ip >> 8) & 0xff) << "." << (ip & 0xff); INFO("client: DS overriding server IP to " << os.str()); diff --git a/ntcore/src/main/native/cpp/DsClient.h b/ntcore/src/main/native/cpp/DsClient.h index 623a33cd4d..6e540bfad0 100644 --- a/ntcore/src/main/native/cpp/DsClient.h +++ b/ntcore/src/main/native/cpp/DsClient.h @@ -8,7 +8,7 @@ #ifndef NTCORE_DSCLIENT_H_ #define NTCORE_DSCLIENT_H_ -#include +#include #include "Log.h" diff --git a/ntcore/src/main/native/cpp/EntryNotifier.cpp b/ntcore/src/main/native/cpp/EntryNotifier.cpp index dfb7ab1c01..80f1a71f61 100644 --- a/ntcore/src/main/native/cpp/EntryNotifier.cpp +++ b/ntcore/src/main/native/cpp/EntryNotifier.cpp @@ -41,7 +41,7 @@ bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener, // must match local id or prefix if (listener.entry != 0 && data.entry != listener.entry) return false; if (listener.entry == 0 && - !llvm::StringRef(data.name).startswith(listener.prefix)) + !wpi::StringRef(data.name).startswith(listener.prefix)) return false; return true; @@ -62,7 +62,7 @@ unsigned int EntryNotifier::Add( } unsigned int EntryNotifier::AddPolled(unsigned int poller_uid, - llvm::StringRef prefix, + wpi::StringRef prefix, unsigned int flags) { if ((flags & NT_NOTIFY_LOCAL) != 0) m_local_notifiers = true; return DoAdd(poller_uid, prefix, flags); diff --git a/ntcore/src/main/native/cpp/EntryNotifier.h b/ntcore/src/main/native/cpp/EntryNotifier.h index cb5a61c516..c82b9cb5bc 100644 --- a/ntcore/src/main/native/cpp/EntryNotifier.h +++ b/ntcore/src/main/native/cpp/EntryNotifier.h @@ -86,10 +86,10 @@ class EntryNotifier bool local_notifiers() const override; unsigned int Add(std::function callback, - llvm::StringRef prefix, unsigned int flags) override; + wpi::StringRef prefix, unsigned int flags) override; unsigned int Add(std::function callback, unsigned int local_id, unsigned int flags) override; - unsigned int AddPolled(unsigned int poller_uid, llvm::StringRef prefix, + unsigned int AddPolled(unsigned int poller_uid, wpi::StringRef prefix, unsigned int flags) override; unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id, unsigned int flags) override; diff --git a/ntcore/src/main/native/cpp/IEntryNotifier.h b/ntcore/src/main/native/cpp/IEntryNotifier.h index 34db97cc25..f338a77387 100644 --- a/ntcore/src/main/native/cpp/IEntryNotifier.h +++ b/ntcore/src/main/native/cpp/IEntryNotifier.h @@ -25,12 +25,12 @@ class IEntryNotifier { virtual unsigned int Add( std::function callback, - llvm::StringRef prefix, unsigned int flags) = 0; + wpi::StringRef prefix, unsigned int flags) = 0; virtual unsigned int Add( std::function callback, unsigned int local_id, unsigned int flags) = 0; virtual unsigned int AddPolled(unsigned int poller_uid, - llvm::StringRef prefix, + wpi::StringRef prefix, unsigned int flags) = 0; virtual unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id, unsigned int flags) = 0; diff --git a/ntcore/src/main/native/cpp/IStorage.h b/ntcore/src/main/native/cpp/IStorage.h index 9eb096add1..1cbb2cdab1 100644 --- a/ntcore/src/main/native/cpp/IStorage.h +++ b/ntcore/src/main/native/cpp/IStorage.h @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include #include "Message.h" #include "ntcore_cpp.h" @@ -48,7 +48,7 @@ class IStorage { INetworkConnection& conn, std::vector>* msgs) = 0; virtual void ApplyInitialAssignments( - INetworkConnection& conn, llvm::ArrayRef> msgs, + INetworkConnection& conn, wpi::ArrayRef> msgs, bool new_server, std::vector>* out_msgs) = 0; // Filename-based save/load functions. Used both by periodic saves and diff --git a/ntcore/src/main/native/cpp/InstanceImpl.h b/ntcore/src/main/native/cpp/InstanceImpl.h index a1dc2f3b45..7b3cc9aade 100644 --- a/ntcore/src/main/native/cpp/InstanceImpl.h +++ b/ntcore/src/main/native/cpp/InstanceImpl.h @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include "ConnectionNotifier.h" #include "Dispatcher.h" diff --git a/ntcore/src/main/native/cpp/Log.h b/ntcore/src/main/native/cpp/Log.h index bcc9078999..9af3b60db8 100644 --- a/ntcore/src/main/native/cpp/Log.h +++ b/ntcore/src/main/native/cpp/Log.h @@ -8,7 +8,7 @@ #ifndef NTCORE_LOG_H_ #define NTCORE_LOG_H_ -#include +#include #define LOG(level, x) WPI_LOG(m_logger, level, x) diff --git a/ntcore/src/main/native/cpp/LoggerImpl.cpp b/ntcore/src/main/native/cpp/LoggerImpl.cpp index c6c58b7127..7706cff40a 100644 --- a/ntcore/src/main/native/cpp/LoggerImpl.cpp +++ b/ntcore/src/main/native/cpp/LoggerImpl.cpp @@ -7,24 +7,24 @@ #include "LoggerImpl.h" -#include -#include -#include -#include +#include +#include +#include +#include using namespace nt; static void DefaultLogger(unsigned int level, const char* file, unsigned int line, const char* msg) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream oss(buf); if (level == 20) { oss << "NT: " << msg << '\n'; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); return; } - llvm::StringRef levelmsg; + wpi::StringRef levelmsg; if (level >= 50) levelmsg = "CRITICAL: "; else if (level >= 40) @@ -34,7 +34,7 @@ static void DefaultLogger(unsigned int level, const char* file, else return; oss << "NT: " << levelmsg << msg << " (" << file << ':' << line << ")\n"; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); } LoggerImpl::LoggerImpl(int inst) : m_inst(inst) {} @@ -67,7 +67,7 @@ unsigned int LoggerImpl::GetMinLevel() { void LoggerImpl::Log(unsigned int level, const char* file, unsigned int line, const char* msg) { // this is safe because it's null terminated and always the end - const char* filename = llvm::sys::path::filename(file).data(); + const char* filename = wpi::sys::path::filename(file).data(); { auto thr = GetThread(); if (!thr || thr->m_listeners.empty()) diff --git a/ntcore/src/main/native/cpp/Message.cpp b/ntcore/src/main/native/cpp/Message.cpp index e20f1492d0..b3474d4f19 100644 --- a/ntcore/src/main/native/cpp/Message.cpp +++ b/ntcore/src/main/native/cpp/Message.cpp @@ -126,7 +126,7 @@ std::shared_ptr Message::Read(WireDecoder& decoder, if (!decoder.ReadUleb128(&size)) return nullptr; const char* params; if (!decoder.Read(¶ms, size)) return nullptr; - msg->m_str = llvm::StringRef(params, size); + msg->m_str = wpi::StringRef(params, size); break; } case kRpcResponse: { @@ -140,7 +140,7 @@ std::shared_ptr Message::Read(WireDecoder& decoder, if (!decoder.ReadUleb128(&size)) return nullptr; const char* results; if (!decoder.Read(&results, size)) return nullptr; - msg->m_str = llvm::StringRef(results, size); + msg->m_str = wpi::StringRef(results, size); break; } default: @@ -151,21 +151,21 @@ std::shared_ptr Message::Read(WireDecoder& decoder, return msg; } -std::shared_ptr Message::ClientHello(llvm::StringRef self_id) { +std::shared_ptr Message::ClientHello(wpi::StringRef self_id) { auto msg = std::make_shared(kClientHello, private_init()); msg->m_str = self_id; return msg; } std::shared_ptr Message::ServerHello(unsigned int flags, - llvm::StringRef self_id) { + wpi::StringRef self_id) { auto msg = std::make_shared(kServerHello, private_init()); msg->m_str = self_id; msg->m_flags = flags; return msg; } -std::shared_ptr Message::EntryAssign(llvm::StringRef name, +std::shared_ptr Message::EntryAssign(wpi::StringRef name, unsigned int id, unsigned int seq_num, std::shared_ptr value, @@ -204,7 +204,7 @@ std::shared_ptr Message::EntryDelete(unsigned int id) { } std::shared_ptr Message::ExecuteRpc(unsigned int id, unsigned int uid, - llvm::StringRef params) { + wpi::StringRef params) { auto msg = std::make_shared(kExecuteRpc, private_init()); msg->m_str = params; msg->m_id = id; @@ -213,7 +213,7 @@ std::shared_ptr Message::ExecuteRpc(unsigned int id, unsigned int uid, } std::shared_ptr Message::RpcResponse(unsigned int id, unsigned int uid, - llvm::StringRef result) { + wpi::StringRef result) { auto msg = std::make_shared(kRpcResponse, private_init()); msg->m_str = result; msg->m_id = id; diff --git a/ntcore/src/main/native/cpp/Message.h b/ntcore/src/main/native/cpp/Message.h index 369b48f439..592ae73a60 100644 --- a/ntcore/src/main/native/cpp/Message.h +++ b/ntcore/src/main/native/cpp/Message.h @@ -50,7 +50,7 @@ class Message { // Message data accessors. Callers are responsible for knowing what data is // actually provided for a particular message. - llvm::StringRef str() const { return m_str; } + wpi::StringRef str() const { return m_str; } std::shared_ptr value() const { return m_value; } unsigned int id() const { return m_id; } unsigned int flags() const { return m_flags; } @@ -79,10 +79,10 @@ class Message { } // Create messages with data - static std::shared_ptr ClientHello(llvm::StringRef self_id); + static std::shared_ptr ClientHello(wpi::StringRef self_id); static std::shared_ptr ServerHello(unsigned int flags, - llvm::StringRef self_id); - static std::shared_ptr EntryAssign(llvm::StringRef name, + wpi::StringRef self_id); + static std::shared_ptr EntryAssign(wpi::StringRef name, unsigned int id, unsigned int seq_num, std::shared_ptr value, @@ -94,9 +94,9 @@ class Message { unsigned int flags); static std::shared_ptr EntryDelete(unsigned int id); static std::shared_ptr ExecuteRpc(unsigned int id, unsigned int uid, - llvm::StringRef params); + wpi::StringRef params); static std::shared_ptr RpcResponse(unsigned int id, unsigned int uid, - llvm::StringRef result); + wpi::StringRef result); Message(const Message&) = delete; Message& operator=(const Message&) = delete; diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp index dac87b907e..db7b3f7496 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.cpp +++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp @@ -7,14 +7,14 @@ #include "NetworkConnection.h" -#include -#include +#include +#include +#include #include "IConnectionNotifier.h" #include "Log.h" #include "WireDecoder.h" #include "WireEncoder.h" -#include "tcpsockets/NetworkStream.h" using namespace nt; @@ -143,7 +143,7 @@ void NetworkConnection::ReadThreadMain() { DEBUG("error reading in handshake: " << decoder.error()); return msg; }, - [&](llvm::ArrayRef> msgs) { + [&](wpi::ArrayRef> msgs) { m_outgoing.emplace(msgs); })) { set_state(kDead); diff --git a/ntcore/src/main/native/cpp/NetworkConnection.h b/ntcore/src/main/native/cpp/NetworkConnection.h index 2e57a42deb..05ce7a97e8 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.h +++ b/ntcore/src/main/native/cpp/NetworkConnection.h @@ -18,9 +18,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "INetworkConnection.h" #include "Message.h" @@ -40,7 +40,7 @@ class NetworkConnection : public INetworkConnection { typedef std::function()> get_msg, - std::function>)> send_msgs)> + std::function>)> send_msgs)> HandshakeFunc; typedef std::function msg, NetworkConnection* conn)> diff --git a/ntcore/src/main/native/cpp/RpcServer.cpp b/ntcore/src/main/native/cpp/RpcServer.cpp index 19b1e368f0..f70648e459 100644 --- a/ntcore/src/main/native/cpp/RpcServer.cpp +++ b/ntcore/src/main/native/cpp/RpcServer.cpp @@ -36,7 +36,7 @@ void RpcServer::ProcessRpc(unsigned int local_id, unsigned int call_uid, } void RpcServer::PostRpcResponse(unsigned int local_id, unsigned int call_uid, - llvm::StringRef result) { + wpi::StringRef result) { auto thr = GetThread(); auto i = thr->m_response_map.find(impl::RpcIdPair{local_id, call_uid}); if (i == thr->m_response_map.end()) { diff --git a/ntcore/src/main/native/cpp/RpcServer.h b/ntcore/src/main/native/cpp/RpcServer.h index 2b80db7f04..6a38c07f97 100644 --- a/ntcore/src/main/native/cpp/RpcServer.h +++ b/ntcore/src/main/native/cpp/RpcServer.h @@ -10,8 +10,8 @@ #include -#include -#include +#include +#include #include "CallbackManager.h" #include "Handle.h" @@ -75,7 +75,7 @@ class RpcServerThread int m_inst; wpi::Logger& m_logger; - llvm::DenseMap m_response_map; + wpi::DenseMap m_response_map; }; } // namespace impl @@ -100,7 +100,7 @@ class RpcServer : public IRpcServer, unsigned int rpc_uid) override; void PostRpcResponse(unsigned int local_id, unsigned int call_uid, - llvm::StringRef result); + wpi::StringRef result); private: int m_inst; diff --git a/ntcore/src/main/native/cpp/Storage.cpp b/ntcore/src/main/native/cpp/Storage.cpp index 9f8a7a3a11..a7d8ba127b 100644 --- a/ntcore/src/main/native/cpp/Storage.cpp +++ b/ntcore/src/main/native/cpp/Storage.cpp @@ -7,7 +7,7 @@ #include "Storage.h" -#include +#include #include "Handle.h" #include "IDispatcher.h" @@ -386,7 +386,7 @@ void Storage::GetInitialAssignments( } void Storage::ApplyInitialAssignments( - INetworkConnection& conn, llvm::ArrayRef> msgs, + INetworkConnection& conn, wpi::ArrayRef> msgs, bool new_server, std::vector>* out_msgs) { std::unique_lock lock(m_mutex); if (m_server) return; // should not do this on server @@ -758,7 +758,7 @@ void Storage::DeleteAllEntries() { } Storage::Entry* Storage::GetOrNew(const Twine& name) { - llvm::SmallString<128> nameBuf; + wpi::SmallString<128> nameBuf; StringRef nameStr = name.toStringRef(nameBuf); auto& entry = m_entries[nameStr]; if (!entry) { @@ -779,7 +779,7 @@ unsigned int Storage::GetEntry(const Twine& name) { std::vector Storage::GetEntries(const Twine& prefix, unsigned int types) { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); std::lock_guard lock(m_mutex); std::vector ids; @@ -837,7 +837,7 @@ uint64_t Storage::GetEntryLastChange(unsigned int local_id) const { std::vector Storage::GetEntryInfo(int inst, const Twine& prefix, unsigned int types) { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); std::lock_guard lock(m_mutex); std::vector infos; @@ -861,7 +861,7 @@ unsigned int Storage::AddListener( const Twine& prefix, std::function callback, unsigned int flags) const { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); std::lock_guard lock(m_mutex); unsigned int uid = m_notifier.Add(callback, prefixStr, flags); @@ -898,7 +898,7 @@ unsigned int Storage::AddListener( unsigned int Storage::AddPolledListener(unsigned int poller, const Twine& prefix, unsigned int flags) const { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); std::lock_guard lock(m_mutex); unsigned int uid = m_notifier.AddPolled(poller, prefixStr, flags); @@ -965,7 +965,7 @@ bool Storage::GetEntries( const Twine& prefix, std::vector>>* entries) const { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); // copy values out of storage as quickly as possible so lock isn't held { diff --git a/ntcore/src/main/native/cpp/Storage.h b/ntcore/src/main/native/cpp/Storage.h index 333f218108..002b83d06c 100644 --- a/ntcore/src/main/native/cpp/Storage.h +++ b/ntcore/src/main/native/cpp/Storage.h @@ -18,24 +18,21 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "IStorage.h" #include "Message.h" #include "SequenceNumber.h" #include "ntcore_cpp.h" -namespace llvm { -class raw_ostream; -} // namespace llvm - namespace wpi { class Logger; class raw_istream; +class raw_ostream; } // namespace wpi namespace nt { @@ -72,7 +69,7 @@ class Storage : public IStorage { INetworkConnection& conn, std::vector>* msgs) override; void ApplyInitialAssignments( - INetworkConnection& conn, llvm::ArrayRef> msgs, + INetworkConnection& conn, wpi::ArrayRef> msgs, bool new_server, std::vector>* out_msgs) override; @@ -142,11 +139,11 @@ class Storage : public IStorage { // Stream-based save/load functions (exposed for testing purposes). These // implement the guts of the filename-based functions. - void SavePersistent(llvm::raw_ostream& os, bool periodic) const; + void SavePersistent(wpi::raw_ostream& os, bool periodic) const; bool LoadEntries(wpi::raw_istream& is, const Twine& prefix, bool persistent, std::function warn); - void SaveEntries(llvm::raw_ostream& os, const Twine& prefix) const; + void SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const; // RPC configuration needs to come through here as RPC definitions are // actually special Storage value types. @@ -161,7 +158,7 @@ class Storage : public IStorage { private: // Data for each table entry. struct Entry { - explicit Entry(llvm::StringRef name_) : name(name_) {} + explicit Entry(wpi::StringRef name_) : name(name_) {} bool IsPersistent() const { return (flags & NT_PERSISTENT) != 0; } // We redundantly store the name so that it's available when accessing the @@ -195,12 +192,12 @@ class Storage : public IStorage { unsigned int rpc_call_uid{0}; }; - typedef llvm::StringMap EntriesMap; + typedef wpi::StringMap EntriesMap; typedef std::vector IdMap; typedef std::vector> LocalMap; typedef std::pair RpcIdPair; - typedef llvm::DenseMap RpcResultMap; - typedef llvm::SmallSet RpcBlockingCallSet; + typedef wpi::DenseMap RpcResultMap; + typedef wpi::SmallSet RpcBlockingCallSet; mutable wpi::mutex m_mutex; EntriesMap m_entries; diff --git a/ntcore/src/main/native/cpp/Storage_load.cpp b/ntcore/src/main/native/cpp/Storage_load.cpp index 4c8641cdc1..84d0c3e6c3 100644 --- a/ntcore/src/main/native/cpp/Storage_load.cpp +++ b/ntcore/src/main/native/cpp/Storage_load.cpp @@ -8,10 +8,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "IDispatcher.h" #include "IEntryNotifier.h" @@ -35,7 +35,7 @@ class LoadPersistentImpl { bool ReadLine(); bool ReadHeader(); NT_Type ReadType(); - llvm::StringRef ReadName(llvm::SmallVectorImpl& buf); + wpi::StringRef ReadName(wpi::SmallVectorImpl& buf); std::shared_ptr ReadValue(NT_Type type); std::shared_ptr ReadBooleanValue(); std::shared_ptr ReadDoubleValue(); @@ -52,8 +52,8 @@ class LoadPersistentImpl { wpi::raw_istream& m_is; WarnFunc m_warn; - llvm::StringRef m_line; - llvm::SmallString<128> m_line_buf; + wpi::StringRef m_line; + wpi::SmallString<128> m_line_buf; size_t m_line_num = 0; std::vector m_buf_boolean_array; @@ -71,11 +71,11 @@ class LoadPersistentImpl { * Returns a pair containing the extracted token (if any) and the remaining * tail string. */ -static std::pair ReadStringToken( - llvm::StringRef source) { +static std::pair ReadStringToken( + wpi::StringRef source) { // Match opening quote if (source.empty() || source.front() != '"') - return std::make_pair(llvm::StringRef(), source); + return std::make_pair(wpi::StringRef(), source); // Scan for ending double quote, checking for escaped as we go. size_t size = source.size(); @@ -98,8 +98,8 @@ static int fromxdigit(char ch) { return ch - '0'; } -static llvm::StringRef UnescapeString(llvm::StringRef source, - llvm::SmallVectorImpl& buf) { +static wpi::StringRef UnescapeString(wpi::StringRef source, + wpi::SmallVectorImpl& buf) { assert(source.size() >= 2 && source.front() == '"' && source.back() == '"'); buf.clear(); buf.reserve(source.size() - 2); @@ -137,7 +137,7 @@ static llvm::StringRef UnescapeString(llvm::StringRef source, break; } } - return llvm::StringRef{buf.data(), buf.size()}; + return wpi::StringRef{buf.data(), buf.size()}; } bool LoadPersistentImpl::Load(StringRef prefix, std::vector* entries) { @@ -152,8 +152,8 @@ bool LoadPersistentImpl::Load(StringRef prefix, std::vector* entries) { } // name - llvm::SmallString<128> buf; - llvm::StringRef name = ReadName(buf); + wpi::SmallString<128> buf; + wpi::StringRef name = ReadName(buf); if (name.empty() || !name.startswith(prefix)) continue; // = @@ -194,7 +194,7 @@ bool LoadPersistentImpl::ReadHeader() { } NT_Type LoadPersistentImpl::ReadType() { - llvm::StringRef tok; + wpi::StringRef tok; std::tie(tok, m_line) = m_line.split(' '); if (tok == "boolean") { return NT_BOOLEAN; @@ -205,7 +205,7 @@ NT_Type LoadPersistentImpl::ReadType() { } else if (tok == "raw") { return NT_RAW; } else if (tok == "array") { - llvm::StringRef array_tok; + wpi::StringRef array_tok; std::tie(array_tok, m_line) = m_line.split(' '); if (array_tok == "boolean") return NT_BOOLEAN_ARRAY; @@ -217,16 +217,16 @@ NT_Type LoadPersistentImpl::ReadType() { return NT_UNASSIGNED; } -llvm::StringRef LoadPersistentImpl::ReadName(llvm::SmallVectorImpl& buf) { - llvm::StringRef tok; +wpi::StringRef LoadPersistentImpl::ReadName(wpi::SmallVectorImpl& buf) { + wpi::StringRef tok; std::tie(tok, m_line) = ReadStringToken(m_line); if (tok.empty()) { Warn("missing name"); - return llvm::StringRef{}; + return wpi::StringRef{}; } if (tok.back() != '"') { Warn("unterminated name string"); - return llvm::StringRef{}; + return wpi::StringRef{}; } return UnescapeString(tok, buf); } @@ -262,7 +262,7 @@ std::shared_ptr LoadPersistentImpl::ReadBooleanValue() { std::shared_ptr LoadPersistentImpl::ReadDoubleValue() { // need to convert to null-terminated string for std::strtod() - llvm::SmallString<64> buf; + wpi::SmallString<64> buf; char* end; double v = std::strtod(m_line.c_str(buf), &end); if (*end != '\0') { @@ -273,7 +273,7 @@ std::shared_ptr LoadPersistentImpl::ReadDoubleValue() { } std::shared_ptr LoadPersistentImpl::ReadStringValue() { - llvm::StringRef tok; + wpi::StringRef tok; std::tie(tok, m_line) = ReadStringToken(m_line); if (tok.empty()) { Warn("missing string value"); @@ -283,12 +283,12 @@ std::shared_ptr LoadPersistentImpl::ReadStringValue() { Warn("unterminated string value"); return nullptr; } - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; return Value::MakeString(UnescapeString(tok, buf)); } std::shared_ptr LoadPersistentImpl::ReadRawValue() { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; size_t nr; return Value::MakeRaw(wpi::Base64Decode(m_line, &nr, buf)); } @@ -296,7 +296,7 @@ std::shared_ptr LoadPersistentImpl::ReadRawValue() { std::shared_ptr LoadPersistentImpl::ReadBooleanArrayValue() { m_buf_boolean_array.clear(); while (!m_line.empty()) { - llvm::StringRef tok; + wpi::StringRef tok; std::tie(tok, m_line) = m_line.split(','); tok = tok.trim(" \t"); if (tok == "true") { @@ -314,11 +314,11 @@ std::shared_ptr LoadPersistentImpl::ReadBooleanArrayValue() { std::shared_ptr LoadPersistentImpl::ReadDoubleArrayValue() { m_buf_double_array.clear(); while (!m_line.empty()) { - llvm::StringRef tok; + wpi::StringRef tok; std::tie(tok, m_line) = m_line.split(','); tok = tok.trim(" \t"); // need to convert to null-terminated string for std::strtod() - llvm::SmallString<64> buf; + wpi::SmallString<64> buf; char* end; double v = std::strtod(tok.c_str(buf), &end); if (*end != '\0') { @@ -334,7 +334,7 @@ std::shared_ptr LoadPersistentImpl::ReadDoubleArrayValue() { std::shared_ptr LoadPersistentImpl::ReadStringArrayValue() { m_buf_string_array.clear(); while (!m_line.empty()) { - llvm::StringRef tok; + wpi::StringRef tok; std::tie(tok, m_line) = ReadStringToken(m_line); if (tok.empty()) { Warn("missing string value"); @@ -345,7 +345,7 @@ std::shared_ptr LoadPersistentImpl::ReadStringArrayValue() { return nullptr; } - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; m_buf_string_array.push_back(UnescapeString(tok, buf)); m_line = m_line.ltrim(" \t"); @@ -363,7 +363,7 @@ std::shared_ptr LoadPersistentImpl::ReadStringArrayValue() { bool Storage::LoadEntries( wpi::raw_istream& is, const Twine& prefix, bool persistent, std::function warn) { - llvm::SmallString<128> prefixBuf; + wpi::SmallString<128> prefixBuf; StringRef prefixStr = prefix.toStringRef(prefixBuf); // entries to add diff --git a/ntcore/src/main/native/cpp/Storage_save.cpp b/ntcore/src/main/native/cpp/Storage_save.cpp index efe918f7c6..d10bb88d33 100644 --- a/ntcore/src/main/native/cpp/Storage_save.cpp +++ b/ntcore/src/main/native/cpp/Storage_save.cpp @@ -8,11 +8,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "Log.h" #include "Storage.h" @@ -25,25 +25,25 @@ class SavePersistentImpl { public: typedef std::pair> Entry; - explicit SavePersistentImpl(llvm::raw_ostream& os) : m_os(os) {} + explicit SavePersistentImpl(wpi::raw_ostream& os) : m_os(os) {} - void Save(llvm::ArrayRef entries); + void Save(wpi::ArrayRef entries); private: - void WriteString(llvm::StringRef str); + void WriteString(wpi::StringRef str); void WriteHeader(); - void WriteEntries(llvm::ArrayRef entries); - void WriteEntry(llvm::StringRef name, const Value& value); + void WriteEntries(wpi::ArrayRef entries); + void WriteEntry(wpi::StringRef name, const Value& value); bool WriteType(NT_Type type); void WriteValue(const Value& value); - llvm::raw_ostream& m_os; + wpi::raw_ostream& m_os; }; } // namespace /* Escapes and writes a string, including start and end double quotes */ -void SavePersistentImpl::WriteString(llvm::StringRef str) { +void SavePersistentImpl::WriteString(wpi::StringRef str) { m_os << '"'; for (auto c : str) { switch (c) { @@ -67,14 +67,14 @@ void SavePersistentImpl::WriteString(llvm::StringRef str) { // Write out the escaped representation. m_os << "\\x"; - m_os << llvm::hexdigit((c >> 4) & 0xF); - m_os << llvm::hexdigit((c >> 0) & 0xF); + m_os << wpi::hexdigit((c >> 4) & 0xF); + m_os << wpi::hexdigit((c >> 0) & 0xF); } } m_os << '"'; } -void SavePersistentImpl::Save(llvm::ArrayRef entries) { +void SavePersistentImpl::Save(wpi::ArrayRef entries) { WriteHeader(); WriteEntries(entries); } @@ -83,14 +83,14 @@ void SavePersistentImpl::WriteHeader() { m_os << "[NetworkTables Storage 3.0]\n"; } -void SavePersistentImpl::WriteEntries(llvm::ArrayRef entries) { +void SavePersistentImpl::WriteEntries(wpi::ArrayRef entries) { for (auto& i : entries) { if (!i.second) continue; WriteEntry(i.first, *i.second); } } -void SavePersistentImpl::WriteEntry(llvm::StringRef name, const Value& value) { +void SavePersistentImpl::WriteEntry(wpi::StringRef name, const Value& value) { if (!WriteType(value.type())) return; // type WriteString(name); // name m_os << '='; // '=' @@ -133,7 +133,7 @@ void SavePersistentImpl::WriteValue(const Value& value) { m_os << (value.GetBoolean() ? "true" : "false"); break; case NT_DOUBLE: - m_os << llvm::format("%g", value.GetDouble()); + m_os << wpi::format("%g", value.GetDouble()); break; case NT_STRING: WriteString(value.GetString()); @@ -156,7 +156,7 @@ void SavePersistentImpl::WriteValue(const Value& value) { for (auto elem : value.GetDoubleArray()) { if (!first) m_os << ','; first = false; - m_os << llvm::format("%g", elem); + m_os << wpi::format("%g", elem); } break; } @@ -174,7 +174,7 @@ void SavePersistentImpl::WriteValue(const Value& value) { } } -void Storage::SavePersistent(llvm::raw_ostream& os, bool periodic) const { +void Storage::SavePersistent(wpi::raw_ostream& os, bool periodic) const { std::vector entries; if (!GetPersistentEntries(periodic, &entries)) return; SavePersistentImpl(os).Save(entries); @@ -182,11 +182,11 @@ void Storage::SavePersistent(llvm::raw_ostream& os, bool periodic) const { const char* Storage::SavePersistent(const Twine& filename, bool periodic) const { - llvm::SmallString<128> fn; + wpi::SmallString<128> fn; filename.toVector(fn); - llvm::SmallString<128> tmp = fn; + wpi::SmallString<128> tmp = fn; tmp += ".tmp"; - llvm::SmallString<128> bak = fn; + wpi::SmallString<128> bak = fn; bak += ".bak"; // Get entries before creating file @@ -197,7 +197,7 @@ const char* Storage::SavePersistent(const Twine& filename, // start by writing to temporary file std::error_code ec; - llvm::raw_fd_ostream os(tmp, ec, llvm::sys::fs::F_Text); + wpi::raw_fd_ostream os(tmp, ec, wpi::sys::fs::F_Text); if (ec.value() != 0) { err = "could not open file"; goto done; @@ -226,7 +226,7 @@ done: return err; } -void Storage::SaveEntries(llvm::raw_ostream& os, const Twine& prefix) const { +void Storage::SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const { std::vector entries; if (!GetEntries(prefix, &entries)) return; SavePersistentImpl(os).Save(entries); @@ -234,11 +234,11 @@ void Storage::SaveEntries(llvm::raw_ostream& os, const Twine& prefix) const { const char* Storage::SaveEntries(const Twine& filename, const Twine& prefix) const { - llvm::SmallString<128> fn; + wpi::SmallString<128> fn; filename.toVector(fn); - llvm::SmallString<128> tmp = fn; + wpi::SmallString<128> tmp = fn; tmp += ".tmp"; - llvm::SmallString<128> bak = fn; + wpi::SmallString<128> bak = fn; bak += ".bak"; // Get entries before creating file @@ -247,7 +247,7 @@ const char* Storage::SaveEntries(const Twine& filename, // start by writing to temporary file std::error_code ec; - llvm::raw_fd_ostream os(tmp, ec, llvm::sys::fs::F_Text); + wpi::raw_fd_ostream os(tmp, ec, wpi::sys::fs::F_Text); if (ec.value() != 0) { return "could not open file"; } diff --git a/ntcore/src/main/native/cpp/Value.cpp b/ntcore/src/main/native/cpp/Value.cpp index fc63eeae87..0c906b1852 100644 --- a/ntcore/src/main/native/cpp/Value.cpp +++ b/ntcore/src/main/native/cpp/Value.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include "Value_internal.h" #include "networktables/NetworkTableValue.h" @@ -42,7 +42,7 @@ Value::~Value() { delete[] m_val.data.arr_string.arr; } -std::shared_ptr Value::MakeBooleanArray(llvm::ArrayRef value, +std::shared_ptr Value::MakeBooleanArray(wpi::ArrayRef value, uint64_t time) { auto val = std::make_shared(NT_BOOLEAN_ARRAY, time, private_init()); val->m_val.data.arr_boolean.arr = new int[value.size()]; @@ -51,7 +51,7 @@ std::shared_ptr Value::MakeBooleanArray(llvm::ArrayRef value, return val; } -std::shared_ptr Value::MakeDoubleArray(llvm::ArrayRef value, +std::shared_ptr Value::MakeDoubleArray(wpi::ArrayRef value, uint64_t time) { auto val = std::make_shared(NT_DOUBLE_ARRAY, time, private_init()); val->m_val.data.arr_double.arr = new double[value.size()]; @@ -60,7 +60,7 @@ std::shared_ptr Value::MakeDoubleArray(llvm::ArrayRef value, return val; } -std::shared_ptr Value::MakeStringArray(llvm::ArrayRef value, +std::shared_ptr Value::MakeStringArray(wpi::ArrayRef value, uint64_t time) { auto val = std::make_shared(NT_STRING_ARRAY, time, private_init()); val->m_string_array = value; @@ -142,7 +142,7 @@ void nt::ConvertToC(const Value& in, NT_Value* out) { out->type = in.type(); } -void nt::ConvertToC(llvm::StringRef in, NT_String* out) { +void nt::ConvertToC(wpi::StringRef in, NT_String* out) { out->len = in.size(); out->str = static_cast(std::malloc(in.size() + 1)); std::memcpy(out->str, in.data(), in.size()); @@ -164,10 +164,10 @@ std::shared_ptr nt::ConvertFromC(const NT_Value& value) { case NT_RPC: return Value::MakeRpc(ConvertFromC(value.data.v_raw)); case NT_BOOLEAN_ARRAY: - return Value::MakeBooleanArray(llvm::ArrayRef( + return Value::MakeBooleanArray(wpi::ArrayRef( value.data.arr_boolean.arr, value.data.arr_boolean.size)); case NT_DOUBLE_ARRAY: - return Value::MakeDoubleArray(llvm::ArrayRef( + return Value::MakeDoubleArray(wpi::ArrayRef( value.data.arr_double.arr, value.data.arr_double.size)); case NT_STRING_ARRAY: { std::vector v; diff --git a/ntcore/src/main/native/cpp/Value_internal.h b/ntcore/src/main/native/cpp/Value_internal.h index 6eb710b5a2..d06d58c8df 100644 --- a/ntcore/src/main/native/cpp/Value_internal.h +++ b/ntcore/src/main/native/cpp/Value_internal.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "ntcore_c.h" @@ -21,9 +21,9 @@ class Value; void ConvertToC(const Value& in, NT_Value* out); std::shared_ptr ConvertFromC(const NT_Value& value); -void ConvertToC(llvm::StringRef in, NT_String* out); -inline llvm::StringRef ConvertFromC(const NT_String& str) { - return llvm::StringRef(str.str, str.len); +void ConvertToC(wpi::StringRef in, NT_String* out); +inline wpi::StringRef ConvertFromC(const NT_String& str) { + return wpi::StringRef(str.str, str.len); } } // namespace nt diff --git a/ntcore/src/main/native/cpp/WireDecoder.cpp b/ntcore/src/main/native/cpp/WireDecoder.cpp index 4713823152..b86472bfe6 100644 --- a/ntcore/src/main/native/cpp/WireDecoder.cpp +++ b/ntcore/src/main/native/cpp/WireDecoder.cpp @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include using namespace nt; @@ -43,7 +43,7 @@ static double ReadDouble(const char*& buf) { val <<= 8; val |= (*reinterpret_cast(buf)) & 0xff; ++buf; - return llvm::BitsToDouble(val); + return wpi::BitsToDouble(val); } WireDecoder::WireDecoder(wpi::raw_istream& is, unsigned int proto_rev, @@ -202,6 +202,6 @@ bool WireDecoder::ReadString(std::string* str) { } const char* buf; if (!Read(&buf, len)) return false; - *str = llvm::StringRef(buf, len); + *str = wpi::StringRef(buf, len); return true; } diff --git a/ntcore/src/main/native/cpp/WireDecoder.h b/ntcore/src/main/native/cpp/WireDecoder.h index c8b166cbc0..a8b724fae2 100644 --- a/ntcore/src/main/native/cpp/WireDecoder.h +++ b/ntcore/src/main/native/cpp/WireDecoder.h @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include #include "Log.h" #include "networktables/NetworkTableValue.h" diff --git a/ntcore/src/main/native/cpp/WireEncoder.cpp b/ntcore/src/main/native/cpp/WireEncoder.cpp index 6457b20e4b..ba0c79ff1c 100644 --- a/ntcore/src/main/native/cpp/WireEncoder.cpp +++ b/ntcore/src/main/native/cpp/WireEncoder.cpp @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include using namespace nt; @@ -25,7 +25,7 @@ WireEncoder::WireEncoder(unsigned int proto_rev) { void WireEncoder::WriteDouble(double val) { // The highest performance way to do this, albeit non-portable. - uint64_t v = llvm::DoubleToBits(val); + uint64_t v = wpi::DoubleToBits(val); m_data.append( {static_cast((v >> 56) & 0xff), static_cast((v >> 48) & 0xff), static_cast((v >> 40) & 0xff), static_cast((v >> 32) & 0xff), @@ -175,7 +175,7 @@ void WireEncoder::WriteValue(const Value& value) { } } -size_t WireEncoder::GetStringSize(llvm::StringRef str) const { +size_t WireEncoder::GetStringSize(wpi::StringRef str) const { if (m_proto_rev < 0x0300u) { size_t len = str.size(); if (len > 0xffff) len = 0xffff; // Limited to 64K length; truncate @@ -184,7 +184,7 @@ size_t WireEncoder::GetStringSize(llvm::StringRef str) const { return wpi::SizeUleb128(str.size()) + str.size(); } -void WireEncoder::WriteString(llvm::StringRef str) { +void WireEncoder::WriteString(wpi::StringRef str) { // length size_t len = str.size(); if (m_proto_rev < 0x0300u) { diff --git a/ntcore/src/main/native/cpp/WireEncoder.h b/ntcore/src/main/native/cpp/WireEncoder.h index 07e987977f..a787306b16 100644 --- a/ntcore/src/main/native/cpp/WireEncoder.h +++ b/ntcore/src/main/native/cpp/WireEncoder.h @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include #include "networktables/NetworkTableValue.h" @@ -52,8 +52,8 @@ class WireEncoder { /* Returns number of bytes written to memory buffer. */ size_t size() const { return m_data.size(); } - llvm::StringRef ToStringRef() const { - return llvm::StringRef(m_data.data(), m_data.size()); + wpi::StringRef ToStringRef() const { + return wpi::StringRef(m_data.data(), m_data.size()); } /* Writes a single byte. */ @@ -83,7 +83,7 @@ class WireEncoder { void WriteType(NT_Type type); void WriteValue(const Value& value); - void WriteString(llvm::StringRef str); + void WriteString(wpi::StringRef str); /* Utility function to get the written size of a value (without actually * writing it). @@ -93,7 +93,7 @@ class WireEncoder { /* Utility function to get the written size of a string (without actually * writing it). */ - size_t GetStringSize(llvm::StringRef str) const; + size_t GetStringSize(wpi::StringRef str) const; protected: /* The protocol revision. E.g. 0x0200 for version 2.0. */ @@ -103,7 +103,7 @@ class WireEncoder { const char* m_error; private: - llvm::SmallVector m_data; + wpi::SmallVector m_data; }; } // namespace nt diff --git a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp index 9f01a0ec42..6b068837f4 100644 --- a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp +++ b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp @@ -3,10 +3,10 @@ #include "edu_wpi_first_networktables_NetworkTablesJNI.h" #include "ntcore.h" -#include "support/jni_util.h" -#include "llvm/ConvertUTF.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" +#include "wpi/ConvertUTF.h" +#include "wpi/SmallString.h" +#include "wpi/jni_util.h" +#include "wpi/raw_ostream.h" using namespace wpi::java; @@ -141,7 +141,7 @@ std::shared_ptr FromJavaBooleanArray(JNIEnv* env, jbooleanArray jarr, jlong time) { CriticalJBooleanArrayRef ref{env, jarr}; if (!ref) return nullptr; - llvm::ArrayRef elements{ref}; + wpi::ArrayRef elements{ref}; size_t len = elements.size(); std::vector arr; arr.reserve(len); @@ -286,7 +286,7 @@ static jobject MakeJObject(JNIEnv *env, jobject inst, } static jobjectArray MakeJObject(JNIEnv *env, jobject inst, - llvm::ArrayRef arr) { + wpi::ArrayRef arr) { jobjectArray jarr = env->NewObjectArray(arr.size(), connectionNotificationCls, nullptr); if (!jarr) return nullptr; for (size_t i = 0; i < arr.size(); ++i) { @@ -297,7 +297,7 @@ static jobjectArray MakeJObject(JNIEnv *env, jobject inst, } static jobjectArray MakeJObject(JNIEnv *env, jobject inst, - llvm::ArrayRef arr) { + wpi::ArrayRef arr) { jobjectArray jarr = env->NewObjectArray(arr.size(), entryNotificationCls, nullptr); if (!jarr) return nullptr; for (size_t i = 0; i < arr.size(); ++i) { @@ -308,7 +308,7 @@ static jobjectArray MakeJObject(JNIEnv *env, jobject inst, } static jobjectArray MakeJObject(JNIEnv *env, jobject inst, - llvm::ArrayRef arr) { + wpi::ArrayRef arr) { jobjectArray jarr = env->NewObjectArray(arr.size(), logMessageCls, nullptr); if (!jarr) return nullptr; for (size_t i = 0; i < arr.size(); ++i) { @@ -319,7 +319,7 @@ static jobjectArray MakeJObject(JNIEnv *env, jobject inst, } static jobjectArray MakeJObject(JNIEnv *env, jobject inst, - llvm::ArrayRef arr) { + wpi::ArrayRef arr) { jobjectArray jarr = env->NewObjectArray(arr.size(), rpcAnswerCls, nullptr); if (!jarr) return nullptr; for (size_t i = 0; i < arr.size(); ++i) { @@ -1593,8 +1593,8 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_first_networktables_NetworkTablesJNI std::vector warns; const char* err = nt::LoadPersistent(inst, JStringRef{env, filename}.str(), [&](size_t line, const char* msg) { - llvm::SmallString<128> warn; - llvm::raw_svector_ostream oss(warn); + wpi::SmallString<128> warn; + wpi::raw_svector_ostream oss(warn); oss << line << ": " << msg; warns.emplace_back(oss.str()); }); @@ -1646,8 +1646,8 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_first_networktables_NetworkTablesJNI const char* err = nt::LoadEntries(inst, JStringRef{env, filename}.str(), JStringRef{env, prefix}.str(), [&](size_t line, const char* msg) { - llvm::SmallString<128> warn; - llvm::raw_svector_ostream oss(warn); + wpi::SmallString<128> warn; + wpi::raw_svector_ostream oss(warn); oss << line << ": " << msg; warns.emplace_back(oss.str()); }); diff --git a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp index 3414bff3a5..b685d4fe0f 100644 --- a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp +++ b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp @@ -9,9 +9,9 @@ #include -#include -#include -#include +#include +#include +#include #include "networktables/NetworkTableInstance.h" #include "ntcore.h" @@ -38,19 +38,19 @@ StringRef NetworkTable::BasenameKey(StringRef key) { std::string NetworkTable::NormalizeKey(const Twine& key, bool withLeadingSlash) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; return NormalizeKey(key, buf, withLeadingSlash); } StringRef NetworkTable::NormalizeKey(const Twine& key, - llvm::SmallVectorImpl& buf, + wpi::SmallVectorImpl& buf, bool withLeadingSlash) { buf.clear(); if (withLeadingSlash) buf.push_back(PATH_SEPARATOR_CHAR); // for each path element, add it with a slash following - llvm::SmallString<128> keyBuf; + wpi::SmallString<128> keyBuf; StringRef keyStr = key.toStringRef(keyBuf); - llvm::SmallVector parts; + wpi::SmallVector parts; keyStr.split(parts, PATH_SEPARATOR_CHAR, -1, false); for (auto i = parts.begin(); i != parts.end(); ++i) { buf.append(i->begin(), i->end()); @@ -65,10 +65,10 @@ std::vector NetworkTable::GetHierarchy(const Twine& key) { std::vector hierarchy; hierarchy.emplace_back(1, PATH_SEPARATOR_CHAR); // for each path element, add it to the end of what we built previously - llvm::SmallString<128> keyBuf; + wpi::SmallString<128> keyBuf; StringRef keyStr = key.toStringRef(keyBuf); - llvm::SmallString<128> path; - llvm::SmallVector parts; + wpi::SmallString<128> path; + wpi::SmallVector parts; keyStr.split(parts, PATH_SEPARATOR_CHAR, -1, false); if (!parts.empty()) { for (auto i = parts.begin(); i != parts.end(); ++i) { @@ -121,7 +121,7 @@ void NetworkTable::SetTeam(int team) { void NetworkTable::SetIPAddress(StringRef address) { auto inst = NetworkTableInstance::GetDefault(); - llvm::SmallString<32> addr_copy{address}; + wpi::SmallString<32> addr_copy{address}; inst.SetServer(addr_copy.c_str(), s_port); // Stop the DS client if we're explicitly connecting to localhost @@ -133,7 +133,7 @@ void NetworkTable::SetIPAddress(StringRef address) { void NetworkTable::SetIPAddress(ArrayRef addresses) { auto inst = NetworkTableInstance::GetDefault(); - llvm::SmallVector servers; + wpi::SmallVector servers; for (const auto& ip_address : addresses) servers.emplace_back(ip_address); inst.SetServer(servers, s_port); @@ -201,7 +201,7 @@ NetworkTableInstance NetworkTable::GetInstance() const { } NetworkTableEntry NetworkTable::GetEntry(const Twine& key) const { - llvm::SmallString<128> keyBuf; + wpi::SmallString<128> keyBuf; StringRef keyStr = key.toStringRef(keyBuf); std::lock_guard lock(m_mutex); NT_Entry& entry = m_entries[keyStr]; @@ -257,7 +257,7 @@ void NetworkTable::AddTableListener(ITableListener* listener, void NetworkTable::AddTableListenerEx(ITableListener* listener, unsigned int flags) { std::lock_guard lock(m_mutex); - llvm::SmallString<128> path(m_path); + wpi::SmallString<128> path(m_path); path += PATH_SEPARATOR_CHAR; size_t prefix_len = path.size(); NT_EntryListener id = nt::AddEntryListener( @@ -304,7 +304,7 @@ void NetworkTable::AddSubTableListener(ITableListener* listener, // The lambda needs to be copyable, but StringMap is not, so use // a shared_ptr to it. - auto notified_tables = std::make_shared>(); + auto notified_tables = std::make_shared>(); unsigned int flags = NT_NOTIFY_NEW | NT_NOTIFY_IMMEDIATE; if (localNotify) flags |= NT_NOTIFY_LOCAL; diff --git a/ntcore/src/main/native/cpp/networktables/NetworkTableInstance.cpp b/ntcore/src/main/native/cpp/networktables/NetworkTableInstance.cpp index e01dade0f9..47762285c5 100644 --- a/ntcore/src/main/native/cpp/networktables/NetworkTableInstance.cpp +++ b/ntcore/src/main/native/cpp/networktables/NetworkTableInstance.cpp @@ -7,7 +7,7 @@ #include "networktables/NetworkTableInstance.h" -#include +#include using namespace nt; @@ -31,7 +31,7 @@ std::shared_ptr NetworkTableInstance::GetTable( void NetworkTableInstance::StartClient(ArrayRef servers, unsigned int port) { - llvm::SmallVector, 8> server_ports; + wpi::SmallVector, 8> server_ports; for (const auto& server : servers) server_ports.emplace_back(std::make_pair(server, port)); StartClient(server_ports); @@ -39,7 +39,7 @@ void NetworkTableInstance::StartClient(ArrayRef servers, void NetworkTableInstance::SetServer(ArrayRef servers, unsigned int port) { - llvm::SmallVector, 8> server_ports; + wpi::SmallVector, 8> server_ports; for (const auto& server : servers) server_ports.emplace_back(std::make_pair(server, port)); SetServer(server_ports); diff --git a/ntcore/src/main/native/cpp/ntcore_c.cpp b/ntcore/src/main/native/cpp/ntcore_c.cpp index 35ebbc5f68..09b457a713 100644 --- a/ntcore/src/main/native/cpp/ntcore_c.cpp +++ b/ntcore/src/main/native/cpp/ntcore_c.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Value_internal.h" #include "ntcore.h" @@ -19,7 +19,7 @@ using namespace nt; // Conversion helpers -static void ConvertToC(llvm::StringRef in, char** out) { +static void ConvertToC(wpi::StringRef in, char** out) { *out = static_cast(std::malloc(in.size() + 1)); std::memmove(*out, in.data(), in.size()); (*out)[in.size()] = '\0'; @@ -915,11 +915,11 @@ NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, uint64_t time, NT_Bool force) { if (force != 0) { nt::SetEntryTypeValue( - entry, Value::MakeBooleanArray(llvm::makeArrayRef(arr, size), time)); + entry, Value::MakeBooleanArray(wpi::makeArrayRef(arr, size), time)); return 1; } else { return nt::SetEntryValue( - entry, Value::MakeBooleanArray(llvm::makeArrayRef(arr, size), time)); + entry, Value::MakeBooleanArray(wpi::makeArrayRef(arr, size), time)); } } @@ -927,11 +927,11 @@ NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, uint64_t time, const double* arr, size_t size, NT_Bool force) { if (force != 0) { nt::SetEntryTypeValue( - entry, Value::MakeDoubleArray(llvm::makeArrayRef(arr, size), time)); + entry, Value::MakeDoubleArray(wpi::makeArrayRef(arr, size), time)); return 1; } else { return nt::SetEntryValue( - entry, Value::MakeDoubleArray(llvm::makeArrayRef(arr, size), time)); + entry, Value::MakeDoubleArray(wpi::makeArrayRef(arr, size), time)); } } @@ -1061,7 +1061,7 @@ NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time, size_t default_size) { return nt::SetDefaultEntryValue( entry, Value::MakeBooleanArray( - llvm::makeArrayRef(default_value, default_size), time)); + wpi::makeArrayRef(default_value, default_size), time)); } NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time, @@ -1069,7 +1069,7 @@ NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time, size_t default_size) { return nt::SetDefaultEntryValue( entry, Value::MakeDoubleArray( - llvm::makeArrayRef(default_value, default_size), time)); + wpi::makeArrayRef(default_value, default_size), time)); } NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, uint64_t time, diff --git a/ntcore/src/main/native/cpp/ntcore_cpp.cpp b/ntcore/src/main/native/cpp/ntcore_cpp.cpp index 5e2b95ce0c..3146f16c1f 100644 --- a/ntcore/src/main/native/cpp/ntcore_cpp.cpp +++ b/ntcore/src/main/native/cpp/ntcore_cpp.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "Handle.h" #include "InstanceImpl.h" diff --git a/ntcore/src/main/native/cpp/ntcore_test.cpp b/ntcore/src/main/native/cpp/ntcore_test.cpp index ac5cc80995..26ec755161 100644 --- a/ntcore/src/main/native/cpp/ntcore_test.cpp +++ b/ntcore/src/main/native/cpp/ntcore_test.cpp @@ -13,7 +13,7 @@ extern "C" { struct NT_String* NT_GetStringForTesting(const char* string, int* struct_size) { struct NT_String* str = static_cast(std::calloc(1, sizeof(NT_String))); - nt::ConvertToC(llvm::StringRef(string), str); + nt::ConvertToC(wpi::StringRef(string), str); *struct_size = sizeof(NT_String); return str; } @@ -25,7 +25,7 @@ struct NT_EntryInfo* NT_GetEntryInfoForTesting(const char* name, int* struct_size) { struct NT_EntryInfo* entry_info = static_cast(std::calloc(1, sizeof(NT_EntryInfo))); - nt::ConvertToC(llvm::StringRef(name), &entry_info->name); + nt::ConvertToC(wpi::StringRef(name), &entry_info->name); entry_info->type = type; entry_info->flags = flags; entry_info->last_change = last_change; @@ -43,8 +43,8 @@ struct NT_ConnectionInfo* NT_GetConnectionInfoForTesting( uint64_t last_update, unsigned int protocol_version, int* struct_size) { struct NT_ConnectionInfo* conn_info = static_cast( std::calloc(1, sizeof(NT_ConnectionInfo))); - nt::ConvertToC(llvm::StringRef(remote_id), &conn_info->remote_id); - nt::ConvertToC(llvm::StringRef(remote_ip), &conn_info->remote_ip); + nt::ConvertToC(wpi::StringRef(remote_id), &conn_info->remote_id); + nt::ConvertToC(wpi::StringRef(remote_ip), &conn_info->remote_ip); conn_info->remote_port = remote_port; conn_info->last_update = last_update; conn_info->protocol_version = protocol_version; @@ -87,7 +87,7 @@ struct NT_Value* NT_GetValueStringForTesting(uint64_t last_change, static_cast(std::calloc(1, sizeof(NT_Value))); value->type = NT_STRING; value->last_change = last_change; - nt::ConvertToC(llvm::StringRef(str), &value->data.v_string); + nt::ConvertToC(wpi::StringRef(str), &value->data.v_string); *struct_size = sizeof(NT_Value); return value; } @@ -98,7 +98,7 @@ struct NT_Value* NT_GetValueRawForTesting(uint64_t last_change, const char* raw, static_cast(std::calloc(1, sizeof(NT_Value))); value->type = NT_RAW; value->last_change = last_change; - nt::ConvertToC(llvm::StringRef(raw, raw_len), &value->data.v_string); + nt::ConvertToC(wpi::StringRef(raw, raw_len), &value->data.v_string); *struct_size = sizeof(NT_Value); return value; } @@ -165,7 +165,7 @@ static void CopyNtValue(const struct NT_Value* copy_from, static void CopyNtString(const struct NT_String* copy_from, struct NT_String* copy_to) { - nt::ConvertToC(llvm::StringRef(copy_from->str, copy_from->len), copy_to); + nt::ConvertToC(wpi::StringRef(copy_from->str, copy_from->len), copy_to); } struct NT_RpcParamDef* NT_GetRpcParamDefForTesting(const char* name, @@ -173,7 +173,7 @@ struct NT_RpcParamDef* NT_GetRpcParamDefForTesting(const char* name, int* struct_size) { struct NT_RpcParamDef* def = static_cast(std::calloc(1, sizeof(NT_RpcParamDef))); - nt::ConvertToC(llvm::StringRef(name), &def->name); + nt::ConvertToC(wpi::StringRef(name), &def->name); CopyNtValue(val, &def->def_value); *struct_size = sizeof(NT_RpcParamDef); return def; @@ -190,7 +190,7 @@ struct NT_RpcResultDef* NT_GetRpcResultsDefForTesting(const char* name, int* struct_size) { struct NT_RpcResultDef* def = static_cast(std::calloc(1, sizeof(NT_RpcResultDef))); - nt::ConvertToC(llvm::StringRef(name), &def->name); + nt::ConvertToC(wpi::StringRef(name), &def->name); def->type = type; *struct_size = sizeof(NT_RpcResultDef); return def; @@ -208,7 +208,7 @@ struct NT_RpcDefinition* NT_GetRpcDefinitionForTesting( struct NT_RpcDefinition* def = static_cast(std::calloc(1, sizeof(NT_RpcDefinition))); def->version = version; - nt::ConvertToC(llvm::StringRef(name), &def->name); + nt::ConvertToC(wpi::StringRef(name), &def->name); def->num_params = num_params; def->params = static_cast( std::malloc(num_params * sizeof(NT_RpcParamDef))); @@ -235,8 +235,8 @@ struct NT_RpcAnswer* NT_GetRpcAnswerForTesting( static_cast(std::calloc(1, sizeof(NT_RpcAnswer))); info->entry = rpc_id; info->call = call_uid; - nt::ConvertToC(llvm::StringRef(name), &info->name); - nt::ConvertToC(llvm::StringRef(params, params_len), &info->params); + nt::ConvertToC(wpi::StringRef(name), &info->name); + nt::ConvertToC(wpi::StringRef(params, params_len), &info->params); *struct_size = sizeof(NT_RpcAnswer); return info; } diff --git a/ntcore/src/main/native/cpp/tables/ITableListener.cpp b/ntcore/src/main/native/cpp/tables/ITableListener.cpp index f576b200a8..b334959388 100644 --- a/ntcore/src/main/native/cpp/tables/ITableListener.cpp +++ b/ntcore/src/main/native/cpp/tables/ITableListener.cpp @@ -9,7 +9,7 @@ #include "ntcore_c.h" -void ITableListener::ValueChangedEx(ITable* source, llvm::StringRef key, +void ITableListener::ValueChangedEx(ITable* source, wpi::StringRef key, std::shared_ptr value, unsigned int flags) { ValueChanged(source, key, value, (flags & NT_NOTIFY_NEW) != 0); diff --git a/ntcore/src/main/native/include/networktables/NetworkTable.h b/ntcore/src/main/native/include/networktables/NetworkTable.h index 0c049a2e79..c29b9f0265 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTable.h +++ b/ntcore/src/main/native/include/networktables/NetworkTable.h @@ -14,10 +14,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "networktables/NetworkTableEntry.h" #include "networktables/TableEntryListener.h" @@ -27,9 +27,9 @@ namespace nt { -using llvm::ArrayRef; -using llvm::StringRef; -using llvm::Twine; +using wpi::ArrayRef; +using wpi::StringRef; +using wpi::Twine; class NetworkTableInstance; @@ -46,7 +46,7 @@ class NetworkTable final : public ITable { NT_Inst m_inst; std::string m_path; mutable wpi::mutex m_mutex; - mutable llvm::StringMap m_entries; + mutable wpi::StringMap m_entries; typedef std::pair Listener; std::vector m_listeners; @@ -89,7 +89,7 @@ class NetworkTable final : public ITable { bool withLeadingSlash = true); static StringRef NormalizeKey(const Twine& key, - llvm::SmallVectorImpl& buf, + wpi::SmallVectorImpl& buf, bool withLeadingSlash = true); /** diff --git a/ntcore/src/main/native/include/networktables/NetworkTableEntry.h b/ntcore/src/main/native/include/networktables/NetworkTableEntry.h index c4fddcefad..5a1c7da402 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableEntry.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableEntry.h @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include #include "networktables/NetworkTableType.h" #include "networktables/NetworkTableValue.h" @@ -25,9 +25,9 @@ namespace nt { -using llvm::ArrayRef; -using llvm::StringRef; -using llvm::Twine; +using wpi::ArrayRef; +using wpi::StringRef; +using wpi::Twine; class NetworkTableInstance; diff --git a/ntcore/src/main/native/include/networktables/NetworkTableInstance.h b/ntcore/src/main/native/include/networktables/NetworkTableInstance.h index fc5c53ad78..7b24612c35 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableInstance.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableInstance.h @@ -14,9 +14,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "networktables/NetworkTable.h" #include "networktables/NetworkTableEntry.h" @@ -37,9 +37,9 @@ namespace nt { -using llvm::ArrayRef; -using llvm::StringRef; -using llvm::Twine; +using wpi::ArrayRef; +using wpi::StringRef; +using wpi::Twine; /** NetworkTables Instance. * diff --git a/ntcore/src/main/native/include/networktables/NetworkTableValue.h b/ntcore/src/main/native/include/networktables/NetworkTableValue.h index a8a6c8e710..c6877ead3c 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableValue.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableValue.h @@ -17,17 +17,17 @@ #include #include -#include -#include -#include +#include +#include +#include #include "ntcore_c.h" namespace nt { -using llvm::ArrayRef; -using llvm::StringRef; -using llvm::Twine; +using wpi::ArrayRef; +using wpi::StringRef; +using wpi::Twine; /** * A network table entry value. diff --git a/ntcore/src/main/native/include/networktables/TableEntryListener.h b/ntcore/src/main/native/include/networktables/TableEntryListener.h index 8142847ba9..e2c2ee990c 100644 --- a/ntcore/src/main/native/include/networktables/TableEntryListener.h +++ b/ntcore/src/main/native/include/networktables/TableEntryListener.h @@ -11,7 +11,7 @@ #include #include -#include +#include namespace nt { @@ -19,7 +19,7 @@ class NetworkTable; class NetworkTableEntry; class Value; -using llvm::StringRef; +using wpi::StringRef; /** * A listener that listens to changes in values in a NetworkTable. diff --git a/ntcore/src/main/native/include/networktables/TableListener.h b/ntcore/src/main/native/include/networktables/TableListener.h index e498690a1c..f30606a148 100644 --- a/ntcore/src/main/native/include/networktables/TableListener.h +++ b/ntcore/src/main/native/include/networktables/TableListener.h @@ -11,13 +11,13 @@ #include #include -#include +#include namespace nt { class NetworkTable; -using llvm::StringRef; +using wpi::StringRef; /** * A listener that listens to new sub-tables in a NetworkTable. diff --git a/ntcore/src/main/native/include/ntcore_c.h b/ntcore/src/main/native/include/ntcore_c.h index 8a93002174..cea67bab10 100644 --- a/ntcore/src/main/native/include/ntcore_c.h +++ b/ntcore/src/main/native/include/ntcore_c.h @@ -12,7 +12,7 @@ #include -#include +#include #ifdef __cplusplus extern "C" { diff --git a/ntcore/src/main/native/include/ntcore_cpp.h b/ntcore/src/main/native/include/ntcore_cpp.h index 786c9659f8..d5139ff2c6 100644 --- a/ntcore/src/main/native/include/ntcore_cpp.h +++ b/ntcore/src/main/native/include/ntcore_cpp.h @@ -17,18 +17,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "networktables/NetworkTableValue.h" namespace nt { -using llvm::ArrayRef; -using llvm::StringRef; -using llvm::Twine; +using wpi::ArrayRef; +using wpi::StringRef; +using wpi::Twine; /** NetworkTables Entry Information */ struct EntryInfo { diff --git a/ntcore/src/main/native/include/tables/ITable.h b/ntcore/src/main/native/include/tables/ITable.h index f14860e3cb..a769032504 100644 --- a/ntcore/src/main/native/include/tables/ITable.h +++ b/ntcore/src/main/native/include/tables/ITable.h @@ -12,9 +12,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "networktables/NetworkTableValue.h" @@ -35,7 +35,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param key the key to search for * @return true if the table as a value assigned to the given key */ - virtual bool ContainsKey(const llvm::Twine& key) const = 0; + virtual bool ContainsKey(const wpi::Twine& key) const = 0; /** * Determines whether there exists a non-empty subtable for this key @@ -45,7 +45,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @return true if there is a subtable with the key which contains at least * one key/subtable of its own */ - virtual bool ContainsSubTable(const llvm::Twine& key) const = 0; + virtual bool ContainsSubTable(const wpi::Twine& key) const = 0; /** * Gets the subtable in this table for the given name. @@ -54,7 +54,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @return a sub table relative to this one */ virtual std::shared_ptr GetSubTable( - const llvm::Twine& key) const = 0; + const wpi::Twine& key) const = 0; /** * @param types bitmask of types; 0 is treated as a "don't care". @@ -72,7 +72,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * * @param key the key to make persistent */ - virtual void SetPersistent(llvm::StringRef key) = 0; + virtual void SetPersistent(wpi::StringRef key) = 0; /** * Stop making a key's value persistent through program restarts. @@ -80,7 +80,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * * @param key the key name */ - virtual void ClearPersistent(llvm::StringRef key) = 0; + virtual void ClearPersistent(wpi::StringRef key) = 0; /** * Returns whether the value is persistent through program restarts. @@ -88,7 +88,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * * @param key the key name */ - virtual bool IsPersistent(llvm::StringRef key) const = 0; + virtual bool IsPersistent(wpi::StringRef key) const = 0; /** * Sets flags on the specified key in this table. The key can @@ -97,7 +97,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param key the key name * @param flags the flags to set (bitmask) */ - virtual void SetFlags(llvm::StringRef key, unsigned int flags) = 0; + virtual void SetFlags(wpi::StringRef key, unsigned int flags) = 0; /** * Clears flags on the specified key in this table. The key can @@ -106,7 +106,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param key the key name * @param flags the flags to clear (bitmask) */ - virtual void ClearFlags(llvm::StringRef key, unsigned int flags) = 0; + virtual void ClearFlags(wpi::StringRef key, unsigned int flags) = 0; /** * Returns the flags for the specified key. @@ -114,14 +114,14 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param key the key name * @return the flags, or 0 if the key is not defined */ - virtual unsigned int GetFlags(llvm::StringRef key) const = 0; + virtual unsigned int GetFlags(wpi::StringRef key) const = 0; /** * Deletes the specified key in this table. * * @param key the key name */ - virtual void Delete(const llvm::Twine& key) = 0; + virtual void Delete(const wpi::Twine& key) = 0; /** * Gets the value associated with a key as an object @@ -130,7 +130,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @return the value associated with the given key, or nullptr if the key * does not exist */ - virtual std::shared_ptr GetValue(const llvm::Twine& key) const = 0; + virtual std::shared_ptr GetValue(const wpi::Twine& key) const = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -138,7 +138,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultValue(const llvm::Twine& key, + virtual bool SetDefaultValue(const wpi::Twine& key, std::shared_ptr defaultValue) = 0; /** @@ -148,7 +148,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutValue(const llvm::Twine& key, + virtual bool PutValue(const wpi::Twine& key, std::shared_ptr value) = 0; /** @@ -158,7 +158,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutNumber(llvm::StringRef key, double value) = 0; + virtual bool PutNumber(wpi::StringRef key, double value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -166,7 +166,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultNumber(llvm::StringRef key, double defaultValue) = 0; + virtual bool SetDefaultNumber(wpi::StringRef key, double defaultValue) = 0; /** * Gets the number associated with the given name. @@ -176,7 +176,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @return the value associated with the given key or the given default value * if there is no value associated with the key */ - virtual double GetNumber(llvm::StringRef key, double defaultValue) const = 0; + virtual double GetNumber(wpi::StringRef key, double defaultValue) const = 0; /** * Put a string in the table @@ -185,7 +185,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutString(llvm::StringRef key, llvm::StringRef value) = 0; + virtual bool PutString(wpi::StringRef key, wpi::StringRef value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -193,8 +193,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultString(llvm::StringRef key, - llvm::StringRef defaultValue) = 0; + virtual bool SetDefaultString(wpi::StringRef key, + wpi::StringRef defaultValue) = 0; /** * Gets the string associated with the given name. If the key does not @@ -208,8 +208,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @note This makes a copy of the string. If the overhead of this is a * concern, use GetValue() instead. */ - virtual std::string GetString(llvm::StringRef key, - llvm::StringRef defaultValue) const = 0; + virtual std::string GetString(wpi::StringRef key, + wpi::StringRef defaultValue) const = 0; /** * Put a boolean in the table @@ -218,7 +218,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutBoolean(llvm::StringRef key, bool value) = 0; + virtual bool PutBoolean(wpi::StringRef key, bool value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -226,7 +226,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue) = 0; + virtual bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue) = 0; /** * Gets the boolean associated with the given name. If the key does not @@ -237,7 +237,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @return the value associated with the given key or the given default value * if there is no value associated with the key */ - virtual bool GetBoolean(llvm::StringRef key, bool defaultValue) const = 0; + virtual bool GetBoolean(wpi::StringRef key, bool defaultValue) const = 0; /** * Put a boolean array in the table @@ -249,8 +249,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * std::vector is special-cased in C++. 0 is false, any * non-zero value is true. */ - virtual bool PutBooleanArray(llvm::StringRef key, - llvm::ArrayRef value) = 0; + virtual bool PutBooleanArray(wpi::StringRef key, + wpi::ArrayRef value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -258,8 +258,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultBooleanArray(llvm::StringRef key, - llvm::ArrayRef defaultValue) = 0; + virtual bool SetDefaultBooleanArray(wpi::StringRef key, + wpi::ArrayRef defaultValue) = 0; /** * Returns the boolean array the key maps to. If the key does not exist or is @@ -277,7 +277,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * non-zero value is true. */ virtual std::vector GetBooleanArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) const = 0; + wpi::StringRef key, wpi::ArrayRef defaultValue) const = 0; /** * Put a number array in the table @@ -285,8 +285,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutNumberArray(llvm::StringRef key, - llvm::ArrayRef value) = 0; + virtual bool PutNumberArray(wpi::StringRef key, + wpi::ArrayRef value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -294,8 +294,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultNumberArray(llvm::StringRef key, - llvm::ArrayRef defaultValue) = 0; + virtual bool SetDefaultNumberArray(wpi::StringRef key, + wpi::ArrayRef defaultValue) = 0; /** * Returns the number array the key maps to. If the key does not exist or is @@ -309,7 +309,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * concern, use GetValue() instead. */ virtual std::vector GetNumberArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) const = 0; + wpi::StringRef key, wpi::ArrayRef defaultValue) const = 0; /** * Put a string array in the table @@ -317,8 +317,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutStringArray(llvm::StringRef key, - llvm::ArrayRef value) = 0; + virtual bool PutStringArray(wpi::StringRef key, + wpi::ArrayRef value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -327,7 +327,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @returns False if the table key exists with a different type */ virtual bool SetDefaultStringArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) = 0; + wpi::StringRef key, wpi::ArrayRef defaultValue) = 0; /** * Returns the string array the key maps to. If the key does not exist or is @@ -341,7 +341,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * concern, use GetValue() instead. */ virtual std::vector GetStringArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) const = 0; + wpi::StringRef key, wpi::ArrayRef defaultValue) const = 0; /** * Put a raw value (byte array) in the table @@ -349,7 +349,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param value the value that will be assigned * @return False if the table key already exists with a different type */ - virtual bool PutRaw(llvm::StringRef key, llvm::StringRef value) = 0; + virtual bool PutRaw(wpi::StringRef key, wpi::StringRef value) = 0; /** * Gets the current value in the table, setting it if it does not exist. @@ -357,8 +357,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ - virtual bool SetDefaultRaw(llvm::StringRef key, - llvm::StringRef defaultValue) = 0; + virtual bool SetDefaultRaw(wpi::StringRef key, + wpi::StringRef defaultValue) = 0; /** * Returns the raw value (byte array) the key maps to. If the key does not @@ -371,8 +371,8 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @note This makes a copy of the raw contents. If the overhead of this is a * concern, use GetValue() instead. */ - virtual std::string GetRaw(llvm::StringRef key, - llvm::StringRef defaultValue) const = 0; + virtual std::string GetRaw(wpi::StringRef key, + wpi::StringRef defaultValue) const = 0; /** * Add a listener for changes to the table @@ -410,7 +410,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * @param immediateNotify if true then this listener will be notified of all * current entries (marked as new) */ - virtual void AddTableListener(llvm::StringRef key, ITableListener* listener, + virtual void AddTableListener(wpi::StringRef key, ITableListener* listener, bool immediateNotify) = 0; /** @@ -422,7 +422,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { * current entries (marked as new) * @param flags bitmask of NT_NotifyKind specifying desired notifications */ - virtual void AddTableListenerEx(llvm::StringRef key, ITableListener* listener, + virtual void AddTableListenerEx(wpi::StringRef key, ITableListener* listener, unsigned int flags) = 0; /** @@ -450,7 +450,7 @@ class WPI_DEPRECATED("Use NetworkTable directly") ITable { /** * Gets the full path of this table. */ - virtual llvm::StringRef GetPath() const = 0; + virtual wpi::StringRef GetPath() const = 0; }; #endif // NTCORE_TABLES_ITABLE_H_ diff --git a/ntcore/src/main/native/include/tables/ITableListener.h b/ntcore/src/main/native/include/tables/ITableListener.h index 48127a631a..0ac7c6f15c 100644 --- a/ntcore/src/main/native/include/tables/ITableListener.h +++ b/ntcore/src/main/native/include/tables/ITableListener.h @@ -10,8 +10,8 @@ #include -#include -#include +#include +#include #include "networktables/NetworkTableValue.h" @@ -38,7 +38,7 @@ class WPI_DEPRECATED( * @param isNew true if the key did not previously exist in the table, * otherwise it is false */ - virtual void ValueChanged(ITable* source, llvm::StringRef key, + virtual void ValueChanged(ITable* source, wpi::StringRef key, std::shared_ptr value, bool isNew) = 0; /** @@ -51,7 +51,7 @@ class WPI_DEPRECATED( * @param flags update flags; for example, NT_NOTIFY_NEW if the key did not * previously exist in the table */ - virtual void ValueChangedEx(ITable* source, llvm::StringRef key, + virtual void ValueChangedEx(ITable* source, wpi::StringRef key, std::shared_ptr value, unsigned int flags); }; diff --git a/ntcore/src/test/native/cpp/EntryNotifierTest.cpp b/ntcore/src/test/native/cpp/EntryNotifierTest.cpp index 7982c28b57..8ef299d946 100644 --- a/ntcore/src/test/native/cpp/EntryNotifierTest.cpp +++ b/ntcore/src/test/native/cpp/EntryNotifierTest.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include +#include #include "EntryNotifier.h" #include "TestPrinters.h" diff --git a/ntcore/src/test/native/cpp/MockEntryNotifier.h b/ntcore/src/test/native/cpp/MockEntryNotifier.h index 3eff0f529b..2608a75d86 100644 --- a/ntcore/src/test/native/cpp/MockEntryNotifier.h +++ b/ntcore/src/test/native/cpp/MockEntryNotifier.h @@ -21,13 +21,13 @@ class MockEntryNotifier : public IEntryNotifier { MOCK_METHOD3( Add, unsigned int(std::function callback, - llvm::StringRef prefix, unsigned int flags)); + wpi::StringRef prefix, unsigned int flags)); MOCK_METHOD3( Add, unsigned int(std::function callback, unsigned int local_id, unsigned int flags)); MOCK_METHOD3(AddPolled, - unsigned int(unsigned int poller_uid, llvm::StringRef prefix, + unsigned int(unsigned int poller_uid, wpi::StringRef prefix, unsigned int flags)); MOCK_METHOD3(AddPolled, unsigned int(unsigned int poller_uid, unsigned int local_id, diff --git a/ntcore/src/test/native/cpp/StorageTest.cpp b/ntcore/src/test/native/cpp/StorageTest.cpp index c0be44b5c0..adfe61e0a3 100644 --- a/ntcore/src/test/native/cpp/StorageTest.cpp +++ b/ntcore/src/test/native/cpp/StorageTest.cpp @@ -7,8 +7,8 @@ #include "StorageTest.h" -#include -#include +#include +#include #include "MessageMatcher.h" #include "MockNetworkConnection.h" @@ -128,7 +128,7 @@ class StorageTestPersistent : public StorageTestEmpty { class MockLoadWarn { public: - MOCK_METHOD2(Warn, void(size_t line, llvm::StringRef msg)); + MOCK_METHOD2(Warn, void(size_t line, wpi::StringRef msg)); }; TEST_P(StorageTestEmpty, Construct) { @@ -546,20 +546,20 @@ TEST_P(StorageTestPopulated, GetEntryInfoPrefixTypes) { } TEST_P(StorageTestPersistent, SavePersistentEmpty) { - llvm::SmallString<256> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<256> buf; + wpi::raw_svector_ostream oss(buf); storage.SavePersistent(oss, false); ASSERT_EQ("[NetworkTables Storage 3.0]\n", oss.str()); } TEST_P(StorageTestPersistent, SavePersistent) { for (auto& i : entries()) i.getValue()->flags = NT_PERSISTENT; - llvm::SmallString<256> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<256> buf; + wpi::raw_svector_ostream oss(buf); storage.SavePersistent(oss, false); - llvm::StringRef out = oss.str(); + wpi::StringRef out = oss.str(); // std::fputs(out.c_str(), stderr); - llvm::StringRef line, rem = out; + wpi::StringRef line, rem = out; std::tie(line, rem) = rem.split('\n'); ASSERT_EQ("[NetworkTables Storage 3.0]", line); std::tie(line, rem) = rem.split('\n'); @@ -621,13 +621,13 @@ TEST_P(StorageTestEmpty, LoadPersistentBadHeader) { wpi::raw_mem_istream iss(""); EXPECT_CALL( warn, - Warn(1, llvm::StringRef("header line mismatch, ignoring rest of file"))); + Warn(1, wpi::StringRef("header line mismatch, ignoring rest of file"))); EXPECT_FALSE(storage.LoadEntries(iss, "", true, warn_func)); wpi::raw_mem_istream iss2("[NetworkTables"); EXPECT_CALL( warn, - Warn(1, llvm::StringRef("header line mismatch, ignoring rest of file"))); + Warn(1, wpi::StringRef("header line mismatch, ignoring rest of file"))); EXPECT_FALSE(storage.LoadEntries(iss2, "", true, warn_func)); EXPECT_TRUE(entries().empty()); @@ -850,7 +850,7 @@ TEST_P(StorageTestEmpty, LoadPersistentWarn) { wpi::raw_mem_istream iss( "[NetworkTables Storage 3.0]\nboolean \"foo\"=foo\n"); EXPECT_CALL( - warn, Warn(2, llvm::StringRef( + warn, Warn(2, wpi::StringRef( "unrecognized boolean value, not 'true' or 'false'"))); EXPECT_TRUE(storage.LoadEntries(iss, "", true, warn_func)); diff --git a/ntcore/src/test/native/cpp/TestPrinters.h b/ntcore/src/test/native/cpp/TestPrinters.h index 462db93d25..c2b4914d98 100644 --- a/ntcore/src/test/native/cpp/TestPrinters.h +++ b/ntcore/src/test/native/cpp/TestPrinters.h @@ -11,17 +11,17 @@ #include #include -#include +#include #include "gtest/gtest.h" -namespace llvm { +namespace wpi { inline void PrintTo(StringRef str, ::std::ostream* os) { ::testing::internal::PrintStringTo(str.str(), os); } -} // namespace llvm +} // namespace wpi namespace nt { diff --git a/ntcore/src/test/native/cpp/ValueTest.cpp b/ntcore/src/test/native/cpp/ValueTest.cpp index 1d087027f4..ffc3ee5202 100644 --- a/ntcore/src/test/native/cpp/ValueTest.cpp +++ b/ntcore/src/test/native/cpp/ValueTest.cpp @@ -69,7 +69,7 @@ TEST_F(ValueTest, String) { NT_InitValue(&cv); ConvertToC(*v, &cv); ASSERT_EQ(NT_STRING, cv.type); - ASSERT_EQ(llvm::StringRef("hello"), cv.data.v_string.str); + ASSERT_EQ(wpi::StringRef("hello"), cv.data.v_string.str); ASSERT_EQ(5u, cv.data.v_string.len); v = Value::MakeString("goodbye"); @@ -77,7 +77,7 @@ TEST_F(ValueTest, String) { ASSERT_EQ("goodbye", v->GetString()); ConvertToC(*v, &cv); ASSERT_EQ(NT_STRING, cv.type); - ASSERT_EQ(llvm::StringRef("goodbye"), cv.data.v_string.str); + ASSERT_EQ(wpi::StringRef("goodbye"), cv.data.v_string.str); ASSERT_EQ(7u, cv.data.v_string.len); NT_DisposeValue(&cv); @@ -91,7 +91,7 @@ TEST_F(ValueTest, Raw) { NT_InitValue(&cv); ConvertToC(*v, &cv); ASSERT_EQ(NT_RAW, cv.type); - ASSERT_EQ(llvm::StringRef("hello"), cv.data.v_string.str); + ASSERT_EQ(wpi::StringRef("hello"), cv.data.v_string.str); ASSERT_EQ(5u, cv.data.v_string.len); v = Value::MakeRaw("goodbye"); @@ -99,7 +99,7 @@ TEST_F(ValueTest, Raw) { ASSERT_EQ("goodbye", v->GetRaw()); ConvertToC(*v, &cv); ASSERT_EQ(NT_RAW, cv.type); - ASSERT_EQ(llvm::StringRef("goodbye"), cv.data.v_string.str); + ASSERT_EQ(wpi::StringRef("goodbye"), cv.data.v_string.str); ASSERT_EQ(7u, cv.data.v_string.len); NT_DisposeValue(&cv); @@ -109,7 +109,7 @@ TEST_F(ValueTest, BooleanArray) { std::vector vec{1, 0, 1}; auto v = Value::MakeBooleanArray(vec); ASSERT_EQ(NT_BOOLEAN_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetBooleanArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetBooleanArray()); NT_Value cv; NT_InitValue(&cv); ConvertToC(*v, &cv); @@ -123,7 +123,7 @@ TEST_F(ValueTest, BooleanArray) { vec = {0, 1, 0}; v = Value::MakeBooleanArray(vec); ASSERT_EQ(NT_BOOLEAN_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetBooleanArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetBooleanArray()); ConvertToC(*v, &cv); ASSERT_EQ(NT_BOOLEAN_ARRAY, cv.type); ASSERT_EQ(3u, cv.data.arr_boolean.size); @@ -135,7 +135,7 @@ TEST_F(ValueTest, BooleanArray) { vec = {1, 0}; v = Value::MakeBooleanArray(vec); ASSERT_EQ(NT_BOOLEAN_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetBooleanArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetBooleanArray()); ConvertToC(*v, &cv); ASSERT_EQ(NT_BOOLEAN_ARRAY, cv.type); ASSERT_EQ(2u, cv.data.arr_boolean.size); @@ -149,7 +149,7 @@ TEST_F(ValueTest, DoubleArray) { std::vector vec{0.5, 0.25, 0.5}; auto v = Value::MakeDoubleArray(vec); ASSERT_EQ(NT_DOUBLE_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetDoubleArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetDoubleArray()); NT_Value cv; NT_InitValue(&cv); ConvertToC(*v, &cv); @@ -163,7 +163,7 @@ TEST_F(ValueTest, DoubleArray) { vec = {0.25, 0.5, 0.25}; v = Value::MakeDoubleArray(vec); ASSERT_EQ(NT_DOUBLE_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetDoubleArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetDoubleArray()); ConvertToC(*v, &cv); ASSERT_EQ(NT_DOUBLE_ARRAY, cv.type); ASSERT_EQ(3u, cv.data.arr_double.size); @@ -175,7 +175,7 @@ TEST_F(ValueTest, DoubleArray) { vec = {0.5, 0.25}; v = Value::MakeDoubleArray(vec); ASSERT_EQ(NT_DOUBLE_ARRAY, v->type()); - ASSERT_EQ(llvm::ArrayRef(vec), v->GetDoubleArray()); + ASSERT_EQ(wpi::ArrayRef(vec), v->GetDoubleArray()); ConvertToC(*v, &cv); ASSERT_EQ(NT_DOUBLE_ARRAY, cv.type); ASSERT_EQ(2u, cv.data.arr_double.size); @@ -193,17 +193,17 @@ TEST_F(ValueTest, StringArray) { auto v = Value::MakeStringArray(std::move(vec)); ASSERT_EQ(NT_STRING_ARRAY, v->type()); ASSERT_EQ(3u, v->GetStringArray().size()); - ASSERT_EQ(llvm::StringRef("hello"), v->GetStringArray()[0]); - ASSERT_EQ(llvm::StringRef("goodbye"), v->GetStringArray()[1]); - ASSERT_EQ(llvm::StringRef("string"), v->GetStringArray()[2]); + ASSERT_EQ(wpi::StringRef("hello"), v->GetStringArray()[0]); + ASSERT_EQ(wpi::StringRef("goodbye"), v->GetStringArray()[1]); + ASSERT_EQ(wpi::StringRef("string"), v->GetStringArray()[2]); NT_Value cv; NT_InitValue(&cv); ConvertToC(*v, &cv); ASSERT_EQ(NT_STRING_ARRAY, cv.type); ASSERT_EQ(3u, cv.data.arr_string.size); - ASSERT_EQ(llvm::StringRef("hello"), cv.data.arr_string.arr[0].str); - ASSERT_EQ(llvm::StringRef("goodbye"), cv.data.arr_string.arr[1].str); - ASSERT_EQ(llvm::StringRef("string"), cv.data.arr_string.arr[2].str); + ASSERT_EQ(wpi::StringRef("hello"), cv.data.arr_string.arr[0].str); + ASSERT_EQ(wpi::StringRef("goodbye"), cv.data.arr_string.arr[1].str); + ASSERT_EQ(wpi::StringRef("string"), cv.data.arr_string.arr[2].str); // assign with same size vec.clear(); @@ -213,15 +213,15 @@ TEST_F(ValueTest, StringArray) { v = Value::MakeStringArray(vec); ASSERT_EQ(NT_STRING_ARRAY, v->type()); ASSERT_EQ(3u, v->GetStringArray().size()); - ASSERT_EQ(llvm::StringRef("s1"), v->GetStringArray()[0]); - ASSERT_EQ(llvm::StringRef("str2"), v->GetStringArray()[1]); - ASSERT_EQ(llvm::StringRef("string3"), v->GetStringArray()[2]); + ASSERT_EQ(wpi::StringRef("s1"), v->GetStringArray()[0]); + ASSERT_EQ(wpi::StringRef("str2"), v->GetStringArray()[1]); + ASSERT_EQ(wpi::StringRef("string3"), v->GetStringArray()[2]); ConvertToC(*v, &cv); ASSERT_EQ(NT_STRING_ARRAY, cv.type); ASSERT_EQ(3u, cv.data.arr_string.size); - ASSERT_EQ(llvm::StringRef("s1"), cv.data.arr_string.arr[0].str); - ASSERT_EQ(llvm::StringRef("str2"), cv.data.arr_string.arr[1].str); - ASSERT_EQ(llvm::StringRef("string3"), cv.data.arr_string.arr[2].str); + ASSERT_EQ(wpi::StringRef("s1"), cv.data.arr_string.arr[0].str); + ASSERT_EQ(wpi::StringRef("str2"), cv.data.arr_string.arr[1].str); + ASSERT_EQ(wpi::StringRef("string3"), cv.data.arr_string.arr[2].str); // assign with different size vec.clear(); @@ -230,13 +230,13 @@ TEST_F(ValueTest, StringArray) { v = Value::MakeStringArray(std::move(vec)); ASSERT_EQ(NT_STRING_ARRAY, v->type()); ASSERT_EQ(2u, v->GetStringArray().size()); - ASSERT_EQ(llvm::StringRef("short"), v->GetStringArray()[0]); - ASSERT_EQ(llvm::StringRef("er"), v->GetStringArray()[1]); + ASSERT_EQ(wpi::StringRef("short"), v->GetStringArray()[0]); + ASSERT_EQ(wpi::StringRef("er"), v->GetStringArray()[1]); ConvertToC(*v, &cv); ASSERT_EQ(NT_STRING_ARRAY, cv.type); ASSERT_EQ(2u, cv.data.arr_string.size); - ASSERT_EQ(llvm::StringRef("short"), cv.data.arr_string.arr[0].str); - ASSERT_EQ(llvm::StringRef("er"), cv.data.arr_string.arr[1].str); + ASSERT_EQ(wpi::StringRef("short"), cv.data.arr_string.arr[0].str); + ASSERT_EQ(wpi::StringRef("er"), cv.data.arr_string.arr[1].str); NT_DisposeValue(&cv); } diff --git a/ntcore/src/test/native/cpp/WireDecoderTest.cpp b/ntcore/src/test/native/cpp/WireDecoderTest.cpp index 5ac9a72197..4826639e94 100644 --- a/ntcore/src/test/native/cpp/WireDecoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireDecoderTest.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "TestPrinters.h" #include "WireDecoder.h" @@ -24,8 +24,8 @@ class WireDecoderTest : public ::testing::Test { WireDecoderTest() { v_boolean = Value::MakeBoolean(true); v_double = Value::MakeDouble(1.0); - v_string = Value::MakeString(llvm::StringRef("hello")); - v_raw = Value::MakeRaw(llvm::StringRef("hello")); + v_string = Value::MakeString(wpi::StringRef("hello")); + v_raw = Value::MakeRaw(wpi::StringRef("hello")); v_boolean_array = Value::MakeBooleanArray(std::vector{0, 1, 0}); v_boolean_array_big = Value::MakeBooleanArray(std::vector(255)); v_double_array = Value::MakeDoubleArray(std::vector{0.5, 0.25}); @@ -269,7 +269,7 @@ TEST_F(WireDecoderTest, ReadStringValue2) { ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_string, *val); - auto v_bye = Value::MakeString(llvm::StringRef("bye")); + auto v_bye = Value::MakeString(wpi::StringRef("bye")); val = d.ReadValue(NT_STRING); ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_bye, *val); @@ -442,7 +442,7 @@ TEST_F(WireDecoderTest, ReadStringValue3) { ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_string, *val); - auto v_bye = Value::MakeString(llvm::StringRef("bye")); + auto v_bye = Value::MakeString(wpi::StringRef("bye")); val = d.ReadValue(NT_STRING); ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_bye, *val); @@ -466,7 +466,7 @@ TEST_F(WireDecoderTest, ReadRawValue3) { ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_raw, *val); - auto v_bye = Value::MakeRaw(llvm::StringRef("bye")); + auto v_bye = Value::MakeRaw(wpi::StringRef("bye")); val = d.ReadValue(NT_RAW); ASSERT_TRUE(static_cast(val)); EXPECT_EQ(*v_bye, *val); diff --git a/ntcore/src/test/native/cpp/WireEncoderTest.cpp b/ntcore/src/test/native/cpp/WireEncoderTest.cpp index dd73b2e9e4..7332cdabaa 100644 --- a/ntcore/src/test/native/cpp/WireEncoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireEncoderTest.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "TestPrinters.h" #include "WireEncoder.h" @@ -25,8 +25,8 @@ class WireEncoderTest : public ::testing::Test { v_empty = std::make_shared(); v_boolean = Value::MakeBoolean(true); v_double = Value::MakeDouble(1.0); - v_string = Value::MakeString(llvm::StringRef("hello")); - v_raw = Value::MakeRaw(llvm::StringRef("hello")); + v_string = Value::MakeString(wpi::StringRef("hello")); + v_raw = Value::MakeRaw(wpi::StringRef("hello")); v_boolean_array = Value::MakeBooleanArray(std::vector{0, 1, 0}); v_boolean_array_big = Value::MakeBooleanArray(std::vector(256)); v_double_array = Value::MakeDoubleArray(std::vector{0.5, 0.25}); @@ -82,8 +82,8 @@ TEST_F(WireEncoderTest, Write8) { e.Write8(0x101u); // should be truncated e.Write8(0u); ASSERT_EQ(3u, e.size() - off); - ASSERT_EQ(llvm::StringRef("\x05\x01\x00", 3), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x05\x01\x00", 3), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, Write16) { @@ -95,8 +95,8 @@ TEST_F(WireEncoderTest, Write16) { e.Write16(0x4567u); e.Write16(0u); ASSERT_EQ(8u, e.size() - off); - ASSERT_EQ(llvm::StringRef("\x00\x05\x00\x01\x45\x67\x00\x00", 8), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x00\x05\x00\x01\x45\x67\x00\x00", 8), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, Write32) { @@ -109,10 +109,10 @@ TEST_F(WireEncoderTest, Write32) { e.Write32(0x12345678ul); e.Write32(0ul); ASSERT_EQ(20u, e.size() - off); - ASSERT_EQ(llvm::StringRef("\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\xab\xcd" - "\x12\x34\x56\x78\x00\x00\x00\x00", - 20), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\xab\xcd" + "\x12\x34\x56\x78\x00\x00\x00\x00", + 20), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, WriteDouble) { @@ -127,13 +127,13 @@ TEST_F(WireEncoderTest, WriteDouble) { ASSERT_EQ(40u, e.size() - off); // golden values except min and max from // http://www.binaryconvert.com/result_double.html - ASSERT_EQ(llvm::StringRef("\x00\x00\x00\x00\x00\x00\x00\x00" - "\x41\x0c\x13\x80\x00\x00\x00\x00" - "\x7f\xf0\x00\x00\x00\x00\x00\x00" - "\x00\x10\x00\x00\x00\x00\x00\x00" - "\x7f\xef\xff\xff\xff\xff\xff\xff", - 40), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x00\x00\x00\x00\x00\x00\x00\x00" + "\x41\x0c\x13\x80\x00\x00\x00\x00" + "\x7f\xf0\x00\x00\x00\x00\x00\x00" + "\x00\x10\x00\x00\x00\x00\x00\x00" + "\x7f\xef\xff\xff\xff\xff\xff\xff", + 40), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, WriteUleb128) { @@ -144,8 +144,8 @@ TEST_F(WireEncoderTest, WriteUleb128) { e.WriteUleb128(0x7ful); e.WriteUleb128(0x80ul); ASSERT_EQ(4u, e.size() - off); - ASSERT_EQ(llvm::StringRef("\x00\x7f\x80\x01", 4), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x00\x7f\x80\x01", 4), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, WriteType) { @@ -162,8 +162,8 @@ TEST_F(WireEncoderTest, WriteType) { e.WriteType(NT_RPC); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(8u, e.size() - off); - ASSERT_EQ(llvm::StringRef("\x00\x01\x02\x03\x10\x11\x12\x20", 8), - llvm::StringRef(e.data(), e.size()).substr(off)); + ASSERT_EQ(wpi::StringRef("\x00\x01\x02\x03\x10\x11\x12\x20", 8), + wpi::StringRef(e.data(), e.size()).substr(off)); } TEST_F(WireEncoderTest, WriteTypeError) { @@ -224,8 +224,8 @@ TEST_F(WireEncoderTest, WriteBooleanValue2) { e.WriteValue(*v_false); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(2u, e.size()); - ASSERT_EQ(llvm::StringRef("\x01\x00", 2), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x01\x00", 2), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteDoubleValue2) { @@ -233,8 +233,8 @@ TEST_F(WireEncoderTest, WriteDoubleValue2) { e.WriteValue(*v_double); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(8u, e.size()); - ASSERT_EQ(llvm::StringRef("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteStringValue2) { @@ -242,8 +242,8 @@ TEST_F(WireEncoderTest, WriteStringValue2) { e.WriteValue(*v_string); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(7u, e.size()); - ASSERT_EQ(llvm::StringRef("\x00\x05hello", 7), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x00\x05hello", 7), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteBooleanArrayValue2) { @@ -251,15 +251,15 @@ TEST_F(WireEncoderTest, WriteBooleanArrayValue2) { e.WriteValue(*v_boolean_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 3u, e.size()); - ASSERT_EQ(llvm::StringRef("\x03\x00\x01\x00", 4), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x03\x00\x01\x00", 4), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_boolean_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x00", 2), llvm::StringRef(e.data(), 2)); + ASSERT_EQ(wpi::StringRef("\xff\x00", 2), wpi::StringRef(e.data(), 2)); } TEST_F(WireEncoderTest, WriteDoubleArrayValue2) { @@ -267,17 +267,17 @@ TEST_F(WireEncoderTest, WriteDoubleArrayValue2) { e.WriteValue(*v_double_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 2u * 8u, e.size()); - ASSERT_EQ(llvm::StringRef("\x02\x3f\xe0\x00\x00\x00\x00\x00\x00" - "\x3f\xd0\x00\x00\x00\x00\x00\x00", - 17), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x02\x3f\xe0\x00\x00\x00\x00\x00\x00" + "\x3f\xd0\x00\x00\x00\x00\x00\x00", + 17), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_double_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u * 8u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x00", 2), llvm::StringRef(e.data(), 2)); + ASSERT_EQ(wpi::StringRef("\xff\x00", 2), wpi::StringRef(e.data(), 2)); } TEST_F(WireEncoderTest, WriteStringArrayValue2) { @@ -285,15 +285,15 @@ TEST_F(WireEncoderTest, WriteStringArrayValue2) { e.WriteValue(*v_string_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 7u + 9u, e.size()); - ASSERT_EQ(llvm::StringRef("\x02\x00\x05hello\x00\x07goodbye", 17), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x02\x00\x05hello\x00\x07goodbye", 17), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_string_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u * 3u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x00\x01", 3), llvm::StringRef(e.data(), 3)); + ASSERT_EQ(wpi::StringRef("\xff\x00\x01", 3), wpi::StringRef(e.data(), 3)); } TEST_F(WireEncoderTest, WriteValueError2) { @@ -336,8 +336,8 @@ TEST_F(WireEncoderTest, WriteBooleanValue3) { e.WriteValue(*v_false); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(2u, e.size()); - ASSERT_EQ(llvm::StringRef("\x01\x00", 2), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x01\x00", 2), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteDoubleValue3) { @@ -345,8 +345,8 @@ TEST_F(WireEncoderTest, WriteDoubleValue3) { e.WriteValue(*v_double); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(8u, e.size()); - ASSERT_EQ(llvm::StringRef("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteStringValue3) { @@ -354,8 +354,8 @@ TEST_F(WireEncoderTest, WriteStringValue3) { e.WriteValue(*v_string); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(6u, e.size()); - ASSERT_EQ(llvm::StringRef("\x05hello", 6), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x05hello", 6), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteRawValue3) { @@ -363,8 +363,8 @@ TEST_F(WireEncoderTest, WriteRawValue3) { e.WriteValue(*v_raw); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(6u, e.size()); - ASSERT_EQ(llvm::StringRef("\x05hello", 6), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x05hello", 6), + wpi::StringRef(e.data(), e.size())); } TEST_F(WireEncoderTest, WriteBooleanArrayValue3) { @@ -372,15 +372,15 @@ TEST_F(WireEncoderTest, WriteBooleanArrayValue3) { e.WriteValue(*v_boolean_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 3u, e.size()); - ASSERT_EQ(llvm::StringRef("\x03\x00\x01\x00", 4), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x03\x00\x01\x00", 4), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_boolean_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x00", 2), llvm::StringRef(e.data(), 2)); + ASSERT_EQ(wpi::StringRef("\xff\x00", 2), wpi::StringRef(e.data(), 2)); } TEST_F(WireEncoderTest, WriteDoubleArrayValue3) { @@ -388,17 +388,17 @@ TEST_F(WireEncoderTest, WriteDoubleArrayValue3) { e.WriteValue(*v_double_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 2u * 8u, e.size()); - ASSERT_EQ(llvm::StringRef("\x02\x3f\xe0\x00\x00\x00\x00\x00\x00" - "\x3f\xd0\x00\x00\x00\x00\x00\x00", - 17), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x02\x3f\xe0\x00\x00\x00\x00\x00\x00" + "\x3f\xd0\x00\x00\x00\x00\x00\x00", + 17), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_double_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u * 8u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x00", 2), llvm::StringRef(e.data(), 2)); + ASSERT_EQ(wpi::StringRef("\xff\x00", 2), wpi::StringRef(e.data(), 2)); } TEST_F(WireEncoderTest, WriteStringArrayValue3) { @@ -406,15 +406,15 @@ TEST_F(WireEncoderTest, WriteStringArrayValue3) { e.WriteValue(*v_string_array); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 6u + 8u, e.size()); - ASSERT_EQ(llvm::StringRef("\x02\x05hello\x07goodbye", 15), - llvm::StringRef(e.data(), e.size())); + ASSERT_EQ(wpi::StringRef("\x02\x05hello\x07goodbye", 15), + wpi::StringRef(e.data(), e.size())); // truncated e.Reset(); e.WriteValue(*v_string_array_big); ASSERT_EQ(nullptr, e.error()); ASSERT_EQ(1u + 255u * 2u, e.size()); - ASSERT_EQ(llvm::StringRef("\xff\x01", 2), llvm::StringRef(e.data(), 2)); + ASSERT_EQ(wpi::StringRef("\xff\x01", 2), wpi::StringRef(e.data(), 2)); } TEST_F(WireEncoderTest, WriteValueError3) { @@ -438,14 +438,14 @@ TEST_F(WireEncoderTest, WriteString2) { e.WriteString(s_normal); EXPECT_EQ(nullptr, e.error()); EXPECT_EQ(7u, e.size()); - EXPECT_EQ(llvm::StringRef("\x00\x05hello", 7), - llvm::StringRef(e.data(), e.size())); + EXPECT_EQ(wpi::StringRef("\x00\x05hello", 7), + wpi::StringRef(e.data(), e.size())); e.Reset(); e.WriteString(s_long); EXPECT_EQ(nullptr, e.error()); ASSERT_EQ(130u, e.size()); - EXPECT_EQ(llvm::StringRef("\x00\x80**", 4), llvm::StringRef(e.data(), 4)); + EXPECT_EQ(wpi::StringRef("\x00\x80**", 4), wpi::StringRef(e.data(), 4)); EXPECT_EQ('*', e.data()[128]); EXPECT_EQ('x', e.data()[129]); @@ -454,7 +454,7 @@ TEST_F(WireEncoderTest, WriteString2) { e.WriteString(s_big); EXPECT_EQ(nullptr, e.error()); ASSERT_EQ(65537u, e.size()); - EXPECT_EQ(llvm::StringRef("\xff\xff**", 4), llvm::StringRef(e.data(), 4)); + EXPECT_EQ(wpi::StringRef("\xff\xff**", 4), wpi::StringRef(e.data(), 4)); EXPECT_EQ('*', e.data()[65535]); EXPECT_EQ('x', e.data()[65536]); } @@ -472,14 +472,14 @@ TEST_F(WireEncoderTest, WriteString3) { e.WriteString(s_normal); EXPECT_EQ(nullptr, e.error()); EXPECT_EQ(6u, e.size()); - EXPECT_EQ(llvm::StringRef("\x05hello", 6), - llvm::StringRef(e.data(), e.size())); + EXPECT_EQ(wpi::StringRef("\x05hello", 6), + wpi::StringRef(e.data(), e.size())); e.Reset(); e.WriteString(s_long); EXPECT_EQ(nullptr, e.error()); ASSERT_EQ(130u, e.size()); - EXPECT_EQ(llvm::StringRef("\x80\x01**", 4), llvm::StringRef(e.data(), 4)); + EXPECT_EQ(wpi::StringRef("\x80\x01**", 4), wpi::StringRef(e.data(), 4)); EXPECT_EQ('*', e.data()[128]); EXPECT_EQ('x', e.data()[129]); @@ -488,7 +488,7 @@ TEST_F(WireEncoderTest, WriteString3) { e.WriteString(s_big); EXPECT_EQ(nullptr, e.error()); ASSERT_EQ(65540u, e.size()); - EXPECT_EQ(llvm::StringRef("\x81\x80\x04*", 4), llvm::StringRef(e.data(), 4)); + EXPECT_EQ(wpi::StringRef("\x81\x80\x04*", 4), wpi::StringRef(e.data(), 4)); EXPECT_EQ('*', e.data()[65536]); EXPECT_EQ('x', e.data()[65537]); EXPECT_EQ('x', e.data()[65538]); diff --git a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h index 59164ff8df..763c3fa66f 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h +++ b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" diff --git a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h index e466fb1c47..894f2a337f 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h +++ b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "MockData/NotifyListenerVector.h" diff --git a/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h b/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h index 0f5792589f..e2fddc3351 100644 --- a/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h +++ b/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h @@ -13,7 +13,7 @@ #include #include -#include +#include enum HALSimDSNT_Mode { teleop, auton, test }; diff --git a/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp b/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp index 46d96b57d6..f82efb77b8 100644 --- a/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp +++ b/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp @@ -7,7 +7,7 @@ #include "HALSimLowFi.h" -#include +#include void HALSimLowFi::Initialize() { table = nt::NetworkTableInstance::GetDefault().GetTable("sim"); @@ -38,7 +38,7 @@ void HALSimNTProvider::InitializeDefault( cbInfos.reserve(numChannels); for (int i = 0; i < numChannels; i++) { struct NTProviderCallbackInfo info = { - this, table->GetSubTable(tableName + llvm::Twine(i)), i}; + this, table->GetSubTable(tableName + wpi::Twine(i)), i}; cbInfos.emplace_back(info); } diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp index 7cd90b28dc..7b1276fd22 100644 --- a/wpilibc/src/main/native/cpp/AnalogInput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp @@ -27,7 +27,7 @@ using namespace frc; AnalogInput::AnalogInput(int channel) { if (!SensorBase::CheckAnalogInputChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "Analog Input " + llvm::Twine(channel)); + "Analog Input " + wpi::Twine(channel)); return; } diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp index f70bf07030..cf8e1fb0bf 100644 --- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp @@ -28,7 +28,7 @@ using namespace frc; AnalogOutput::AnalogOutput(int channel) { if (!SensorBase::CheckAnalogOutputChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "analog output " + llvm::Twine(channel)); + "analog output " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); m_port = HAL_kInvalidHandle; return; diff --git a/wpilibc/src/main/native/cpp/Buttons/NetworkButton.cpp b/wpilibc/src/main/native/cpp/Buttons/NetworkButton.cpp index 475ee7c8b0..0ac5ffff6b 100644 --- a/wpilibc/src/main/native/cpp/Buttons/NetworkButton.cpp +++ b/wpilibc/src/main/native/cpp/Buttons/NetworkButton.cpp @@ -12,13 +12,13 @@ using namespace frc; -NetworkButton::NetworkButton(const llvm::Twine& tableName, - const llvm::Twine& field) +NetworkButton::NetworkButton(const wpi::Twine& tableName, + const wpi::Twine& field) : NetworkButton(nt::NetworkTableInstance::GetDefault().GetTable(tableName), field) {} NetworkButton::NetworkButton(std::shared_ptr table, - const llvm::Twine& field) + const wpi::Twine& field) : m_entry(table->GetEntry(field)) {} bool NetworkButton::Get() { diff --git a/wpilibc/src/main/native/cpp/Commands/Command.cpp b/wpilibc/src/main/native/cpp/Commands/Command.cpp index f189b619d8..7185e8f152 100644 --- a/wpilibc/src/main/native/cpp/Commands/Command.cpp +++ b/wpilibc/src/main/native/cpp/Commands/Command.cpp @@ -33,7 +33,7 @@ Command::Command() : Command("", -1.0) {} * * @param name the name for this command */ -Command::Command(const llvm::Twine& name) : Command(name, -1.0) {} +Command::Command(const wpi::Twine& name) : Command(name, -1.0) {} /** * Creates a new command with the given timeout and a default name. @@ -50,7 +50,7 @@ Command::Command(double timeout) : Command("", timeout) {} * @param timeout the time (in seconds) before this command "times out" * @see IsTimedOut() */ -Command::Command(const llvm::Twine& name, double timeout) +Command::Command(const wpi::Twine& name, double timeout) : SendableBase(false) { // We use -1.0 to indicate no timeout. if (timeout < 0.0 && timeout != -1.0) @@ -61,7 +61,7 @@ Command::Command(const llvm::Twine& name, double timeout) // If name contains an empty string if (name.isTriviallyEmpty() || (name.isSingleStringRef() && name.getSingleStringRef().empty())) { - SetName("Command_" + llvm::Twine(typeid(*this).name())); + SetName("Command_" + wpi::Twine(typeid(*this).name())); } else { SetName(name); } diff --git a/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp b/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp index ccf691cf25..0855911313 100644 --- a/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp +++ b/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp @@ -16,7 +16,7 @@ using namespace frc; * * @param name The name for this command group */ -CommandGroup::CommandGroup(const llvm::Twine& name) : Command(name) {} +CommandGroup::CommandGroup(const wpi::Twine& name) : Command(name) {} /** * Adds a new Command to the group. The Command will be started after all the diff --git a/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp b/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp index ffcd696608..c11ed811fe 100644 --- a/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp @@ -44,7 +44,7 @@ ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) { * @param onTrue The Command to execute if Condition() returns true * @param onFalse The Command to execute if Condition() returns false */ -ConditionalCommand::ConditionalCommand(const llvm::Twine& name, Command* onTrue, +ConditionalCommand::ConditionalCommand(const wpi::Twine& name, Command* onTrue, Command* onFalse) : Command(name) { m_onTrue = onTrue; diff --git a/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp b/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp index a8d2881ebc..99c83d027b 100644 --- a/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp @@ -14,6 +14,6 @@ using namespace frc; * * @param name The name for this command */ -InstantCommand::InstantCommand(const llvm::Twine& name) : Command(name) {} +InstantCommand::InstantCommand(const wpi::Twine& name) : Command(name) {} bool InstantCommand::IsFinished() { return true; } diff --git a/wpilibc/src/main/native/cpp/Commands/PIDCommand.cpp b/wpilibc/src/main/native/cpp/Commands/PIDCommand.cpp index 35d5eccf62..e2c394934c 100644 --- a/wpilibc/src/main/native/cpp/Commands/PIDCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/PIDCommand.cpp @@ -11,7 +11,7 @@ using namespace frc; -PIDCommand::PIDCommand(const llvm::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, double f, double period) : Command(name) { m_controller = std::make_shared(p, i, d, this, this, period); @@ -22,12 +22,12 @@ PIDCommand::PIDCommand(double p, double i, double d, double f, double period) { std::make_shared(p, i, d, f, this, this, period); } -PIDCommand::PIDCommand(const llvm::Twine& name, double p, double i, double d) +PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d) : Command(name) { m_controller = std::make_shared(p, i, d, this, this); } -PIDCommand::PIDCommand(const llvm::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, double period) : Command(name) { m_controller = std::make_shared(p, i, d, this, this, period); diff --git a/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp b/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp index 070f39085f..006a4e4f9e 100644 --- a/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp +++ b/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp @@ -19,7 +19,7 @@ using namespace frc; * @param i the integral value * @param d the derivative value */ -PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i, +PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d) : Subsystem(name) { m_controller = std::make_shared(p, i, d, this, this); @@ -35,7 +35,7 @@ PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i, * @param d the derivative value * @param f the feedforward value */ -PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i, +PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f) : Subsystem(name) { m_controller = std::make_shared(p, i, d, f, this, this); @@ -55,7 +55,7 @@ PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i, * @param f the feedfoward value * @param period the time (in seconds) between calculations */ -PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i, +PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f, double period) : Subsystem(name) { m_controller = diff --git a/wpilibc/src/main/native/cpp/Commands/PrintCommand.cpp b/wpilibc/src/main/native/cpp/Commands/PrintCommand.cpp index e53ea4a458..01a3b42710 100644 --- a/wpilibc/src/main/native/cpp/Commands/PrintCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/PrintCommand.cpp @@ -7,13 +7,13 @@ #include "Commands/PrintCommand.h" -#include +#include using namespace frc; -PrintCommand::PrintCommand(const llvm::Twine& message) - : InstantCommand("Print \"" + message + llvm::Twine('"')) { +PrintCommand::PrintCommand(const wpi::Twine& message) + : InstantCommand("Print \"" + message + wpi::Twine('"')) { m_message = message.str(); } -void PrintCommand::Initialize() { llvm::outs() << m_message << '\n'; } +void PrintCommand::Initialize() { wpi::outs() << m_message << '\n'; } diff --git a/wpilibc/src/main/native/cpp/Commands/Subsystem.cpp b/wpilibc/src/main/native/cpp/Commands/Subsystem.cpp index ea51b68df3..99c33eab84 100644 --- a/wpilibc/src/main/native/cpp/Commands/Subsystem.cpp +++ b/wpilibc/src/main/native/cpp/Commands/Subsystem.cpp @@ -20,7 +20,7 @@ using namespace frc; * * @param name the name of the subsystem */ -Subsystem::Subsystem(const llvm::Twine& name) { +Subsystem::Subsystem(const wpi::Twine& name) { SetName(name, name); Scheduler::GetInstance()->RegisterSubsystem(this); } @@ -87,12 +87,12 @@ Command* Subsystem::GetDefaultCommand() { * * @return the default command name */ -llvm::StringRef Subsystem::GetDefaultCommandName() { +wpi::StringRef Subsystem::GetDefaultCommandName() { Command* defaultCommand = GetDefaultCommand(); if (defaultCommand) { return defaultCommand->GetName(); } else { - return llvm::StringRef(); + return wpi::StringRef(); } } @@ -118,12 +118,12 @@ Command* Subsystem::GetCurrentCommand() const { return m_currentCommand; } * * @return the current command name */ -llvm::StringRef Subsystem::GetCurrentCommandName() const { +wpi::StringRef Subsystem::GetCurrentCommandName() const { Command* currentCommand = GetCurrentCommand(); if (currentCommand) { return currentCommand->GetName(); } else { - return llvm::StringRef(); + return wpi::StringRef(); } } @@ -151,7 +151,7 @@ void Subsystem::ConfirmCommand() { * @param name name to give child * @param child sendable */ -void Subsystem::AddChild(const llvm::Twine& name, +void Subsystem::AddChild(const wpi::Twine& name, std::shared_ptr child) { AddChild(name, *child); } @@ -163,7 +163,7 @@ void Subsystem::AddChild(const llvm::Twine& name, * @param name name to give child * @param child sendable */ -void Subsystem::AddChild(const llvm::Twine& name, Sendable* child) { +void Subsystem::AddChild(const wpi::Twine& name, Sendable* child) { AddChild(name, *child); } @@ -174,7 +174,7 @@ void Subsystem::AddChild(const llvm::Twine& name, Sendable* child) { * @param name name to give child * @param child sendable */ -void Subsystem::AddChild(const llvm::Twine& name, Sendable& child) { +void Subsystem::AddChild(const wpi::Twine& name, Sendable& child) { child.SetName(GetSubsystem(), name); LiveWindow::GetInstance()->Add(&child); } diff --git a/wpilibc/src/main/native/cpp/Commands/TimedCommand.cpp b/wpilibc/src/main/native/cpp/Commands/TimedCommand.cpp index 6ee992726f..f8e94a3afd 100644 --- a/wpilibc/src/main/native/cpp/Commands/TimedCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/TimedCommand.cpp @@ -15,7 +15,7 @@ using namespace frc; * @param name the name of the command * @param timeout the time (in seconds) before this command "times out" */ -TimedCommand::TimedCommand(const llvm::Twine& name, double timeout) +TimedCommand::TimedCommand(const wpi::Twine& name, double timeout) : Command(name, timeout) {} /** diff --git a/wpilibc/src/main/native/cpp/Commands/WaitCommand.cpp b/wpilibc/src/main/native/cpp/Commands/WaitCommand.cpp index d61b1794fa..4806076cf6 100644 --- a/wpilibc/src/main/native/cpp/Commands/WaitCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/WaitCommand.cpp @@ -23,5 +23,5 @@ WaitCommand::WaitCommand(double timeout) * * @param timeout the time (in seconds) before this command "times out" */ -WaitCommand::WaitCommand(const llvm::Twine& name, double timeout) +WaitCommand::WaitCommand(const wpi::Twine& name, double timeout) : TimedCommand(name, timeout) {} diff --git a/wpilibc/src/main/native/cpp/Commands/WaitForChildren.cpp b/wpilibc/src/main/native/cpp/Commands/WaitForChildren.cpp index 72a4f3801f..7d63a48f0a 100644 --- a/wpilibc/src/main/native/cpp/Commands/WaitForChildren.cpp +++ b/wpilibc/src/main/native/cpp/Commands/WaitForChildren.cpp @@ -14,7 +14,7 @@ using namespace frc; WaitForChildren::WaitForChildren(double timeout) : Command("WaitForChildren", timeout) {} -WaitForChildren::WaitForChildren(const llvm::Twine& name, double timeout) +WaitForChildren::WaitForChildren(const wpi::Twine& name, double timeout) : Command(name, timeout) {} bool WaitForChildren::IsFinished() { diff --git a/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp b/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp index 442ea8726b..99cdbb42d3 100644 --- a/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp @@ -23,7 +23,7 @@ WaitUntilCommand::WaitUntilCommand(double time) m_time = time; } -WaitUntilCommand::WaitUntilCommand(const llvm::Twine& name, double time) +WaitUntilCommand::WaitUntilCommand(const wpi::Twine& name, double time) : Command(name, time) { m_time = time; } diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index 521b698753..826a72511b 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -28,7 +28,7 @@ using namespace frc; DigitalInput::DigitalInput(int channel) { if (!CheckDigitalChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "Digital Channel " + llvm::Twine(channel)); + "Digital Channel " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); return; } diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index cc7897b493..df6fbeb14e 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -31,7 +31,7 @@ DigitalOutput::DigitalOutput(int channel) { m_pwmGenerator = HAL_kInvalidHandle; if (!SensorBase::CheckDigitalChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "Digital Channel " + llvm::Twine(channel)); + "Digital Channel " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); return; } diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp index 4cef7ff480..82dc46833f 100644 --- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp @@ -44,19 +44,19 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel, if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) { wpi_setWPIErrorWithContext( ModuleIndexOutOfRange, - "Solenoid Module " + llvm::Twine(m_moduleNumber)); + "Solenoid Module " + wpi::Twine(m_moduleNumber)); return; } if (!SensorBase::CheckSolenoidChannel(m_forwardChannel)) { wpi_setWPIErrorWithContext( ChannelIndexOutOfRange, - "Solenoid Channel " + llvm::Twine(m_forwardChannel)); + "Solenoid Channel " + wpi::Twine(m_forwardChannel)); return; } if (!SensorBase::CheckSolenoidChannel(m_reverseChannel)) { wpi_setWPIErrorWithContext( ChannelIndexOutOfRange, - "Solenoid Channel " + llvm::Twine(m_reverseChannel)); + "Solenoid Channel " + wpi::Twine(m_reverseChannel)); return; } int32_t status = 0; @@ -186,7 +186,7 @@ void DoubleSolenoid::InitSendable(SendableBuilder& builder) { builder.SetSafeState([=]() { Set(kOff); }); builder.AddSmallStringProperty( "Value", - [=](llvm::SmallVectorImpl& buf) -> llvm::StringRef { + [=](wpi::SmallVectorImpl& buf) -> wpi::StringRef { switch (Get()) { case kForward: return "Forward"; @@ -196,7 +196,7 @@ void DoubleSolenoid::InitSendable(SendableBuilder& builder) { return "Off"; } }, - [=](llvm::StringRef value) { + [=](wpi::StringRef value) { Value lvalue = kOff; if (value == "Forward") lvalue = kForward; diff --git a/wpilibc/src/main/native/cpp/Drive/DifferentialDrive.cpp b/wpilibc/src/main/native/cpp/Drive/DifferentialDrive.cpp index b8cab7ed83..ceb72d1b31 100644 --- a/wpilibc/src/main/native/cpp/Drive/DifferentialDrive.cpp +++ b/wpilibc/src/main/native/cpp/Drive/DifferentialDrive.cpp @@ -262,7 +262,7 @@ void DifferentialDrive::StopMotor() { m_safetyHelper.Feed(); } -void DifferentialDrive::GetDescription(llvm::raw_ostream& desc) const { +void DifferentialDrive::GetDescription(wpi::raw_ostream& desc) const { desc << "DifferentialDrive"; } diff --git a/wpilibc/src/main/native/cpp/Drive/KilloughDrive.cpp b/wpilibc/src/main/native/cpp/Drive/KilloughDrive.cpp index 20ee1a750d..3223add231 100644 --- a/wpilibc/src/main/native/cpp/Drive/KilloughDrive.cpp +++ b/wpilibc/src/main/native/cpp/Drive/KilloughDrive.cpp @@ -150,7 +150,7 @@ void KilloughDrive::StopMotor() { m_safetyHelper.Feed(); } -void KilloughDrive::GetDescription(llvm::raw_ostream& desc) const { +void KilloughDrive::GetDescription(wpi::raw_ostream& desc) const { desc << "KilloughDrive"; } diff --git a/wpilibc/src/main/native/cpp/Drive/MecanumDrive.cpp b/wpilibc/src/main/native/cpp/Drive/MecanumDrive.cpp index 959a424754..11310c449c 100644 --- a/wpilibc/src/main/native/cpp/Drive/MecanumDrive.cpp +++ b/wpilibc/src/main/native/cpp/Drive/MecanumDrive.cpp @@ -124,7 +124,7 @@ void MecanumDrive::StopMotor() { m_safetyHelper.Feed(); } -void MecanumDrive::GetDescription(llvm::raw_ostream& desc) const { +void MecanumDrive::GetDescription(wpi::raw_ostream& desc) const { desc << "MecanumDrive"; } diff --git a/wpilibc/src/main/native/cpp/Drive/RobotDriveBase.cpp b/wpilibc/src/main/native/cpp/Drive/RobotDriveBase.cpp index 26e4c31c28..b21f1c1961 100644 --- a/wpilibc/src/main/native/cpp/Drive/RobotDriveBase.cpp +++ b/wpilibc/src/main/native/cpp/Drive/RobotDriveBase.cpp @@ -93,7 +93,7 @@ double RobotDriveBase::ApplyDeadband(double value, double deadband) { /** * Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0. */ -void RobotDriveBase::Normalize(llvm::MutableArrayRef wheelSpeeds) { +void RobotDriveBase::Normalize(wpi::MutableArrayRef wheelSpeeds) { double maxMagnitude = std::abs(wheelSpeeds[0]); for (size_t i = 1; i < wheelSpeeds.size(); i++) { double temp = std::abs(wheelSpeeds[i]); diff --git a/wpilibc/src/main/native/cpp/DriverStation.cpp b/wpilibc/src/main/native/cpp/DriverStation.cpp index 88329ca3de..df34738165 100644 --- a/wpilibc/src/main/native/cpp/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/DriverStation.cpp @@ -12,11 +12,11 @@ #include #include #include -#include -#include #include #include #include +#include +#include #include "AnalogInput.h" #include "MotorSafetyHelper.h" @@ -96,8 +96,8 @@ DriverStation& DriverStation::GetInstance() { * * The error is also printed to the program console. */ -void DriverStation::ReportError(const llvm::Twine& error) { - llvm::SmallString<128> temp; +void DriverStation::ReportError(const wpi::Twine& error) { + wpi::SmallString<128> temp; HAL_SendError(1, 1, 0, error.toNullTerminatedStringRef(temp).data(), "", "", 1); } @@ -107,8 +107,8 @@ void DriverStation::ReportError(const llvm::Twine& error) { * * The warning is also printed to the program console. */ -void DriverStation::ReportWarning(const llvm::Twine& error) { - llvm::SmallString<128> temp; +void DriverStation::ReportWarning(const wpi::Twine& error) { + wpi::SmallString<128> temp; HAL_SendError(0, 1, 0, error.toNullTerminatedStringRef(temp).data(), "", "", 1); } @@ -119,12 +119,12 @@ void DriverStation::ReportWarning(const llvm::Twine& error) { * The error is also printed to the program console. */ void DriverStation::ReportError(bool isError, int32_t code, - const llvm::Twine& error, - const llvm::Twine& location, - const llvm::Twine& stack) { - llvm::SmallString<128> errorTemp; - llvm::SmallString<128> locationTemp; - llvm::SmallString<128> stackTemp; + const wpi::Twine& error, + const wpi::Twine& location, + const wpi::Twine& stack) { + wpi::SmallString<128> errorTemp; + wpi::SmallString<128> locationTemp; + wpi::SmallString<128> stackTemp; HAL_SendError(isError, code, 0, error.toNullTerminatedStringRef(errorTemp).data(), location.toNullTerminatedStringRef(locationTemp).data(), @@ -853,7 +853,7 @@ DriverStation::DriverStation() { * Reports errors related to unplugged joysticks * Throttles the errors so that they don't overwhelm the DS */ -void DriverStation::ReportJoystickUnpluggedError(const llvm::Twine& message) { +void DriverStation::ReportJoystickUnpluggedError(const wpi::Twine& message) { double currentTime = Timer::GetFPGATimestamp(); if (currentTime > m_nextMessageTime) { ReportError(message); @@ -866,7 +866,7 @@ void DriverStation::ReportJoystickUnpluggedError(const llvm::Twine& message) { * * Throttles the errors so that they don't overwhelm the DS. */ -void DriverStation::ReportJoystickUnpluggedWarning(const llvm::Twine& message) { +void DriverStation::ReportJoystickUnpluggedWarning(const wpi::Twine& message) { double currentTime = Timer::GetFPGATimestamp(); if (currentTime > m_nextMessageTime) { ReportWarning(message); diff --git a/wpilibc/src/main/native/cpp/Error.cpp b/wpilibc/src/main/native/cpp/Error.cpp index a3717ad64f..fcd74c5117 100644 --- a/wpilibc/src/main/native/cpp/Error.cpp +++ b/wpilibc/src/main/native/cpp/Error.cpp @@ -7,7 +7,7 @@ #include "Error.h" -#include +#include #include "DriverStation.h" #include "Timer.h" @@ -41,8 +41,8 @@ const ErrorBase* Error::GetOriginatingObject() const { double Error::GetTimestamp() const { return m_timestamp; } -void Error::Set(Code code, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, +void Error::Set(Code code, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber, const ErrorBase* originatingObject) { bool report = true; @@ -66,8 +66,8 @@ void Error::Set(Code code, const llvm::Twine& contextMessage, void Error::Report() { DriverStation::ReportError( true, m_code, m_message, - m_function + llvm::Twine(" [") + llvm::sys::path::filename(m_filename) + - llvm::Twine(':') + llvm::Twine(m_lineNumber) + llvm::Twine(']'), + m_function + wpi::Twine(" [") + wpi::sys::path::filename(m_filename) + + wpi::Twine(':') + wpi::Twine(m_lineNumber) + wpi::Twine(']'), GetStackTrace(4)); } diff --git a/wpilibc/src/main/native/cpp/ErrorBase.cpp b/wpilibc/src/main/native/cpp/ErrorBase.cpp index 358e85be0c..2373948d55 100644 --- a/wpilibc/src/main/native/cpp/ErrorBase.cpp +++ b/wpilibc/src/main/native/cpp/ErrorBase.cpp @@ -12,12 +12,12 @@ #include #include +#include +#include +#include #define WPI_ERRORS_DEFINE_STRINGS #include "WPIErrors.h" -#include "llvm/Format.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" using namespace frc; @@ -49,16 +49,16 @@ void ErrorBase::ClearError() const { m_error.Clear(); } * @param function Function of the error source * @param lineNumber Line number of the error source */ -void ErrorBase::SetErrnoError(const llvm::Twine& contextMessage, - llvm::StringRef filename, - llvm::StringRef function, int lineNumber) const { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream err(buf); +void ErrorBase::SetErrnoError(const wpi::Twine& contextMessage, + wpi::StringRef filename, + wpi::StringRef function, int lineNumber) const { + wpi::SmallString<128> buf; + wpi::raw_svector_ostream err(buf); int errNo = errno; if (errNo == 0) { err << "OK: "; } else { - err << std::strerror(errNo) << " (" << llvm::format_hex(errNo, 10, true) + err << std::strerror(errNo) << " (" << wpi::format_hex(errNo, 10, true) << "): "; } @@ -83,13 +83,13 @@ void ErrorBase::SetErrnoError(const llvm::Twine& contextMessage, * @param function Function of the error source * @param lineNumber Line number of the error source */ -void ErrorBase::SetImaqError(int success, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, +void ErrorBase::SetImaqError(int success, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const { // If there was an error if (success <= 0) { // Set the current error information for this object. - m_error.Set(success, llvm::Twine(success) + ": " + contextMessage, filename, + m_error.Set(success, wpi::Twine(success) + ": " + contextMessage, filename, function, lineNumber, this); // Update the global error if there is not one already set. @@ -109,8 +109,8 @@ void ErrorBase::SetImaqError(int success, const llvm::Twine& contextMessage, * @param function Function of the error source * @param lineNumber Line number of the error source */ -void ErrorBase::SetError(Error::Code code, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, +void ErrorBase::SetError(Error::Code code, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const { // If there was an error if (code != 0) { @@ -140,16 +140,16 @@ void ErrorBase::SetError(Error::Code code, const llvm::Twine& contextMessage, */ void ErrorBase::SetErrorRange(Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, - const llvm::Twine& contextMessage, - llvm::StringRef filename, - llvm::StringRef function, int lineNumber) const { + const wpi::Twine& contextMessage, + wpi::StringRef filename, + wpi::StringRef function, int lineNumber) const { // If there was an error if (code != 0) { // Set the current error information for this object. m_error.Set(code, - contextMessage + ", Minimum Value: " + llvm::Twine(minRange) + - ", MaximumValue: " + llvm::Twine(maxRange) + - ", Requested Value: " + llvm::Twine(requestedValue), + contextMessage + ", Minimum Value: " + wpi::Twine(minRange) + + ", MaximumValue: " + wpi::Twine(maxRange) + + ", Requested Value: " + wpi::Twine(requestedValue), filename, function, lineNumber, this); // Update the global error if there is not one already set. @@ -169,9 +169,9 @@ void ErrorBase::SetErrorRange(Error::Code code, int32_t minRange, * @param function Function of the error source * @param lineNumber Line number of the error source */ -void ErrorBase::SetWPIError(const llvm::Twine& errorMessage, Error::Code code, - const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, +void ErrorBase::SetWPIError(const wpi::Twine& errorMessage, Error::Code code, + const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const { // Set the current error information for this object. m_error.Set(code, errorMessage + ": " + contextMessage, filename, function, @@ -196,9 +196,9 @@ void ErrorBase::CloneError(const ErrorBase& rhs) const { bool ErrorBase::StatusIsFatal() const { return m_error.GetCode() < 0; } void ErrorBase::SetGlobalError(Error::Code code, - const llvm::Twine& contextMessage, - llvm::StringRef filename, - llvm::StringRef function, int lineNumber) { + const wpi::Twine& contextMessage, + wpi::StringRef filename, + wpi::StringRef function, int lineNumber) { // If there was an error if (code != 0) { std::lock_guard mutex(_globalErrorMutex); @@ -209,10 +209,10 @@ void ErrorBase::SetGlobalError(Error::Code code, } } -void ErrorBase::SetGlobalWPIError(const llvm::Twine& errorMessage, - const llvm::Twine& contextMessage, - llvm::StringRef filename, - llvm::StringRef function, int lineNumber) { +void ErrorBase::SetGlobalWPIError(const wpi::Twine& errorMessage, + const wpi::Twine& contextMessage, + wpi::StringRef filename, + wpi::StringRef function, int lineNumber) { std::lock_guard mutex(_globalErrorMutex); if (_globalError.GetCode() != 0) { _globalError.Clear(); diff --git a/wpilibc/src/main/native/cpp/Filters/LinearDigitalFilter.cpp b/wpilibc/src/main/native/cpp/Filters/LinearDigitalFilter.cpp index c1157541c6..310e2ba13a 100644 --- a/wpilibc/src/main/native/cpp/Filters/LinearDigitalFilter.cpp +++ b/wpilibc/src/main/native/cpp/Filters/LinearDigitalFilter.cpp @@ -20,8 +20,8 @@ using namespace frc; * @param fbGains The "feed back" or IIR gains */ LinearDigitalFilter::LinearDigitalFilter(PIDSource& source, - llvm::ArrayRef ffGains, - llvm::ArrayRef fbGains) + wpi::ArrayRef ffGains, + wpi::ArrayRef fbGains) : Filter(source), m_inputs(ffGains.size()), m_outputs(fbGains.size()), @@ -36,8 +36,8 @@ LinearDigitalFilter::LinearDigitalFilter(PIDSource& source, * @param fbGains The "feed back" or IIR gains */ LinearDigitalFilter::LinearDigitalFilter(std::shared_ptr source, - llvm::ArrayRef ffGains, - llvm::ArrayRef fbGains) + wpi::ArrayRef ffGains, + wpi::ArrayRef fbGains) : Filter(source), m_inputs(ffGains.size()), m_outputs(fbGains.size()), diff --git a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp index ea7ea9dccc..f7cbc76f68 100644 --- a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp +++ b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Commands/Scheduler.h" #include "LiveWindow/LiveWindow.h" @@ -31,7 +31,7 @@ using namespace frc; * ready, causing the robot to be bypassed in a match. */ void IterativeRobotBase::RobotInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -42,7 +42,7 @@ void IterativeRobotBase::RobotInit() { * the robot enters disabled mode. */ void IterativeRobotBase::DisabledInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -52,7 +52,7 @@ void IterativeRobotBase::DisabledInit() { * called each time the robot enters autonomous mode. */ void IterativeRobotBase::AutonomousInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -62,7 +62,7 @@ void IterativeRobotBase::AutonomousInit() { * called each time the robot enters teleop mode. */ void IterativeRobotBase::TeleopInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -72,7 +72,7 @@ void IterativeRobotBase::TeleopInit() { * called each time the robot enters test mode. */ void IterativeRobotBase::TestInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -84,7 +84,7 @@ void IterativeRobotBase::TestInit() { void IterativeRobotBase::RobotPeriodic() { static bool firstRun = true; if (firstRun) { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; firstRun = false; } } @@ -99,7 +99,7 @@ void IterativeRobotBase::RobotPeriodic() { void IterativeRobotBase::DisabledPeriodic() { static bool firstRun = true; if (firstRun) { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; firstRun = false; } } @@ -114,7 +114,7 @@ void IterativeRobotBase::DisabledPeriodic() { void IterativeRobotBase::AutonomousPeriodic() { static bool firstRun = true; if (firstRun) { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; firstRun = false; } } @@ -129,7 +129,7 @@ void IterativeRobotBase::AutonomousPeriodic() { void IterativeRobotBase::TeleopPeriodic() { static bool firstRun = true; if (firstRun) { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; firstRun = false; } } @@ -143,7 +143,7 @@ void IterativeRobotBase::TeleopPeriodic() { void IterativeRobotBase::TestPeriodic() { static bool firstRun = true; if (firstRun) { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; firstRun = false; } } diff --git a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp index 7622a9b60e..1ca537ca8c 100644 --- a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp +++ b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp @@ -9,20 +9,20 @@ #include -#include -#include -#include #include #include #include -#include +#include +#include +#include +#include #include "Commands/Scheduler.h" #include "SmartDashboard/SendableBuilderImpl.h" using namespace frc; -using llvm::Twine; +using wpi::Twine; struct LiveWindow::Impl { Impl(); @@ -37,7 +37,7 @@ struct LiveWindow::Impl { wpi::mutex mutex; - llvm::DenseMap components; + wpi::DenseMap components; std::shared_ptr liveWindowTable; std::shared_ptr statusTable; @@ -115,8 +115,8 @@ void LiveWindow::SetEnabled(bool enabled) { * @brief Use a STL smart pointer to share ownership of component. * @deprecated Use Sendable::SetName() instead. */ -void LiveWindow::AddSensor(const llvm::Twine& subsystem, - const llvm::Twine& name, +void LiveWindow::AddSensor(const wpi::Twine& subsystem, + const wpi::Twine& name, std::shared_ptr component) { Add(component); component->SetName(subsystem, name); @@ -126,8 +126,8 @@ void LiveWindow::AddSensor(const llvm::Twine& subsystem, * @brief Pass a reference to LiveWindow and retain ownership of the component. * @deprecated Use Sendable::SetName() instead. */ -void LiveWindow::AddSensor(const llvm::Twine& subsystem, - const llvm::Twine& name, Sendable& component) { +void LiveWindow::AddSensor(const wpi::Twine& subsystem, + const wpi::Twine& name, Sendable& component) { Add(&component); component.SetName(subsystem, name); } @@ -136,8 +136,8 @@ void LiveWindow::AddSensor(const llvm::Twine& subsystem, * @brief Use a raw pointer to the LiveWindow. * @deprecated Use Sendable::SetName() instead. */ -void LiveWindow::AddSensor(const llvm::Twine& subsystem, - const llvm::Twine& name, Sendable* component) { +void LiveWindow::AddSensor(const wpi::Twine& subsystem, + const wpi::Twine& name, Sendable* component) { Add(component); component->SetName(subsystem, name); } @@ -157,8 +157,8 @@ void LiveWindow::AddSensor(const llvm::Twine& subsystem, /** * @brief Use a STL smart pointer to share ownership of component. */ -void LiveWindow::AddActuator(const llvm::Twine& subsystem, - const llvm::Twine& name, +void LiveWindow::AddActuator(const wpi::Twine& subsystem, + const wpi::Twine& name, std::shared_ptr component) { Add(component); component->SetName(subsystem, name); @@ -168,8 +168,8 @@ void LiveWindow::AddActuator(const llvm::Twine& subsystem, * @brief Pass a reference to LiveWindow and retain ownership of the component. * @deprecated Use Sendable::SetName() instead. */ -void LiveWindow::AddActuator(const llvm::Twine& subsystem, - const llvm::Twine& name, Sendable& component) { +void LiveWindow::AddActuator(const wpi::Twine& subsystem, + const wpi::Twine& name, Sendable& component) { Add(&component); component.SetName(subsystem, name); } @@ -178,8 +178,8 @@ void LiveWindow::AddActuator(const llvm::Twine& subsystem, * @brief Use a raw pointer to the LiveWindow. * @deprecated Use Sendable::SetName() instead. */ -void LiveWindow::AddActuator(const llvm::Twine& subsystem, - const llvm::Twine& name, Sendable* component) { +void LiveWindow::AddActuator(const wpi::Twine& subsystem, + const wpi::Twine& name, Sendable* component) { Add(component); component->SetName(subsystem, name); } @@ -189,7 +189,7 @@ void LiveWindow::AddActuator(const llvm::Twine& subsystem, * Meant for internal use in other WPILib classes. * @deprecated Use SensorBase::SetName() instead. */ -void LiveWindow::AddSensor(const llvm::Twine& type, int channel, +void LiveWindow::AddSensor(const wpi::Twine& type, int channel, Sendable* component) { Add(component); component->SetName("Ungrouped", @@ -200,7 +200,7 @@ void LiveWindow::AddSensor(const llvm::Twine& type, int channel, * Meant for internal use in other WPILib classes. * @deprecated Use SensorBase::SetName() instead. */ -void LiveWindow::AddActuator(const llvm::Twine& type, int channel, +void LiveWindow::AddActuator(const wpi::Twine& type, int channel, Sendable* component) { Add(component); component->SetName("Ungrouped", @@ -211,7 +211,7 @@ void LiveWindow::AddActuator(const llvm::Twine& type, int channel, * Meant for internal use in other WPILib classes. * @deprecated Use SensorBase::SetName() instead. */ -void LiveWindow::AddActuator(const llvm::Twine& type, int module, int channel, +void LiveWindow::AddActuator(const wpi::Twine& type, int module, int channel, Sendable* component) { Add(component); component->SetName("Ungrouped", type + Twine('[') + Twine(module) + diff --git a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindowSendable.cpp b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindowSendable.cpp index bddb136629..54f598f68a 100644 --- a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindowSendable.cpp +++ b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindowSendable.cpp @@ -13,11 +13,11 @@ using namespace frc; std::string LiveWindowSendable::GetName() const { return std::string(); } -void LiveWindowSendable::SetName(const llvm::Twine&) {} +void LiveWindowSendable::SetName(const wpi::Twine&) {} std::string LiveWindowSendable::GetSubsystem() const { return std::string(); } -void LiveWindowSendable::SetSubsystem(const llvm::Twine&) {} +void LiveWindowSendable::SetSubsystem(const wpi::Twine&) {} void LiveWindowSendable::InitSendable(SendableBuilder& builder) { builder.SetUpdateTable([=]() { UpdateTable(); }); diff --git a/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp b/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp index a0e7d75786..843432ca99 100644 --- a/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp +++ b/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp @@ -7,8 +7,8 @@ #include "MotorSafetyHelper.h" -#include -#include +#include +#include #include "DriverStation.h" #include "MotorSafety.h" @@ -109,8 +109,8 @@ void MotorSafetyHelper::Check() { if (!enabled || ds.IsDisabled() || ds.IsTest()) return; if (stopTime < Timer::GetFPGATimestamp()) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream desc(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream desc(buf); m_safeObject->GetDescription(desc); desc << "... Output not updated often enough."; wpi_setWPIErrorWithContext(Timeout, desc.str()); diff --git a/wpilibc/src/main/native/cpp/NidecBrushless.cpp b/wpilibc/src/main/native/cpp/NidecBrushless.cpp index bb5869cd46..c74ac17e1e 100644 --- a/wpilibc/src/main/native/cpp/NidecBrushless.cpp +++ b/wpilibc/src/main/native/cpp/NidecBrushless.cpp @@ -120,7 +120,7 @@ void NidecBrushless::SetSafetyEnabled(bool enabled) { m_safetyHelper.SetSafetyEnabled(enabled); } -void NidecBrushless::GetDescription(llvm::raw_ostream& desc) const { +void NidecBrushless::GetDescription(wpi::raw_ostream& desc) const { desc << "Nidec " << GetChannel(); } diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp index a35465190a..42627339f1 100644 --- a/wpilibc/src/main/native/cpp/PWM.cpp +++ b/wpilibc/src/main/native/cpp/PWM.cpp @@ -31,7 +31,7 @@ using namespace frc; PWM::PWM(int channel) { if (!SensorBase::CheckPWMChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "PWM Channel " + llvm::Twine(channel)); + "PWM Channel " + wpi::Twine(channel)); return; } diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp index beac93dc11..d99ac506f9 100644 --- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp +++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp @@ -10,8 +10,8 @@ #include #include #include -#include -#include +#include +#include #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -78,8 +78,8 @@ double PowerDistributionPanel::GetCurrent(int channel) const { int32_t status = 0; if (!CheckPDPChannel(channel)) { - llvm::SmallString<32> str; - llvm::raw_svector_ostream buf(str); + wpi::SmallString<32> str; + wpi::raw_svector_ostream buf(str); buf << "PDP Channel " << channel; wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str()); } @@ -175,7 +175,7 @@ void PowerDistributionPanel::ClearStickyFaults() { void PowerDistributionPanel::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PowerDistributionPanel"); for (int i = 0; i < kPDPChannels; ++i) { - builder.AddDoubleProperty("Chan" + llvm::Twine(i), + builder.AddDoubleProperty("Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr); } builder.AddDoubleProperty("Voltage", [=]() { return GetVoltage(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/Preferences.cpp b/wpilibc/src/main/native/cpp/Preferences.cpp index 6c0203489f..1f65e0c8ee 100644 --- a/wpilibc/src/main/native/cpp/Preferences.cpp +++ b/wpilibc/src/main/native/cpp/Preferences.cpp @@ -10,21 +10,21 @@ #include #include -#include #include +#include #include "WPIErrors.h" using namespace frc; // The Preferences table name -static llvm::StringRef kTableName{"Preferences"}; +static wpi::StringRef kTableName{"Preferences"}; Preferences::Preferences() : m_table(nt::NetworkTableInstance::GetDefault().GetTable(kTableName)) { m_table->GetEntry(".type").SetString("RobotPreferences"); m_listener = m_table->AddEntryListener( - [=](nt::NetworkTable* table, llvm::StringRef name, + [=](nt::NetworkTable* table, wpi::StringRef name, nt::NetworkTableEntry entry, std::shared_ptr value, int flags) { entry.SetPersistent(); }, NT_NOTIFY_NEW | NT_NOTIFY_IMMEDIATE); @@ -56,8 +56,8 @@ std::vector Preferences::GetKeys() { return m_table->GetKeys(); } * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -std::string Preferences::GetString(llvm::StringRef key, - llvm::StringRef defaultValue) { +std::string Preferences::GetString(wpi::StringRef key, + wpi::StringRef defaultValue) { return m_table->GetString(key, defaultValue); } @@ -69,7 +69,7 @@ std::string Preferences::GetString(llvm::StringRef key, * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -int Preferences::GetInt(llvm::StringRef key, int defaultValue) { +int Preferences::GetInt(wpi::StringRef key, int defaultValue) { return static_cast(m_table->GetNumber(key, defaultValue)); } @@ -81,7 +81,7 @@ int Preferences::GetInt(llvm::StringRef key, int defaultValue) { * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -double Preferences::GetDouble(llvm::StringRef key, double defaultValue) { +double Preferences::GetDouble(wpi::StringRef key, double defaultValue) { return m_table->GetNumber(key, defaultValue); } @@ -93,7 +93,7 @@ double Preferences::GetDouble(llvm::StringRef key, double defaultValue) { * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -float Preferences::GetFloat(llvm::StringRef key, float defaultValue) { +float Preferences::GetFloat(wpi::StringRef key, float defaultValue) { return m_table->GetNumber(key, defaultValue); } @@ -105,7 +105,7 @@ float Preferences::GetFloat(llvm::StringRef key, float defaultValue) { * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -bool Preferences::GetBoolean(llvm::StringRef key, bool defaultValue) { +bool Preferences::GetBoolean(wpi::StringRef key, bool defaultValue) { return m_table->GetBoolean(key, defaultValue); } @@ -117,7 +117,7 @@ bool Preferences::GetBoolean(llvm::StringRef key, bool defaultValue) { * @param defaultValue the value to return if none exists in the table * @return either the value in the table, or the defaultValue */ -int64_t Preferences::GetLong(llvm::StringRef key, int64_t defaultValue) { +int64_t Preferences::GetLong(wpi::StringRef key, int64_t defaultValue) { return static_cast(m_table->GetNumber(key, defaultValue)); } @@ -130,7 +130,7 @@ int64_t Preferences::GetLong(llvm::StringRef key, int64_t defaultValue) { * @param key the key * @param value the value */ -void Preferences::PutString(llvm::StringRef key, llvm::StringRef value) { +void Preferences::PutString(wpi::StringRef key, wpi::StringRef value) { auto entry = m_table->GetEntry(key); entry.SetString(value); entry.SetPersistent(); @@ -144,7 +144,7 @@ void Preferences::PutString(llvm::StringRef key, llvm::StringRef value) { * @param key the key * @param value the value */ -void Preferences::PutInt(llvm::StringRef key, int value) { +void Preferences::PutInt(wpi::StringRef key, int value) { auto entry = m_table->GetEntry(key); entry.SetDouble(value); entry.SetPersistent(); @@ -158,7 +158,7 @@ void Preferences::PutInt(llvm::StringRef key, int value) { * @param key the key * @param value the value */ -void Preferences::PutDouble(llvm::StringRef key, double value) { +void Preferences::PutDouble(wpi::StringRef key, double value) { auto entry = m_table->GetEntry(key); entry.SetDouble(value); entry.SetPersistent(); @@ -172,7 +172,7 @@ void Preferences::PutDouble(llvm::StringRef key, double value) { * @param key the key * @param value the value */ -void Preferences::PutFloat(llvm::StringRef key, float value) { +void Preferences::PutFloat(wpi::StringRef key, float value) { auto entry = m_table->GetEntry(key); entry.SetDouble(value); entry.SetPersistent(); @@ -186,7 +186,7 @@ void Preferences::PutFloat(llvm::StringRef key, float value) { * @param key the key * @param value the value */ -void Preferences::PutBoolean(llvm::StringRef key, bool value) { +void Preferences::PutBoolean(wpi::StringRef key, bool value) { auto entry = m_table->GetEntry(key); entry.SetBoolean(value); entry.SetPersistent(); @@ -200,7 +200,7 @@ void Preferences::PutBoolean(llvm::StringRef key, bool value) { * @param key the key * @param value the value */ -void Preferences::PutLong(llvm::StringRef key, int64_t value) { +void Preferences::PutLong(wpi::StringRef key, int64_t value) { auto entry = m_table->GetEntry(key); entry.SetDouble(value); entry.SetPersistent(); @@ -212,7 +212,7 @@ void Preferences::PutLong(llvm::StringRef key, int64_t value) { * @param key the key * @return if there is a value at the given key */ -bool Preferences::ContainsKey(llvm::StringRef key) { +bool Preferences::ContainsKey(wpi::StringRef key) { return m_table->ContainsKey(key); } @@ -221,4 +221,4 @@ bool Preferences::ContainsKey(llvm::StringRef key) { * * @param key the key */ -void Preferences::Remove(llvm::StringRef key) { m_table->Delete(key); } +void Preferences::Remove(wpi::StringRef key) { m_table->Delete(key); } diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp index 9eaf756a14..9cd2c31d8d 100644 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ b/wpilibc/src/main/native/cpp/Relay.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "MotorSafetyHelper.h" #include "SensorBase.h" @@ -32,7 +32,7 @@ Relay::Relay(int channel, Relay::Direction direction) : m_channel(channel), m_direction(direction) { if (!SensorBase::CheckRelayChannel(m_channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "Relay Channel " + llvm::Twine(m_channel)); + "Relay Channel " + wpi::Twine(m_channel)); return; } @@ -268,7 +268,7 @@ bool Relay::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void Relay::GetDescription(llvm::raw_ostream& desc) const { +void Relay::GetDescription(wpi::raw_ostream& desc) const { desc << "Relay " << GetChannel(); } @@ -277,7 +277,7 @@ void Relay::InitSendable(SendableBuilder& builder) { builder.SetSafeState([=]() { Set(kOff); }); builder.AddSmallStringProperty( "Value", - [=](llvm::SmallVectorImpl& buf) -> llvm::StringRef { + [=](wpi::SmallVectorImpl& buf) -> wpi::StringRef { switch (Get()) { case kOn: return "On"; @@ -289,7 +289,7 @@ void Relay::InitSendable(SendableBuilder& builder) { return "Off"; } }, - [=](llvm::StringRef value) { + [=](wpi::StringRef value) { if (value == "Off") Set(kOff); else if (value == "Forward") diff --git a/wpilibc/src/main/native/cpp/RobotBase.cpp b/wpilibc/src/main/native/cpp/RobotBase.cpp index 7d629c65de..ef1cb70603 100644 --- a/wpilibc/src/main/native/cpp/RobotBase.cpp +++ b/wpilibc/src/main/native/cpp/RobotBase.cpp @@ -39,13 +39,13 @@ class WPILibCameraServerShared : public frc::CameraServerShared { void ReportVideoServer(int id) override { HAL_Report(HALUsageReporting::kResourceType_PCVideoServer, id); } - void SetCameraServerError(llvm::StringRef error) override { + void SetCameraServerError(wpi::StringRef error) override { wpi_setGlobalWPIErrorWithContext(CameraServerError, error); } - void SetVisionRunnerError(llvm::StringRef error) override { + void SetVisionRunnerError(wpi::StringRef error) override { wpi_setGlobalErrorWithContext(-1, error); } - void ReportDriverStationError(llvm::StringRef error) override { + void ReportDriverStationError(wpi::StringRef error) override { DriverStation::ReportError(error); } std::pair GetRobotMainThreadId() const override { diff --git a/wpilibc/src/main/native/cpp/RobotDrive.cpp b/wpilibc/src/main/native/cpp/RobotDrive.cpp index 72ecd58f4a..b824170eaf 100644 --- a/wpilibc/src/main/native/cpp/RobotDrive.cpp +++ b/wpilibc/src/main/native/cpp/RobotDrive.cpp @@ -735,7 +735,7 @@ void RobotDrive::SetSafetyEnabled(bool enabled) { m_safetyHelper->SetSafetyEnabled(enabled); } -void RobotDrive::GetDescription(llvm::raw_ostream& desc) const { +void RobotDrive::GetDescription(wpi::raw_ostream& desc) const { desc << "RobotDrive"; } diff --git a/wpilibc/src/main/native/cpp/SPI.cpp b/wpilibc/src/main/native/cpp/SPI.cpp index f8c154ca5e..7d2cab8763 100644 --- a/wpilibc/src/main/native/cpp/SPI.cpp +++ b/wpilibc/src/main/native/cpp/SPI.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include "DigitalSource.h" #include "Notifier.h" @@ -257,7 +257,7 @@ int SPI::Write(uint8_t* data, int size) { int SPI::Read(bool initiate, uint8_t* dataReceived, int size) { int retVal = 0; if (initiate) { - llvm::SmallVector dataToSend; + wpi::SmallVector dataToSend; dataToSend.resize(size); retVal = HAL_TransactionSPI(m_port, dataToSend.data(), dataReceived, size); } else { @@ -311,7 +311,7 @@ void SPI::FreeAuto() { * @param dataToSend data to send (maximum 16 bytes) * @param zeroSize number of zeros to send after the data */ -void SPI::SetAutoTransmitData(llvm::ArrayRef dataToSend, +void SPI::SetAutoTransmitData(wpi::ArrayRef dataToSend, int zeroSize) { int32_t status = 0; HAL_SetSPIAutoTransmitData(m_port, dataToSend.data(), dataToSend.size(), diff --git a/wpilibc/src/main/native/cpp/SafePWM.cpp b/wpilibc/src/main/native/cpp/SafePWM.cpp index d57364997e..1f83561a15 100644 --- a/wpilibc/src/main/native/cpp/SafePWM.cpp +++ b/wpilibc/src/main/native/cpp/SafePWM.cpp @@ -74,7 +74,7 @@ bool SafePWM::IsSafetyEnabled() const { return m_safetyHelper->IsSafetyEnabled(); } -void SafePWM::GetDescription(llvm::raw_ostream& desc) const { +void SafePWM::GetDescription(wpi::raw_ostream& desc) const { desc << "PWM " << GetChannel(); } diff --git a/wpilibc/src/main/native/cpp/SampleRobot.cpp b/wpilibc/src/main/native/cpp/SampleRobot.cpp index 3041388969..25cdb4cc1e 100644 --- a/wpilibc/src/main/native/cpp/SampleRobot.cpp +++ b/wpilibc/src/main/native/cpp/SampleRobot.cpp @@ -7,8 +7,8 @@ #include "SampleRobot.h" -#include #include +#include #include "DriverStation.h" #include "LiveWindow/LiveWindow.h" @@ -78,7 +78,7 @@ void SampleRobot::StartCompetition() { * ready, causing the robot to be bypassed in a match. */ void SampleRobot::RobotInit() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -88,7 +88,7 @@ void SampleRobot::RobotInit() { * field is disabled. */ void SampleRobot::Disabled() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -99,7 +99,7 @@ void SampleRobot::Disabled() { * robot enters the autonomous state. */ void SampleRobot::Autonomous() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -110,7 +110,7 @@ void SampleRobot::Autonomous() { * each time the robot enters the teleop state. */ void SampleRobot::OperatorControl() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** @@ -121,7 +121,7 @@ void SampleRobot::OperatorControl() { * test mode */ void SampleRobot::Test() { - llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; + wpi::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n"; } /** diff --git a/wpilibc/src/main/native/cpp/SerialPort.cpp b/wpilibc/src/main/native/cpp/SerialPort.cpp index 979004069f..377cbfe0b4 100644 --- a/wpilibc/src/main/native/cpp/SerialPort.cpp +++ b/wpilibc/src/main/native/cpp/SerialPort.cpp @@ -73,14 +73,14 @@ SerialPort::SerialPort(int baudRate, Port port, int dataBits, * @param stopBits The number of stop bits to use as defined by the enum * StopBits. */ -SerialPort::SerialPort(int baudRate, llvm::StringRef portName, Port port, +SerialPort::SerialPort(int baudRate, wpi::StringRef portName, Port port, int dataBits, SerialPort::Parity parity, SerialPort::StopBits stopBits) { int32_t status = 0; m_port = port; - llvm::SmallVector buf; + wpi::SmallVector buf; const char* portNameC = portName.c_str(buf); HAL_InitializeSerialPortDirect(static_cast(port), portNameC, @@ -194,7 +194,7 @@ int SerialPort::Read(char* buffer, int count) { * @return The number of bytes actually written into the port. */ int SerialPort::Write(const char* buffer, int count) { - return Write(llvm::StringRef(buffer, static_cast(count))); + return Write(wpi::StringRef(buffer, static_cast(count))); } /** @@ -206,7 +206,7 @@ int SerialPort::Write(const char* buffer, int count) { * @param buffer StringRef to the buffer to read the bytes from. * @return The number of bytes actually written into the port. */ -int SerialPort::Write(llvm::StringRef buffer) { +int SerialPort::Write(wpi::StringRef buffer) { int32_t status = 0; int retVal = HAL_WriteSerial(static_cast(m_port), buffer.data(), buffer.size(), &status); diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/NamedSendable.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/NamedSendable.cpp index fe812c17bf..3f1d3292ea 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/NamedSendable.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/NamedSendable.cpp @@ -9,10 +9,10 @@ using namespace frc; -void NamedSendable::SetName(const llvm::Twine&) {} +void NamedSendable::SetName(const wpi::Twine&) {} std::string NamedSendable::GetSubsystem() const { return std::string(); } -void NamedSendable::SetSubsystem(const llvm::Twine&) {} +void NamedSendable::SetSubsystem(const wpi::Twine&) {} void NamedSendable::InitSendable(SendableBuilder&) {} diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SendableBase.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SendableBase.cpp index 41fbd0e206..dde39165ab 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SendableBase.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SendableBase.cpp @@ -30,7 +30,7 @@ std::string SendableBase::GetName() const { return m_name; } -void SendableBase::SetName(const llvm::Twine& name) { +void SendableBase::SetName(const wpi::Twine& name) { std::lock_guard lock(m_mutex); m_name = name.str(); } @@ -40,7 +40,7 @@ std::string SendableBase::GetSubsystem() const { return m_subsystem; } -void SendableBase::SetSubsystem(const llvm::Twine& subsystem) { +void SendableBase::SetSubsystem(const wpi::Twine& subsystem) { std::lock_guard lock(m_mutex); m_subsystem = subsystem.str(); } @@ -70,9 +70,9 @@ void SendableBase::AddChild(void* child) { * value * @param channel The channel number the device is plugged into */ -void SendableBase::SetName(const llvm::Twine& moduleType, int channel) { - SetName(moduleType + llvm::Twine('[') + llvm::Twine(channel) + - llvm::Twine(']')); +void SendableBase::SetName(const wpi::Twine& moduleType, int channel) { + SetName(moduleType + wpi::Twine('[') + wpi::Twine(channel) + + wpi::Twine(']')); } /** @@ -84,8 +84,8 @@ void SendableBase::SetName(const llvm::Twine& moduleType, int channel) { * @param channel The channel number the device is plugged into (usually * PWM) */ -void SendableBase::SetName(const llvm::Twine& moduleType, int moduleNumber, +void SendableBase::SetName(const wpi::Twine& moduleType, int moduleNumber, int channel) { - SetName(moduleType + llvm::Twine('[') + llvm::Twine(moduleNumber) + - llvm::Twine(',') + llvm::Twine(channel) + llvm::Twine(']')); + SetName(moduleType + wpi::Twine('[') + wpi::Twine(moduleNumber) + + wpi::Twine(',') + wpi::Twine(channel) + wpi::Twine(']')); } diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SendableBuilderImpl.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SendableBuilderImpl.cpp index 2af2f3ae65..011f330b7a 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SendableBuilderImpl.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SendableBuilderImpl.cpp @@ -7,7 +7,7 @@ #include "SmartDashboard/SendableBuilderImpl.h" -#include +#include #include "ntcore_cpp.h" @@ -47,7 +47,7 @@ void SendableBuilderImpl::StopLiveWindowMode() { if (m_safeState) m_safeState(); } -void SendableBuilderImpl::SetSmartDashboardType(const llvm::Twine& type) { +void SendableBuilderImpl::SetSmartDashboardType(const wpi::Twine& type) { m_table->GetEntry(".type").SetString(type); } @@ -59,11 +59,11 @@ void SendableBuilderImpl::SetUpdateTable(std::function func) { m_updateTable = func; } -nt::NetworkTableEntry SendableBuilderImpl::GetEntry(const llvm::Twine& key) { +nt::NetworkTableEntry SendableBuilderImpl::GetEntry(const wpi::Twine& key) { return m_table->GetEntry(key); } -void SendableBuilderImpl::AddBooleanProperty(const llvm::Twine& key, +void SendableBuilderImpl::AddBooleanProperty(const wpi::Twine& key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); @@ -87,7 +87,7 @@ void SendableBuilderImpl::AddBooleanProperty(const llvm::Twine& key, } void SendableBuilderImpl::AddDoubleProperty( - const llvm::Twine& key, std::function getter, + const wpi::Twine& key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -110,8 +110,8 @@ void SendableBuilderImpl::AddDoubleProperty( } void SendableBuilderImpl::AddStringProperty( - const llvm::Twine& key, std::function getter, - std::function setter) { + const wpi::Twine& key, std::function getter, + std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, @@ -133,8 +133,8 @@ void SendableBuilderImpl::AddStringProperty( } void SendableBuilderImpl::AddBooleanArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) { + const wpi::Twine& key, std::function()> getter, + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, @@ -156,8 +156,8 @@ void SendableBuilderImpl::AddBooleanArrayProperty( } void SendableBuilderImpl::AddDoubleArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) { + const wpi::Twine& key, std::function()> getter, + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, @@ -179,8 +179,8 @@ void SendableBuilderImpl::AddDoubleArrayProperty( } void SendableBuilderImpl::AddStringArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) { + const wpi::Twine& key, std::function()> getter, + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, @@ -202,8 +202,8 @@ void SendableBuilderImpl::AddStringArrayProperty( } void SendableBuilderImpl::AddRawProperty( - const llvm::Twine& key, std::function getter, - std::function setter) { + const wpi::Twine& key, std::function getter, + std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, @@ -225,7 +225,7 @@ void SendableBuilderImpl::AddRawProperty( } void SendableBuilderImpl::AddValueProperty( - const llvm::Twine& key, std::function()> getter, + const wpi::Twine& key, std::function()> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -245,14 +245,14 @@ void SendableBuilderImpl::AddValueProperty( } void SendableBuilderImpl::AddSmallStringProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) { + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, uint64_t time) { - llvm::SmallString<128> buf; + wpi::SmallString<128> buf; entry.SetValue(nt::Value::MakeString(getter(buf), time)); }; } @@ -270,14 +270,14 @@ void SendableBuilderImpl::AddSmallStringProperty( } void SendableBuilderImpl::AddSmallBooleanArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> getter, - std::function)> setter) { + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, uint64_t time) { - llvm::SmallVector buf; + wpi::SmallVector buf; entry.SetValue(nt::Value::MakeBooleanArray(getter(buf), time)); }; } @@ -295,15 +295,15 @@ void SendableBuilderImpl::AddSmallBooleanArrayProperty( } void SendableBuilderImpl::AddSmallDoubleArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) { + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, uint64_t time) { - llvm::SmallVector buf; + wpi::SmallVector buf; entry.SetValue(nt::Value::MakeDoubleArray(getter(buf), time)); }; } @@ -321,16 +321,16 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty( } void SendableBuilderImpl::AddSmallStringArrayProperty( - const llvm::Twine& key, + const wpi::Twine& key, std::function< - llvm::ArrayRef(llvm::SmallVectorImpl& buf)> + wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) { + std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, uint64_t time) { - llvm::SmallVector buf; + wpi::SmallVector buf; entry.SetValue(nt::Value::MakeStringArray(getter(buf), time)); }; } @@ -348,14 +348,14 @@ void SendableBuilderImpl::AddSmallStringArrayProperty( } void SendableBuilderImpl::AddSmallRawProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) { + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { m_properties.back().update = [=](nt::NetworkTableEntry entry, uint64_t time) { - llvm::SmallVector buf; + wpi::SmallVector buf; entry.SetValue(nt::Value::MakeRaw(getter(buf), time)); }; } diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp index 1c5c5a6c81..41a459d640 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp @@ -7,10 +7,10 @@ #include "SmartDashboard/SmartDashboard.h" -#include #include #include -#include +#include +#include #include "HLUsageReporting.h" #include "SmartDashboard/Sendable.h" @@ -34,7 +34,7 @@ class Singleton { static Singleton& GetInstance(); std::shared_ptr table; - llvm::StringMap tablesToData; + wpi::StringMap tablesToData; wpi::mutex tablesToDataMutex; private: @@ -61,7 +61,7 @@ void SmartDashboard::init() { Singleton::GetInstance(); } * @param key the key to search for * @return true if the table as a value assigned to the given key */ -bool SmartDashboard::ContainsKey(llvm::StringRef key) { +bool SmartDashboard::ContainsKey(wpi::StringRef key) { return Singleton::GetInstance().table->ContainsKey(key); } @@ -78,7 +78,7 @@ std::vector SmartDashboard::GetKeys(int types) { * * @param key the key to make persistent */ -void SmartDashboard::SetPersistent(llvm::StringRef key) { +void SmartDashboard::SetPersistent(wpi::StringRef key) { Singleton::GetInstance().table->GetEntry(key).SetPersistent(); } @@ -88,7 +88,7 @@ void SmartDashboard::SetPersistent(llvm::StringRef key) { * * @param key the key name */ -void SmartDashboard::ClearPersistent(llvm::StringRef key) { +void SmartDashboard::ClearPersistent(wpi::StringRef key) { Singleton::GetInstance().table->GetEntry(key).ClearPersistent(); } @@ -98,7 +98,7 @@ void SmartDashboard::ClearPersistent(llvm::StringRef key) { * * @param key the key name */ -bool SmartDashboard::IsPersistent(llvm::StringRef key) { +bool SmartDashboard::IsPersistent(wpi::StringRef key) { return Singleton::GetInstance().table->GetEntry(key).IsPersistent(); } @@ -109,7 +109,7 @@ bool SmartDashboard::IsPersistent(llvm::StringRef key) { * @param key the key name * @param flags the flags to set (bitmask) */ -void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) { +void SmartDashboard::SetFlags(wpi::StringRef key, unsigned int flags) { Singleton::GetInstance().table->GetEntry(key).SetFlags(flags); } @@ -120,7 +120,7 @@ void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) { * @param key the key name * @param flags the flags to clear (bitmask) */ -void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) { +void SmartDashboard::ClearFlags(wpi::StringRef key, unsigned int flags) { Singleton::GetInstance().table->GetEntry(key).ClearFlags(flags); } @@ -130,7 +130,7 @@ void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) { * @param key the key name * @return the flags, or 0 if the key is not defined */ -unsigned int SmartDashboard::GetFlags(llvm::StringRef key) { +unsigned int SmartDashboard::GetFlags(wpi::StringRef key) { return Singleton::GetInstance().table->GetEntry(key).GetFlags(); } @@ -139,7 +139,7 @@ unsigned int SmartDashboard::GetFlags(llvm::StringRef key) { * * @param key the key name */ -void SmartDashboard::Delete(llvm::StringRef key) { +void SmartDashboard::Delete(wpi::StringRef key) { Singleton::GetInstance().table->Delete(key); } @@ -152,7 +152,7 @@ void SmartDashboard::Delete(llvm::StringRef key) { * @param keyName the key * @param value the value */ -void SmartDashboard::PutData(llvm::StringRef key, Sendable* data) { +void SmartDashboard::PutData(wpi::StringRef key, Sendable* data) { if (data == nullptr) { wpi_setGlobalWPIErrorWithContext(NullParameter, "value"); return; @@ -194,7 +194,7 @@ void SmartDashboard::PutData(Sendable* value) { * @param keyName the key * @return the value */ -Sendable* SmartDashboard::GetData(llvm::StringRef key) { +Sendable* SmartDashboard::GetData(wpi::StringRef key) { auto& inst = Singleton::GetInstance(); std::lock_guard lock(inst.tablesToDataMutex); auto data = inst.tablesToData.find(key); @@ -216,7 +216,7 @@ Sendable* SmartDashboard::GetData(llvm::StringRef key) { * @param value the value * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutValue(llvm::StringRef keyName, +bool SmartDashboard::PutValue(wpi::StringRef keyName, std::shared_ptr value) { return Singleton::GetInstance().table->GetEntry(keyName).SetValue(value); } @@ -228,7 +228,7 @@ bool SmartDashboard::PutValue(llvm::StringRef keyName, * @param defaultValue The default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultValue(llvm::StringRef key, +bool SmartDashboard::SetDefaultValue(wpi::StringRef key, std::shared_ptr defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultValue( defaultValue); @@ -241,7 +241,7 @@ bool SmartDashboard::SetDefaultValue(llvm::StringRef key, * @param keyName the key * @param value the object to retrieve the value into */ -std::shared_ptr SmartDashboard::GetValue(llvm::StringRef keyName) { +std::shared_ptr SmartDashboard::GetValue(wpi::StringRef keyName) { return Singleton::GetInstance().table->GetEntry(keyName).GetValue(); } @@ -255,7 +255,7 @@ std::shared_ptr SmartDashboard::GetValue(llvm::StringRef keyName) { * @param value the value * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) { +bool SmartDashboard::PutBoolean(wpi::StringRef keyName, bool value) { return Singleton::GetInstance().table->GetEntry(keyName).SetBoolean(value); } @@ -265,7 +265,7 @@ bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) { +bool SmartDashboard::SetDefaultBoolean(wpi::StringRef key, bool defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultBoolean( defaultValue); } @@ -278,7 +278,7 @@ bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) { * @param keyName the key * @return the value */ -bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) { +bool SmartDashboard::GetBoolean(wpi::StringRef keyName, bool defaultValue) { return Singleton::GetInstance().table->GetEntry(keyName).GetBoolean( defaultValue); } @@ -293,7 +293,7 @@ bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) { * @param value the value * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) { +bool SmartDashboard::PutNumber(wpi::StringRef keyName, double value) { return Singleton::GetInstance().table->GetEntry(keyName).SetDouble(value); } @@ -304,7 +304,7 @@ bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) { * @param defaultValue The default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultNumber(llvm::StringRef key, +bool SmartDashboard::SetDefaultNumber(wpi::StringRef key, double defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultDouble( defaultValue); @@ -318,7 +318,7 @@ bool SmartDashboard::SetDefaultNumber(llvm::StringRef key, * @param keyName the key * @return the value */ -double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) { +double SmartDashboard::GetNumber(wpi::StringRef keyName, double defaultValue) { return Singleton::GetInstance().table->GetEntry(keyName).GetDouble( defaultValue); } @@ -333,7 +333,7 @@ double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) { * @param value the value * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) { +bool SmartDashboard::PutString(wpi::StringRef keyName, wpi::StringRef value) { return Singleton::GetInstance().table->GetEntry(keyName).SetString(value); } @@ -343,8 +343,8 @@ bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) { * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultString(llvm::StringRef key, - llvm::StringRef defaultValue) { +bool SmartDashboard::SetDefaultString(wpi::StringRef key, + wpi::StringRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultString( defaultValue); } @@ -357,8 +357,8 @@ bool SmartDashboard::SetDefaultString(llvm::StringRef key, * @param keyName the key * @return the value */ -std::string SmartDashboard::GetString(llvm::StringRef keyName, - llvm::StringRef defaultValue) { +std::string SmartDashboard::GetString(wpi::StringRef keyName, + wpi::StringRef defaultValue) { return Singleton::GetInstance().table->GetEntry(keyName).GetString( defaultValue); } @@ -374,8 +374,8 @@ std::string SmartDashboard::GetString(llvm::StringRef keyName, * std::vector is special-cased in C++. 0 is false, any * non-zero value is true. */ -bool SmartDashboard::PutBooleanArray(llvm::StringRef key, - llvm::ArrayRef value) { +bool SmartDashboard::PutBooleanArray(wpi::StringRef key, + wpi::ArrayRef value) { return Singleton::GetInstance().table->GetEntry(key).SetBooleanArray(value); } @@ -386,8 +386,8 @@ bool SmartDashboard::PutBooleanArray(llvm::StringRef key, * @param defaultValue the default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key, - llvm::ArrayRef defaultValue) { +bool SmartDashboard::SetDefaultBooleanArray(wpi::StringRef key, + wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultBooleanArray( defaultValue); } @@ -411,7 +411,7 @@ bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key, * non-zero value is true. */ std::vector SmartDashboard::GetBooleanArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) { + wpi::StringRef key, wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).GetBooleanArray( defaultValue); } @@ -423,8 +423,8 @@ std::vector SmartDashboard::GetBooleanArray( * @param value The value that will be assigned. * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutNumberArray(llvm::StringRef key, - llvm::ArrayRef value) { +bool SmartDashboard::PutNumberArray(wpi::StringRef key, + wpi::ArrayRef value) { return Singleton::GetInstance().table->GetEntry(key).SetDoubleArray(value); } @@ -436,7 +436,7 @@ bool SmartDashboard::PutNumberArray(llvm::StringRef key, * @returns False if the table key exists with a different type */ bool SmartDashboard::SetDefaultNumberArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) { + wpi::StringRef key, wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultDoubleArray( defaultValue); } @@ -456,7 +456,7 @@ bool SmartDashboard::SetDefaultNumberArray( * use GetValue() instead. */ std::vector SmartDashboard::GetNumberArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) { + wpi::StringRef key, wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).GetDoubleArray( defaultValue); } @@ -468,8 +468,8 @@ std::vector SmartDashboard::GetNumberArray( * @param value The value that will be assigned. * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutStringArray(llvm::StringRef key, - llvm::ArrayRef value) { +bool SmartDashboard::PutStringArray(wpi::StringRef key, + wpi::ArrayRef value) { return Singleton::GetInstance().table->GetEntry(key).SetStringArray(value); } @@ -481,7 +481,7 @@ bool SmartDashboard::PutStringArray(llvm::StringRef key, * @returns False if the table key exists with a different type */ bool SmartDashboard::SetDefaultStringArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) { + wpi::StringRef key, wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultStringArray( defaultValue); } @@ -501,7 +501,7 @@ bool SmartDashboard::SetDefaultStringArray( * use GetValue() instead. */ std::vector SmartDashboard::GetStringArray( - llvm::StringRef key, llvm::ArrayRef defaultValue) { + wpi::StringRef key, wpi::ArrayRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).GetStringArray( defaultValue); } @@ -513,7 +513,7 @@ std::vector SmartDashboard::GetStringArray( * @param value The value that will be assigned. * @return False if the table key already exists with a different type */ -bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) { +bool SmartDashboard::PutRaw(wpi::StringRef key, wpi::StringRef value) { return Singleton::GetInstance().table->GetEntry(key).SetRaw(value); } @@ -524,8 +524,8 @@ bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) { * @param defaultValue The default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ -bool SmartDashboard::SetDefaultRaw(llvm::StringRef key, - llvm::StringRef defaultValue) { +bool SmartDashboard::SetDefaultRaw(wpi::StringRef key, + wpi::StringRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).SetDefaultRaw( defaultValue); } @@ -544,8 +544,8 @@ bool SmartDashboard::SetDefaultRaw(llvm::StringRef key, * @note This makes a copy of the raw contents. If the overhead of this is a * concern, use GetValue() instead. */ -std::string SmartDashboard::GetRaw(llvm::StringRef key, - llvm::StringRef defaultValue) { +std::string SmartDashboard::GetRaw(wpi::StringRef key, + wpi::StringRef defaultValue) { return Singleton::GetInstance().table->GetEntry(key).GetRaw(defaultValue); } diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp index 1d27391728..55a94f487c 100644 --- a/wpilibc/src/main/native/cpp/Solenoid.cpp +++ b/wpilibc/src/main/native/cpp/Solenoid.cpp @@ -36,12 +36,12 @@ Solenoid::Solenoid(int moduleNumber, int channel) if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) { wpi_setWPIErrorWithContext( ModuleIndexOutOfRange, - "Solenoid Module " + llvm::Twine(m_moduleNumber)); + "Solenoid Module " + wpi::Twine(m_moduleNumber)); return; } if (!SensorBase::CheckSolenoidChannel(m_channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, - "Solenoid Channel " + llvm::Twine(m_channel)); + "Solenoid Channel " + wpi::Twine(m_channel)); return; } diff --git a/wpilibc/src/main/native/cpp/Utility.cpp b/wpilibc/src/main/native/cpp/Utility.cpp index 7d5e615c2b..8ff9eabc75 100644 --- a/wpilibc/src/main/native/cpp/Utility.cpp +++ b/wpilibc/src/main/native/cpp/Utility.cpp @@ -16,13 +16,13 @@ #include #include -#include +#include +#include +#include #include "ErrorBase.h" #include "HAL/DriverStation.h" #include "HAL/HAL.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" using namespace frc; @@ -32,17 +32,17 @@ using namespace frc; * This allows breakpoints to be set on an assert. The users don't call this, * but instead use the wpi_assert macros in Utility.h. */ -bool wpi_assert_impl(bool conditionValue, const llvm::Twine& conditionText, - const llvm::Twine& message, llvm::StringRef fileName, - int lineNumber, llvm::StringRef funcName) { +bool wpi_assert_impl(bool conditionValue, const wpi::Twine& conditionText, + const wpi::Twine& message, wpi::StringRef fileName, + int lineNumber, wpi::StringRef funcName) { if (!conditionValue) { - llvm::SmallString<128> locBuf; - llvm::raw_svector_ostream locStream(locBuf); - locStream << funcName << " [" << llvm::sys::path::filename(fileName) << ":" + wpi::SmallString<128> locBuf; + wpi::raw_svector_ostream locStream(locBuf); + locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":" << lineNumber << "]"; - llvm::SmallString<128> errorBuf; - llvm::raw_svector_ostream errorStream(errorBuf); + wpi::SmallString<128> errorBuf; + wpi::raw_svector_ostream errorStream(errorBuf); errorStream << "Assertion \"" << conditionText << "\" "; @@ -68,19 +68,19 @@ bool wpi_assert_impl(bool conditionValue, const llvm::Twine& conditionText, * This should not be called directly; it should only be used by * wpi_assertEqual_impl and wpi_assertNotEqual_impl. */ -void wpi_assertEqual_common_impl(const llvm::Twine& valueA, - const llvm::Twine& valueB, - const llvm::Twine& equalityType, - const llvm::Twine& message, - llvm::StringRef fileName, int lineNumber, - llvm::StringRef funcName) { - llvm::SmallString<128> locBuf; - llvm::raw_svector_ostream locStream(locBuf); - locStream << funcName << " [" << llvm::sys::path::filename(fileName) << ":" +void wpi_assertEqual_common_impl(const wpi::Twine& valueA, + const wpi::Twine& valueB, + const wpi::Twine& equalityType, + const wpi::Twine& message, + wpi::StringRef fileName, int lineNumber, + wpi::StringRef funcName) { + wpi::SmallString<128> locBuf; + wpi::raw_svector_ostream locStream(locBuf); + locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":" << lineNumber << "]"; - llvm::SmallString<128> errorBuf; - llvm::raw_svector_ostream errorStream(errorBuf); + wpi::SmallString<128> errorBuf; + wpi::raw_svector_ostream errorStream(errorBuf); errorStream << "Assertion \"" << valueA << " " << equalityType << " " << valueB << "\" "; @@ -106,10 +106,10 @@ void wpi_assertEqual_common_impl(const llvm::Twine& valueA, * call this, but instead use the wpi_assertEqual macros in Utility.h. */ bool wpi_assertEqual_impl(int valueA, int valueB, - const llvm::Twine& valueAString, - const llvm::Twine& valueBString, - const llvm::Twine& message, llvm::StringRef fileName, - int lineNumber, llvm::StringRef funcName) { + const wpi::Twine& valueAString, + const wpi::Twine& valueBString, + const wpi::Twine& message, wpi::StringRef fileName, + int lineNumber, wpi::StringRef funcName) { if (!(valueA == valueB)) { wpi_assertEqual_common_impl(valueAString, valueBString, "==", message, fileName, lineNumber, funcName); @@ -125,11 +125,11 @@ bool wpi_assertEqual_impl(int valueA, int valueB, * this, but instead use the wpi_assertNotEqual macros in Utility.h. */ bool wpi_assertNotEqual_impl(int valueA, int valueB, - const llvm::Twine& valueAString, - const llvm::Twine& valueBString, - const llvm::Twine& message, - llvm::StringRef fileName, int lineNumber, - llvm::StringRef funcName) { + const wpi::Twine& valueAString, + const wpi::Twine& valueBString, + const wpi::Twine& message, + wpi::StringRef fileName, int lineNumber, + wpi::StringRef funcName) { if (!(valueA != valueB)) { wpi_assertEqual_common_impl(valueAString, valueBString, "!=", message, fileName, lineNumber, funcName); @@ -234,8 +234,8 @@ std::string GetStackTrace(int offset) { void* stackTrace[128]; int stackSize = backtrace(stackTrace, 128); char** mangledSymbols = backtrace_symbols(stackTrace, stackSize); - llvm::SmallString<1024> buf; - llvm::raw_svector_ostream trace(buf); + wpi::SmallString<1024> buf; + wpi::raw_svector_ostream trace(buf); for (int i = offset; i < stackSize; i++) { // Only print recursive functions once in a row. diff --git a/wpilibc/src/main/native/include/Buttons/NetworkButton.h b/wpilibc/src/main/native/include/Buttons/NetworkButton.h index dffc9ff14e..3296adc05d 100644 --- a/wpilibc/src/main/native/include/Buttons/NetworkButton.h +++ b/wpilibc/src/main/native/include/Buttons/NetworkButton.h @@ -9,9 +9,9 @@ #include -#include #include #include +#include #include "Buttons/Button.h" @@ -19,9 +19,9 @@ namespace frc { class NetworkButton : public Button { public: - NetworkButton(const llvm::Twine& tableName, const llvm::Twine& field); + NetworkButton(const wpi::Twine& tableName, const wpi::Twine& field); NetworkButton(std::shared_ptr table, - const llvm::Twine& field); + const wpi::Twine& field); virtual ~NetworkButton() = default; virtual bool Get(); diff --git a/wpilibc/src/main/native/include/Commands/Command.h b/wpilibc/src/main/native/include/Commands/Command.h index ee8b94267a..dab8200bf0 100644 --- a/wpilibc/src/main/native/include/Commands/Command.h +++ b/wpilibc/src/main/native/include/Commands/Command.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "ErrorBase.h" #include "SmartDashboard/SendableBase.h" @@ -51,9 +51,9 @@ class Command : public ErrorBase, public SendableBase { public: Command(); - explicit Command(const llvm::Twine& name); + explicit Command(const wpi::Twine& name); explicit Command(double timeout); - Command(const llvm::Twine& name, double timeout); + Command(const wpi::Twine& name, double timeout); ~Command() override = default; double TimeSinceInitialized() const; void Requires(Subsystem* s); diff --git a/wpilibc/src/main/native/include/Commands/CommandGroup.h b/wpilibc/src/main/native/include/Commands/CommandGroup.h index f5042167d1..859ed2bf66 100644 --- a/wpilibc/src/main/native/include/Commands/CommandGroup.h +++ b/wpilibc/src/main/native/include/Commands/CommandGroup.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Commands/Command.h" #include "Commands/CommandGroupEntry.h" @@ -37,7 +37,7 @@ namespace frc { class CommandGroup : public Command { public: CommandGroup() = default; - explicit CommandGroup(const llvm::Twine& name); + explicit CommandGroup(const wpi::Twine& name); virtual ~CommandGroup() = default; void AddSequential(Command* command); diff --git a/wpilibc/src/main/native/include/Commands/ConditionalCommand.h b/wpilibc/src/main/native/include/Commands/ConditionalCommand.h index eee537039b..38e50c13f3 100644 --- a/wpilibc/src/main/native/include/Commands/ConditionalCommand.h +++ b/wpilibc/src/main/native/include/Commands/ConditionalCommand.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/Command.h" @@ -35,7 +35,7 @@ namespace frc { class ConditionalCommand : public Command { public: explicit ConditionalCommand(Command* onTrue, Command* onFalse = nullptr); - ConditionalCommand(const llvm::Twine& name, Command* onTrue, + ConditionalCommand(const wpi::Twine& name, Command* onTrue, Command* onFalse = nullptr); virtual ~ConditionalCommand() = default; diff --git a/wpilibc/src/main/native/include/Commands/InstantCommand.h b/wpilibc/src/main/native/include/Commands/InstantCommand.h index 54ef31f567..2a0422c216 100644 --- a/wpilibc/src/main/native/include/Commands/InstantCommand.h +++ b/wpilibc/src/main/native/include/Commands/InstantCommand.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/Command.h" @@ -20,7 +20,7 @@ namespace frc { */ class InstantCommand : public Command { public: - explicit InstantCommand(const llvm::Twine& name); + explicit InstantCommand(const wpi::Twine& name); InstantCommand() = default; virtual ~InstantCommand() = default; diff --git a/wpilibc/src/main/native/include/Commands/PIDCommand.h b/wpilibc/src/main/native/include/Commands/PIDCommand.h index 950bb7e53c..42be0889b2 100644 --- a/wpilibc/src/main/native/include/Commands/PIDCommand.h +++ b/wpilibc/src/main/native/include/Commands/PIDCommand.h @@ -9,7 +9,7 @@ #include -#include +#include #include "Commands/Command.h" #include "PIDController.h" @@ -20,10 +20,10 @@ namespace frc { class PIDCommand : public Command, public PIDOutput, public PIDSource { public: - PIDCommand(const llvm::Twine& name, double p, double i, double d); - PIDCommand(const llvm::Twine& name, double p, double i, double d, + PIDCommand(const wpi::Twine& name, double p, double i, double d); + PIDCommand(const wpi::Twine& name, double p, double i, double d, double period); - PIDCommand(const llvm::Twine& name, double p, double i, double d, double f, + PIDCommand(const wpi::Twine& name, double p, double i, double d, double f, double period); PIDCommand(double p, double i, double d); PIDCommand(double p, double i, double d, double period); diff --git a/wpilibc/src/main/native/include/Commands/PIDSubsystem.h b/wpilibc/src/main/native/include/Commands/PIDSubsystem.h index 079028067a..38154e4c7e 100644 --- a/wpilibc/src/main/native/include/Commands/PIDSubsystem.h +++ b/wpilibc/src/main/native/include/Commands/PIDSubsystem.h @@ -9,7 +9,7 @@ #include -#include +#include #include "Commands/Subsystem.h" #include "PIDController.h" @@ -29,9 +29,9 @@ namespace frc { */ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource { public: - PIDSubsystem(const llvm::Twine& name, double p, double i, double d); - PIDSubsystem(const llvm::Twine& name, double p, double i, double d, double f); - PIDSubsystem(const llvm::Twine& name, double p, double i, double d, double f, + PIDSubsystem(const wpi::Twine& name, double p, double i, double d); + PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f); + PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f, double period); PIDSubsystem(double p, double i, double d); PIDSubsystem(double p, double i, double d, double f); diff --git a/wpilibc/src/main/native/include/Commands/PrintCommand.h b/wpilibc/src/main/native/include/Commands/PrintCommand.h index 8d32febbd0..5a5365ff7b 100644 --- a/wpilibc/src/main/native/include/Commands/PrintCommand.h +++ b/wpilibc/src/main/native/include/Commands/PrintCommand.h @@ -9,7 +9,7 @@ #include -#include +#include #include "Commands/InstantCommand.h" @@ -17,7 +17,7 @@ namespace frc { class PrintCommand : public InstantCommand { public: - explicit PrintCommand(const llvm::Twine& message); + explicit PrintCommand(const wpi::Twine& message); virtual ~PrintCommand() = default; protected: diff --git a/wpilibc/src/main/native/include/Commands/Scheduler.h b/wpilibc/src/main/native/include/Commands/Scheduler.h index 29d48ceb64..821750d2cc 100644 --- a/wpilibc/src/main/native/include/Commands/Scheduler.h +++ b/wpilibc/src/main/native/include/Commands/Scheduler.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include "Commands/Command.h" #include "ErrorBase.h" diff --git a/wpilibc/src/main/native/include/Commands/Subsystem.h b/wpilibc/src/main/native/include/Commands/Subsystem.h index 6d7e008756..e6b6911d64 100644 --- a/wpilibc/src/main/native/include/Commands/Subsystem.h +++ b/wpilibc/src/main/native/include/Commands/Subsystem.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "ErrorBase.h" #include "SmartDashboard/Sendable.h" @@ -24,20 +24,20 @@ class Subsystem : public ErrorBase, public SendableBase { friend class Scheduler; public: - explicit Subsystem(const llvm::Twine& name); + explicit Subsystem(const wpi::Twine& name); void SetDefaultCommand(Command* command); Command* GetDefaultCommand(); - llvm::StringRef GetDefaultCommandName(); + wpi::StringRef GetDefaultCommandName(); void SetCurrentCommand(Command* command); Command* GetCurrentCommand() const; - llvm::StringRef GetCurrentCommandName() const; + wpi::StringRef GetCurrentCommandName() const; virtual void Periodic(); virtual void InitDefaultCommand(); - void AddChild(const llvm::Twine& name, std::shared_ptr child); - void AddChild(const llvm::Twine& name, Sendable* child); - void AddChild(const llvm::Twine& name, Sendable& child); + void AddChild(const wpi::Twine& name, std::shared_ptr child); + void AddChild(const wpi::Twine& name, Sendable* child); + void AddChild(const wpi::Twine& name, Sendable& child); void AddChild(std::shared_ptr child); void AddChild(Sendable* child); void AddChild(Sendable& child); diff --git a/wpilibc/src/main/native/include/Commands/TimedCommand.h b/wpilibc/src/main/native/include/Commands/TimedCommand.h index e52109376a..51940fed3e 100644 --- a/wpilibc/src/main/native/include/Commands/TimedCommand.h +++ b/wpilibc/src/main/native/include/Commands/TimedCommand.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/Command.h" @@ -20,7 +20,7 @@ namespace frc { */ class TimedCommand : public Command { public: - TimedCommand(const llvm::Twine& name, double timeout); + TimedCommand(const wpi::Twine& name, double timeout); explicit TimedCommand(double timeout); virtual ~TimedCommand() = default; diff --git a/wpilibc/src/main/native/include/Commands/WaitCommand.h b/wpilibc/src/main/native/include/Commands/WaitCommand.h index 4a64580dfd..a577c13f6b 100644 --- a/wpilibc/src/main/native/include/Commands/WaitCommand.h +++ b/wpilibc/src/main/native/include/Commands/WaitCommand.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/TimedCommand.h" @@ -16,7 +16,7 @@ namespace frc { class WaitCommand : public TimedCommand { public: explicit WaitCommand(double timeout); - WaitCommand(const llvm::Twine& name, double timeout); + WaitCommand(const wpi::Twine& name, double timeout); virtual ~WaitCommand() = default; }; diff --git a/wpilibc/src/main/native/include/Commands/WaitForChildren.h b/wpilibc/src/main/native/include/Commands/WaitForChildren.h index e5ee31df8f..cefe9f9e7f 100644 --- a/wpilibc/src/main/native/include/Commands/WaitForChildren.h +++ b/wpilibc/src/main/native/include/Commands/WaitForChildren.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/Command.h" @@ -16,7 +16,7 @@ namespace frc { class WaitForChildren : public Command { public: explicit WaitForChildren(double timeout); - WaitForChildren(const llvm::Twine& name, double timeout); + WaitForChildren(const wpi::Twine& name, double timeout); virtual ~WaitForChildren() = default; protected: diff --git a/wpilibc/src/main/native/include/Commands/WaitUntilCommand.h b/wpilibc/src/main/native/include/Commands/WaitUntilCommand.h index 7813d6af5f..1f3d846b79 100644 --- a/wpilibc/src/main/native/include/Commands/WaitUntilCommand.h +++ b/wpilibc/src/main/native/include/Commands/WaitUntilCommand.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Commands/Command.h" @@ -16,7 +16,7 @@ namespace frc { class WaitUntilCommand : public Command { public: explicit WaitUntilCommand(double time); - WaitUntilCommand(const llvm::Twine& name, double time); + WaitUntilCommand(const wpi::Twine& name, double time); virtual ~WaitUntilCommand() = default; protected: diff --git a/wpilibc/src/main/native/include/ControllerPower.h b/wpilibc/src/main/native/include/ControllerPower.h index 29b8a3df74..d62d553741 100644 --- a/wpilibc/src/main/native/include/ControllerPower.h +++ b/wpilibc/src/main/native/include/ControllerPower.h @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace frc { diff --git a/wpilibc/src/main/native/include/DigitalGlitchFilter.h b/wpilibc/src/main/native/include/DigitalGlitchFilter.h index 55448d757e..84a86f55c0 100644 --- a/wpilibc/src/main/native/include/DigitalGlitchFilter.h +++ b/wpilibc/src/main/native/include/DigitalGlitchFilter.h @@ -11,7 +11,7 @@ #include -#include +#include #include "DigitalSource.h" #include "SensorBase.h" diff --git a/wpilibc/src/main/native/include/Drive/DifferentialDrive.h b/wpilibc/src/main/native/include/Drive/DifferentialDrive.h index afbdb66af7..4f249588f4 100644 --- a/wpilibc/src/main/native/include/Drive/DifferentialDrive.h +++ b/wpilibc/src/main/native/include/Drive/DifferentialDrive.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "Drive/RobotDriveBase.h" @@ -116,7 +116,7 @@ class DifferentialDrive : public RobotDriveBase { void SetQuickStopAlpha(double alpha); void StopMotor() override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/Drive/KilloughDrive.h b/wpilibc/src/main/native/include/Drive/KilloughDrive.h index 34844ed48f..5600c44b59 100644 --- a/wpilibc/src/main/native/include/Drive/KilloughDrive.h +++ b/wpilibc/src/main/native/include/Drive/KilloughDrive.h @@ -9,7 +9,7 @@ #include -#include +#include #include "Drive/RobotDriveBase.h" #include "Drive/Vector2d.h" @@ -65,7 +65,7 @@ class KilloughDrive : public RobotDriveBase { void DrivePolar(double magnitude, double angle, double zRotation); void StopMotor() override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/Drive/MecanumDrive.h b/wpilibc/src/main/native/include/Drive/MecanumDrive.h index 46e45a9112..430af70e95 100644 --- a/wpilibc/src/main/native/include/Drive/MecanumDrive.h +++ b/wpilibc/src/main/native/include/Drive/MecanumDrive.h @@ -9,7 +9,7 @@ #include -#include +#include #include "Drive/RobotDriveBase.h" @@ -77,7 +77,7 @@ class MecanumDrive : public RobotDriveBase { void DrivePolar(double magnitude, double angle, double rotation); void StopMotor() override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/Drive/RobotDriveBase.h b/wpilibc/src/main/native/include/Drive/RobotDriveBase.h index aad36c1691..892e0a9ffc 100644 --- a/wpilibc/src/main/native/include/Drive/RobotDriveBase.h +++ b/wpilibc/src/main/native/include/Drive/RobotDriveBase.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "MotorSafety.h" #include "MotorSafetyHelper.h" @@ -53,12 +53,12 @@ class RobotDriveBase : public MotorSafety, public SendableBase { void StopMotor() override = 0; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(llvm::raw_ostream& desc) const override = 0; + void GetDescription(wpi::raw_ostream& desc) const override = 0; protected: double Limit(double number); double ApplyDeadband(double number, double deadband); - void Normalize(llvm::MutableArrayRef wheelSpeeds); + void Normalize(wpi::MutableArrayRef wheelSpeeds); double m_deadband = 0.02; double m_maxOutput = 1.0; diff --git a/wpilibc/src/main/native/include/DriverStation.h b/wpilibc/src/main/native/include/DriverStation.h index 9f9b1af82b..17f372fd78 100644 --- a/wpilibc/src/main/native/include/DriverStation.h +++ b/wpilibc/src/main/native/include/DriverStation.h @@ -14,10 +14,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "ErrorBase.h" #include "RobotState.h" @@ -38,11 +38,11 @@ class DriverStation : public ErrorBase, public RobotStateInterface { ~DriverStation() override; static DriverStation& GetInstance(); - static void ReportError(const llvm::Twine& error); - static void ReportWarning(const llvm::Twine& error); - static void ReportError(bool isError, int code, const llvm::Twine& error, - const llvm::Twine& location, - const llvm::Twine& stack); + static void ReportError(const wpi::Twine& error); + static void ReportWarning(const wpi::Twine& error); + static void ReportError(bool isError, int code, const wpi::Twine& error, + const wpi::Twine& location, + const wpi::Twine& stack); static constexpr int kJoystickPorts = 6; @@ -130,8 +130,8 @@ class DriverStation : public ErrorBase, public RobotStateInterface { private: DriverStation(); - void ReportJoystickUnpluggedError(const llvm::Twine& message); - void ReportJoystickUnpluggedWarning(const llvm::Twine& message); + void ReportJoystickUnpluggedError(const wpi::Twine& message); + void ReportJoystickUnpluggedWarning(const wpi::Twine& message); void Run(); void UpdateControlWord(bool force, HAL_ControlWord& controlWord) const; void SendMatchData(); diff --git a/wpilibc/src/main/native/include/Error.h b/wpilibc/src/main/native/include/Error.h index 532b2ab8f7..46c1501ca9 100644 --- a/wpilibc/src/main/native/include/Error.h +++ b/wpilibc/src/main/native/include/Error.h @@ -11,8 +11,8 @@ #include -#include -#include +#include +#include #ifdef _WIN32 #include @@ -47,8 +47,8 @@ class Error { const ErrorBase* GetOriginatingObject() const; double GetTimestamp() const; void Clear(); - void Set(Code code, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, int lineNumber, + void Set(Code code, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber, const ErrorBase* originatingObject); private: diff --git a/wpilibc/src/main/native/include/ErrorBase.h b/wpilibc/src/main/native/include/ErrorBase.h index 5f510d57a6..4ed4fac928 100644 --- a/wpilibc/src/main/native/include/ErrorBase.h +++ b/wpilibc/src/main/native/include/ErrorBase.h @@ -7,9 +7,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include "Base.h" #include "Error.h" @@ -82,35 +82,35 @@ class ErrorBase { virtual Error& GetError(); virtual const Error& GetError() const; - virtual void SetErrnoError(const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + virtual void SetErrnoError(const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const; - virtual void SetImaqError(int success, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + virtual void SetImaqError(int success, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const; - virtual void SetError(Error::Code code, const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + virtual void SetError(Error::Code code, const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const; virtual void SetErrorRange(Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, - const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const; - virtual void SetWPIError(const llvm::Twine& errorMessage, Error::Code code, - const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + virtual void SetWPIError(const wpi::Twine& errorMessage, Error::Code code, + const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber) const; virtual void CloneError(const ErrorBase& rhs) const; virtual void ClearError() const; virtual bool StatusIsFatal() const; static void SetGlobalError(Error::Code code, - const llvm::Twine& contextMessage, - llvm::StringRef filename, llvm::StringRef function, + const wpi::Twine& contextMessage, + wpi::StringRef filename, wpi::StringRef function, int lineNumber); - static void SetGlobalWPIError(const llvm::Twine& errorMessage, - const llvm::Twine& contextMessage, - llvm::StringRef filename, - llvm::StringRef function, int lineNumber); + static void SetGlobalWPIError(const wpi::Twine& errorMessage, + const wpi::Twine& contextMessage, + wpi::StringRef filename, + wpi::StringRef function, int lineNumber); static Error& GetGlobalError(); protected: diff --git a/wpilibc/src/main/native/include/Filters/LinearDigitalFilter.h b/wpilibc/src/main/native/include/Filters/LinearDigitalFilter.h index 0e265a9ff5..089e840f99 100644 --- a/wpilibc/src/main/native/include/Filters/LinearDigitalFilter.h +++ b/wpilibc/src/main/native/include/Filters/LinearDigitalFilter.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Filter.h" #include "circular_buffer.h" @@ -69,11 +69,11 @@ namespace frc { */ class LinearDigitalFilter : public Filter { public: - LinearDigitalFilter(PIDSource& source, llvm::ArrayRef ffGains, - llvm::ArrayRef fbGains); + LinearDigitalFilter(PIDSource& source, wpi::ArrayRef ffGains, + wpi::ArrayRef fbGains); LinearDigitalFilter(std::shared_ptr source, - llvm::ArrayRef ffGains, - llvm::ArrayRef fbGains); + wpi::ArrayRef ffGains, + wpi::ArrayRef fbGains); // Static methods to create commonly used filters static LinearDigitalFilter SinglePoleIIR(PIDSource& source, diff --git a/wpilibc/src/main/native/include/GamepadBase.h b/wpilibc/src/main/native/include/GamepadBase.h index ba2ca573d5..21c89f4803 100644 --- a/wpilibc/src/main/native/include/GamepadBase.h +++ b/wpilibc/src/main/native/include/GamepadBase.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "GenericHID.h" diff --git a/wpilibc/src/main/native/include/Joystick.h b/wpilibc/src/main/native/include/Joystick.h index 3ed257a426..e5debc04f6 100644 --- a/wpilibc/src/main/native/include/Joystick.h +++ b/wpilibc/src/main/native/include/Joystick.h @@ -9,7 +9,7 @@ #include -#include +#include #include "GenericHID.h" diff --git a/wpilibc/src/main/native/include/JoystickBase.h b/wpilibc/src/main/native/include/JoystickBase.h index f936e3f36d..0cbffd0006 100644 --- a/wpilibc/src/main/native/include/JoystickBase.h +++ b/wpilibc/src/main/native/include/JoystickBase.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "GenericHID.h" diff --git a/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h b/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h index 56d6f85be2..fffc2b8b6a 100644 --- a/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h +++ b/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "SmartDashboard/Sendable.h" @@ -31,30 +31,30 @@ class LiveWindow { void Run() { UpdateValues(); } WPI_DEPRECATED("use Sendable::SetName() instead") - void AddSensor(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddSensor(const wpi::Twine& subsystem, const wpi::Twine& name, Sendable* component); WPI_DEPRECATED("use Sendable::SetName() instead") - void AddSensor(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddSensor(const wpi::Twine& subsystem, const wpi::Twine& name, Sendable& component); WPI_DEPRECATED("use Sendable::SetName() instead") - void AddSensor(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddSensor(const wpi::Twine& subsystem, const wpi::Twine& name, std::shared_ptr component); WPI_DEPRECATED("use Sendable::SetName() instead") - void AddActuator(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name, Sendable* component); WPI_DEPRECATED("use Sendable::SetName() instead") - void AddActuator(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name, Sendable& component); WPI_DEPRECATED("use Sendable::SetName() instead") - void AddActuator(const llvm::Twine& subsystem, const llvm::Twine& name, + void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name, std::shared_ptr component); WPI_DEPRECATED("use SensorBase::SetName() instead") - void AddSensor(const llvm::Twine& type, int channel, Sendable* component); + void AddSensor(const wpi::Twine& type, int channel, Sendable* component); WPI_DEPRECATED("use SensorBase::SetName() instead") - void AddActuator(const llvm::Twine& type, int channel, Sendable* component); + void AddActuator(const wpi::Twine& type, int channel, Sendable* component); WPI_DEPRECATED("use SensorBase::SetName() instead") - void AddActuator(const llvm::Twine& type, int module, int channel, + void AddActuator(const wpi::Twine& type, int module, int channel, Sendable* component); void Add(std::shared_ptr component); diff --git a/wpilibc/src/main/native/include/LiveWindow/LiveWindowSendable.h b/wpilibc/src/main/native/include/LiveWindow/LiveWindowSendable.h index 101334ad46..b5e7bfff37 100644 --- a/wpilibc/src/main/native/include/LiveWindow/LiveWindowSendable.h +++ b/wpilibc/src/main/native/include/LiveWindow/LiveWindowSendable.h @@ -9,7 +9,7 @@ #include -#include +#include #include "SmartDashboard/Sendable.h" @@ -39,9 +39,9 @@ class WPI_DEPRECATED("use Sendable directly instead") LiveWindowSendable virtual void StopLiveWindowMode() = 0; std::string GetName() const override; - void SetName(const llvm::Twine& name) override; + void SetName(const wpi::Twine& name) override; std::string GetSubsystem() const override; - void SetSubsystem(const llvm::Twine& subsystem) override; + void SetSubsystem(const wpi::Twine& subsystem) override; void InitSendable(SendableBuilder& builder) override; }; diff --git a/wpilibc/src/main/native/include/MotorSafety.h b/wpilibc/src/main/native/include/MotorSafety.h index 37a73390bf..7711df9941 100644 --- a/wpilibc/src/main/native/include/MotorSafety.h +++ b/wpilibc/src/main/native/include/MotorSafety.h @@ -9,7 +9,7 @@ #define DEFAULT_SAFETY_EXPIRATION 0.1 -#include +#include namespace frc { @@ -21,7 +21,7 @@ class MotorSafety { virtual void StopMotor() = 0; virtual void SetSafetyEnabled(bool enabled) = 0; virtual bool IsSafetyEnabled() const = 0; - virtual void GetDescription(llvm::raw_ostream& desc) const = 0; + virtual void GetDescription(wpi::raw_ostream& desc) const = 0; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/MotorSafetyHelper.h b/wpilibc/src/main/native/include/MotorSafetyHelper.h index 7e51818cff..8e8577fe1d 100644 --- a/wpilibc/src/main/native/include/MotorSafetyHelper.h +++ b/wpilibc/src/main/native/include/MotorSafetyHelper.h @@ -9,7 +9,7 @@ #include -#include +#include #include "ErrorBase.h" diff --git a/wpilibc/src/main/native/include/NidecBrushless.h b/wpilibc/src/main/native/include/NidecBrushless.h index f228b93dd6..a956174fe6 100644 --- a/wpilibc/src/main/native/include/NidecBrushless.h +++ b/wpilibc/src/main/native/include/NidecBrushless.h @@ -49,7 +49,7 @@ class NidecBrushless : public ErrorBase, bool IsAlive() const override; void SetSafetyEnabled(bool enabled) override; bool IsSafetyEnabled() const override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; int GetChannel() const; diff --git a/wpilibc/src/main/native/include/Notifier.h b/wpilibc/src/main/native/include/Notifier.h index 02eaff10b1..a3b37c131f 100644 --- a/wpilibc/src/main/native/include/Notifier.h +++ b/wpilibc/src/main/native/include/Notifier.h @@ -15,7 +15,7 @@ #include #include -#include +#include #include "ErrorBase.h" diff --git a/wpilibc/src/main/native/include/PIDController.h b/wpilibc/src/main/native/include/PIDController.h index 7d8592a6ad..89adb415a3 100644 --- a/wpilibc/src/main/native/include/PIDController.h +++ b/wpilibc/src/main/native/include/PIDController.h @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "Base.h" #include "Controller.h" diff --git a/wpilibc/src/main/native/include/Preferences.h b/wpilibc/src/main/native/include/Preferences.h index f98466816a..70f28d742c 100644 --- a/wpilibc/src/main/native/include/Preferences.h +++ b/wpilibc/src/main/native/include/Preferences.h @@ -38,20 +38,20 @@ class Preferences : public ErrorBase { static Preferences* GetInstance(); std::vector GetKeys(); - std::string GetString(llvm::StringRef key, llvm::StringRef defaultValue = ""); - int GetInt(llvm::StringRef key, int defaultValue = 0); - double GetDouble(llvm::StringRef key, double defaultValue = 0.0); - float GetFloat(llvm::StringRef key, float defaultValue = 0.0); - bool GetBoolean(llvm::StringRef key, bool defaultValue = false); - int64_t GetLong(llvm::StringRef key, int64_t defaultValue = 0); - void PutString(llvm::StringRef key, llvm::StringRef value); - void PutInt(llvm::StringRef key, int value); - void PutDouble(llvm::StringRef key, double value); - void PutFloat(llvm::StringRef key, float value); - void PutBoolean(llvm::StringRef key, bool value); - void PutLong(llvm::StringRef key, int64_t value); - bool ContainsKey(llvm::StringRef key); - void Remove(llvm::StringRef key); + std::string GetString(wpi::StringRef key, wpi::StringRef defaultValue = ""); + int GetInt(wpi::StringRef key, int defaultValue = 0); + double GetDouble(wpi::StringRef key, double defaultValue = 0.0); + float GetFloat(wpi::StringRef key, float defaultValue = 0.0); + bool GetBoolean(wpi::StringRef key, bool defaultValue = false); + int64_t GetLong(wpi::StringRef key, int64_t defaultValue = 0); + void PutString(wpi::StringRef key, wpi::StringRef value); + void PutInt(wpi::StringRef key, int value); + void PutDouble(wpi::StringRef key, double value); + void PutFloat(wpi::StringRef key, float value); + void PutBoolean(wpi::StringRef key, bool value); + void PutLong(wpi::StringRef key, int64_t value); + bool ContainsKey(wpi::StringRef key); + void Remove(wpi::StringRef key); protected: Preferences(); diff --git a/wpilibc/src/main/native/include/Relay.h b/wpilibc/src/main/native/include/Relay.h index 241029ab25..d13ab299f5 100644 --- a/wpilibc/src/main/native/include/Relay.h +++ b/wpilibc/src/main/native/include/Relay.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "ErrorBase.h" #include "MotorSafety.h" @@ -50,7 +50,7 @@ class Relay : public MotorSafety, public ErrorBase, public SendableBase { void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/Resource.h b/wpilibc/src/main/native/include/Resource.h index 0cd7d56de3..3685cab413 100644 --- a/wpilibc/src/main/native/include/Resource.h +++ b/wpilibc/src/main/native/include/Resource.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include "ErrorBase.h" diff --git a/wpilibc/src/main/native/include/RobotBase.h b/wpilibc/src/main/native/include/RobotBase.h index 95f0a82f26..91f04919bb 100644 --- a/wpilibc/src/main/native/include/RobotBase.h +++ b/wpilibc/src/main/native/include/RobotBase.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Base.h" @@ -18,17 +18,17 @@ namespace frc { class DriverStation; -#define START_ROBOT_CLASS(_ClassName_) \ - int main() { \ - if (!HAL_Initialize(500, 0)) { \ - llvm::errs() << "FATAL ERROR: HAL could not be initialized\n"; \ - return -1; \ - } \ - HAL_Report(HALUsageReporting::kResourceType_Language, \ - HALUsageReporting::kLanguage_CPlusPlus); \ - llvm::outs() << "\n********** Robot program starting **********\n"; \ - static _ClassName_ robot; \ - robot.StartCompetition(); \ +#define START_ROBOT_CLASS(_ClassName_) \ + int main() { \ + if (!HAL_Initialize(500, 0)) { \ + wpi::errs() << "FATAL ERROR: HAL could not be initialized\n"; \ + return -1; \ + } \ + HAL_Report(HALUsageReporting::kResourceType_Language, \ + HALUsageReporting::kLanguage_CPlusPlus); \ + wpi::outs() << "\n********** Robot program starting **********\n"; \ + static _ClassName_ robot; \ + robot.StartCompetition(); \ } /** diff --git a/wpilibc/src/main/native/include/RobotDrive.h b/wpilibc/src/main/native/include/RobotDrive.h index 834469042f..20a54f0789 100644 --- a/wpilibc/src/main/native/include/RobotDrive.h +++ b/wpilibc/src/main/native/include/RobotDrive.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "ErrorBase.h" #include "MotorSafety.h" @@ -105,7 +105,7 @@ class RobotDrive : public MotorSafety, public ErrorBase { void StopMotor() override; bool IsSafetyEnabled() const override; void SetSafetyEnabled(bool enabled) override; - void GetDescription(llvm::raw_ostream& desc) const override; + void GetDescription(wpi::raw_ostream& desc) const override; protected: void InitRobotDrive(); diff --git a/wpilibc/src/main/native/include/SPI.h b/wpilibc/src/main/native/include/SPI.h index c54eb7d15d..5805b588fe 100644 --- a/wpilibc/src/main/native/include/SPI.h +++ b/wpilibc/src/main/native/include/SPI.h @@ -11,7 +11,7 @@ #include -#include +#include #include "ErrorBase.h" @@ -58,7 +58,7 @@ class SPI : public ErrorBase { void InitAuto(int bufferSize); void FreeAuto(); - void SetAutoTransmitData(llvm::ArrayRef dataToSend, int zeroSize); + void SetAutoTransmitData(wpi::ArrayRef dataToSend, int zeroSize); void StartAutoRate(double period); void StartAutoTrigger(DigitalSource& source, bool rising, bool falling); void StopAuto(); diff --git a/wpilibc/src/main/native/include/SafePWM.h b/wpilibc/src/main/native/include/SafePWM.h index 3d37edc7c6..ea268f6c17 100644 --- a/wpilibc/src/main/native/include/SafePWM.h +++ b/wpilibc/src/main/native/include/SafePWM.h @@ -9,7 +9,7 @@ #include -#include +#include #include "MotorSafety.h" #include "MotorSafetyHelper.h" @@ -36,7 +36,7 @@ class SafePWM : public PWM, public MotorSafety { void StopMotor(); bool IsSafetyEnabled() const; void SetSafetyEnabled(bool enabled); - void GetDescription(llvm::raw_ostream& desc) const; + void GetDescription(wpi::raw_ostream& desc) const; virtual void SetSpeed(double speed); diff --git a/wpilibc/src/main/native/include/SampleRobot.h b/wpilibc/src/main/native/include/SampleRobot.h index 4858a33740..4ef2220f0c 100644 --- a/wpilibc/src/main/native/include/SampleRobot.h +++ b/wpilibc/src/main/native/include/SampleRobot.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "RobotBase.h" diff --git a/wpilibc/src/main/native/include/SerialPort.h b/wpilibc/src/main/native/include/SerialPort.h index 0d43115d6a..935bad69cc 100644 --- a/wpilibc/src/main/native/include/SerialPort.h +++ b/wpilibc/src/main/native/include/SerialPort.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "ErrorBase.h" @@ -58,7 +58,7 @@ class SerialPort : public ErrorBase { SerialPort(int baudRate, Port port = kOnboard, int dataBits = 8, Parity parity = kParity_None, StopBits stopBits = kStopBits_One); WPI_DEPRECATED("Will be removed for 2019") - SerialPort(int baudRate, llvm::StringRef portName, Port port = kOnboard, + SerialPort(int baudRate, wpi::StringRef portName, Port port = kOnboard, int dataBits = 8, Parity parity = kParity_None, StopBits stopBits = kStopBits_One); ~SerialPort(); @@ -72,7 +72,7 @@ class SerialPort : public ErrorBase { int GetBytesReceived(); int Read(char* buffer, int count); int Write(const char* buffer, int count); - int Write(llvm::StringRef buffer); + int Write(wpi::StringRef buffer); void SetTimeout(double timeout); void SetReadBufferSize(int size); void SetWriteBufferSize(int size); diff --git a/wpilibc/src/main/native/include/SmartDashboard/NamedSendable.h b/wpilibc/src/main/native/include/SmartDashboard/NamedSendable.h index ff3e1c3bb2..bb308bcf9b 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/NamedSendable.h +++ b/wpilibc/src/main/native/include/SmartDashboard/NamedSendable.h @@ -9,7 +9,7 @@ #include -#include +#include #include "SmartDashboard/Sendable.h" @@ -23,9 +23,9 @@ namespace frc { class WPI_DEPRECATED("use Sendable directly instead") NamedSendable : public Sendable { public: - void SetName(const llvm::Twine& name) override; + void SetName(const wpi::Twine& name) override; std::string GetSubsystem() const override; - void SetSubsystem(const llvm::Twine& subsystem) override; + void SetSubsystem(const wpi::Twine& subsystem) override; void InitSendable(SendableBuilder& builder) override; }; diff --git a/wpilibc/src/main/native/include/SmartDashboard/Sendable.h b/wpilibc/src/main/native/include/SmartDashboard/Sendable.h index ffaf7c5e1f..d340752588 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/Sendable.h +++ b/wpilibc/src/main/native/include/SmartDashboard/Sendable.h @@ -9,7 +9,7 @@ #include -#include +#include namespace frc { @@ -31,7 +31,7 @@ class Sendable { * * @param name name */ - virtual void SetName(const llvm::Twine& name) = 0; + virtual void SetName(const wpi::Twine& name) = 0; /** * Sets both the subsystem name and device name of this Sendable object. @@ -39,7 +39,7 @@ class Sendable { * @param subsystem subsystem name * @param name device name */ - void SetName(const llvm::Twine& subsystem, const llvm::Twine& name) { + void SetName(const wpi::Twine& subsystem, const wpi::Twine& name) { SetSubsystem(subsystem); SetName(name); } @@ -56,7 +56,7 @@ class Sendable { * * @param subsystem subsystem name */ - virtual void SetSubsystem(const llvm::Twine& subsystem) = 0; + virtual void SetSubsystem(const wpi::Twine& subsystem) = 0; /** * Initializes this Sendable object. diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableBase.h b/wpilibc/src/main/native/include/SmartDashboard/SendableBase.h index e2b953324e..f003047128 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableBase.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableBase.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "Sendable.h" @@ -24,16 +24,16 @@ class SendableBase : public Sendable { using Sendable::SetName; std::string GetName() const final; - void SetName(const llvm::Twine& name) final; + void SetName(const wpi::Twine& name) final; std::string GetSubsystem() const final; - void SetSubsystem(const llvm::Twine& subsystem) final; + void SetSubsystem(const wpi::Twine& subsystem) final; protected: void AddChild(std::shared_ptr child); void AddChild(void* child); - void SetName(const llvm::Twine& moduleType, int channel); - void SetName(const llvm::Twine& moduleType, int moduleNumber, int channel); + void SetName(const wpi::Twine& moduleType, int channel); + void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel); private: mutable wpi::mutex m_mutex; diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableBuilder.h b/wpilibc/src/main/native/include/SmartDashboard/SendableBuilder.h index 49be390714..8c65158e0a 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableBuilder.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableBuilder.h @@ -12,11 +12,11 @@ #include #include -#include -#include -#include #include #include +#include +#include +#include namespace frc { @@ -30,7 +30,7 @@ class SendableBuilder { * * @param type data type */ - virtual void SetSmartDashboardType(const llvm::Twine& type) = 0; + virtual void SetSmartDashboardType(const wpi::Twine& type) = 0; /** * Set the function that should be called to set the Sendable into a safe @@ -57,7 +57,7 @@ class SendableBuilder { * @param key property name * @return Network table entry */ - virtual nt::NetworkTableEntry GetEntry(const llvm::Twine& key) = 0; + virtual nt::NetworkTableEntry GetEntry(const wpi::Twine& key) = 0; /** * Add a boolean property. @@ -66,7 +66,7 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddBooleanProperty(const llvm::Twine& key, + virtual void AddBooleanProperty(const wpi::Twine& key, std::function getter, std::function setter) = 0; @@ -77,7 +77,7 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddDoubleProperty(const llvm::Twine& key, + virtual void AddDoubleProperty(const wpi::Twine& key, std::function getter, std::function setter) = 0; @@ -89,8 +89,8 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddStringProperty( - const llvm::Twine& key, std::function getter, - std::function setter) = 0; + const wpi::Twine& key, std::function getter, + std::function setter) = 0; /** * Add a boolean array property. @@ -100,8 +100,8 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddBooleanArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) = 0; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) = 0; /** * Add a double array property. @@ -111,8 +111,8 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddDoubleArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) = 0; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) = 0; /** * Add a string array property. @@ -122,8 +122,8 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddStringArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) = 0; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) = 0; /** * Add a raw property. @@ -132,9 +132,9 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddRawProperty(const llvm::Twine& key, + virtual void AddRawProperty(const wpi::Twine& key, std::function getter, - std::function setter) = 0; + std::function setter) = 0; /** * Add a NetworkTableValue property. @@ -144,7 +144,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddValueProperty( - const llvm::Twine& key, + const wpi::Twine& key, std::function()> getter, std::function)> setter) = 0; @@ -156,9 +156,9 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallStringProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) = 0; + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) = 0; /** * Add a boolean array property (SmallVector form). @@ -168,10 +168,10 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallBooleanArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) = 0; + std::function)> setter) = 0; /** * Add a double array property (SmallVector form). @@ -181,10 +181,10 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallDoubleArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) = 0; + std::function)> setter) = 0; /** * Add a string array property (SmallVector form). @@ -194,11 +194,11 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallStringArrayProperty( - const llvm::Twine& key, + const wpi::Twine& key, std::function< - llvm::ArrayRef(llvm::SmallVectorImpl& buf)> + wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) = 0; + std::function)> setter) = 0; /** * Add a raw property (SmallVector form). @@ -208,9 +208,9 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallRawProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) = 0; + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) = 0; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/SmartDashboard/SendableBuilderImpl.h index 6278de6d90..87e1eaa8f7 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableBuilderImpl.h @@ -13,12 +13,12 @@ #include #include -#include -#include -#include #include #include #include +#include +#include +#include #include "SendableBuilder.h" @@ -73,74 +73,74 @@ class SendableBuilderImpl : public SendableBuilder { */ void StopLiveWindowMode(); - void SetSmartDashboardType(const llvm::Twine& type) override; + void SetSmartDashboardType(const wpi::Twine& type) override; void SetSafeState(std::function func) override; void SetUpdateTable(std::function func) override; - nt::NetworkTableEntry GetEntry(const llvm::Twine& key) override; + nt::NetworkTableEntry GetEntry(const wpi::Twine& key) override; - void AddBooleanProperty(const llvm::Twine& key, std::function getter, + void AddBooleanProperty(const wpi::Twine& key, std::function getter, std::function setter) override; - void AddDoubleProperty(const llvm::Twine& key, std::function getter, + void AddDoubleProperty(const wpi::Twine& key, std::function getter, std::function setter) override; - void AddStringProperty(const llvm::Twine& key, + void AddStringProperty(const wpi::Twine& key, std::function getter, - std::function setter) override; + std::function setter) override; void AddBooleanArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) override; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) override; void AddDoubleArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) override; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) override; void AddStringArrayProperty( - const llvm::Twine& key, std::function()> getter, - std::function)> setter) override; + const wpi::Twine& key, std::function()> getter, + std::function)> setter) override; - void AddRawProperty(const llvm::Twine& key, + void AddRawProperty(const wpi::Twine& key, std::function getter, - std::function setter) override; + std::function setter) override; void AddValueProperty( - const llvm::Twine& key, + const wpi::Twine& key, std::function()> getter, std::function)> setter) override; void AddSmallStringProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) override; + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) override; void AddSmallBooleanArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) override; + std::function)> setter) override; void AddSmallDoubleArrayProperty( - const llvm::Twine& key, - std::function(llvm::SmallVectorImpl& buf)> + const wpi::Twine& key, + std::function(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) override; + std::function)> setter) override; void AddSmallStringArrayProperty( - const llvm::Twine& key, + const wpi::Twine& key, std::function< - llvm::ArrayRef(llvm::SmallVectorImpl& buf)> + wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, - std::function)> setter) override; + std::function)> setter) override; void AddSmallRawProperty( - const llvm::Twine& key, - std::function& buf)> getter, - std::function setter) override; + const wpi::Twine& key, + std::function& buf)> getter, + std::function setter) override; private: struct Property { - Property(nt::NetworkTable& table, const llvm::Twine& key) + Property(nt::NetworkTable& table, const wpi::Twine& key) : entry(table.GetEntry(key)) {} Property(const Property&) = delete; diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.h b/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.h index 9a8a69d873..b0a2c01a57 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include "SmartDashboard/SendableChooserBase.h" @@ -31,7 +31,7 @@ namespace frc { */ template class SendableChooser : public SendableChooserBase { - llvm::StringMap m_choices; + wpi::StringMap m_choices; template static U _unwrap_smart_ptr(const U& value); @@ -45,8 +45,8 @@ class SendableChooser : public SendableChooserBase { public: ~SendableChooser() override = default; - void AddObject(llvm::StringRef name, T object); - void AddDefault(llvm::StringRef name, T object); + void AddObject(wpi::StringRef name, T object); + void AddDefault(wpi::StringRef name, T object); auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""])); diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.inc b/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.inc index f68a996a1e..15a7efd1fb 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.inc +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableChooser.inc @@ -13,7 +13,7 @@ #include #include -#include +#include #include "SendableBuilder.h" @@ -29,7 +29,7 @@ namespace frc { * @param object the option */ template -void SendableChooser::AddObject(llvm::StringRef name, T object) { +void SendableChooser::AddObject(wpi::StringRef name, T object) { m_choices[name] = std::move(object); } @@ -43,7 +43,7 @@ void SendableChooser::AddObject(llvm::StringRef name, T object) { * @param object the option */ template -void SendableChooser::AddDefault(llvm::StringRef name, T object) { +void SendableChooser::AddDefault(wpi::StringRef name, T object) { m_defaultChoice = name; AddObject(name, std::move(object)); } @@ -83,7 +83,7 @@ void SendableChooser::InitSendable(SendableBuilder& builder) { keys.push_back(choice.first()); } - // Unlike std::map, llvm::StringMap elements + // Unlike std::map, wpi::StringMap elements // are not sorted std::sort(keys.begin(), keys.end()); @@ -92,7 +92,7 @@ void SendableChooser::InitSendable(SendableBuilder& builder) { nullptr); builder.AddSmallStringProperty( kDefault, - [=](const llvm::SmallVectorImpl&) -> llvm::StringRef { + [=](const wpi::SmallVectorImpl&) -> wpi::StringRef { return m_defaultChoice; }, nullptr); diff --git a/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h b/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h index 717a69bc03..2acf534fd8 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h @@ -23,66 +23,66 @@ class SmartDashboard : public SensorBase { public: static void init(); - static bool ContainsKey(llvm::StringRef key); + static bool ContainsKey(wpi::StringRef key); static std::vector GetKeys(int types = 0); - static void SetPersistent(llvm::StringRef key); - static void ClearPersistent(llvm::StringRef key); - static bool IsPersistent(llvm::StringRef key); + static void SetPersistent(wpi::StringRef key); + static void ClearPersistent(wpi::StringRef key); + static bool IsPersistent(wpi::StringRef key); - static void SetFlags(llvm::StringRef key, unsigned int flags); - static void ClearFlags(llvm::StringRef key, unsigned int flags); - static unsigned int GetFlags(llvm::StringRef key); + static void SetFlags(wpi::StringRef key, unsigned int flags); + static void ClearFlags(wpi::StringRef key, unsigned int flags); + static unsigned int GetFlags(wpi::StringRef key); - static void Delete(llvm::StringRef key); + static void Delete(wpi::StringRef key); - static void PutData(llvm::StringRef key, Sendable* data); + static void PutData(wpi::StringRef key, Sendable* data); static void PutData(Sendable* value); - static Sendable* GetData(llvm::StringRef keyName); + static Sendable* GetData(wpi::StringRef keyName); - static bool PutBoolean(llvm::StringRef keyName, bool value); - static bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue); - static bool GetBoolean(llvm::StringRef keyName, bool defaultValue); + static bool PutBoolean(wpi::StringRef keyName, bool value); + static bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue); + static bool GetBoolean(wpi::StringRef keyName, bool defaultValue); - static bool PutNumber(llvm::StringRef keyName, double value); - static bool SetDefaultNumber(llvm::StringRef key, double defaultValue); - static double GetNumber(llvm::StringRef keyName, double defaultValue); + static bool PutNumber(wpi::StringRef keyName, double value); + static bool SetDefaultNumber(wpi::StringRef key, double defaultValue); + static double GetNumber(wpi::StringRef keyName, double defaultValue); - static bool PutString(llvm::StringRef keyName, llvm::StringRef value); - static bool SetDefaultString(llvm::StringRef key, - llvm::StringRef defaultValue); - static std::string GetString(llvm::StringRef keyName, - llvm::StringRef defaultValue); + static bool PutString(wpi::StringRef keyName, wpi::StringRef value); + static bool SetDefaultString(wpi::StringRef key, + wpi::StringRef defaultValue); + static std::string GetString(wpi::StringRef keyName, + wpi::StringRef defaultValue); - static bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef value); - static bool SetDefaultBooleanArray(llvm::StringRef key, - llvm::ArrayRef defaultValue); - static std::vector GetBooleanArray(llvm::StringRef key, - llvm::ArrayRef defaultValue); + static bool PutBooleanArray(wpi::StringRef key, wpi::ArrayRef value); + static bool SetDefaultBooleanArray(wpi::StringRef key, + wpi::ArrayRef defaultValue); + static std::vector GetBooleanArray(wpi::StringRef key, + wpi::ArrayRef defaultValue); - static bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef value); - static bool SetDefaultNumberArray(llvm::StringRef key, - llvm::ArrayRef defaultValue); + static bool PutNumberArray(wpi::StringRef key, wpi::ArrayRef value); + static bool SetDefaultNumberArray(wpi::StringRef key, + wpi::ArrayRef defaultValue); static std::vector GetNumberArray( - llvm::StringRef key, llvm::ArrayRef defaultValue); + wpi::StringRef key, wpi::ArrayRef defaultValue); - static bool PutStringArray(llvm::StringRef key, - llvm::ArrayRef value); - static bool SetDefaultStringArray(llvm::StringRef key, - llvm::ArrayRef defaultValue); + static bool PutStringArray(wpi::StringRef key, + wpi::ArrayRef value); + static bool SetDefaultStringArray(wpi::StringRef key, + wpi::ArrayRef defaultValue); static std::vector GetStringArray( - llvm::StringRef key, llvm::ArrayRef defaultValue); + wpi::StringRef key, wpi::ArrayRef defaultValue); - static bool PutRaw(llvm::StringRef key, llvm::StringRef value); - static bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue); - static std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue); + static bool PutRaw(wpi::StringRef key, wpi::StringRef value); + static bool SetDefaultRaw(wpi::StringRef key, wpi::StringRef defaultValue); + static std::string GetRaw(wpi::StringRef key, wpi::StringRef defaultValue); - static bool PutValue(llvm::StringRef keyName, + static bool PutValue(wpi::StringRef keyName, std::shared_ptr value); - static bool SetDefaultValue(llvm::StringRef key, + static bool SetDefaultValue(wpi::StringRef key, std::shared_ptr defaultValue); - static std::shared_ptr GetValue(llvm::StringRef keyName); + static std::shared_ptr GetValue(wpi::StringRef keyName); static void UpdateValues(); diff --git a/wpilibc/src/main/native/include/Timer.h b/wpilibc/src/main/native/include/Timer.h index 228a521977..88dab0f01b 100644 --- a/wpilibc/src/main/native/include/Timer.h +++ b/wpilibc/src/main/native/include/Timer.h @@ -7,8 +7,8 @@ #pragma once -#include -#include +#include +#include #include "Base.h" diff --git a/wpilibc/src/main/native/include/Utility.h b/wpilibc/src/main/native/include/Utility.h index 616f4e3cd3..cda2217823 100644 --- a/wpilibc/src/main/native/include/Utility.h +++ b/wpilibc/src/main/native/include/Utility.h @@ -15,9 +15,9 @@ #include -#include -#include -#include +#include +#include +#include #define wpi_assert(condition) \ wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__) @@ -36,20 +36,20 @@ wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \ __FUNCTION__) -bool wpi_assert_impl(bool conditionValue, const llvm::Twine& conditionText, - const llvm::Twine& message, llvm::StringRef fileName, - int lineNumber, llvm::StringRef funcName); +bool wpi_assert_impl(bool conditionValue, const wpi::Twine& conditionText, + const wpi::Twine& message, wpi::StringRef fileName, + int lineNumber, wpi::StringRef funcName); bool wpi_assertEqual_impl(int valueA, int valueB, - const llvm::Twine& valueAString, - const llvm::Twine& valueBString, - const llvm::Twine& message, llvm::StringRef fileName, - int lineNumber, llvm::StringRef funcName); + const wpi::Twine& valueAString, + const wpi::Twine& valueBString, + const wpi::Twine& message, wpi::StringRef fileName, + int lineNumber, wpi::StringRef funcName); bool wpi_assertNotEqual_impl(int valueA, int valueB, - const llvm::Twine& valueAString, - const llvm::Twine& valueBString, - const llvm::Twine& message, - llvm::StringRef fileName, int lineNumber, - llvm::StringRef funcName); + const wpi::Twine& valueAString, + const wpi::Twine& valueBString, + const wpi::Twine& message, + wpi::StringRef fileName, int lineNumber, + wpi::StringRef funcName); void wpi_suspendOnAssertEnabled(bool enabled); diff --git a/wpilibcExamples/src/main/cpp/examples/IntermediateVision/src/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/IntermediateVision/src/Robot.cpp index 5e25d077d1..2e920568d0 100644 --- a/wpilibcExamples/src/main/cpp/examples/IntermediateVision/src/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/IntermediateVision/src/Robot.cpp @@ -9,10 +9,10 @@ #include #include -#include #include #include #include +#include /** * This is a demo program showing the use of OpenCV to do vision processing. The @@ -69,8 +69,8 @@ private: std::thread visionThread(VisionThread); visionThread.detach(); #else - llvm::errs() << "Vision only available on Linux.\n"; - llvm::errs().flush(); + wpi::errs() << "Vision only available on Linux.\n"; + wpi::errs().flush(); #endif } }; diff --git a/wpilibcExamples/src/main/cpp/examples/QuickVision/src/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/QuickVision/src/Robot.cpp index a8595ad9dd..ec22c65b85 100644 --- a/wpilibcExamples/src/main/cpp/examples/QuickVision/src/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/QuickVision/src/Robot.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include /** * Uses the CameraServer class to automatically capture video from a USB webcam @@ -22,8 +22,8 @@ public: #if defined(__linux__) CameraServer::GetInstance()->StartAutomaticCapture(); #else - llvm::errs() << "Vision only available on Linux.\n"; - llvm::errs().flush(); + wpi::errs() << "Vision only available on Linux.\n"; + wpi::errs().flush(); #endif } }; diff --git a/wpilibcIntegrationTests/src/main/native/cpp/NotifierTest.cpp b/wpilibcIntegrationTests/src/main/native/cpp/NotifierTest.cpp index 012312a98c..e181fa0a94 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/NotifierTest.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/NotifierTest.cpp @@ -7,7 +7,7 @@ #include "Notifier.h" // NOLINT(build/include_order) -#include +#include #include "TestBench.h" #include "Timer.h" @@ -23,21 +23,21 @@ void notifierHandler(void*) { notifierCounter++; } * Test if the Wait function works */ TEST(NotifierTest, DISABLED_TestTimerNotifications) { - llvm::outs() << "NotifierTest...\n"; + wpi::outs() << "NotifierTest...\n"; notifierCounter = 0; - llvm::outs() << "notifier(notifierHandler, nullptr)...\n"; + wpi::outs() << "notifier(notifierHandler, nullptr)...\n"; Notifier notifier(notifierHandler, nullptr); - llvm::outs() << "Start Periodic...\n"; + wpi::outs() << "Start Periodic...\n"; notifier.StartPeriodic(1.0); - llvm::outs() << "Wait...\n"; + wpi::outs() << "Wait...\n"; Wait(10.5); - llvm::outs() << "...Wait\n"; + wpi::outs() << "...Wait\n"; EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter << " notifications in 10.5 seconds"; - llvm::outs() << "Received " << notifierCounter - << " notifications in 10.5 seconds"; + wpi::outs() << "Received " << notifierCounter + << " notifications in 10.5 seconds"; - llvm::outs() << "...NotifierTest\n"; + wpi::outs() << "...NotifierTest\n"; } diff --git a/wpilibcIntegrationTests/src/main/native/cpp/TestEnvironment.cpp b/wpilibcIntegrationTests/src/main/native/cpp/TestEnvironment.cpp index dd5b3688b4..e76a0a085b 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/TestEnvironment.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/TestEnvironment.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "DriverStation.h" #include "LiveWindow/LiveWindow.h" @@ -30,7 +30,7 @@ class TestEnvironment : public testing::Environment { m_alreadySetUp = true; if (!HAL_Initialize(500, 0)) { - llvm::errs() << "FATAL ERROR: HAL could not be initialized\n"; + wpi::errs() << "FATAL ERROR: HAL could not be initialized\n"; std::exit(-1); } @@ -43,20 +43,20 @@ class TestEnvironment : public testing::Environment { HAL_ObserveUserProgramStarting(); LiveWindow::GetInstance()->SetEnabled(false); - llvm::outs() << "Started coms\n"; + wpi::outs() << "Started coms\n"; int enableCounter = 0; while (!DriverStation::GetInstance().IsEnabled()) { if (enableCounter > 50) { // Robot did not enable properly after 5 seconds. // Force exit - llvm::errs() << " Failed to enable. Aborting\n"; + wpi::errs() << " Failed to enable. Aborting\n"; std::terminate(); } Wait(0.1); - llvm::outs() << "Waiting for enable: " << enableCounter++ << "\n"; + wpi::outs() << "Waiting for enable: " << enableCounter++ << "\n"; } } diff --git a/wpilibcIntegrationTests/src/main/native/cpp/mockds/MockDS.cpp b/wpilibcIntegrationTests/src/main/native/cpp/mockds/MockDS.cpp index fa307435a6..0c5432e620 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/mockds/MockDS.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/mockds/MockDS.cpp @@ -10,24 +10,23 @@ #include #include -#include -#include -#include -#include - -#include "udpsockets/UDPClient.h" +#include +#include +#include +#include +#include static void LoggerFunc(unsigned int level, const char* file, unsigned int line, const char* msg) { - llvm::SmallString<128> buf; - llvm::raw_svector_ostream oss(buf); + wpi::SmallString<128> buf; + wpi::raw_svector_ostream oss(buf); if (level == 20) { oss << "DS: " << msg << '\n'; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); return; } - llvm::StringRef levelmsg; + wpi::StringRef levelmsg; if (level >= 50) levelmsg = "CRITICAL: "; else if (level >= 40) @@ -37,10 +36,10 @@ static void LoggerFunc(unsigned int level, const char* file, unsigned int line, else return; oss << "DS: " << levelmsg << msg << " (" << file << ':' << line << ")\n"; - llvm::errs() << oss.str(); + wpi::errs() << oss.str(); } -static void generateEnabledDsPacket(llvm::SmallVectorImpl& data, +static void generateEnabledDsPacket(wpi::SmallVectorImpl& data, uint16_t sendCount) { data.clear(); data.push_back(sendCount >> 8); @@ -63,7 +62,7 @@ void MockDS::start() { auto timeout_time = hal::fpga_clock::now(); int initCount = 0; uint16_t sendCount = 0; - llvm::SmallVector data; + wpi::SmallVector data; while (m_active) { // Keep 20ms intervals, and increase time to next interval auto current = hal::fpga_clock::now(); diff --git a/wpiutil/.styleguide b/wpiutil/.styleguide index 320e549106..cef0b77771 100644 --- a/wpiutil/.styleguide +++ b/wpiutil/.styleguide @@ -9,23 +9,53 @@ cppSrcFileInclude { generatedFileExclude { gmock/ - llvm/ - src/main/native/cpp/support/json - src/main/native/include/support/json + src/main/native/cpp/llvm/ + src/main/native/include/wpi/AlignOf\.h$ + src/main/native/include/wpi/ArrayRef\.h$ + src/main/native/include/wpi/Compiler\.h$ + src/main/native/include/wpi/ConvertUTF\.h$ + src/main/native/include/wpi/DenseMap\.h$ + src/main/native/include/wpi/DenseMapInfo\.h$ + src/main/native/include/wpi/EpochTracker\.h$ + src/main/native/include/wpi/FileSystem\.h$ + src/main/native/include/wpi/Format\.h$ + src/main/native/include/wpi/Hashing\.h$ + src/main/native/include/wpi/IntrusiveRefCntPtr\.h$ + src/main/native/include/wpi/MathExtras\.h$ + src/main/native/include/wpi/None\.h$ + src/main/native/include/wpi/Optional\.h$ + src/main/native/include/wpi/Path\.h $ + src/main/native/include/wpi/PointerLikeTypeTraits\.h$ + src/main/native/include/wpi/STLExtras\.h$ + src/main/native/include/wpi/SmallPtrSet\.h$ + src/main/native/include/wpi/SmallSet\.h$ + src/main/native/include/wpi/SmallString\.h$ + src/main/native/include/wpi/SmallVector\.h$ + src/main/native/include/wpi/StringExtras\.h$ + src/main/native/include/wpi/StringMap\.h$ + src/main/native/include/wpi/StringRef\.h$ + src/main/native/include/wpi/Twine\.h$ + src/main/native/include/wpi/WindowsError\.h$ + src/main/native/include/wpi/iterator_range\.h$ + src/main/native/include/wpi/raw_os_ostream\.h$ + src/main/native/include/wpi/raw_ostream\.h$ + src/main/native/include/wpi/type_traits\.h$ + src/main/native/cpp/json + src/main/native/include/wpi/json src/test/native/cpp/json/ } licenseUpdateExclude { - src/main/native/cpp/support/Base64\.cpp$ - src/main/native/cpp/support/sha1\.cpp$ - src/main/native/cpp/tcpsockets/TCPAcceptor\.cpp$ - src/main/native/cpp/tcpsockets/TCPConnector\.cpp$ - src/main/native/cpp/tcpsockets/TCPStream\.cpp$ - src/main/native/include/support/ConcurrentQueue\.h$ - src/main/native/include/support/sha1\.h$ - src/main/native/include/tcpsockets/TCPAcceptor\.h$ - src/main/native/include/tcpsockets/TCPConnector\.h$ - src/main/native/include/tcpsockets/TCPStream\.h$ + src/main/native/cpp/Base64\.cpp$ + src/main/native/cpp/sha1\.cpp$ + src/main/native/cpp/TCPAcceptor\.cpp$ + src/main/native/cpp/TCPConnector\.cpp$ + src/main/native/cpp/TCPStream\.cpp$ + src/main/native/include/wpi/ConcurrentQueue\.h$ + src/main/native/include/wpi/sha1\.h$ + src/main/native/include/wpi/TCPAcceptor\.h$ + src/main/native/include/wpi/TCPConnector\.h$ + src/main/native/include/wpi/TCPStream\.h$ } includeGuardRoots { diff --git a/wpiutil/src/dev/native/cpp/main.cpp b/wpiutil/src/dev/native/cpp/main.cpp index ba2318f936..9ac3bab151 100644 --- a/wpiutil/src/dev/native/cpp/main.cpp +++ b/wpiutil/src/dev/native/cpp/main.cpp @@ -7,11 +7,11 @@ #include -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" -#include "support/hostname.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" +#include "wpi/hostname.h" int main() { - llvm::StringRef v1("Hello"); + wpi::StringRef v1("Hello"); std::cout << v1.lower() << std::endl; } diff --git a/wpiutil/src/main/native/cpp/support/Base64.cpp b/wpiutil/src/main/native/cpp/Base64.cpp similarity index 89% rename from wpiutil/src/main/native/cpp/support/Base64.cpp rename to wpiutil/src/main/native/cpp/Base64.cpp index 461d752629..35ac76c5a8 100644 --- a/wpiutil/src/main/native/cpp/support/Base64.cpp +++ b/wpiutil/src/main/native/cpp/Base64.cpp @@ -55,10 +55,10 @@ * */ -#include "support/Base64.h" +#include "wpi/Base64.h" -#include "llvm/SmallVector.h" -#include "llvm/raw_ostream.h" +#include "wpi/SmallVector.h" +#include "wpi/raw_ostream.h" namespace wpi { @@ -80,7 +80,7 @@ static const unsigned char pr2six[256] = { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}; -size_t Base64Decode(llvm::raw_ostream& os, llvm::StringRef encoded) { +size_t Base64Decode(raw_ostream& os, StringRef encoded) { const unsigned char* end = encoded.bytes_begin(); while (pr2six[*end] <= 63 && end != encoded.bytes_end()) ++end; size_t nprbytes = end - encoded.bytes_begin(); @@ -107,18 +107,18 @@ size_t Base64Decode(llvm::raw_ostream& os, llvm::StringRef encoded) { return (end - encoded.bytes_begin()) + ((4 - nprbytes) & 3); } -size_t Base64Decode(llvm::StringRef encoded, std::string* plain) { +size_t Base64Decode(StringRef encoded, std::string* plain) { plain->resize(0); - llvm::raw_string_ostream os(*plain); + raw_string_ostream os(*plain); size_t rv = Base64Decode(os, encoded); os.flush(); return rv; } -llvm::StringRef Base64Decode(llvm::StringRef encoded, size_t* num_read, - llvm::SmallVectorImpl& buf) { +StringRef Base64Decode(StringRef encoded, size_t* num_read, + SmallVectorImpl& buf) { buf.clear(); - llvm::raw_svector_ostream os(buf); + raw_svector_ostream os(buf); *num_read = Base64Decode(os, encoded); return os.str(); } @@ -126,7 +126,7 @@ llvm::StringRef Base64Decode(llvm::StringRef encoded, size_t* num_read, static const char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -void Base64Encode(llvm::raw_ostream& os, llvm::StringRef plain) { +void Base64Encode(raw_ostream& os, StringRef plain) { if (plain.empty()) return; size_t len = plain.size(); @@ -153,17 +153,16 @@ void Base64Encode(llvm::raw_ostream& os, llvm::StringRef plain) { } } -void Base64Encode(llvm::StringRef plain, std::string* encoded) { +void Base64Encode(StringRef plain, std::string* encoded) { encoded->resize(0); - llvm::raw_string_ostream os(*encoded); + raw_string_ostream os(*encoded); Base64Encode(os, plain); os.flush(); } -llvm::StringRef Base64Encode(llvm::StringRef plain, - llvm::SmallVectorImpl& buf) { +StringRef Base64Encode(StringRef plain, SmallVectorImpl& buf) { buf.clear(); - llvm::raw_svector_ostream os(buf); + raw_svector_ostream os(buf); Base64Encode(os, plain); return os.str(); } diff --git a/wpiutil/src/main/native/cpp/support/HttpUtil.cpp b/wpiutil/src/main/native/cpp/HttpUtil.cpp similarity index 76% rename from wpiutil/src/main/native/cpp/support/HttpUtil.cpp rename to wpiutil/src/main/native/cpp/HttpUtil.cpp index be23193902..284b91535b 100644 --- a/wpiutil/src/main/native/cpp/support/HttpUtil.cpp +++ b/wpiutil/src/main/native/cpp/HttpUtil.cpp @@ -5,22 +5,22 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/HttpUtil.h" +#include "wpi/HttpUtil.h" #include -#include "llvm/STLExtras.h" -#include "llvm/StringExtras.h" -#include "llvm/raw_ostream.h" -#include "support/Base64.h" -#include "tcpsockets/TCPConnector.h" +#include "wpi/Base64.h" +#include "wpi/STLExtras.h" +#include "wpi/StringExtras.h" +#include "wpi/TCPConnector.h" +#include "wpi/raw_ostream.h" namespace wpi { -llvm::StringRef UnescapeURI(const llvm::Twine& str, - llvm::SmallVectorImpl& buf, bool* error) { - llvm::SmallString<128> strBuf; - llvm::StringRef strStr = str.toStringRef(strBuf); +StringRef UnescapeURI(const Twine& str, SmallVectorImpl& buf, + bool* error) { + SmallString<128> strBuf; + StringRef strStr = str.toStringRef(strBuf); buf.clear(); for (auto i = strStr.begin(), end = strStr.end(); i != end; ++i) { // pass non-escaped characters to output @@ -36,33 +36,33 @@ llvm::StringRef UnescapeURI(const llvm::Twine& str, // are there enough characters left? if (i + 2 >= end) { *error = true; - return llvm::StringRef{}; + return StringRef{}; } // replace %xx with the corresponding character - unsigned val1 = llvm::hexDigitValue(*++i); + unsigned val1 = hexDigitValue(*++i); if (val1 == -1U) { *error = true; - return llvm::StringRef{}; + return StringRef{}; } - unsigned val2 = llvm::hexDigitValue(*++i); + unsigned val2 = hexDigitValue(*++i); if (val2 == -1U) { *error = true; - return llvm::StringRef{}; + return StringRef{}; } buf.push_back((val1 << 4) | val2); } *error = false; - return llvm::StringRef{buf.data(), buf.size()}; + return StringRef{buf.data(), buf.size()}; } -llvm::StringRef EscapeURI(const llvm::Twine& str, - llvm::SmallVectorImpl& buf, bool spacePlus) { +StringRef EscapeURI(const Twine& str, SmallVectorImpl& buf, + bool spacePlus) { static const char* const hexLut = "0123456789ABCDEF"; - llvm::SmallString<128> strBuf; - llvm::StringRef strStr = str.toStringRef(strBuf); + SmallString<128> strBuf; + StringRef strStr = str.toStringRef(strBuf); buf.clear(); for (auto i = strStr.begin(), end = strStr.end(); i != end; ++i) { // pass unreserved characters to output @@ -83,19 +83,19 @@ llvm::StringRef EscapeURI(const llvm::Twine& str, buf.push_back(hexLut[(*i) & 0x0f]); } - return llvm::StringRef{buf.data(), buf.size()}; + return StringRef{buf.data(), buf.size()}; } -bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl* contentType, - llvm::SmallVectorImpl* contentLength) { +bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl* contentType, + SmallVectorImpl* contentLength) { if (contentType) contentType->clear(); if (contentLength) contentLength->clear(); bool inContentType = false; bool inContentLength = false; - llvm::SmallString<64> lineBuf; + SmallString<64> lineBuf; for (;;) { - llvm::StringRef line = is.getline(lineBuf, 1024).rtrim(); + StringRef line = is.getline(lineBuf, 1024).rtrim(); if (is.has_error()) return false; if (line.empty()) return true; // empty line signals end of headers @@ -103,7 +103,7 @@ bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl* contentType, if (!std::isspace(line[0])) { inContentType = false; inContentLength = false; - llvm::StringRef field; + StringRef field; std::tie(field, line) = line.split(':'); field = field.rtrim(); if (field.equals_lower("content-type")) @@ -125,9 +125,9 @@ bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl* contentType, } } -bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary, +bool FindMultipartBoundary(raw_istream& is, StringRef boundary, std::string* saveBuf) { - llvm::SmallString<64> searchBuf; + SmallString<64> searchBuf; searchBuf.resize(boundary.size() + 2); size_t searchPos = 0; @@ -157,7 +157,7 @@ bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary, // Fast-scan for '-' size_t pos = searchBuf.find('-', searchBuf[0] == '-' ? 1 : 0); - if (pos == llvm::StringRef::npos) { + if (pos == StringRef::npos) { if (saveBuf) saveBuf->append(searchBuf.data(), searchBuf.size()); } else { if (saveBuf) saveBuf->append(searchBuf.data(), pos); @@ -170,14 +170,14 @@ bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary, } } -HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error, +HttpLocation::HttpLocation(const Twine& url_, bool* error, std::string* errorMsg) : url{url_.str()} { // Split apart into components - llvm::StringRef query{url}; + StringRef query{url}; // scheme: - llvm::StringRef scheme; + StringRef scheme; std::tie(scheme, query) = query.split(':'); if (!scheme.equals_lower("http")) { *errorMsg = "only supports http URLs"; @@ -194,38 +194,38 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error, query = query.drop_front(2); // user:password@host:port/ - llvm::StringRef authority; + StringRef authority; std::tie(authority, query) = query.split('/'); - llvm::StringRef userpass, hostport; + StringRef userpass, hostport; std::tie(userpass, hostport) = authority.split('@'); // split leaves the RHS empty if the split char isn't present... if (hostport.empty()) { hostport = userpass; - userpass = llvm::StringRef{}; + userpass = StringRef{}; } if (!userpass.empty()) { - llvm::StringRef rawUser, rawPassword; + StringRef rawUser, rawPassword; std::tie(rawUser, rawPassword) = userpass.split(':'); - llvm::SmallString<64> userBuf, passBuf; + SmallString<64> userBuf, passBuf; user = UnescapeURI(rawUser, userBuf, error); if (*error) { - llvm::raw_string_ostream oss(*errorMsg); + raw_string_ostream oss(*errorMsg); oss << "could not unescape user \"" << rawUser << "\""; oss.flush(); return; } password = UnescapeURI(rawPassword, passBuf, error); if (*error) { - llvm::raw_string_ostream oss(*errorMsg); + raw_string_ostream oss(*errorMsg); oss << "could not unescape password \"" << rawPassword << "\""; oss.flush(); return; } } - llvm::StringRef portStr; + StringRef portStr; std::tie(host, portStr) = hostport.rsplit(':'); if (host.empty()) { *errorMsg = "host is empty"; @@ -235,7 +235,7 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error, if (portStr.empty()) { port = 80; } else if (portStr.getAsInteger(10, port)) { - llvm::raw_string_ostream oss(*errorMsg); + raw_string_ostream oss(*errorMsg); oss << "port \"" << portStr << "\" is not an integer"; oss.flush(); *error = true; @@ -249,27 +249,27 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error, // Split query string into parameters while (!query.empty()) { // split out next param and value - llvm::StringRef rawParam, rawValue; + StringRef rawParam, rawValue; std::tie(rawParam, query) = query.split('&'); if (rawParam.empty()) continue; // ignore "&&" std::tie(rawParam, rawValue) = rawParam.split('='); // unescape param *error = false; - llvm::SmallString<64> paramBuf; - llvm::StringRef param = UnescapeURI(rawParam, paramBuf, error); + SmallString<64> paramBuf; + StringRef param = UnescapeURI(rawParam, paramBuf, error); if (*error) { - llvm::raw_string_ostream oss(*errorMsg); + raw_string_ostream oss(*errorMsg); oss << "could not unescape parameter \"" << rawParam << "\""; oss.flush(); return; } // unescape value - llvm::SmallString<64> valueBuf; - llvm::StringRef value = UnescapeURI(rawValue, valueBuf, error); + SmallString<64> valueBuf; + StringRef value = UnescapeURI(rawValue, valueBuf, error); if (*error) { - llvm::raw_string_ostream oss(*errorMsg); + raw_string_ostream oss(*errorMsg); oss << "could not unescape value \"" << rawValue << "\""; oss.flush(); return; @@ -283,7 +283,7 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error, void HttpRequest::SetAuth(const HttpLocation& loc) { if (!loc.user.empty()) { - llvm::SmallString<64> userpass; + SmallString<64> userpass; userpass += loc.user; userpass += ':'; userpass += loc.password; @@ -302,15 +302,15 @@ bool HttpConnection::Handshake(const HttpRequest& request, os.flush(); // read first line of response - llvm::SmallString<64> lineBuf; - llvm::StringRef line = is.getline(lineBuf, 1024).rtrim(); + SmallString<64> lineBuf; + StringRef line = is.getline(lineBuf, 1024).rtrim(); if (is.has_error()) { *warnMsg = "disconnected before response"; return false; } // see if we got a HTTP 200 response - llvm::StringRef httpver, code, codeText; + StringRef httpver, code, codeText; std::tie(httpver, line) = line.split(' '); std::tie(code, codeText) = line.split(' '); if (!httpver.startswith("HTTP")) { @@ -318,7 +318,7 @@ bool HttpConnection::Handshake(const HttpRequest& request, return false; } if (code != "200") { - llvm::raw_string_ostream oss(*warnMsg); + raw_string_ostream oss(*warnMsg); oss << "received " << code << " " << codeText << " response"; oss.flush(); return false; diff --git a/wpiutil/src/main/native/cpp/tcpsockets/SocketError.cpp b/wpiutil/src/main/native/cpp/SocketError.cpp similarity index 96% rename from wpiutil/src/main/native/cpp/tcpsockets/SocketError.cpp rename to wpiutil/src/main/native/cpp/SocketError.cpp index 3f3fd63083..16958461ce 100644 --- a/wpiutil/src/main/native/cpp/tcpsockets/SocketError.cpp +++ b/wpiutil/src/main/native/cpp/SocketError.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "tcpsockets/SocketError.h" +#include "wpi/SocketError.h" #ifdef _WIN32 #include diff --git a/wpiutil/src/main/native/cpp/tcpsockets/TCPAcceptor.cpp b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp similarity index 95% rename from wpiutil/src/main/native/cpp/tcpsockets/TCPAcceptor.cpp rename to wpiutil/src/main/native/cpp/TCPAcceptor.cpp index a71356c60c..0abf8623f6 100644 --- a/wpiutil/src/main/native/cpp/tcpsockets/TCPAcceptor.cpp +++ b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp @@ -21,7 +21,7 @@ limitations under the License. */ -#include "tcpsockets/TCPAcceptor.h" +#include "wpi/TCPAcceptor.h" #include #include @@ -37,9 +37,9 @@ #include #endif -#include "llvm/SmallString.h" -#include "support/Logger.h" -#include "tcpsockets/SocketError.h" +#include "wpi/Logger.h" +#include "wpi/SmallString.h" +#include "wpi/SocketError.h" using namespace wpi; @@ -85,7 +85,7 @@ int TCPAcceptor::start() { address.sin_family = PF_INET; if (m_address.size() > 0) { #ifdef _WIN32 - llvm::SmallString<128> addr_copy(m_address); + SmallString<128> addr_copy(m_address); addr_copy.push_back('\0'); int res = InetPton(PF_INET, addr_copy.data(), &(address.sin_addr)); #else @@ -139,7 +139,7 @@ void TCPAcceptor::shutdown() { std::memset(&address, 0, sizeof(address)); address.sin_family = PF_INET; - llvm::SmallString<128> addr_copy; + SmallString<128> addr_copy; if (m_address.size() > 0) addr_copy = m_address; else diff --git a/wpiutil/src/main/native/cpp/tcpsockets/TCPConnector.cpp b/wpiutil/src/main/native/cpp/TCPConnector.cpp similarity index 96% rename from wpiutil/src/main/native/cpp/tcpsockets/TCPConnector.cpp rename to wpiutil/src/main/native/cpp/TCPConnector.cpp index a9e7df8303..6110133b93 100644 --- a/wpiutil/src/main/native/cpp/tcpsockets/TCPConnector.cpp +++ b/wpiutil/src/main/native/cpp/TCPConnector.cpp @@ -21,7 +21,7 @@ limitations under the License */ -#include "tcpsockets/TCPConnector.h" +#include "wpi/TCPConnector.h" #include @@ -40,10 +40,10 @@ #include #endif -#include "llvm/SmallString.h" -#include "support/Logger.h" -#include "tcpsockets/SocketError.h" -#include "tcpsockets/TCPStream.h" +#include "wpi/Logger.h" +#include "wpi/SmallString.h" +#include "wpi/SocketError.h" +#include "wpi/TCPStream.h" using namespace wpi; @@ -89,7 +89,7 @@ std::unique_ptr TCPConnector::connect(const char* server, address.sin_family = AF_INET; if (ResolveHostName(server, &(address.sin_addr)) != 0) { #ifdef _WIN32 - llvm::SmallString<128> addr_copy(server); + SmallString<128> addr_copy(server); addr_copy.push_back('\0'); int res = InetPton(PF_INET, addr_copy.data(), &(address.sin_addr)); #else diff --git a/wpiutil/src/main/native/cpp/tcpsockets/TCPConnector_parallel.cpp b/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp similarity index 91% rename from wpiutil/src/main/native/cpp/tcpsockets/TCPConnector_parallel.cpp rename to wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp index 92db3d81b4..e0a8a92740 100644 --- a/wpiutil/src/main/native/cpp/tcpsockets/TCPConnector_parallel.cpp +++ b/wpiutil/src/main/native/cpp/TCPConnector_parallel.cpp @@ -5,16 +5,16 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "tcpsockets/TCPConnector.h" // NOLINT(build/include_order) +#include "wpi/TCPConnector.h" // NOLINT(build/include_order) #include #include #include #include -#include "llvm/SmallSet.h" -#include "support/condition_variable.h" -#include "support/mutex.h" +#include "wpi/SmallSet.h" +#include "wpi/condition_variable.h" +#include "wpi/mutex.h" using namespace wpi; @@ -27,7 +27,7 @@ using namespace wpi; #endif std::unique_ptr TCPConnector::connect_parallel( - llvm::ArrayRef> servers, Logger& logger, + ArrayRef> servers, Logger& logger, int timeout) { if (servers.empty()) return nullptr; @@ -35,9 +35,9 @@ std::unique_ptr TCPConnector::connect_parallel( struct GlobalState { wpi::mutex mtx; #ifdef HAVE_THREAD_LOCAL - llvm::SmallSet, 16> active; + SmallSet, 16> active; #else - llvm::SmallSet, 16> active; + SmallSet, 16> active; #endif }; #ifdef HAVE_THREAD_LOCAL diff --git a/wpiutil/src/main/native/cpp/tcpsockets/TCPStream.cpp b/wpiutil/src/main/native/cpp/TCPStream.cpp similarity index 97% rename from wpiutil/src/main/native/cpp/tcpsockets/TCPStream.cpp rename to wpiutil/src/main/native/cpp/TCPStream.cpp index 399a4e9e48..08c710996a 100644 --- a/wpiutil/src/main/native/cpp/tcpsockets/TCPStream.cpp +++ b/wpiutil/src/main/native/cpp/TCPStream.cpp @@ -21,7 +21,7 @@ limitations under the License. */ -#include "tcpsockets/TCPStream.h" +#include "wpi/TCPStream.h" #include @@ -162,7 +162,7 @@ void TCPStream::close() { m_sd = -1; } -llvm::StringRef TCPStream::getPeerIP() const { return m_peerIP; } +StringRef TCPStream::getPeerIP() const { return m_peerIP; } int TCPStream::getPeerPort() const { return m_peerPort; } diff --git a/wpiutil/src/main/native/cpp/udpsockets/UDPClient.cpp b/wpiutil/src/main/native/cpp/UDPClient.cpp similarity index 89% rename from wpiutil/src/main/native/cpp/udpsockets/UDPClient.cpp rename to wpiutil/src/main/native/cpp/UDPClient.cpp index eb615a6a54..c447b3f0a7 100644 --- a/wpiutil/src/main/native/cpp/udpsockets/UDPClient.cpp +++ b/wpiutil/src/main/native/cpp/UDPClient.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "udpsockets/UDPClient.h" +#include "wpi/UDPClient.h" #ifdef _WIN32 #include @@ -18,14 +18,14 @@ #include #endif -#include "support/Logger.h" -#include "tcpsockets/SocketError.h" +#include "wpi/Logger.h" +#include "wpi/SocketError.h" using namespace wpi; UDPClient::UDPClient(Logger& logger) : UDPClient("", logger) {} -UDPClient::UDPClient(llvm::StringRef address, Logger& logger) +UDPClient::UDPClient(StringRef address, Logger& logger) : m_lsd(0), m_address(address), m_logger(logger) {} UDPClient::UDPClient(UDPClient&& other) @@ -72,7 +72,7 @@ int UDPClient::start() { addr.sin_family = AF_INET; if (m_address.size() > 0) { #ifdef _WIN32 - llvm::SmallString<128> addr_copy(m_address); + SmallString<128> addr_copy(m_address); addr_copy.push_back('\0'); int res = InetPton(PF_INET, addr_copy.data(), &(addr.sin_addr)); #else @@ -109,14 +109,13 @@ void UDPClient::shutdown() { } } -int UDPClient::send(llvm::ArrayRef data, llvm::StringRef server, - int port) { +int UDPClient::send(ArrayRef data, StringRef server, int port) { // server must be a resolvable IP address struct sockaddr_in addr; std::memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; if (server.size() > 0) { - llvm::SmallVector addr_store; + SmallVector addr_store; auto remoteAddr = server.c_str(addr_store); #ifdef _WIN32 int res = InetPton(AF_INET, remoteAddr, &(addr.sin_addr)); @@ -140,13 +139,13 @@ int UDPClient::send(llvm::ArrayRef data, llvm::StringRef server, return result; } -int UDPClient::send(llvm::StringRef data, llvm::StringRef server, int port) { +int UDPClient::send(StringRef data, StringRef server, int port) { // server must be a resolvable IP address struct sockaddr_in addr; std::memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; if (server.size() > 0) { - llvm::SmallVector addr_store; + SmallVector addr_store; auto remoteAddr = server.c_str(addr_store); #ifdef _WIN32 int res = InetPton(AF_INET, remoteAddr, &(addr.sin_addr)); diff --git a/wpiutil/src/main/native/cpp/support/hostname.cpp b/wpiutil/src/main/native/cpp/hostname.cpp similarity index 86% rename from wpiutil/src/main/native/cpp/support/hostname.cpp rename to wpiutil/src/main/native/cpp/hostname.cpp index 12b533014a..e4862d1f74 100644 --- a/wpiutil/src/main/native/cpp/support/hostname.cpp +++ b/wpiutil/src/main/native/cpp/hostname.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/hostname.h" +#include "wpi/hostname.h" #ifdef _WIN32 #include @@ -16,8 +16,8 @@ #include -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" #ifdef _WIN32 struct WSAHelper { @@ -51,15 +51,15 @@ std::string GetHostname() { return name; } -llvm::StringRef GetHostname(llvm::SmallVectorImpl& name) { +StringRef GetHostname(SmallVectorImpl& name) { // Use a tmp array to not require the SmallVector to be too large. char tmpName[256]; if (!GetHostnameImpl(tmpName, sizeof(tmpName))) { - return llvm::StringRef{}; + return StringRef{}; } name.clear(); name.append(tmpName, tmpName + std::strlen(tmpName) + 1); - return llvm::StringRef{name.data(), name.size(), true}; + return StringRef{name.data(), name.size(), true}; } } // namespace wpi diff --git a/wpiutil/src/main/native/cpp/support/json.cpp b/wpiutil/src/main/native/cpp/json.cpp similarity index 97% rename from wpiutil/src/main/native/cpp/support/json.cpp rename to wpiutil/src/main/native/cpp/json.cpp index 698a9463dd..6be69a12a8 100644 --- a/wpiutil/src/main/native/cpp/support/json.cpp +++ b/wpiutil/src/main/native/cpp/json.cpp @@ -32,7 +32,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" using namespace wpi; @@ -141,7 +141,7 @@ json::json_value::json_value(value_t t) } } -json::json_value::json_value(llvm::StringRef value) +json::json_value::json_value(StringRef value) { string = create(value); } @@ -727,7 +727,7 @@ void json::push_back(const json& val) m_value.array->push_back(val); } -void json::push_back(const std::pair& val) +void json::push_back(const std::pair& val) { // push_back only works for null objects or objects if (!(is_null() || is_object())) @@ -752,7 +752,7 @@ void json::push_back(std::initializer_list init) if (is_object() && init.size() == 2 && init.begin()->is_string()) { const std::string key = *init.begin(); - push_back(std::pair(key, *(init.begin() + 1))); + push_back(std::pair(key, *(init.begin() + 1))); } else { @@ -802,7 +802,7 @@ json::const_reference json::at(size_type idx) const } } -json::reference json::at(llvm::StringRef key) +json::reference json::at(StringRef key) { // at only works for objects if (is_object()) @@ -820,7 +820,7 @@ json::reference json::at(llvm::StringRef key) } } -json::const_reference json::at(llvm::StringRef key) const +json::const_reference json::at(StringRef key) const { // at only works for objects if (is_object()) @@ -877,7 +877,7 @@ json::const_reference json::operator[](size_type idx) const JSON_THROW(type_error::create(305, "cannot use operator[] with " + type_name())); } -json::reference json::operator[](llvm::StringRef key) +json::reference json::operator[](StringRef key) { // implicitly convert null value to an empty object if (is_null()) @@ -896,7 +896,7 @@ json::reference json::operator[](llvm::StringRef key) JSON_THROW(type_error::create(305, "cannot use operator[] with " + type_name())); } -json::const_reference json::operator[](llvm::StringRef key) const +json::const_reference json::operator[](StringRef key) const { // const operator[] only works for objects if (is_object()) @@ -960,7 +960,7 @@ json::const_reference json::back() const } } -json::size_type json::erase(llvm::StringRef key) +json::size_type json::erase(StringRef key) { // this erase only works for objects if (is_object()) @@ -989,7 +989,7 @@ void json::erase(const size_type idx) } } -json::iterator json::find(llvm::StringRef key) +json::iterator json::find(StringRef key) { auto result = end(); @@ -1001,7 +1001,7 @@ json::iterator json::find(llvm::StringRef key) return result; } -json::const_iterator json::find(llvm::StringRef key) const +json::const_iterator json::find(StringRef key) const { auto result = cend(); @@ -1173,8 +1173,8 @@ std::size_t hash::operator()(const wpi::json& j) const { // a naive hashing via the string representation const auto& h = hash(); - llvm::SmallVector buf; - llvm::raw_svector_ostream os(buf); + SmallVector buf; + raw_svector_ostream os(buf); j.dump(os); return h(os.str()); } diff --git a/wpiutil/src/main/native/cpp/support/json_binary_reader.cpp b/wpiutil/src/main/native/cpp/json_binary_reader.cpp similarity index 98% rename from wpiutil/src/main/native/cpp/support/json_binary_reader.cpp rename to wpiutil/src/main/native/cpp/json_binary_reader.cpp index 551b1ddb15..480f46a354 100644 --- a/wpiutil/src/main/native/cpp/support/json_binary_reader.cpp +++ b/wpiutil/src/main/native/cpp/json_binary_reader.cpp @@ -32,13 +32,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" #include -#include "llvm/Format.h" -#include "llvm/raw_ostream.h" -#include "support/raw_istream.h" +#include "wpi/Format.h" +#include "wpi/raw_istream.h" +#include "wpi/raw_ostream.h" using namespace wpi; @@ -627,9 +627,9 @@ json binary_reader::parse_cbor(bool get_char) default: // anything else (0xFF is handled inside the other types) { std::string s; - llvm::raw_string_ostream ss(s); + raw_string_ostream ss(s); ss << "error reading CBOR; last byte: "; - ss << llvm::format_hex(current, 2); + ss << format_hex(current, 2); JSON_THROW(json::parse_error::create(112, chars_read, ss.str())); } } @@ -709,9 +709,9 @@ std::string binary_reader::get_cbor_string() default: { std::string s; - llvm::raw_string_ostream ss(s); + raw_string_ostream ss(s); ss << "expected a CBOR string; last byte: "; - ss << llvm::format_hex(current, 2); + ss << format_hex(current, 2); JSON_THROW(json::parse_error::create(113, chars_read, ss.str())); } } @@ -1113,9 +1113,9 @@ json binary_reader::parse_msgpack() default: // anything else { std::string s; - llvm::raw_string_ostream ss(s); + raw_string_ostream ss(s); ss << "error reading MessagePack; last byte: "; - ss << llvm::format_hex(current, 2); + ss << format_hex(current, 2); JSON_THROW(json::parse_error::create(112, chars_read, ss.str())); } } @@ -1186,9 +1186,9 @@ std::string binary_reader::get_msgpack_string() default: { std::string s; - llvm::raw_string_ostream ss(s); + raw_string_ostream ss(s); ss << "expected a MessagePack string; last byte: "; - ss << llvm::format_hex(current, 2); + ss << format_hex(current, 2); JSON_THROW(json::parse_error::create(113, chars_read, ss.str())); } } @@ -1212,7 +1212,7 @@ json json::from_cbor(wpi::raw_istream& is) return br.parse_cbor(); } -json json::from_cbor(llvm::StringRef s) +json json::from_cbor(StringRef s) { wpi::raw_mem_istream is(s.data(), s.size()); binary_reader br(is); @@ -1225,7 +1225,7 @@ json json::from_msgpack(wpi::raw_istream& is) return br.parse_msgpack(); } -json json::from_msgpack(llvm::StringRef s) +json json::from_msgpack(StringRef s) { wpi::raw_mem_istream is(s.data(), s.size()); binary_reader br(is); diff --git a/wpiutil/src/main/native/cpp/support/json_binary_writer.cpp b/wpiutil/src/main/native/cpp/json_binary_writer.cpp similarity index 96% rename from wpiutil/src/main/native/cpp/support/json_binary_writer.cpp rename to wpiutil/src/main/native/cpp/json_binary_writer.cpp index 86a98115bf..aeacac123d 100644 --- a/wpiutil/src/main/native/cpp/support/json_binary_writer.cpp +++ b/wpiutil/src/main/native/cpp/json_binary_writer.cpp @@ -32,16 +32,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" #include #include // lconv, localeconv #include // locale #include // accumulate -#include "llvm/raw_ostream.h" -#include "llvm/SmallString.h" -#include "llvm/StringExtras.h" +#include "wpi/SmallString.h" +#include "wpi/StringExtras.h" +#include "wpi/raw_ostream.h" using namespace wpi; @@ -56,7 +56,7 @@ class json::binary_writer @param[in] adapter output adapter to write to */ - explicit binary_writer(llvm::raw_ostream& s) + explicit binary_writer(raw_ostream& s) : is_little_endian(little_endianess()), o(s) { } @@ -88,12 +88,12 @@ class json::binary_writer /*! @brief[in] str string to serialize */ - void write_cbor_string(llvm::StringRef str); + void write_cbor_string(StringRef str); /*! @brief[in] str string to serialize */ - void write_msgpack_string(llvm::StringRef str); + void write_msgpack_string(StringRef str); /* @brief write a number to output input @@ -132,7 +132,7 @@ class json::binary_writer const bool is_little_endian = true; /// the output - llvm::raw_ostream& o; + raw_ostream& o; }; void json::binary_writer::write_cbor(const json& j) @@ -345,7 +345,7 @@ void json::binary_writer::write_cbor(const json& j) } } -void json::binary_writer::write_cbor_string(llvm::StringRef str) +void json::binary_writer::write_cbor_string(StringRef str) { // step 1: write control byte and the string length const auto N = str.size(); @@ -587,7 +587,7 @@ void json::binary_writer::write_msgpack(const json& j) } } -void json::binary_writer::write_msgpack_string(llvm::StringRef str) +void json::binary_writer::write_msgpack_string(StringRef str) { // step 1: write control byte and the string length const auto N = str.size(); @@ -619,15 +619,15 @@ void json::binary_writer::write_msgpack_string(llvm::StringRef str) o << str; } -void json::to_cbor(llvm::raw_ostream& os, const json& j) +void json::to_cbor(raw_ostream& os, const json& j) { binary_writer bw(os); bw.write_cbor(j); } -llvm::StringRef json::to_cbor(const json& j, llvm::SmallVectorImpl buf) +StringRef json::to_cbor(const json& j, SmallVectorImpl buf) { - llvm::raw_svector_ostream os(buf); + raw_svector_ostream os(buf); binary_writer bw(os); bw.write_cbor(j); return os.str(); @@ -636,22 +636,22 @@ llvm::StringRef json::to_cbor(const json& j, llvm::SmallVectorImpl buf) std::string json::to_cbor(const json& j) { std::string s; - llvm::raw_string_ostream os(s); + raw_string_ostream os(s); binary_writer bw(os); bw.write_cbor(j); os.flush(); return s; } -void json::to_msgpack(llvm::raw_ostream& os, const json& j) +void json::to_msgpack(raw_ostream& os, const json& j) { binary_writer bw(os); bw.write_msgpack(j); } -llvm::StringRef json::to_msgpack(const json& j, llvm::SmallVectorImpl buf) +StringRef json::to_msgpack(const json& j, SmallVectorImpl buf) { - llvm::raw_svector_ostream os(buf); + raw_svector_ostream os(buf); binary_writer bw(os); bw.write_msgpack(j); return os.str(); @@ -660,7 +660,7 @@ llvm::StringRef json::to_msgpack(const json& j, llvm::SmallVectorImpl buf) std::string json::to_msgpack(const json& j) { std::string s; - llvm::raw_string_ostream os(s); + raw_string_ostream os(s); binary_writer bw(os); bw.write_msgpack(j); os.flush(); diff --git a/wpiutil/src/main/native/cpp/support/json_parser.cpp b/wpiutil/src/main/native/cpp/json_parser.cpp similarity index 99% rename from wpiutil/src/main/native/cpp/support/json_parser.cpp rename to wpiutil/src/main/native/cpp/json_parser.cpp index 1ff331392f..4327b406ca 100644 --- a/wpiutil/src/main/native/cpp/support/json_parser.cpp +++ b/wpiutil/src/main/native/cpp/json_parser.cpp @@ -32,16 +32,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" #include #include // lconv, localeconv #include // locale -#include "llvm/Format.h" -#include "llvm/raw_ostream.h" -#include "llvm/SmallString.h" -#include "support/raw_istream.h" +#include "wpi/Format.h" +#include "wpi/SmallString.h" +#include "wpi/raw_istream.h" +#include "wpi/raw_ostream.h" using namespace wpi; @@ -259,7 +259,7 @@ class lexer } /// return string value - llvm::StringRef get_string() + StringRef get_string() { return yytext.str(); } @@ -303,10 +303,10 @@ class lexer size_t chars_read = 0; /// buffer for raw byte sequence of the current token - llvm::SmallString<128> token_string; + SmallString<128> token_string; /// buffer for variable-length tokens (numbers, strings) - llvm::SmallString<128> yytext; + SmallString<128> yytext; /// a description of occurred lexer errors std::string error_message = ""; @@ -616,8 +616,8 @@ int lexer::get_codepoint() std::string lexer::codepoint_to_string(int codepoint) { std::string s; - llvm::raw_string_ostream ss(s); - ss << "U+" << llvm::format_hex_no_prefix(codepoint, 4, true); + raw_string_ostream ss(s); + ss << "U+" << format_hex_no_prefix(codepoint, 4, true); return ss.str(); } @@ -2073,7 +2073,7 @@ void json::parser::unexpect(lexer::token_type t) const } } -json json::parse(llvm::StringRef s, const parser_callback_t cb) +json json::parse(StringRef s, const parser_callback_t cb) { wpi::raw_mem_istream is(s.data(), s.size()); return parser(is, cb).parse(true); diff --git a/wpiutil/src/main/native/cpp/support/json_pointer.cpp b/wpiutil/src/main/native/cpp/json_pointer.cpp similarity index 98% rename from wpiutil/src/main/native/cpp/support/json_pointer.cpp rename to wpiutil/src/main/native/cpp/json_pointer.cpp index 375805a30c..d0ebb28059 100644 --- a/wpiutil/src/main/native/cpp/support/json_pointer.cpp +++ b/wpiutil/src/main/native/cpp/json_pointer.cpp @@ -32,7 +32,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" #include #include // accumulate @@ -505,7 +505,7 @@ json json::json_pointer::unflatten(const json& value) } // we need to iterate over the object values in sorted key order - llvm::SmallVector, 64> sorted; + SmallVector, 64> sorted; for (auto i = value.m_value.object->begin(), end = value.m_value.object->end(); i != end; ++i) { @@ -516,8 +516,8 @@ json json::json_pointer::unflatten(const json& value) sorted.push_back(i); } std::sort(sorted.begin(), sorted.end(), - [](const llvm::StringMapConstIterator& a, - const llvm::StringMapConstIterator& b) { + [](const StringMapConstIterator& a, + const StringMapConstIterator& b) { return a->getKey() < b->getKey(); }); diff --git a/wpiutil/src/main/native/cpp/support/json_serializer.cpp b/wpiutil/src/main/native/cpp/json_serializer.cpp similarity index 95% rename from wpiutil/src/main/native/cpp/support/json_serializer.cpp rename to wpiutil/src/main/native/cpp/json_serializer.cpp index 3ee052d2ba..51bc87a8e6 100644 --- a/wpiutil/src/main/native/cpp/support/json_serializer.cpp +++ b/wpiutil/src/main/native/cpp/json_serializer.cpp @@ -32,10 +32,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define WPI_JSON_IMPLEMENTATION -#include "support/json.h" +#include "wpi/json.h" -#include "llvm/SmallString.h" -#include "llvm/StringExtras.h" +#include "wpi/SmallString.h" +#include "wpi/StringExtras.h" #include "json_serializer.h" @@ -221,7 +221,7 @@ void json::serializer::dump(const json& val, } } -void json::serializer::dump_escaped(llvm::StringRef s) const +void json::serializer::dump_escaped(StringRef s) const { for (const auto& c : s) { @@ -307,8 +307,8 @@ void json::serializer::dump_escaped(llvm::StringRef s) const { // print character c as \uxxxx o << "\\u00"; - o << llvm::hexdigit((c >> 4) & 0xf, true); - o << llvm::hexdigit((c >> 0) & 0xf, true); + o << hexdigit((c >> 4) & 0xf, true); + o << hexdigit((c >> 0) & 0xf, true); break; } @@ -349,7 +349,7 @@ void json::serializer::dump_float(double x) static constexpr auto d = std::numeric_limits::digits10; // the actual conversion - llvm::SmallString<64> number_buffer; + SmallString<64> number_buffer; number_buffer.resize(64); std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x); @@ -401,7 +401,7 @@ void json::serializer::dump_float(double x) namespace wpi { -llvm::raw_ostream& operator<<(llvm::raw_ostream& o, const json& j) +raw_ostream& operator<<(raw_ostream& o, const json& j) { j.dump(o, 0); return o; @@ -412,13 +412,13 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& o, const json& j) std::string json::dump(int indent) const { std::string s; - llvm::raw_string_ostream os(s); + raw_string_ostream os(s); dump(os, indent); os.flush(); return s; } -void json::dump(llvm::raw_ostream& os, int indent) const +void json::dump(raw_ostream& os, int indent) const { serializer s(os); diff --git a/wpiutil/src/main/native/cpp/support/json_serializer.h b/wpiutil/src/main/native/cpp/json_serializer.h similarity index 96% rename from wpiutil/src/main/native/cpp/support/json_serializer.h rename to wpiutil/src/main/native/cpp/json_serializer.h index fcbb488eb5..b596f0145f 100644 --- a/wpiutil/src/main/native/cpp/support/json_serializer.h +++ b/wpiutil/src/main/native/cpp/json_serializer.h @@ -31,12 +31,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "support/json.h" +#include "wpi/json.h" #include // lconv, localeconv #include // locale -#include "llvm/raw_ostream.h" +#include "wpi/raw_ostream.h" namespace wpi { @@ -53,7 +53,7 @@ class json::serializer @param[in] s output stream to serialize to @param[in] ichar indentation character to use */ - explicit serializer(llvm::raw_ostream& s) + explicit serializer(raw_ostream& s) : o(s), loc(std::localeconv()), thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]), decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0]) @@ -93,7 +93,7 @@ class json::serializer @complexity Linear in the length of string @a s. */ - void dump_escaped(llvm::StringRef s) const; + void dump_escaped(StringRef s) const; /*! @brief dump a floating-point number @@ -107,7 +107,7 @@ class json::serializer private: /// the output of the serializer - llvm::raw_ostream& o; + raw_ostream& o; /// the locale const std::lconv* loc = nullptr; diff --git a/wpiutil/src/main/native/cpp/support/leb128.cpp b/wpiutil/src/main/native/cpp/leb128.cpp similarity index 95% rename from wpiutil/src/main/native/cpp/support/leb128.cpp rename to wpiutil/src/main/native/cpp/leb128.cpp index fd7e48fdf8..510d4ee340 100644 --- a/wpiutil/src/main/native/cpp/support/leb128.cpp +++ b/wpiutil/src/main/native/cpp/leb128.cpp @@ -5,9 +5,9 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/leb128.h" +#include "wpi/leb128.h" -#include "support/raw_istream.h" +#include "wpi/raw_istream.h" namespace wpi { @@ -39,7 +39,7 @@ uint64_t SizeUleb128(uint64_t val) { * encodings refer to section "7.6 - Variable Length Data". Return * the number of bytes written. */ -uint64_t WriteUleb128(llvm::SmallVectorImpl& dest, uint64_t val) { +uint64_t WriteUleb128(SmallVectorImpl& dest, uint64_t val) { size_t count = 0; do { diff --git a/wpiutil/src/main/native/cpp/llvm/ConvertUTF.cpp b/wpiutil/src/main/native/cpp/llvm/ConvertUTF.cpp index a164790a07..74fd8d430b 100644 --- a/wpiutil/src/main/native/cpp/llvm/ConvertUTF.cpp +++ b/wpiutil/src/main/native/cpp/llvm/ConvertUTF.cpp @@ -47,7 +47,7 @@ ------------------------------------------------------------------------ */ -#include "llvm/ConvertUTF.h" +#include "wpi/ConvertUTF.h" #ifdef CVTUTF_DEBUG #include #endif diff --git a/wpiutil/src/main/native/cpp/llvm/ConvertUTFWrapper.cpp b/wpiutil/src/main/native/cpp/llvm/ConvertUTFWrapper.cpp index 810c135166..3402988d4e 100644 --- a/wpiutil/src/main/native/cpp/llvm/ConvertUTFWrapper.cpp +++ b/wpiutil/src/main/native/cpp/llvm/ConvertUTFWrapper.cpp @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ConvertUTF.h" +#include "wpi/ConvertUTF.h" #include #include -namespace llvm { +namespace wpi { bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) { const UTF32 *SourceStart = &Source; @@ -118,5 +118,5 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8, return true; } -} // end namespace llvm +} // end namespace wpi diff --git a/wpiutil/src/main/native/cpp/llvm/ErrorHandling.cpp b/wpiutil/src/main/native/cpp/llvm/ErrorHandling.cpp index 1ab2405c9b..088e80537a 100644 --- a/wpiutil/src/main/native/cpp/llvm/ErrorHandling.cpp +++ b/wpiutil/src/main/native/cpp/llvm/ErrorHandling.cpp @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/WindowsError.h" +#include "wpi/WindowsError.h" #ifdef _WIN32 @@ -24,7 +24,7 @@ case x: \ return std::make_error_code(std::errc::y) -std::error_code llvm::mapWindowsError(unsigned EV) { +std::error_code wpi::mapWindowsError(unsigned EV) { switch (EV) { MAP_ERR_TO_COND(ERROR_ACCESS_DENIED, permission_denied); MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS, file_exists); diff --git a/wpiutil/src/main/native/cpp/llvm/Hashing.cpp b/wpiutil/src/main/native/cpp/llvm/Hashing.cpp index b2800436bf..51c033ed34 100644 --- a/wpiutil/src/main/native/cpp/llvm/Hashing.cpp +++ b/wpiutil/src/main/native/cpp/llvm/Hashing.cpp @@ -13,17 +13,17 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Hashing.h" +#include "wpi/Hashing.h" -using namespace llvm; +using namespace wpi; // Provide a definition and static initializer for the fixed seed. This // initializer should always be zero to ensure its value can never appear to be // non-zero, even during dynamic initialization. -size_t llvm::hashing::detail::fixed_seed_override = 0; +size_t wpi::hashing::detail::fixed_seed_override = 0; // Implement the function for forced setting of the fixed seed. // FIXME: Use atomic operations here so that there is no data race. -void llvm::set_fixed_execution_hash_seed(size_t fixed_value) { +void wpi::set_fixed_execution_hash_seed(size_t fixed_value) { hashing::detail::fixed_seed_override = fixed_value; } diff --git a/wpiutil/src/main/native/cpp/llvm/Path.cpp b/wpiutil/src/main/native/cpp/llvm/Path.cpp index b29f6d13f2..96e2c93b0a 100644 --- a/wpiutil/src/main/native/cpp/llvm/Path.cpp +++ b/wpiutil/src/main/native/cpp/llvm/Path.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Path.h" +#include "wpi/Path.h" #include #include @@ -22,14 +22,14 @@ #include #endif -#include "llvm/FileSystem.h" -#include "llvm/SmallString.h" +#include "wpi/FileSystem.h" +#include "wpi/SmallString.h" -using namespace llvm; +using namespace wpi; namespace { - using llvm::StringRef; - using llvm::sys::path::is_separator; + using wpi::StringRef; + using wpi::sys::path::is_separator; #ifdef _WIN32 const char *separators = "\\/"; @@ -148,7 +148,7 @@ namespace { } } // end unnamed namespace -namespace llvm { +namespace wpi { namespace sys { namespace path { @@ -626,7 +626,7 @@ static SmallString<256> remove_dots(StringRef path, bool remove_dot_dot) { // Skip the root path, then look for traversal in the components. StringRef rel = path::relative_path(path); - for (StringRef C : llvm::make_range(path::begin(rel), path::end(rel))) { + for (StringRef C : wpi::make_range(path::begin(rel), path::end(rel))) { if (C == ".") continue; if (remove_dot_dot) { @@ -795,7 +795,7 @@ std::error_code directory_entry::status(file_status &result) const { } // end namespace fs } // end namespace sys -} // end namespace llvm +} // end namespace wpi // Include the truly platform-specific parts. #ifdef _WIN32 @@ -804,7 +804,7 @@ std::error_code directory_entry::status(file_status &result) const { #include "Unix/Path.inc" #endif -namespace llvm { +namespace wpi { namespace sys { namespace path { @@ -819,4 +819,4 @@ bool user_cache_directory(SmallVectorImpl &Result, const Twine &Path1, } // end namespace path } // end namsspace sys -} // end namespace llvm +} // end namespace wpi diff --git a/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp b/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp index 6187f78fcc..6439263dc1 100644 --- a/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp +++ b/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp @@ -12,13 +12,13 @@ // //===----------------------------------------------------------------------===// -#include "llvm/SmallPtrSet.h" -#include "llvm/DenseMapInfo.h" -#include "llvm/MathExtras.h" +#include "wpi/SmallPtrSet.h" +#include "wpi/DenseMapInfo.h" +#include "wpi/MathExtras.h" #include #include -using namespace llvm; +using namespace wpi; void SmallPtrSetImplBase::shrink_and_clear() { assert(!isSmall() && "Can't shrink a small set!"); diff --git a/wpiutil/src/main/native/cpp/llvm/SmallVector.cpp b/wpiutil/src/main/native/cpp/llvm/SmallVector.cpp index 6aa709e821..8e242167d1 100644 --- a/wpiutil/src/main/native/cpp/llvm/SmallVector.cpp +++ b/wpiutil/src/main/native/cpp/llvm/SmallVector.cpp @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/SmallVector.h" -using namespace llvm; +#include "wpi/SmallVector.h" +using namespace wpi; /// grow_pod - This is an implementation of the grow() method which only works /// on POD-like datatypes and is out of line to reduce code duplication. diff --git a/wpiutil/src/main/native/cpp/llvm/StringExtras.cpp b/wpiutil/src/main/native/cpp/llvm/StringExtras.cpp index 74b47a5c36..9c7d9db649 100644 --- a/wpiutil/src/main/native/cpp/llvm/StringExtras.cpp +++ b/wpiutil/src/main/native/cpp/llvm/StringExtras.cpp @@ -11,14 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "llvm/StringExtras.h" -#include "llvm/SmallVector.h" -using namespace llvm; +#include "wpi/StringExtras.h" +#include "wpi/SmallVector.h" +using namespace wpi; /// StrInStrNoCase - Portable version of strcasestr. Locates the first /// occurrence of string 's1' in string 's2', ignoring case. Returns /// the offset of s2 in s1 or npos if s2 cannot be found. -StringRef::size_type llvm::StrInStrNoCase(StringRef s1, StringRef s2) { +StringRef::size_type wpi::StrInStrNoCase(StringRef s1, StringRef s2) { size_t N = s2.size(), M = s1.size(); if (N > M) return StringRef::npos; @@ -34,7 +34,7 @@ StringRef::size_type llvm::StrInStrNoCase(StringRef s1, StringRef s2) { /// there are no tokens in the source string, an empty string is returned. /// The function returns a pair containing the extracted token and the /// remaining tail string. -std::pair llvm::getToken(StringRef Source, +std::pair wpi::getToken(StringRef Source, StringRef Delimiters) { // Figure out where the token starts. StringRef::size_type Start = Source.find_first_not_of(Delimiters); @@ -47,7 +47,7 @@ std::pair llvm::getToken(StringRef Source, /// SplitString - Split up the specified string according to the specified /// delimiters, appending the result fragments to the output list. -void llvm::SplitString(StringRef Source, +void wpi::SplitString(StringRef Source, SmallVectorImpl &OutFragments, StringRef Delimiters) { std::pair S = getToken(Source, Delimiters); diff --git a/wpiutil/src/main/native/cpp/llvm/StringMap.cpp b/wpiutil/src/main/native/cpp/llvm/StringMap.cpp index 032c3682d8..5c750eb55e 100644 --- a/wpiutil/src/main/native/cpp/llvm/StringMap.cpp +++ b/wpiutil/src/main/native/cpp/llvm/StringMap.cpp @@ -11,12 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/StringMap.h" -#include "llvm/MathExtras.h" -#include "llvm/StringExtras.h" -#include "llvm/Compiler.h" +#include "wpi/StringMap.h" +#include "wpi/MathExtras.h" +#include "wpi/StringExtras.h" +#include "wpi/Compiler.h" #include -using namespace llvm; +using namespace wpi; /// Returns the number of buckets to allocate to ensure that the DenseMap can /// accommodate \p NumEntries without need to grow(). diff --git a/wpiutil/src/main/native/cpp/llvm/StringRef.cpp b/wpiutil/src/main/native/cpp/llvm/StringRef.cpp index c254ae37e8..fff8793004 100644 --- a/wpiutil/src/main/native/cpp/llvm/StringRef.cpp +++ b/wpiutil/src/main/native/cpp/llvm/StringRef.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "llvm/StringRef.h" -#include "llvm/Hashing.h" -#include "llvm/SmallVector.h" +#include "wpi/StringRef.h" +#include "wpi/Hashing.h" +#include "wpi/SmallVector.h" #include #include -using namespace llvm; +using namespace wpi; // MSVC emits references to this into the translation units which reference it. #ifndef _MSC_VER @@ -120,7 +120,7 @@ std::string StringRef::upper() const { return Result; } -const char *StringRef::c_str(llvm::SmallVectorImpl& buf) const { +const char *StringRef::c_str(wpi::SmallVectorImpl& buf) const { if (is_null_terminated()) { // If null terminated, return data directly return data(); @@ -379,7 +379,7 @@ static unsigned GetAutoSenseRadix(StringRef &Str) { /// GetAsUnsignedInteger - Workhorse method that converts a integer character /// sequence of radix up to 36 to an unsigned long long value. -bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix, +bool wpi::getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result) { // Autosense radix if not specified. if (Radix == 0) @@ -420,7 +420,7 @@ bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix, return false; } -bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix, +bool wpi::getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result) { unsigned long long ULLVal; @@ -447,6 +447,6 @@ bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix, } // Implementation of StringRef hashing. -hash_code llvm::hash_value(StringRef S) { +hash_code wpi::hash_value(StringRef S) { return hash_combine_range(S.begin(), S.end()); } diff --git a/wpiutil/src/main/native/cpp/llvm/Twine.cpp b/wpiutil/src/main/native/cpp/llvm/Twine.cpp index 7d771d50a8..3802306f71 100644 --- a/wpiutil/src/main/native/cpp/llvm/Twine.cpp +++ b/wpiutil/src/main/native/cpp/llvm/Twine.cpp @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Twine.h" -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" -using namespace llvm; +#include "wpi/Twine.h" +#include "wpi/SmallString.h" +#include "wpi/raw_ostream.h" +using namespace wpi; std::string Twine::str() const { // If we're storing only a std::string, just return it. diff --git a/wpiutil/src/main/native/cpp/llvm/Unix/Path.inc b/wpiutil/src/main/native/cpp/llvm/Unix/Path.inc index b1bf52d3f1..d9b4a34e77 100644 --- a/wpiutil/src/main/native/cpp/llvm/Unix/Path.inc +++ b/wpiutil/src/main/native/cpp/llvm/Unix/Path.inc @@ -28,7 +28,7 @@ #include #include -namespace llvm { +namespace wpi { namespace sys { namespace fs { UniqueID file_status::getUniqueID() const { @@ -39,10 +39,10 @@ std::error_code current_path(SmallVectorImpl &result) { result.clear(); const char *pwd = ::getenv("PWD"); - llvm::sys::fs::file_status PWDStatus, DotStatus; - if (pwd && llvm::sys::path::is_absolute(pwd) && - !llvm::sys::fs::status(pwd, PWDStatus) && - !llvm::sys::fs::status(".", DotStatus) && + wpi::sys::fs::file_status PWDStatus, DotStatus; + if (pwd && wpi::sys::path::is_absolute(pwd) && + !wpi::sys::fs::status(pwd, PWDStatus) && + !wpi::sys::fs::status(".", DotStatus) && PWDStatus.getUniqueID() == DotStatus.getUniqueID()) { result.append(pwd, pwd + strlen(pwd)); return std::error_code(); @@ -387,4 +387,4 @@ void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl &Result) { } // end namespace path } // end namespace sys -} // end namespace llvm +} // end namespace wpi diff --git a/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc b/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc index 0c4a6fce13..b7b037159e 100644 --- a/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc +++ b/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc @@ -16,8 +16,8 @@ //=== is guaranteed to work on *all* Windows variants. //===----------------------------------------------------------------------===// -#include "llvm/STLExtras.h" -#include "llvm/WindowsError.h" +#include "wpi/STLExtras.h" +#include "wpi/WindowsError.h" #include #include #include @@ -35,11 +35,11 @@ # pragma comment(lib, "ole32.lib") #endif -using namespace llvm; +using namespace wpi; -using llvm::sys::windows::UTF8ToUTF16; -using llvm::sys::windows::UTF16ToUTF8; -using llvm::sys::path::widenPath; +using wpi::sys::windows::UTF8ToUTF16; +using wpi::sys::windows::UTF16ToUTF8; +using wpi::sys::path::widenPath; static bool is_separator(const wchar_t value) { switch (value) { @@ -51,7 +51,7 @@ static bool is_separator(const wchar_t value) { } } -namespace llvm { +namespace wpi { namespace sys { namespace path { @@ -69,7 +69,7 @@ std::error_code widenPath(const Twine &Path8, // If we made this path absolute, how much longer would it get? size_t CurPathLen; - if (llvm::sys::path::is_absolute(Twine(Path8Str))) + if (wpi::sys::path::is_absolute(Twine(Path8Str))) CurPathLen = 0; // No contribution from current_path needed. else { CurPathLen = ::GetCurrentDirectoryW(0, NULL); @@ -83,7 +83,7 @@ std::error_code widenPath(const Twine &Path8, SmallString<2*MAX_PATH> FullPath("\\\\?\\"); if (CurPathLen) { SmallString<80> CurPath; - if (std::error_code EC = llvm::sys::fs::current_path(CurPath)) + if (std::error_code EC = wpi::sys::fs::current_path(CurPath)) return EC; FullPath.append(CurPath); } @@ -91,15 +91,15 @@ std::error_code widenPath(const Twine &Path8, // the \\?\ prefix is documented to treat them as real components). // The iterators don't report separators and append() always attaches // preferred_separator so we don't need to call native() on the result. - for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(Path8Str), - E = llvm::sys::path::end(Path8Str); + for (wpi::sys::path::const_iterator I = wpi::sys::path::begin(Path8Str), + E = wpi::sys::path::end(Path8Str); I != E; ++I) { if (I->size() == 1 && *I == ".") continue; if (I->size() == 2 && *I == "..") - llvm::sys::path::remove_filename(FullPath); + wpi::sys::path::remove_filename(FullPath); else - llvm::sys::path::append(FullPath, *I); + wpi::sys::path::append(FullPath, *I); } return UTF8ToUTF16(FullPath, Path16); } @@ -577,8 +577,8 @@ void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl &Result) { } // end namespace path namespace windows { -std::error_code UTF8ToUTF16(llvm::StringRef utf8, - llvm::SmallVectorImpl &utf16) { +std::error_code UTF8ToUTF16(wpi::StringRef utf8, + wpi::SmallVectorImpl &utf16) { if (!utf8.empty()) { int len = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8.begin(), utf8.size(), utf16.begin(), 0); @@ -606,7 +606,7 @@ std::error_code UTF8ToUTF16(llvm::StringRef utf8, static std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16, size_t utf16_len, - llvm::SmallVectorImpl &utf8) { + wpi::SmallVectorImpl &utf8) { if (utf16_len) { // Get length. int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, utf8.begin(), @@ -634,15 +634,15 @@ std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16, } std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len, - llvm::SmallVectorImpl &utf8) { + wpi::SmallVectorImpl &utf8) { return UTF16ToCodePage(CP_UTF8, utf16, utf16_len, utf8); } std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len, - llvm::SmallVectorImpl &utf8) { + wpi::SmallVectorImpl &utf8) { return UTF16ToCodePage(CP_ACP, utf16, utf16_len, utf8); } } // end namespace windows } // end namespace sys -} // end namespace llvm +} // end namespace wpi diff --git a/wpiutil/src/main/native/cpp/llvm/Windows/WindowsSupport.h b/wpiutil/src/main/native/cpp/llvm/Windows/WindowsSupport.h index fd820e7582..249a8814c6 100644 --- a/wpiutil/src/main/native/cpp/llvm/Windows/WindowsSupport.h +++ b/wpiutil/src/main/native/cpp/llvm/Windows/WindowsSupport.h @@ -34,11 +34,11 @@ #define NOMINMAX #endif -#include "llvm/SmallVector.h" -#include "llvm/StringExtras.h" -#include "llvm/StringRef.h" -#include "llvm/Twine.h" -#include "llvm/Compiler.h" +#include "wpi/SmallVector.h" +#include "wpi/StringExtras.h" +#include "wpi/StringRef.h" +#include "wpi/Twine.h" +#include "wpi/Compiler.h" #include #include #include @@ -79,7 +79,7 @@ inline bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix) { *ErrMsg = prefix + ": " + buffer; else *ErrMsg = prefix + ": Unknown error"; - *ErrMsg += " (0x" + llvm::utohexstr(LastError) + ")"; + *ErrMsg += " (0x" + wpi::utohexstr(LastError) + ")"; LocalFree(buffer); return R != 0; @@ -179,7 +179,7 @@ typedef ScopedHandle ScopedRegHandle; typedef ScopedHandle ScopedFindHandle; typedef ScopedHandle ScopedJobHandle; -namespace llvm { +namespace wpi { template class SmallVectorImpl; @@ -206,6 +206,6 @@ std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len, SmallVectorImpl &utf8); } // end namespace windows } // end namespace sys -} // end namespace llvm. +} // end namespace wpi. #endif diff --git a/wpiutil/src/main/native/cpp/llvm/raw_os_ostream.cpp b/wpiutil/src/main/native/cpp/llvm/raw_os_ostream.cpp index 402004ef89..1fb6c51bcb 100644 --- a/wpiutil/src/main/native/cpp/llvm/raw_os_ostream.cpp +++ b/wpiutil/src/main/native/cpp/llvm/raw_os_ostream.cpp @@ -11,9 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/raw_os_ostream.h" +#include "wpi/raw_os_ostream.h" #include -using namespace llvm; +using namespace wpi; //===----------------------------------------------------------------------===// // raw_os_ostream diff --git a/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp b/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp index 3fab800b79..f5a345475e 100644 --- a/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp +++ b/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp @@ -11,14 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "llvm/raw_ostream.h" -#include "llvm/SmallString.h" -#include "llvm/SmallVector.h" -#include "llvm/StringExtras.h" -#include "llvm/Compiler.h" -#include "llvm/Format.h" -#include "llvm/MathExtras.h" -#include "llvm/WindowsError.h" +#include "wpi/raw_ostream.h" +#include "wpi/SmallString.h" +#include "wpi/SmallVector.h" +#include "wpi/StringExtras.h" +#include "wpi/Compiler.h" +#include "wpi/Format.h" +#include "wpi/MathExtras.h" +#include "wpi/WindowsError.h" #include #include #include @@ -53,7 +53,7 @@ #include "Windows/WindowsSupport.h" #endif -using namespace llvm; +using namespace wpi; raw_ostream::~raw_ostream() { // raw_ostream's subclasses should take care to flush the buffer @@ -657,7 +657,7 @@ size_t raw_fd_ostream::preferred_buffer_size() const { /// outs() - This returns a reference to a raw_ostream for standard output. /// Use it like: outs() << "foo" << "bar"; -raw_ostream &llvm::outs() { +raw_ostream &wpi::outs() { // Set buffer settings to model stdout behavior. Delete the file descriptor // when the program exits, forcing error detection. This means that if you // ever call outs(), you can't open another raw_fd_ostream on stdout, as we'll @@ -670,14 +670,14 @@ raw_ostream &llvm::outs() { /// errs() - This returns a reference to a raw_ostream for standard error. /// Use it like: errs() << "foo" << "bar"; -raw_ostream &llvm::errs() { +raw_ostream &wpi::errs() { // Set standard error to be unbuffered by default. static raw_fd_ostream S(STDERR_FILENO, false, true); return S; } /// nulls() - This returns a reference to a raw_ostream which discards output. -raw_ostream &llvm::nulls() { +raw_ostream &wpi::nulls() { static raw_null_ostream S; return S; } diff --git a/wpiutil/src/main/native/cpp/support/raw_istream.cpp b/wpiutil/src/main/native/cpp/raw_istream.cpp similarity index 82% rename from wpiutil/src/main/native/cpp/support/raw_istream.cpp rename to wpiutil/src/main/native/cpp/raw_istream.cpp index 3c981ee5c9..f5aa97eae3 100644 --- a/wpiutil/src/main/native/cpp/support/raw_istream.cpp +++ b/wpiutil/src/main/native/cpp/raw_istream.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/raw_istream.h" +#include "wpi/raw_istream.h" #ifdef _WIN32 #include @@ -16,9 +16,9 @@ #include #include -#include "llvm/FileSystem.h" -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" +#include "wpi/FileSystem.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" #if defined(_MSC_VER) #ifndef STDIN_FILENO @@ -34,21 +34,20 @@ using namespace wpi; -llvm::StringRef raw_istream::getline(llvm::SmallVectorImpl& buf, - int maxLen) { +StringRef raw_istream::getline(SmallVectorImpl& buf, int maxLen) { buf.clear(); for (int i = 0; i < maxLen; ++i) { char c; read(c); - if (has_error()) return llvm::StringRef{buf.data(), buf.size()}; + if (has_error()) return StringRef{buf.data(), buf.size()}; if (c == '\r') continue; buf.push_back(c); if (c == '\n') break; } - return llvm::StringRef{buf.data(), buf.size()}; + return StringRef{buf.data(), buf.size()}; } -raw_mem_istream::raw_mem_istream(llvm::StringRef mem) +raw_mem_istream::raw_mem_istream(StringRef mem) : raw_mem_istream(mem.data(), mem.size()) {} void raw_mem_istream::close() {} @@ -65,7 +64,7 @@ void raw_mem_istream::read_impl(void* data, size_t len) { m_left -= len; } -static int getFD(const llvm::Twine& Filename, std::error_code& EC) { +static int getFD(const Twine& Filename, std::error_code& EC) { // Handle "-" as stdin. Note that when we do this, we consider ourself // the owner of stdin. This means that we can do things like close the // file descriptor when we're done and set the "binary" flag globally. @@ -76,14 +75,14 @@ static int getFD(const llvm::Twine& Filename, std::error_code& EC) { int FD; - EC = llvm::sys::fs::openFileForRead(Filename, FD); + EC = sys::fs::openFileForRead(Filename, FD); if (EC) return -1; EC = std::error_code(); return FD; } -raw_fd_istream::raw_fd_istream(const llvm::Twine& filename, std::error_code& ec, +raw_fd_istream::raw_fd_istream(const Twine& filename, std::error_code& ec, size_t bufSize) : raw_fd_istream(getFD(filename, ec), true, bufSize) {} diff --git a/wpiutil/src/main/native/cpp/support/raw_socket_istream.cpp b/wpiutil/src/main/native/cpp/raw_socket_istream.cpp similarity index 92% rename from wpiutil/src/main/native/cpp/support/raw_socket_istream.cpp rename to wpiutil/src/main/native/cpp/raw_socket_istream.cpp index 4902be674f..67a491eb19 100644 --- a/wpiutil/src/main/native/cpp/support/raw_socket_istream.cpp +++ b/wpiutil/src/main/native/cpp/raw_socket_istream.cpp @@ -5,9 +5,9 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/raw_socket_istream.h" +#include "wpi/raw_socket_istream.h" -#include "tcpsockets/NetworkStream.h" +#include "wpi/NetworkStream.h" using namespace wpi; diff --git a/wpiutil/src/main/native/cpp/support/raw_socket_ostream.cpp b/wpiutil/src/main/native/cpp/raw_socket_ostream.cpp similarity index 93% rename from wpiutil/src/main/native/cpp/support/raw_socket_ostream.cpp rename to wpiutil/src/main/native/cpp/raw_socket_ostream.cpp index f9a4000705..fb8d94d5e8 100644 --- a/wpiutil/src/main/native/cpp/support/raw_socket_ostream.cpp +++ b/wpiutil/src/main/native/cpp/raw_socket_ostream.cpp @@ -5,9 +5,9 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/raw_socket_ostream.h" +#include "wpi/raw_socket_ostream.h" -#include "tcpsockets/NetworkStream.h" +#include "wpi/NetworkStream.h" using namespace wpi; diff --git a/wpiutil/src/main/native/cpp/support/sha1.cpp b/wpiutil/src/main/native/cpp/sha1.cpp similarity index 94% rename from wpiutil/src/main/native/cpp/support/sha1.cpp rename to wpiutil/src/main/native/cpp/sha1.cpp index 3de313b056..5c861e9063 100644 --- a/wpiutil/src/main/native/cpp/support/sha1.cpp +++ b/wpiutil/src/main/native/cpp/sha1.cpp @@ -17,12 +17,12 @@ -- Eugene Hopkinson */ -#include "support/sha1.h" +#include "wpi/sha1.h" -#include "llvm/SmallVector.h" -#include "llvm/StringExtras.h" -#include "llvm/raw_ostream.h" -#include "support/raw_istream.h" +#include "wpi/SmallVector.h" +#include "wpi/StringExtras.h" +#include "wpi/raw_istream.h" +#include "wpi/raw_ostream.h" using namespace wpi; @@ -214,7 +214,7 @@ static void buffer_to_block(const unsigned char* buffer, SHA1::SHA1() { reset(digest, buf_size, transforms); } -void SHA1::Update(llvm::StringRef s) { +void SHA1::Update(StringRef s) { raw_mem_istream is(s); Update(is); } @@ -237,7 +237,7 @@ void SHA1::Update(raw_istream& is) { */ static void finalize(uint32_t digest[], unsigned char* buffer, size_t& buf_size, - uint64_t& transforms, llvm::raw_ostream& os) { + uint64_t& transforms, raw_ostream& os) { /* Total number of hashed bits */ uint64_t total_bits = (transforms * BLOCK_BYTES + buf_size) * 8; @@ -277,22 +277,22 @@ static void finalize(uint32_t digest[], unsigned char* buffer, size_t& buf_size, std::string SHA1::Final() { std::string out; - llvm::raw_string_ostream os(out); + raw_string_ostream os(out); finalize(digest, buffer, buf_size, transforms, os); return os.str(); } -llvm::StringRef SHA1::Final(llvm::SmallVectorImpl& buf) { - llvm::raw_svector_ostream os(buf); +StringRef SHA1::Final(SmallVectorImpl& buf) { + raw_svector_ostream os(buf); finalize(digest, buffer, buf_size, transforms, os); return os.str(); } -std::string SHA1::FromFile(llvm::StringRef filename) { +std::string SHA1::FromFile(StringRef filename) { std::error_code ec; raw_fd_istream stream(filename, ec); SHA1 checksum; diff --git a/wpiutil/src/main/native/cpp/support/timestamp.cpp b/wpiutil/src/main/native/cpp/timestamp.cpp similarity index 98% rename from wpiutil/src/main/native/cpp/support/timestamp.cpp rename to wpiutil/src/main/native/cpp/timestamp.cpp index a6dc0e2169..7f3b0cf3f6 100644 --- a/wpiutil/src/main/native/cpp/support/timestamp.cpp +++ b/wpiutil/src/main/native/cpp/timestamp.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/timestamp.h" +#include "wpi/timestamp.h" #include diff --git a/wpiutil/src/main/native/include/llvm/AlignOf.h b/wpiutil/src/main/native/include/wpi/AlignOf.h similarity index 95% rename from wpiutil/src/main/native/include/llvm/AlignOf.h rename to wpiutil/src/main/native/include/wpi/AlignOf.h index d54328b615..9c81c42b85 100644 --- a/wpiutil/src/main/native/include/llvm/AlignOf.h +++ b/wpiutil/src/main/native/include/wpi/AlignOf.h @@ -15,11 +15,11 @@ #ifndef LLVM_SUPPORT_ALIGNOF_H #define LLVM_SUPPORT_ALIGNOF_H -#include "llvm/Compiler.h" +#include "wpi/Compiler.h" #include #include -namespace llvm { +namespace wpi { namespace detail { @@ -71,8 +71,8 @@ template struct AlignOf { #ifndef _MSC_VER // Avoid warnings from GCC like: - // comparison between 'enum llvm::AlignOf::' and 'enum - // llvm::AlignOf::' [-Wenum-compare] + // comparison between 'enum wpi::AlignOf::' and 'enum + // wpi::AlignOf::' [-Wenum-compare] // by using constexpr instead of enum. // (except on MSVC, since it doesn't support constexpr yet). static constexpr unsigned Alignment = static_cast( @@ -80,7 +80,7 @@ struct AlignOf { #else enum { Alignment = static_cast( - sizeof(::llvm::detail::AlignmentCalcImpl) - sizeof(T)) + sizeof(::wpi::detail::AlignmentCalcImpl) - sizeof(T)) }; #endif enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 }; @@ -248,12 +248,12 @@ template -struct AlignedCharArrayUnion : llvm::AlignedCharArray< - AlignOf >::Alignment, - sizeof(::llvm::detail::SizerImpl)> { }; -} // end namespace llvm +} // end namespace wpi #endif // LLVM_SUPPORT_ALIGNOF_H diff --git a/wpiutil/src/main/native/include/llvm/ArrayRef.h b/wpiutil/src/main/native/include/wpi/ArrayRef.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/ArrayRef.h rename to wpiutil/src/main/native/include/wpi/ArrayRef.h index 4e7cd1aa05..e09bac72a5 100644 --- a/wpiutil/src/main/native/include/llvm/ArrayRef.h +++ b/wpiutil/src/main/native/include/wpi/ArrayRef.h @@ -10,13 +10,13 @@ #ifndef LLVM_ADT_ARRAYREF_H #define LLVM_ADT_ARRAYREF_H -#include "llvm/Compiler.h" -#include "llvm/Hashing.h" -#include "llvm/None.h" -#include "llvm/SmallVector.h" +#include "wpi/Compiler.h" +#include "wpi/Hashing.h" +#include "wpi/None.h" +#include "wpi/SmallVector.h" #include -namespace llvm { +namespace wpi { /// ArrayRef - Represent a constant reference to an array (0 or more elements /// consecutively in memory), i.e. a start pointer and a length. It allows /// various APIs to take consecutive elements easily and conveniently. @@ -392,6 +392,6 @@ namespace llvm { template hash_code hash_value(ArrayRef S) { return hash_combine_range(S.begin(), S.end()); } -} // end namespace llvm +} // end namespace wpi #endif // LLVM_ADT_ARRAYREF_H diff --git a/wpiutil/src/main/native/include/support/Base64.h b/wpiutil/src/main/native/include/wpi/Base64.h similarity index 55% rename from wpiutil/src/main/native/include/support/Base64.h rename to wpiutil/src/main/native/include/wpi/Base64.h index dcd6c06ded..6d855138d5 100644 --- a/wpiutil/src/main/native/include/support/Base64.h +++ b/wpiutil/src/main/native/include/wpi/Base64.h @@ -11,29 +11,25 @@ #include #include -#include "llvm/StringRef.h" +#include "wpi/StringRef.h" -namespace llvm { +namespace wpi { template class SmallVectorImpl; class raw_ostream; -} // namespace llvm -namespace wpi { +size_t Base64Decode(raw_ostream& os, StringRef encoded); -size_t Base64Decode(llvm::raw_ostream& os, llvm::StringRef encoded); +size_t Base64Decode(StringRef encoded, std::string* plain); -size_t Base64Decode(llvm::StringRef encoded, std::string* plain); +StringRef Base64Decode(StringRef encoded, size_t* num_read, + SmallVectorImpl& buf); -llvm::StringRef Base64Decode(llvm::StringRef encoded, size_t* num_read, - llvm::SmallVectorImpl& buf); +void Base64Encode(raw_ostream& os, StringRef plain); -void Base64Encode(llvm::raw_ostream& os, llvm::StringRef plain); +void Base64Encode(StringRef plain, std::string* encoded); -void Base64Encode(llvm::StringRef plain, std::string* encoded); - -llvm::StringRef Base64Encode(llvm::StringRef plain, - llvm::SmallVectorImpl& buf); +StringRef Base64Encode(StringRef plain, SmallVectorImpl& buf); } // namespace wpi diff --git a/wpiutil/src/main/native/include/llvm/Compiler.h b/wpiutil/src/main/native/include/wpi/Compiler.h similarity index 100% rename from wpiutil/src/main/native/include/llvm/Compiler.h rename to wpiutil/src/main/native/include/wpi/Compiler.h diff --git a/wpiutil/src/main/native/include/support/ConcurrentQueue.h b/wpiutil/src/main/native/include/wpi/ConcurrentQueue.h similarity index 96% rename from wpiutil/src/main/native/include/support/ConcurrentQueue.h rename to wpiutil/src/main/native/include/wpi/ConcurrentQueue.h index f2cc7c9421..f1ea5efef1 100644 --- a/wpiutil/src/main/native/include/support/ConcurrentQueue.h +++ b/wpiutil/src/main/native/include/wpi/ConcurrentQueue.h @@ -11,8 +11,8 @@ #include #include -#include "support/condition_variable.h" -#include "support/mutex.h" +#include "wpi/condition_variable.h" +#include "wpi/mutex.h" namespace wpi { diff --git a/wpiutil/src/main/native/include/llvm/ConvertUTF.h b/wpiutil/src/main/native/include/wpi/ConvertUTF.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/ConvertUTF.h rename to wpiutil/src/main/native/include/wpi/ConvertUTF.h index 5b025331b8..41226335c2 100644 --- a/wpiutil/src/main/native/include/llvm/ConvertUTF.h +++ b/wpiutil/src/main/native/include/wpi/ConvertUTF.h @@ -180,10 +180,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte); /*************************************************************************/ /* Below are LLVM-specific wrappers of the functions above. */ -#include "llvm/ArrayRef.h" -#include "llvm/StringRef.h" +#include "wpi/ArrayRef.h" +#include "wpi/StringRef.h" -namespace llvm { +namespace wpi { /** * Convert an Unicode code point to UTF8 sequence. @@ -246,7 +246,7 @@ bool convertUTF16ToUTF8String(ArrayRef SrcUTF16, bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl &DstUTF16); -} /* end namespace llvm */ +} /* end namespace wpi */ #endif diff --git a/wpiutil/src/main/native/include/llvm/DenseMap.h b/wpiutil/src/main/native/include/wpi/DenseMap.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/DenseMap.h rename to wpiutil/src/main/native/include/wpi/DenseMap.h index 6b66d7e324..3d812c8ea2 100644 --- a/wpiutil/src/main/native/include/llvm/DenseMap.h +++ b/wpiutil/src/main/native/include/wpi/DenseMap.h @@ -14,13 +14,13 @@ #ifndef LLVM_ADT_DENSEMAP_H #define LLVM_ADT_DENSEMAP_H -#include "llvm/DenseMapInfo.h" -#include "llvm/EpochTracker.h" -#include "llvm/AlignOf.h" -#include "llvm/Compiler.h" -#include "llvm/MathExtras.h" -#include "llvm/PointerLikeTypeTraits.h" -#include "llvm/type_traits.h" +#include "wpi/DenseMapInfo.h" +#include "wpi/EpochTracker.h" +#include "wpi/AlignOf.h" +#include "wpi/Compiler.h" +#include "wpi/MathExtras.h" +#include "wpi/PointerLikeTypeTraits.h" +#include "wpi/type_traits.h" #include #include #include @@ -30,7 +30,7 @@ #include #include -namespace llvm { +namespace wpi { namespace detail { // We extend a pair to allow users to override the bucket type with their own @@ -1115,6 +1115,6 @@ capacity_in_bytes(const DenseMap &X) { return X.getMemorySize(); } -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/DenseMapInfo.h b/wpiutil/src/main/native/include/wpi/DenseMapInfo.h similarity index 97% rename from wpiutil/src/main/native/include/llvm/DenseMapInfo.h rename to wpiutil/src/main/native/include/wpi/DenseMapInfo.h index 65e38cc685..ec997d62c0 100644 --- a/wpiutil/src/main/native/include/llvm/DenseMapInfo.h +++ b/wpiutil/src/main/native/include/wpi/DenseMapInfo.h @@ -14,13 +14,13 @@ #ifndef LLVM_ADT_DENSEMAPINFO_H #define LLVM_ADT_DENSEMAPINFO_H -#include "llvm/ArrayRef.h" -#include "llvm/Hashing.h" -#include "llvm/StringRef.h" -#include "llvm/PointerLikeTypeTraits.h" -#include "llvm/type_traits.h" +#include "wpi/ArrayRef.h" +#include "wpi/Hashing.h" +#include "wpi/StringRef.h" +#include "wpi/PointerLikeTypeTraits.h" +#include "wpi/type_traits.h" -namespace llvm { +namespace wpi { template struct DenseMapInfo { @@ -246,6 +246,6 @@ template struct DenseMapInfo> { } }; -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/EpochTracker.h b/wpiutil/src/main/native/include/wpi/EpochTracker.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/EpochTracker.h rename to wpiutil/src/main/native/include/wpi/EpochTracker.h index f589136247..53d540de25 100644 --- a/wpiutil/src/main/native/include/llvm/EpochTracker.h +++ b/wpiutil/src/main/native/include/wpi/EpochTracker.h @@ -18,7 +18,7 @@ #include -namespace llvm { +namespace wpi { #ifdef NDEBUG //ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS @@ -92,6 +92,6 @@ public: #endif // LLVM_ENABLE_ABI_BREAKING_CHECKS -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/FileSystem.h b/wpiutil/src/main/native/include/wpi/FileSystem.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/FileSystem.h rename to wpiutil/src/main/native/include/wpi/FileSystem.h index c45afc877a..b07c106160 100644 --- a/wpiutil/src/main/native/include/llvm/FileSystem.h +++ b/wpiutil/src/main/native/include/wpi/FileSystem.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file declares the llvm::sys::fs namespace. It is designed after +// This file declares the wpi::sys::fs namespace. It is designed after // TR2/boost filesystem (v3), but modified to remove exception handling and the // path class. // @@ -27,9 +27,9 @@ #ifndef LLVM_SUPPORT_FILESYSTEM_H #define LLVM_SUPPORT_FILESYSTEM_H -#include "llvm/IntrusiveRefCntPtr.h" -#include "llvm/SmallString.h" -#include "llvm/Twine.h" +#include "wpi/IntrusiveRefCntPtr.h" +#include "wpi/SmallString.h" +#include "wpi/Twine.h" #include @@ -39,7 +39,7 @@ #include #include -namespace llvm { +namespace wpi { namespace sys { namespace fs { @@ -663,6 +663,6 @@ public: } // end namespace fs } // end namespace sys -} // end namespace llvm +} // end namespace wpi #endif // LLVM_SUPPORT_FILESYSTEM_H diff --git a/wpiutil/src/main/native/include/llvm/Format.h b/wpiutil/src/main/native/include/wpi/Format.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/Format.h rename to wpiutil/src/main/native/include/wpi/Format.h index 5138dece39..b8537af741 100644 --- a/wpiutil/src/main/native/include/llvm/Format.h +++ b/wpiutil/src/main/native/include/wpi/Format.h @@ -23,14 +23,14 @@ #ifndef LLVM_SUPPORT_FORMAT_H #define LLVM_SUPPORT_FORMAT_H -#include "llvm/STLExtras.h" -#include "llvm/StringRef.h" +#include "wpi/STLExtras.h" +#include "wpi/StringRef.h" #include #include #include #include -namespace llvm { +namespace wpi { /// This is a helper class used for handling formatted output. It is the /// abstract base class of a templated derived class. @@ -197,6 +197,6 @@ inline FormattedNumber format_decimal(int64_t N, unsigned Width) { return FormattedNumber(0, N, Width, false, false, false); } -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/Hashing.h b/wpiutil/src/main/native/include/wpi/Hashing.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/Hashing.h rename to wpiutil/src/main/native/include/wpi/Hashing.h index 6efd99e635..06cec62c78 100644 --- a/wpiutil/src/main/native/include/llvm/Hashing.h +++ b/wpiutil/src/main/native/include/wpi/Hashing.h @@ -45,7 +45,7 @@ #ifndef LLVM_ADT_HASHING_H #define LLVM_ADT_HASHING_H -#include "llvm/type_traits.h" +#include "wpi/type_traits.h" #include #include #include @@ -53,7 +53,7 @@ #include #include -namespace llvm { +namespace wpi { /// \brief An opaque object representing a hash code. /// @@ -64,8 +64,8 @@ namespace llvm { /// /// In order to obtain the hash_code for an object 'x': /// \code -/// using llvm::hash_value; -/// llvm::hash_code code = hash_value(x); +/// using wpi::hash_value; +/// wpi::hash_code code = hash_value(x); /// \endcode class hash_code { size_t value; @@ -311,7 +311,7 @@ struct hash_state { /// \brief A global, fixed seed-override variable. /// -/// This variable can be set using the \see llvm::set_fixed_execution_seed +/// This variable can be set using the \see wpi::set_fixed_execution_seed /// function. See that function for details. Do not, under any circumstances, /// set or read this variable. extern size_t fixed_seed_override; @@ -370,7 +370,7 @@ get_hashable_data(const T &value) { template typename std::enable_if::value, size_t>::type get_hashable_data(const T &value) { - using ::llvm::hash_value; + using ::wpi::hash_value; return hash_value(value); } @@ -476,7 +476,7 @@ hash_combine_range_impl(ValueT *first, ValueT *last) { /// a sequence of bytes. template hash_code hash_combine_range(InputIteratorT first, InputIteratorT last) { - return ::llvm::hashing::detail::hash_combine_range_impl(first, last); + return ::wpi::hashing::detail::hash_combine_range_impl(first, last); } @@ -599,7 +599,7 @@ public: /// *not* call this routine, they should instead call 'hash_value'. template hash_code hash_combine(const Ts &...args) { // Recursively hash each argument using a helper class. - ::llvm::hashing::detail::hash_combine_recursive_helper helper; + ::wpi::hashing::detail::hash_combine_recursive_helper helper; return helper.combine(0, helper.buffer, helper.buffer + 64, args...); } @@ -629,14 +629,14 @@ inline hash_code hash_integer_value(uint64_t value) { template typename std::enable_if::value, hash_code>::type hash_value(T value) { - return ::llvm::hashing::detail::hash_integer_value( + return ::wpi::hashing::detail::hash_integer_value( static_cast(value)); } // Declared and documented above, but defined here so that any of the hashing // infrastructure is available. template hash_code hash_value(const T *ptr) { - return ::llvm::hashing::detail::hash_integer_value( + return ::wpi::hashing::detail::hash_integer_value( reinterpret_cast(ptr)); } @@ -654,6 +654,6 @@ hash_code hash_value(const std::basic_string &arg) { return hash_combine_range(arg.begin(), arg.end()); } -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/include/support/HttpUtil.h b/wpiutil/src/main/native/include/wpi/HttpUtil.h similarity index 70% rename from wpiutil/src/main/native/include/support/HttpUtil.h rename to wpiutil/src/main/native/include/wpi/HttpUtil.h index 555af87a6f..250684f5b8 100644 --- a/wpiutil/src/main/native/include/support/HttpUtil.h +++ b/wpiutil/src/main/native/include/wpi/HttpUtil.h @@ -13,16 +13,16 @@ #include #include -#include "llvm/ArrayRef.h" -#include "llvm/SmallString.h" -#include "llvm/SmallVector.h" -#include "llvm/StringMap.h" -#include "llvm/StringRef.h" -#include "llvm/Twine.h" -#include "support/raw_istream.h" -#include "support/raw_socket_istream.h" -#include "support/raw_socket_ostream.h" -#include "tcpsockets/NetworkStream.h" +#include "wpi/ArrayRef.h" +#include "wpi/NetworkStream.h" +#include "wpi/SmallString.h" +#include "wpi/SmallVector.h" +#include "wpi/StringMap.h" +#include "wpi/StringRef.h" +#include "wpi/Twine.h" +#include "wpi/raw_istream.h" +#include "wpi/raw_socket_istream.h" +#include "wpi/raw_socket_ostream.h" namespace wpi { @@ -30,16 +30,15 @@ namespace wpi { // @param buf Buffer for output // @param error Set to true if an error occurred // @return Escaped string -llvm::StringRef UnescapeURI(const llvm::Twine& str, - llvm::SmallVectorImpl& buf, bool* error); +StringRef UnescapeURI(const Twine& str, SmallVectorImpl& buf, + bool* error); // Escape a string with %xx-encoding. // @param buf Buffer for output // @param spacePlus If true, encodes spaces to '+' rather than "%20" // @return Escaped string -llvm::StringRef EscapeURI(const llvm::Twine& str, - llvm::SmallVectorImpl& buf, - bool spacePlus = true); +StringRef EscapeURI(const Twine& str, SmallVectorImpl& buf, + bool spacePlus = true); // Parse a set of HTTP headers. Saves just the Content-Type and Content-Length // fields. @@ -47,9 +46,8 @@ llvm::StringRef EscapeURI(const llvm::Twine& str, // @param contentType If not null, Content-Type contents are saved here. // @param contentLength If not null, Content-Length contents are saved here. // @return False if error occurred in input stream -bool ParseHttpHeaders(wpi::raw_istream& is, - llvm::SmallVectorImpl* contentType, - llvm::SmallVectorImpl* contentLength); +bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl* contentType, + SmallVectorImpl* contentLength); // Look for a MIME multi-part boundary. On return, the input stream will // be located at the character following the boundary (usually "\r\n"). @@ -58,13 +56,13 @@ bool ParseHttpHeaders(wpi::raw_istream& is, // @param saveBuf If not null, all scanned characters up to but not including // the boundary are saved to this string // @return False if error occurred on input stream, true if boundary found. -bool FindMultipartBoundary(wpi::raw_istream& is, llvm::StringRef boundary, +bool FindMultipartBoundary(wpi::raw_istream& is, StringRef boundary, std::string* saveBuf); class HttpLocation { public: HttpLocation() = default; - HttpLocation(const llvm::Twine& url_, bool* error, std::string* errorMsg); + HttpLocation(const Twine& url_, bool* error, std::string* errorMsg); std::string url; // retain copy std::string user; // unescaped @@ -89,38 +87,38 @@ class HttpRequest { template HttpRequest(const HttpLocation& loc, const T& extraParams); - HttpRequest(const HttpLocation& loc, llvm::StringRef path_) + HttpRequest(const HttpLocation& loc, StringRef path_) : host{loc.host}, port{loc.port}, path{path_} { SetAuth(loc); } template - HttpRequest(const HttpLocation& loc, llvm::StringRef path_, const T& params) + HttpRequest(const HttpLocation& loc, StringRef path_, const T& params) : host{loc.host}, port{loc.port} { SetPath(path_, params); SetAuth(loc); } - llvm::SmallString<128> host; + SmallString<128> host; int port; std::string auth; - llvm::SmallString<128> path; + SmallString<128> path; private: void SetAuth(const HttpLocation& loc); template - void SetPath(llvm::StringRef path_, const T& params); + void SetPath(StringRef path_, const T& params); template - static llvm::StringRef GetFirst(const T& elem) { + static StringRef GetFirst(const T& elem) { return elem.first; } template - static llvm::StringRef GetFirst(const llvm::StringMapEntry& elem) { + static StringRef GetFirst(const StringMapEntry& elem) { return elem.getKey(); } template - static llvm::StringRef GetSecond(const T& elem) { + static StringRef GetSecond(const T& elem) { return elem.second; } }; @@ -137,8 +135,8 @@ class HttpConnection { wpi::raw_socket_ostream os; // Valid after Handshake() is successful - llvm::SmallString<64> contentType; - llvm::SmallString<64> contentLength; + SmallString<64> contentType; + SmallString<64> contentLength; explicit operator bool() const { return stream && !is.has_error(); } }; diff --git a/wpiutil/src/main/native/include/support/HttpUtil.inl b/wpiutil/src/main/native/include/wpi/HttpUtil.inl similarity index 78% rename from wpiutil/src/main/native/include/support/HttpUtil.inl rename to wpiutil/src/main/native/include/wpi/HttpUtil.inl index 00538fc3ae..cfeb9b36c0 100644 --- a/wpiutil/src/main/native/include/support/HttpUtil.inl +++ b/wpiutil/src/main/native/include/wpi/HttpUtil.inl @@ -13,19 +13,19 @@ namespace wpi { template HttpRequest::HttpRequest(const HttpLocation& loc, const T& extraParams) : host{loc.host}, port{loc.port} { - llvm::SmallVector, 8> params; + StringMap params; for (const auto& p : loc.params) - params.emplace_back(std::make_pair(GetFirst(p), GetSecond(p))); + params.insert(std::make_pair(GetFirst(p), GetSecond(p))); for (const auto& p : extraParams) - params.emplace_back(std::make_pair(GetFirst(p), GetSecond(p))); + params.insert(std::make_pair(GetFirst(p), GetSecond(p))); SetPath(loc.path, params); SetAuth(loc); } template -void HttpRequest::SetPath(llvm::StringRef path_, const T& params) { +void HttpRequest::SetPath(StringRef path_, const T& params) { // Build location including query string - llvm::raw_svector_ostream pathOs{path}; + raw_svector_ostream pathOs{path}; pathOs << path_; bool first = true; for (const auto& param : params) { @@ -35,7 +35,7 @@ void HttpRequest::SetPath(llvm::StringRef path_, const T& params) { } else { pathOs << '&'; } - llvm::SmallString<64> escapeBuf; + SmallString<64> escapeBuf; pathOs << EscapeURI(GetFirst(param), escapeBuf); if (!GetSecond(param).empty()) { pathOs << '=' << EscapeURI(GetSecond(param), escapeBuf); diff --git a/wpiutil/src/main/native/include/llvm/IntrusiveRefCntPtr.h b/wpiutil/src/main/native/include/wpi/IntrusiveRefCntPtr.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/IntrusiveRefCntPtr.h rename to wpiutil/src/main/native/include/wpi/IntrusiveRefCntPtr.h index 8057ec10be..1a3219e391 100644 --- a/wpiutil/src/main/native/include/llvm/IntrusiveRefCntPtr.h +++ b/wpiutil/src/main/native/include/wpi/IntrusiveRefCntPtr.h @@ -25,7 +25,7 @@ #include #include -namespace llvm { +namespace wpi { template class IntrusiveRefCntPtr; @@ -89,7 +89,7 @@ namespace llvm { static void release(T *obj) { obj->Release(); } }; -/// \brief A thread-safe version of \c llvm::RefCountedBase. +/// \brief A thread-safe version of \c wpi::RefCountedBase. /// /// A generic base class for objects that wish to have their lifetimes managed /// using reference counts. Classes subclass \c ThreadSafeRefCountedBase to @@ -283,6 +283,6 @@ public: } }; -} // end namespace llvm +} // end namespace wpi #endif // LLVM_ADT_INTRUSIVEREFCNTPTR_H diff --git a/wpiutil/src/main/native/include/support/Logger.h b/wpiutil/src/main/native/include/wpi/Logger.h similarity index 94% rename from wpiutil/src/main/native/include/support/Logger.h rename to wpiutil/src/main/native/include/wpi/Logger.h index 6c29f4e328..3002c2f5e1 100644 --- a/wpiutil/src/main/native/include/support/Logger.h +++ b/wpiutil/src/main/native/include/wpi/Logger.h @@ -10,8 +10,8 @@ #include -#include "llvm/SmallString.h" -#include "llvm/raw_ostream.h" +#include "wpi/SmallString.h" +#include "wpi/raw_ostream.h" namespace wpi { @@ -60,8 +60,8 @@ class Logger { do { \ ::wpi::Logger& WPI_logger_ = logger_inst; \ if (WPI_logger_.min_level() <= level && WPI_logger_.HasLogger()) { \ - llvm::SmallString<128> log_buf_; \ - llvm::raw_svector_ostream log_os_{log_buf_}; \ + ::wpi::SmallString<128> log_buf_; \ + ::wpi::raw_svector_ostream log_os_{log_buf_}; \ log_os_ << x; \ WPI_logger_.Log(level, __FILE__, __LINE__, log_buf_.c_str()); \ } \ diff --git a/wpiutil/src/main/native/include/llvm/MathExtras.h b/wpiutil/src/main/native/include/wpi/MathExtras.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/MathExtras.h rename to wpiutil/src/main/native/include/wpi/MathExtras.h index a8258bab5b..a64845be0b 100644 --- a/wpiutil/src/main/native/include/llvm/MathExtras.h +++ b/wpiutil/src/main/native/include/wpi/MathExtras.h @@ -14,7 +14,7 @@ #ifndef LLVM_SUPPORT_MATHEXTRAS_H #define LLVM_SUPPORT_MATHEXTRAS_H -#include "llvm/Compiler.h" +#include "wpi/Compiler.h" #include #include #include @@ -27,7 +27,7 @@ #include #endif -namespace llvm { +namespace wpi { /// \brief The behavior an operation has on an input of 0. enum ZeroBehavior { /// \brief The returned value is undefined. @@ -648,6 +648,6 @@ SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed = nullptr) { return SaturatingAdd(A, Product, &Overflowed); } -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/include/tcpsockets/NetworkAcceptor.h b/wpiutil/src/main/native/include/wpi/NetworkAcceptor.h similarity index 96% rename from wpiutil/src/main/native/include/tcpsockets/NetworkAcceptor.h rename to wpiutil/src/main/native/include/wpi/NetworkAcceptor.h index cf75e3c7b4..128aa5e78e 100644 --- a/wpiutil/src/main/native/include/tcpsockets/NetworkAcceptor.h +++ b/wpiutil/src/main/native/include/wpi/NetworkAcceptor.h @@ -10,7 +10,7 @@ #include -#include "tcpsockets/NetworkStream.h" +#include "wpi/NetworkStream.h" namespace wpi { diff --git a/wpiutil/src/main/native/include/tcpsockets/NetworkStream.h b/wpiutil/src/main/native/include/wpi/NetworkStream.h similarity index 94% rename from wpiutil/src/main/native/include/tcpsockets/NetworkStream.h rename to wpiutil/src/main/native/include/wpi/NetworkStream.h index 4798bad6b6..0b8b23d949 100644 --- a/wpiutil/src/main/native/include/tcpsockets/NetworkStream.h +++ b/wpiutil/src/main/native/include/wpi/NetworkStream.h @@ -10,7 +10,7 @@ #include -#include "llvm/StringRef.h" +#include "wpi/StringRef.h" namespace wpi { @@ -31,7 +31,7 @@ class NetworkStream { int timeout = 0) = 0; virtual void close() = 0; - virtual llvm::StringRef getPeerIP() const = 0; + virtual StringRef getPeerIP() const = 0; virtual int getPeerPort() const = 0; virtual void setNoDelay() = 0; diff --git a/wpiutil/src/main/native/include/llvm/None.h b/wpiutil/src/main/native/include/wpi/None.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/None.h rename to wpiutil/src/main/native/include/wpi/None.h index d69ec17c15..7d996945b9 100644 --- a/wpiutil/src/main/native/include/llvm/None.h +++ b/wpiutil/src/main/native/include/wpi/None.h @@ -16,7 +16,7 @@ #ifndef LLVM_ADT_NONE_H #define LLVM_ADT_NONE_H -namespace llvm { +namespace wpi { /// \brief A simple null object to allow implicit construction of Optional /// and similar types without having to spell out the specialization's name. enum class NoneType { None }; diff --git a/wpiutil/src/main/native/include/llvm/Optional.h b/wpiutil/src/main/native/include/wpi/Optional.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/Optional.h rename to wpiutil/src/main/native/include/wpi/Optional.h index a494c560c9..dabf09a752 100644 --- a/wpiutil/src/main/native/include/llvm/Optional.h +++ b/wpiutil/src/main/native/include/wpi/Optional.h @@ -16,14 +16,14 @@ #ifndef LLVM_ADT_OPTIONAL_H #define LLVM_ADT_OPTIONAL_H -#include "llvm/None.h" -#include "llvm/AlignOf.h" -#include "llvm/Compiler.h" +#include "wpi/None.h" +#include "wpi/AlignOf.h" +#include "wpi/Compiler.h" #include #include #include -namespace llvm { +namespace wpi { template class Optional { @@ -223,6 +223,6 @@ void operator>=(const Optional &X, const Optional &Y); template void operator>(const Optional &X, const Optional &Y); -} // end llvm namespace +} // end wpi namespace #endif diff --git a/wpiutil/src/main/native/include/llvm/Path.h b/wpiutil/src/main/native/include/wpi/Path.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/Path.h rename to wpiutil/src/main/native/include/wpi/Path.h index 1431c47b15..5f392354d1 100644 --- a/wpiutil/src/main/native/include/llvm/Path.h +++ b/wpiutil/src/main/native/include/wpi/Path.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file declares the llvm::sys::path namespace. It is designed after +// This file declares the wpi::sys::path namespace. It is designed after // TR2/boost filesystem (v3), but modified to remove exception handling and the // path class. // @@ -16,12 +16,12 @@ #ifndef LLVM_SUPPORT_PATH_H #define LLVM_SUPPORT_PATH_H -#include "llvm/Twine.h" +#include "wpi/Twine.h" #include #include -namespace llvm { +namespace wpi { namespace sys { namespace path { @@ -452,6 +452,6 @@ bool remove_dots(SmallVectorImpl &path, bool remove_dot_dot = false); } // end namespace path } // end namespace sys -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/PointerLikeTypeTraits.h b/wpiutil/src/main/native/include/wpi/PointerLikeTypeTraits.h similarity index 97% rename from wpiutil/src/main/native/include/llvm/PointerLikeTypeTraits.h rename to wpiutil/src/main/native/include/wpi/PointerLikeTypeTraits.h index 3b966945c8..3a27fa3e70 100644 --- a/wpiutil/src/main/native/include/llvm/PointerLikeTypeTraits.h +++ b/wpiutil/src/main/native/include/wpi/PointerLikeTypeTraits.h @@ -15,10 +15,10 @@ #ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H #define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H -#include "llvm/AlignOf.h" +#include "wpi/AlignOf.h" #include -namespace llvm { +namespace wpi { /// A traits type that is used to handle pointer types and things that are just /// wrappers for pointers as a uniform entity. @@ -89,6 +89,6 @@ public: enum { NumLowBitsAvailable = 0 }; }; -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/STLExtras.h b/wpiutil/src/main/native/include/wpi/STLExtras.h similarity index 97% rename from wpiutil/src/main/native/include/llvm/STLExtras.h rename to wpiutil/src/main/native/include/wpi/STLExtras.h index 1b43f30477..daaf4ab44a 100644 --- a/wpiutil/src/main/native/include/llvm/STLExtras.h +++ b/wpiutil/src/main/native/include/wpi/STLExtras.h @@ -26,10 +26,10 @@ #include #include // for std::pair -#include "llvm/iterator_range.h" -#include "llvm/Compiler.h" +#include "wpi/iterator_range.h" +#include "wpi/Compiler.h" -namespace llvm { +namespace wpi { //===----------------------------------------------------------------------===// // Extra additions to @@ -229,10 +229,10 @@ template auto reverse( ContainerTy &&C, typename std::enable_if::value>::type * = nullptr) - -> decltype(make_range(llvm::make_reverse_iterator(std::end(C)), - llvm::make_reverse_iterator(std::begin(C)))) { - return make_range(llvm::make_reverse_iterator(std::end(C)), - llvm::make_reverse_iterator(std::begin(C))); + -> decltype(make_range(wpi::make_reverse_iterator(std::end(C)), + wpi::make_reverse_iterator(std::begin(C)))) { + return make_range(wpi::make_reverse_iterator(std::end(C)), + wpi::make_reverse_iterator(std::begin(C))); } //===----------------------------------------------------------------------===// @@ -516,6 +516,6 @@ template struct deref { } }; -} // End llvm namespace +} // End wpi namespace #endif diff --git a/wpiutil/src/main/native/include/support/SafeThread.h b/wpiutil/src/main/native/include/wpi/SafeThread.h similarity index 98% rename from wpiutil/src/main/native/include/support/SafeThread.h rename to wpiutil/src/main/native/include/wpi/SafeThread.h index d09faf8344..d1faa3dbb5 100644 --- a/wpiutil/src/main/native/include/support/SafeThread.h +++ b/wpiutil/src/main/native/include/wpi/SafeThread.h @@ -11,8 +11,8 @@ #include #include -#include "support/condition_variable.h" -#include "support/mutex.h" +#include "wpi/condition_variable.h" +#include "wpi/mutex.h" namespace wpi { diff --git a/wpiutil/src/main/native/include/llvm/SmallPtrSet.h b/wpiutil/src/main/native/include/wpi/SmallPtrSet.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/SmallPtrSet.h rename to wpiutil/src/main/native/include/wpi/SmallPtrSet.h index b78e1fd822..397c630238 100644 --- a/wpiutil/src/main/native/include/llvm/SmallPtrSet.h +++ b/wpiutil/src/main/native/include/wpi/SmallPtrSet.h @@ -15,8 +15,8 @@ #ifndef LLVM_ADT_SMALLPTRSET_H #define LLVM_ADT_SMALLPTRSET_H -#include "llvm/Compiler.h" -#include "llvm/PointerLikeTypeTraits.h" +#include "wpi/Compiler.h" +#include "wpi/PointerLikeTypeTraits.h" #include #include #include @@ -25,7 +25,7 @@ #include #include -namespace llvm { +namespace wpi { class SmallPtrSetIteratorImpl; @@ -398,7 +398,7 @@ public: namespace std { /// Implement std::swap in terms of SmallPtrSet swap. template - inline void swap(llvm::SmallPtrSet &LHS, llvm::SmallPtrSet &RHS) { + inline void swap(wpi::SmallPtrSet &LHS, wpi::SmallPtrSet &RHS) { LHS.swap(RHS); } } diff --git a/wpiutil/src/main/native/include/llvm/SmallSet.h b/wpiutil/src/main/native/include/wpi/SmallSet.h similarity index 97% rename from wpiutil/src/main/native/include/llvm/SmallSet.h rename to wpiutil/src/main/native/include/wpi/SmallSet.h index 3dfd1f9bd9..cc08d80b5c 100644 --- a/wpiutil/src/main/native/include/llvm/SmallSet.h +++ b/wpiutil/src/main/native/include/wpi/SmallSet.h @@ -14,12 +14,12 @@ #ifndef LLVM_ADT_SMALLSET_H #define LLVM_ADT_SMALLSET_H -#include "llvm/None.h" -#include "llvm/SmallPtrSet.h" -#include "llvm/SmallVector.h" +#include "wpi/None.h" +#include "wpi/SmallPtrSet.h" +#include "wpi/SmallVector.h" #include -namespace llvm { +namespace wpi { /// SmallSet - This maintains a set of unique values, optimizing for the case /// when the set is small (less than N). In this case, the set can be @@ -131,6 +131,6 @@ private: template class SmallSet : public SmallPtrSet {}; -} // end namespace llvm +} // end namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/SmallString.h b/wpiutil/src/main/native/include/wpi/SmallString.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/SmallString.h rename to wpiutil/src/main/native/include/wpi/SmallString.h index 4c60c9b5d5..6e92770ce7 100644 --- a/wpiutil/src/main/native/include/llvm/SmallString.h +++ b/wpiutil/src/main/native/include/wpi/SmallString.h @@ -14,10 +14,10 @@ #ifndef LLVM_ADT_SMALLSTRING_H #define LLVM_ADT_SMALLSTRING_H -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" -namespace llvm { +namespace wpi { /// SmallString - A SmallString is just a SmallVector with methods and accessors /// that make it work better as a string (e.g. operator+ etc). diff --git a/wpiutil/src/main/native/include/llvm/SmallVector.h b/wpiutil/src/main/native/include/wpi/SmallVector.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/SmallVector.h rename to wpiutil/src/main/native/include/wpi/SmallVector.h index 0f9c73baa0..be2b66ed21 100644 --- a/wpiutil/src/main/native/include/llvm/SmallVector.h +++ b/wpiutil/src/main/native/include/wpi/SmallVector.h @@ -14,11 +14,11 @@ #ifndef LLVM_ADT_SMALLVECTOR_H #define LLVM_ADT_SMALLVECTOR_H -#include "llvm/iterator_range.h" -#include "llvm/AlignOf.h" -#include "llvm/Compiler.h" -#include "llvm/MathExtras.h" -#include "llvm/type_traits.h" +#include "wpi/iterator_range.h" +#include "wpi/AlignOf.h" +#include "wpi/Compiler.h" +#include "wpi/MathExtras.h" +#include "wpi/type_traits.h" #include #include #include @@ -28,7 +28,7 @@ #include #include -namespace llvm { +namespace wpi { /// This is all the non-templated stuff common to all SmallVectors. class SmallVectorBase { @@ -70,7 +70,7 @@ private: // Allocate raw space for N elements of type T. If T has a ctor or dtor, we // don't want it to be automatically run, so we need to represent the space as // something else. Use an array of char of sufficient alignment. - typedef llvm::AlignedCharArrayUnion U; + typedef wpi::AlignedCharArrayUnion U; U FirstEl; // Space after 'FirstEl' is clobbered, do not add any instance vars after it. @@ -849,7 +849,7 @@ public: } template - explicit SmallVector(const llvm::iterator_range R) + explicit SmallVector(const wpi::iterator_range R) : SmallVectorImpl(N) { this->append(R.begin(), R.end()); } @@ -899,20 +899,20 @@ static inline size_t capacity_in_bytes(const SmallVector &X) { return X.capacity_in_bytes(); } -} // End llvm namespace +} // End wpi namespace namespace std { /// Implement std::swap in terms of SmallVector swap. template inline void - swap(llvm::SmallVectorImpl &LHS, llvm::SmallVectorImpl &RHS) { + swap(wpi::SmallVectorImpl &LHS, wpi::SmallVectorImpl &RHS) { LHS.swap(RHS); } /// Implement std::swap in terms of SmallVector swap. template inline void - swap(llvm::SmallVector &LHS, llvm::SmallVector &RHS) { + swap(wpi::SmallVector &LHS, wpi::SmallVector &RHS) { LHS.swap(RHS); } } diff --git a/wpiutil/src/main/native/include/tcpsockets/SocketError.h b/wpiutil/src/main/native/include/wpi/SocketError.h similarity index 100% rename from wpiutil/src/main/native/include/tcpsockets/SocketError.h rename to wpiutil/src/main/native/include/wpi/SocketError.h diff --git a/wpiutil/src/main/native/include/llvm/StringExtras.h b/wpiutil/src/main/native/include/wpi/StringExtras.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/StringExtras.h rename to wpiutil/src/main/native/include/wpi/StringExtras.h index 9cf468a789..cc78b08ad4 100644 --- a/wpiutil/src/main/native/include/llvm/StringExtras.h +++ b/wpiutil/src/main/native/include/wpi/StringExtras.h @@ -14,11 +14,11 @@ #ifndef LLVM_ADT_STRINGEXTRAS_H #define LLVM_ADT_STRINGEXTRAS_H -#include "llvm/StringRef.h" +#include "wpi/StringRef.h" #include #include -namespace llvm { +namespace wpi { template class SmallVectorImpl; /// hexdigit - Return the hexadecimal character for the @@ -192,6 +192,6 @@ inline std::string join(IteratorT Begin, IteratorT End, StringRef Separator) { return join_impl(Begin, End, Separator, tag()); } -} // End llvm namespace +} // End wpi namespace #endif diff --git a/wpiutil/src/main/native/include/llvm/StringMap.h b/wpiutil/src/main/native/include/wpi/StringMap.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/StringMap.h rename to wpiutil/src/main/native/include/wpi/StringMap.h index 615bdb497f..a6b9375163 100644 --- a/wpiutil/src/main/native/include/llvm/StringMap.h +++ b/wpiutil/src/main/native/include/wpi/StringMap.h @@ -14,15 +14,15 @@ #ifndef LLVM_ADT_STRINGMAP_H #define LLVM_ADT_STRINGMAP_H -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" -#include "llvm/PointerLikeTypeTraits.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" +#include "wpi/PointerLikeTypeTraits.h" #include #include #include #include -namespace llvm { +namespace wpi { template class StringMapConstIterator; template @@ -558,6 +558,6 @@ inline bool operator>=(const StringMap& lhs, return !(lhs < rhs); } -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/include/llvm/StringRef.h b/wpiutil/src/main/native/include/wpi/StringRef.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/StringRef.h rename to wpiutil/src/main/native/include/wpi/StringRef.h index 7f149b30a0..56382b7ed4 100644 --- a/wpiutil/src/main/native/include/llvm/StringRef.h +++ b/wpiutil/src/main/native/include/wpi/StringRef.h @@ -10,8 +10,8 @@ #ifndef LLVM_ADT_STRINGREF_H #define LLVM_ADT_STRINGREF_H -#include "llvm/iterator_range.h" -#include "llvm/Compiler.h" +#include "wpi/iterator_range.h" +#include "wpi/Compiler.h" #include #include #include @@ -20,7 +20,7 @@ #include #include -namespace llvm { +namespace wpi { template class SmallVectorImpl; class hash_code; @@ -140,7 +140,7 @@ namespace llvm { /// c_str - Get a null terminated pointer to the start of the string /// If string is not null terminated, use buffer to store new string - const char *c_str(llvm::SmallVectorImpl& buf) const; + const char *c_str(wpi::SmallVectorImpl& buf) const; /// empty - Check if the string is empty. bool empty() const { return size() == 0; } @@ -621,6 +621,6 @@ namespace llvm { // StringRefs can be treated like a POD type. template struct isPodLike; template <> struct isPodLike { static const bool value = true; }; -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/include/tcpsockets/TCPAcceptor.h b/wpiutil/src/main/native/include/wpi/TCPAcceptor.h similarity index 95% rename from wpiutil/src/main/native/include/tcpsockets/TCPAcceptor.h rename to wpiutil/src/main/native/include/wpi/TCPAcceptor.h index d20545d35d..bd1526d4c5 100644 --- a/wpiutil/src/main/native/include/tcpsockets/TCPAcceptor.h +++ b/wpiutil/src/main/native/include/wpi/TCPAcceptor.h @@ -28,8 +28,8 @@ #include #include -#include "tcpsockets/NetworkAcceptor.h" -#include "tcpsockets/TCPStream.h" +#include "wpi/NetworkAcceptor.h" +#include "wpi/TCPStream.h" namespace wpi { diff --git a/wpiutil/src/main/native/include/tcpsockets/TCPConnector.h b/wpiutil/src/main/native/include/wpi/TCPConnector.h similarity index 90% rename from wpiutil/src/main/native/include/tcpsockets/TCPConnector.h rename to wpiutil/src/main/native/include/wpi/TCPConnector.h index 9d2535bd80..d383306a30 100644 --- a/wpiutil/src/main/native/include/tcpsockets/TCPConnector.h +++ b/wpiutil/src/main/native/include/wpi/TCPConnector.h @@ -27,8 +27,8 @@ #include #include -#include "llvm/ArrayRef.h" -#include "tcpsockets/NetworkStream.h" +#include "wpi/ArrayRef.h" +#include "wpi/NetworkStream.h" namespace wpi { @@ -40,7 +40,7 @@ class TCPConnector { Logger& logger, int timeout = 0); static std::unique_ptr connect_parallel( - llvm::ArrayRef> servers, Logger& logger, + ArrayRef> servers, Logger& logger, int timeout = 0); }; diff --git a/wpiutil/src/main/native/include/tcpsockets/TCPStream.h b/wpiutil/src/main/native/include/wpi/TCPStream.h similarity index 95% rename from wpiutil/src/main/native/include/tcpsockets/TCPStream.h rename to wpiutil/src/main/native/include/wpi/TCPStream.h index 9e80bbc58f..e40cca8913 100644 --- a/wpiutil/src/main/native/include/tcpsockets/TCPStream.h +++ b/wpiutil/src/main/native/include/wpi/TCPStream.h @@ -27,7 +27,7 @@ #include #include -#include "tcpsockets/NetworkStream.h" +#include "wpi/NetworkStream.h" struct sockaddr_in; @@ -50,7 +50,7 @@ class TCPStream : public NetworkStream { int timeout = 0) override; void close() override; - llvm::StringRef getPeerIP() const override; + StringRef getPeerIP() const override; int getPeerPort() const override; void setNoDelay() override; bool setBlocking(bool enabled) override; diff --git a/wpiutil/src/main/native/include/llvm/Twine.h b/wpiutil/src/main/native/include/wpi/Twine.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/Twine.h rename to wpiutil/src/main/native/include/wpi/Twine.h index 82687aa96c..b24f5705a1 100644 --- a/wpiutil/src/main/native/include/llvm/Twine.h +++ b/wpiutil/src/main/native/include/wpi/Twine.h @@ -10,14 +10,14 @@ #ifndef LLVM_ADT_TWINE_H #define LLVM_ADT_TWINE_H -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" #include #include #include -namespace llvm { +namespace wpi { class raw_ostream; /// Twine - A lightweight data structure for efficiently representing the diff --git a/wpiutil/src/main/native/include/udpsockets/UDPClient.h b/wpiutil/src/main/native/include/wpi/UDPClient.h similarity index 79% rename from wpiutil/src/main/native/include/udpsockets/UDPClient.h rename to wpiutil/src/main/native/include/wpi/UDPClient.h index e6cd6e0eef..5329ac7214 100644 --- a/wpiutil/src/main/native/include/udpsockets/UDPClient.h +++ b/wpiutil/src/main/native/include/wpi/UDPClient.h @@ -10,9 +10,9 @@ #include -#include "llvm/ArrayRef.h" -#include "llvm/StringRef.h" -#include "support/mutex.h" +#include "wpi/ArrayRef.h" +#include "wpi/StringRef.h" +#include "wpi/mutex.h" namespace wpi { @@ -25,7 +25,7 @@ class UDPClient { public: explicit UDPClient(Logger& logger); - UDPClient(llvm::StringRef address, Logger& logger); + UDPClient(StringRef address, Logger& logger); UDPClient(const UDPClient& other) = delete; UDPClient(UDPClient&& other); ~UDPClient(); @@ -36,8 +36,8 @@ class UDPClient { int start(); void shutdown(); // The passed in address MUST be a resolved IP address. - int send(llvm::ArrayRef data, llvm::StringRef server, int port); - int send(llvm::StringRef data, llvm::StringRef server, int port); + int send(ArrayRef data, StringRef server, int port); + int send(StringRef data, StringRef server, int port); }; } // namespace wpi diff --git a/wpiutil/src/main/native/include/support/UidVector.h b/wpiutil/src/main/native/include/wpi/UidVector.h similarity index 100% rename from wpiutil/src/main/native/include/support/UidVector.h rename to wpiutil/src/main/native/include/wpi/UidVector.h diff --git a/wpiutil/src/main/native/include/llvm/WindowsError.h b/wpiutil/src/main/native/include/wpi/WindowsError.h similarity index 96% rename from wpiutil/src/main/native/include/llvm/WindowsError.h rename to wpiutil/src/main/native/include/wpi/WindowsError.h index 63bfe59765..03935ece5c 100644 --- a/wpiutil/src/main/native/include/llvm/WindowsError.h +++ b/wpiutil/src/main/native/include/wpi/WindowsError.h @@ -12,7 +12,7 @@ #include -namespace llvm { +namespace wpi { std::error_code mapWindowsError(unsigned EV); } diff --git a/wpiutil/src/main/native/include/support/atomic_static.h b/wpiutil/src/main/native/include/wpi/atomic_static.h similarity index 100% rename from wpiutil/src/main/native/include/support/atomic_static.h rename to wpiutil/src/main/native/include/wpi/atomic_static.h diff --git a/wpiutil/src/main/native/include/support/condition_variable.h b/wpiutil/src/main/native/include/wpi/condition_variable.h similarity index 100% rename from wpiutil/src/main/native/include/support/condition_variable.h rename to wpiutil/src/main/native/include/wpi/condition_variable.h diff --git a/wpiutil/src/main/native/include/support/deprecated.h b/wpiutil/src/main/native/include/wpi/deprecated.h similarity index 100% rename from wpiutil/src/main/native/include/support/deprecated.h rename to wpiutil/src/main/native/include/wpi/deprecated.h diff --git a/wpiutil/src/main/native/include/support/hostname.h b/wpiutil/src/main/native/include/wpi/hostname.h similarity index 84% rename from wpiutil/src/main/native/include/support/hostname.h rename to wpiutil/src/main/native/include/wpi/hostname.h index 19e372a6e8..5da983b70c 100644 --- a/wpiutil/src/main/native/include/support/hostname.h +++ b/wpiutil/src/main/native/include/wpi/hostname.h @@ -10,16 +10,14 @@ #include -#include "llvm/StringRef.h" - -namespace llvm { -template -class SmallVectorImpl; -} // namespace llvm +#include "wpi/StringRef.h" namespace wpi { +template +class SmallVectorImpl; + std::string GetHostname(); -llvm::StringRef GetHostname(llvm::SmallVectorImpl& name); +StringRef GetHostname(SmallVectorImpl& name); } // namespace wpi #endif // WPIUTIL_SUPPORT_HOSTNAME_H_ diff --git a/wpiutil/src/main/native/include/llvm/iterator_range.h b/wpiutil/src/main/native/include/wpi/iterator_range.h similarity index 99% rename from wpiutil/src/main/native/include/llvm/iterator_range.h rename to wpiutil/src/main/native/include/wpi/iterator_range.h index 3dd679bd9b..ea37eb1b90 100644 --- a/wpiutil/src/main/native/include/llvm/iterator_range.h +++ b/wpiutil/src/main/native/include/wpi/iterator_range.h @@ -22,7 +22,7 @@ #include #include -namespace llvm { +namespace wpi { /// \brief A range adaptor for a pair of iterators. /// diff --git a/wpiutil/src/main/native/include/support/jni_util.h b/wpiutil/src/main/native/include/wpi/jni_util.h similarity index 86% rename from wpiutil/src/main/native/include/support/jni_util.h rename to wpiutil/src/main/native/include/wpi/jni_util.h index 2b905a0b6e..286eff685d 100644 --- a/wpiutil/src/main/native/include/support/jni_util.h +++ b/wpiutil/src/main/native/include/wpi/jni_util.h @@ -16,16 +16,16 @@ #include #include -#include "llvm/ArrayRef.h" -#include "llvm/ConvertUTF.h" -#include "llvm/SmallString.h" -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" -#include "llvm/raw_ostream.h" -#include "support/SafeThread.h" -#include "support/atomic_static.h" -#include "support/deprecated.h" -#include "support/mutex.h" +#include "wpi/ArrayRef.h" +#include "wpi/ConvertUTF.h" +#include "wpi/SafeThread.h" +#include "wpi/SmallString.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" +#include "wpi/atomic_static.h" +#include "wpi/deprecated.h" +#include "wpi/mutex.h" +#include "wpi/raw_ostream.h" namespace wpi { namespace java { @@ -33,9 +33,8 @@ namespace java { // Gets a Java stack trace. Also provides the last function // in the stack trace not starting with excludeFuncPrefix (useful for e.g. // finding the first user call to a series of library functions). -std::string GetJavaStackTrace( - JNIEnv* env, std::string* func = nullptr, - llvm::StringRef excludeFuncPrefix = llvm::StringRef()); +std::string GetJavaStackTrace(JNIEnv* env, std::string* func = nullptr, + StringRef excludeFuncPrefix = StringRef()); // Shim for backwards compatibility template @@ -43,7 +42,7 @@ WPI_DEPRECATED("use StringRef function instead") std::string GetJavaStackTrace(JNIEnv* env, std::string* func) { return GetJavaStackTrace( env, func, - excludeFuncPrefix == nullptr ? llvm::StringRef() : excludeFuncPrefix); + excludeFuncPrefix == nullptr ? StringRef() : excludeFuncPrefix); } @@ -139,25 +138,25 @@ class JStringRef { jsize size = env->GetStringLength(str); const jchar* chars = env->GetStringCritical(str, nullptr); if (chars) { - llvm::convertUTF16ToUTF8String(llvm::makeArrayRef(chars, size), m_str); + convertUTF16ToUTF8String(makeArrayRef(chars, size), m_str); env->ReleaseStringCritical(str, chars); } } else { - llvm::errs() << "JStringRef was passed a null pointer at \n" - << GetJavaStackTrace(env); + errs() << "JStringRef was passed a null pointer at \n" + << GetJavaStackTrace(env); } // Ensure str is null-terminated. m_str.push_back('\0'); m_str.pop_back(); } - operator llvm::StringRef() const { return m_str; } - llvm::StringRef str() const { return m_str; } + operator StringRef() const { return m_str; } + StringRef str() const { return m_str; } const char* c_str() const { return m_str.data(); } size_t size() const { return m_str.size(); } private: - llvm::SmallString<128> m_str; + SmallString<128> m_str; }; // Details for J*ArrayRef and CriticalJ*ArrayRef @@ -170,13 +169,12 @@ class JArrayRefInner {}; template class JArrayRefInner { public: - operator llvm::StringRef() const { return str(); } + operator StringRef() const { return str(); } - llvm::StringRef str() const { + StringRef str() const { auto arr = static_cast(this)->array(); - if (arr.empty()) return llvm::StringRef{}; - return llvm::StringRef{reinterpret_cast(arr.data()), - arr.size()}; + if (arr.empty()) return StringRef{}; + return StringRef{reinterpret_cast(arr.data()), arr.size()}; } }; @@ -186,11 +184,11 @@ class JArrayRefBase : public JArrayRefInner, T> { public: explicit operator bool() const { return this->m_elements != nullptr; } - operator llvm::ArrayRef() const { return array(); } + operator ArrayRef() const { return array(); } - llvm::ArrayRef array() const { - if (!this->m_elements) return llvm::ArrayRef{}; - return llvm::ArrayRef{this->m_elements, this->m_size}; + ArrayRef array() const { + if (!this->m_elements) return ArrayRef{}; + return ArrayRef{this->m_elements, this->m_size}; } JArrayRefBase(const JArrayRefBase&) = delete; @@ -249,16 +247,16 @@ class JArrayRefBase : public JArrayRefInner, T> { static_cast(bb ? env->GetDirectBufferAddress(bb) : nullptr), \ len) { \ if (!bb) \ - llvm::errs() << "JArrayRef was passed a null pointer at \n" \ - << GetJavaStackTrace(env); \ + errs() << "JArrayRef was passed a null pointer at \n" \ + << GetJavaStackTrace(env); \ } \ J##F##ArrayRef(JNIEnv* env, T##Array jarr) \ : detail::JArrayRefBase(env, jarr) { \ if (jarr) \ m_elements = env->Get##F##ArrayElements(jarr, nullptr); \ else \ - llvm::errs() << "JArrayRef was passed a null pointer at \n" \ - << GetJavaStackTrace(env); \ + errs() << "JArrayRef was passed a null pointer at \n" \ + << GetJavaStackTrace(env); \ } \ ~J##F##ArrayRef() { \ if (m_jarr && m_elements) \ @@ -275,8 +273,8 @@ class JArrayRefBase : public JArrayRefInner, T> { m_elements = \ static_cast(env->GetPrimitiveArrayCritical(jarr, nullptr)); \ else \ - llvm::errs() << "JArrayRef was passed a null pointer at \n" \ - << GetJavaStackTrace(env); \ + errs() << "JArrayRef was passed a null pointer at \n" \ + << GetJavaStackTrace(env); \ } \ ~CriticalJ##F##ArrayRef() { \ if (m_jarr && m_elements) \ @@ -299,9 +297,9 @@ WPI_JNI_JARRAYREF(jdouble, Double) // // Convert a UTF8 string into a jstring. -inline jstring MakeJString(JNIEnv* env, llvm::StringRef str) { - llvm::SmallVector chars; - llvm::convertUTF8ToUTF16String(str, chars); +inline jstring MakeJString(JNIEnv* env, StringRef str) { + SmallVector chars; + convertUTF8ToUTF16String(str, chars); return env->NewString(chars.begin(), chars.size()); } @@ -314,7 +312,7 @@ namespace detail { template ::value && sizeof(jint) == sizeof(T))> struct ConvertIntArray { - static jintArray ToJava(JNIEnv* env, llvm::ArrayRef arr) { + static jintArray ToJava(JNIEnv* env, ArrayRef arr) { jintArray jarr = env->NewIntArray(arr.size()); if (!jarr) return nullptr; jint* elements = @@ -330,7 +328,7 @@ struct ConvertIntArray { // Fast path (use SetIntArrayRegion) template struct ConvertIntArray { - static jintArray ToJava(JNIEnv* env, llvm::ArrayRef arr) { + static jintArray ToJava(JNIEnv* env, ArrayRef arr) { jintArray jarr = env->NewIntArray(arr.size()); if (!jarr) return nullptr; env->SetIntArrayRegion(jarr, 0, arr.size(), @@ -343,15 +341,14 @@ struct ConvertIntArray { // Convert an ArrayRef to a jintArray. template -inline jintArray MakeJIntArray(JNIEnv* env, llvm::ArrayRef arr) { +inline jintArray MakeJIntArray(JNIEnv* env, ArrayRef arr) { return detail::ConvertIntArray::ToJava(env, arr); } // Convert a SmallVector to a jintArray. This is required in addition to // ArrayRef because template resolution occurs prior to implicit conversions. template -inline jintArray MakeJIntArray(JNIEnv* env, - const llvm::SmallVectorImpl& arr) { +inline jintArray MakeJIntArray(JNIEnv* env, const SmallVectorImpl& arr) { return detail::ConvertIntArray::ToJava(env, arr); } @@ -363,7 +360,7 @@ inline jintArray MakeJIntArray(JNIEnv* env, const std::vector& arr) { } // Convert a StringRef into a jbyteArray. -inline jbyteArray MakeJByteArray(JNIEnv* env, llvm::StringRef str) { +inline jbyteArray MakeJByteArray(JNIEnv* env, StringRef str) { jbyteArray jarr = env->NewByteArray(str.size()); if (!jarr) return nullptr; env->SetByteArrayRegion(jarr, 0, str.size(), @@ -372,7 +369,7 @@ inline jbyteArray MakeJByteArray(JNIEnv* env, llvm::StringRef str) { } // Convert an array of integers into a jbooleanArray. -inline jbooleanArray MakeJBooleanArray(JNIEnv* env, llvm::ArrayRef arr) { +inline jbooleanArray MakeJBooleanArray(JNIEnv* env, ArrayRef arr) { jbooleanArray jarr = env->NewBooleanArray(arr.size()); if (!jarr) return nullptr; jboolean* elements = @@ -385,7 +382,7 @@ inline jbooleanArray MakeJBooleanArray(JNIEnv* env, llvm::ArrayRef arr) { } // Convert an array of booleans into a jbooleanArray. -inline jbooleanArray MakeJBooleanArray(JNIEnv* env, llvm::ArrayRef arr) { +inline jbooleanArray MakeJBooleanArray(JNIEnv* env, ArrayRef arr) { jbooleanArray jarr = env->NewBooleanArray(arr.size()); if (!jarr) return nullptr; jboolean* elements = @@ -397,14 +394,14 @@ inline jbooleanArray MakeJBooleanArray(JNIEnv* env, llvm::ArrayRef arr) { return jarr; } - // Other MakeJ*Array conversions. +// Other MakeJ*Array conversions. -#define WPI_JNI_MAKEJARRAY(T, F) \ - inline T##Array MakeJ##F##Array(JNIEnv* env, llvm::ArrayRef arr) { \ - T##Array jarr = env->New##F##Array(arr.size()); \ - if (!jarr) return nullptr; \ - env->Set##F##ArrayRegion(jarr, 0, arr.size(), arr.data()); \ - return jarr; \ +#define WPI_JNI_MAKEJARRAY(T, F) \ + inline T##Array MakeJ##F##Array(JNIEnv* env, ArrayRef arr) { \ + T##Array jarr = env->New##F##Array(arr.size()); \ + if (!jarr) return nullptr; \ + env->Set##F##ArrayRegion(jarr, 0, arr.size(), arr.data()); \ + return jarr; \ } WPI_JNI_MAKEJARRAY(jboolean, Boolean) @@ -417,8 +414,7 @@ WPI_JNI_MAKEJARRAY(jdouble, Double) #undef WPI_JNI_MAKEJARRAY // Convert an array of std::string into a jarray of jstring. -inline jobjectArray MakeJStringArray(JNIEnv* env, - llvm::ArrayRef arr) { +inline jobjectArray MakeJStringArray(JNIEnv* env, ArrayRef arr) { static JClass stringCls{env, "java/lang/String"}; if (!stringCls) return nullptr; jobjectArray jarr = env->NewObjectArray(arr.size(), stringCls, nullptr); @@ -535,7 +531,7 @@ class JSingletonCallbackManager : public JCallbackManager { }; inline std::string GetJavaStackTrace(JNIEnv* env, std::string* func, - llvm::StringRef excludeFuncPrefix) { + StringRef excludeFuncPrefix) { // create a throwable static JClass throwableCls(env, "java/lang/Throwable"); if (!throwableCls) return ""; @@ -572,7 +568,7 @@ inline std::string GetJavaStackTrace(JNIEnv* env, std::string* func, bool haveLoc = false; std::string buf; - llvm::raw_string_ostream oss(buf); + raw_string_ostream oss(buf); for (jsize i = 0; i < stackTraceLength; i++) { // add the result of toString method of each element in the result JLocal curStackTraceElement( @@ -623,9 +619,7 @@ class JException : public JClass { env->Throw(static_cast(exception)); } - void Throw(JNIEnv* env, llvm::StringRef msg) { - Throw(env, MakeJString(env, msg)); - } + void Throw(JNIEnv* env, StringRef msg) { Throw(env, MakeJString(env, msg)); } explicit operator bool() const { return m_constructor; } diff --git a/wpiutil/src/main/native/include/support/json.h b/wpiutil/src/main/native/include/wpi/json.h similarity index 98% rename from wpiutil/src/main/native/include/support/json.h rename to wpiutil/src/main/native/include/wpi/json.h index 6e4b33d4ba..5ed6cf24f6 100644 --- a/wpiutil/src/main/native/include/support/json.h +++ b/wpiutil/src/main/native/include/wpi/json.h @@ -51,10 +51,10 @@ SOFTWARE. #include // declval, forward, make_pair, move, pair, swap #include // vector -#include "llvm/ArrayRef.h" -#include "llvm/raw_ostream.h" -#include "llvm/StringMap.h" -#include "llvm/StringRef.h" +#include "wpi/ArrayRef.h" +#include "wpi/raw_ostream.h" +#include "wpi/StringMap.h" +#include "wpi/StringRef.h" // exclude unsupported compilers #if defined(__clang__) @@ -476,7 +476,7 @@ template<> struct external_constructor { template - static void construct(BasicJsonType& j, llvm::StringRef s) + static void construct(BasicJsonType& j, StringRef s) { j.m_type = value_t::string; j.m_value = s; @@ -532,7 +532,7 @@ struct external_constructor } template - static void construct(BasicJsonType& j, llvm::ArrayRef arr) + static void construct(BasicJsonType& j, ArrayRef arr) { using std::begin; using std::end; @@ -636,7 +636,7 @@ template struct is_compatible_object_type_impl { static constexpr auto value = - std::is_constructible::value && std::is_constructible::value; @@ -666,7 +666,7 @@ struct is_compatible_array_type static auto constexpr value = conjunction>, negation>, - negation>, + negation>, negation>, has_value_type, has_iterator>::value; @@ -712,7 +712,7 @@ void to_json(BasicJsonType& j, T b) noexcept } template::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleString& s) @@ -766,7 +766,7 @@ void to_json(BasicJsonType& j, const std::vector& e) template inline -void to_json(BasicJsonType& j, llvm::ArrayRef arr) +void to_json(BasicJsonType& j, ArrayRef arr) { external_constructor::construct(j, arr); } @@ -795,7 +795,7 @@ void to_json(BasicJsonType& j, const CompatibleObjectType& arr) template ::value, + StringRef, T (&)[N]>::value, int> = 0> inline void to_json(BasicJsonType& j, T (&arr)[N]) @@ -804,7 +804,7 @@ void to_json(BasicJsonType& j, T (&arr)[N]) } template ::value, int> = 0> inline void to_json(BasicJsonType& j, std::pair const& p) @@ -1048,7 +1048,7 @@ void from_json(const BasicJsonType& j, ArithmeticType& val) } template ::value, int> = 0> void from_json(const BasicJsonType& j, std::pair& p) { @@ -1363,7 +1363,7 @@ class json 7159](http://rfc7159.net/rfc7159), because any order implements the specified "unordered" nature of JSON objects. */ - using object_t = llvm::StringMap; + using object_t = StringMap; /*! @brief a type for an array @@ -1754,7 +1754,7 @@ class json json_value(value_t t); /// constructor for strings - json_value(llvm::StringRef value); + json_value(StringRef value); json_value(const std::string& value); /// constructor for objects @@ -1816,7 +1816,7 @@ class json @brief per-element parser callback type With a parser callback function, the result of parsing a JSON text can be - influenced. When passed to @ref parse(wpi::raw_istream&, const + influenced. When passed to @ref parse(raw_istream&, const parser_callback_t) or @ref parse(const CharT, const parser_callback_t), it is called on certain events (passed as @ref parse_event_t via parameter @a event) with a set recursion depth @a depth and context JSON value @@ -1859,7 +1859,7 @@ class json should be kept (`true`) or not (`false`). In the latter case, it is either skipped completely or replaced by an empty discarded object. - @sa @ref parse(wpi::raw_istream&, parser_callback_t) or + @sa @ref parse(raw_istream&, parser_callback_t) or @ref parse(const CharT, const parser_callback_t) for examples @since version 1.0.0 @@ -1962,7 +1962,7 @@ class json See the examples below. @tparam CompatibleType a type such that: - - @a CompatibleType is not derived from `wpi::raw_istream`, + - @a CompatibleType is not derived from `raw_istream`, - @a CompatibleType is not @ref json (to avoid hijacking copy/move constructors), - @a CompatibleType is not a @ref json nested type (e.g., @@ -1986,7 +1986,7 @@ class json @since version 2.1.0 */ template, - detail::enable_if_t::value && + detail::enable_if_t::value && !std::is_same::value && !detail::is_json_nested_type::value, int> = 0> @@ -2477,7 +2477,7 @@ class json @since version 1.0.0; indentaction character added in version 3.0.0 */ - void dump(llvm::raw_ostream& os, int indent = -1) const; + void dump(raw_ostream& os, int indent = -1) const; /*! @brief return the type of the JSON value (explicit) @@ -3354,7 +3354,7 @@ class json @complexity Logarithmic in the size of the container. - @sa @ref operator[](llvm::StringRef) for unchecked + @sa @ref operator[](StringRef) for unchecked access by reference @sa @ref value() for access by value with a default value @@ -3364,7 +3364,7 @@ class json written using `at()`. It also demonstrates the different exceptions that can be thrown.,at__object_t_key_type} */ - reference at(llvm::StringRef key); + reference at(StringRef key); /*! @brief access specified object element with bounds checking @@ -3386,7 +3386,7 @@ class json @complexity Logarithmic in the size of the container. - @sa @ref operator[](llvm::StringRef) for unchecked + @sa @ref operator[](StringRef) for unchecked access by reference @sa @ref value() for access by value with a default value @@ -3396,7 +3396,7 @@ class json `at()`. It also demonstrates the different exceptions that can be thrown., at__object_t_key_type_const} */ - const_reference at(llvm::StringRef key) const; + const_reference at(StringRef key) const; /*! @brief access specified array element @@ -3467,13 +3467,13 @@ class json @liveexample{The example below shows how object elements can be read and written using the `[]` operator.,operatorarray__key_type} - @sa @ref at(llvm::StringRef) for access by reference + @sa @ref at(StringRef) for access by reference with range checking @sa @ref value() for access by value with a default value @since version 1.0.0 */ - reference operator[](llvm::StringRef key); + reference operator[](StringRef key); /*! @brief read-only access specified object element @@ -3499,13 +3499,13 @@ class json @liveexample{The example below shows how object elements can be read using the `[]` operator.,operatorarray__key_type_const} - @sa @ref at(llvm::StringRef) for access by reference + @sa @ref at(StringRef) for access by reference with range checking @sa @ref value() for access by value with a default value @since version 1.0.0 */ - const_reference operator[](llvm::StringRef key) const; + const_reference operator[](StringRef key) const; /*! @brief access specified object element @@ -3605,7 +3605,7 @@ class json template reference operator[](T* key) { - return this->operator[](llvm::StringRef(key)); + return this->operator[](StringRef(key)); } /*! @@ -3641,7 +3641,7 @@ class json template const_reference operator[](T* key) const { - return this->operator[](llvm::StringRef(key)); + return this->operator[](StringRef(key)); } /*! @@ -3659,10 +3659,10 @@ class json } @endcode - @note Unlike @ref at(llvm::StringRef), this function + @note Unlike @ref at(StringRef), this function does not throw if the given key @a key was not found. - @note Unlike @ref operator[](llvm::StringRef key), this + @note Unlike @ref operator[](StringRef key), this function does not implicitly add an element to the position defined by @a key. This function is furthermore also applicable to const objects. @@ -3685,16 +3685,16 @@ class json @liveexample{The example below shows how object elements can be queried with a default value.,json__value} - @sa @ref at(llvm::StringRef) for access by reference + @sa @ref at(StringRef) for access by reference with range checking - @sa @ref operator[](llvm::StringRef) for unchecked + @sa @ref operator[](StringRef) for unchecked access by reference @since version 1.0.0 */ template::value, int>::type = 0> - ValueType value(llvm::StringRef key, ValueType default_value) const + ValueType value(StringRef key, ValueType default_value) const { // at only works for objects if (is_object()) @@ -3716,9 +3716,9 @@ class json /*! @brief overload for a default value of type const char* - @copydoc json::value(llvm::StringRef, ValueType) const + @copydoc json::value(StringRef, ValueType) const */ - std::string value(llvm::StringRef key, const char* default_value) const + std::string value(StringRef key, const char* default_value) const { return value(key, std::string(default_value)); } @@ -3907,7 +3907,7 @@ class json @sa @ref erase(IteratorType, IteratorType) -- removes the elements in the given range - @sa @ref erase(llvm::StringRef) -- removes the element + @sa @ref erase(StringRef) -- removes the element from an object at the given key @sa @ref erase(const size_type) -- removes the element from an array at the given index @@ -4010,7 +4010,7 @@ class json types.,erase__IteratorType_IteratorType} @sa @ref erase(IteratorType) -- removes the element at a given position - @sa @ref erase(llvm::StringRef) -- removes the element + @sa @ref erase(StringRef) -- removes the element from an object at the given key @sa @ref erase(const size_type) -- removes the element from an array at the given index @@ -4098,7 +4098,7 @@ class json @since version 1.0.0 */ - size_type erase(llvm::StringRef key); + size_type erase(StringRef key); /*! @brief remove element from a JSON array given an index @@ -4119,7 +4119,7 @@ class json @sa @ref erase(IteratorType) -- removes the element at a given position @sa @ref erase(IteratorType, IteratorType) -- removes the elements in the given range - @sa @ref erase(llvm::StringRef) -- removes the element + @sa @ref erase(StringRef) -- removes the element from an object at the given key @since version 1.0.0 @@ -4158,13 +4158,13 @@ class json @since version 1.0.0 */ - iterator find(llvm::StringRef key); + iterator find(StringRef key); /*! @brief find an element in a JSON object - @copydoc find(llvm::StringRef) + @copydoc find(StringRef) */ - const_iterator find(llvm::StringRef key) const; + const_iterator find(StringRef key) const; /*! @brief returns the number of occurrences of a key in a JSON object @@ -4187,7 +4187,7 @@ class json @since version 1.0.0 */ - size_type count(llvm::StringRef key) const + size_type count(StringRef key) const { // return 0 for all nonobject types return is_object() ? m_value.object->count(key) : 0; @@ -4605,13 +4605,13 @@ class json @since version 1.0.0 */ - void push_back(const std::pair& val); + void push_back(const std::pair& val); /*! @brief add an object to an object @copydoc push_back(const typename object_t::value_type&) */ - reference operator+=(const std::pair& val) + reference operator+=(const std::pair& val) { push_back(val); return *this; @@ -4724,7 +4724,7 @@ class json @since version 2.0.8 */ template - std::pair emplace(llvm::StringRef key, Args&& ... args) + std::pair emplace(StringRef key, Args&& ... args) { // emplace only works for null objects or arrays if (!(is_null() || is_object())) @@ -5342,7 +5342,7 @@ class json @since version 1.0.0; indentaction character added in version 3.0.0 */ - friend llvm::raw_ostream& operator<<(llvm::raw_ostream& o, const json& j); + friend raw_ostream& operator<<(raw_ostream& o, const json& j); /// @} @@ -5380,12 +5380,12 @@ class json @liveexample{The example below demonstrates the `parse()` function with and without callback function.,parse__string__parser_callback_t} - @sa @ref parse(wpi::raw_istream&, const parser_callback_t) for a version + @sa @ref parse(raw_istream&, const parser_callback_t) for a version that reads from an input stream @since version 1.0.0 (originally for std::string) */ - static json parse(llvm::StringRef s, + static json parse(StringRef s, const parser_callback_t cb = nullptr); /*! @@ -5417,7 +5417,7 @@ class json @since version 1.0.0 */ - static json parse(wpi::raw_istream& i, + static json parse(raw_istream& i, const parser_callback_t cb = nullptr); /*! @@ -5441,12 +5441,12 @@ class json @liveexample{The example below shows how a JSON value is constructed by reading a serialization from a stream.,operator_deserialize} - @sa parse(wpi::raw_istream&, const parser_callback_t) for a variant with a + @sa parse(raw_istream&, const parser_callback_t) for a variant with a parser callback function to filter values while parsing @since version 1.0.0 */ - friend wpi::raw_istream& operator>>(wpi::raw_istream& i, json& j); + friend raw_istream& operator>>(raw_istream& i, json& j); /// @} @@ -5571,7 +5571,7 @@ class json return lhs.m_it - rhs.m_it; } - friend llvm::raw_ostream& operator<<(llvm::raw_ostream& os, primitive_iterator_t it) + friend raw_ostream& operator<<(raw_ostream& os, primitive_iterator_t it) { return os << it.m_it; } @@ -6327,7 +6327,7 @@ class json @brief return the key of an object iterator @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - llvm::StringRef key() const + StringRef key() const { assert(m_object != nullptr); @@ -6445,8 +6445,8 @@ class json @since version 2.0.9 */ - static void to_cbor(llvm::raw_ostream& os, const json& j); - static llvm::StringRef to_cbor(const json& j, llvm::SmallVectorImpl buf); + static void to_cbor(raw_ostream& os, const json& j); + static StringRef to_cbor(const json& j, SmallVectorImpl buf); static std::string to_cbor(const json& j); /*! @@ -6523,8 +6523,8 @@ class json @since version 2.0.9 */ - static void to_msgpack(llvm::raw_ostream& os, const json& j); - static llvm::StringRef to_msgpack(const json& j, llvm::SmallVectorImpl buf); + static void to_msgpack(raw_ostream& os, const json& j); + static StringRef to_msgpack(const json& j, SmallVectorImpl buf); static std::string to_msgpack(const json& j); /*! @@ -6613,8 +6613,8 @@ class json @since version 2.0.9, parameter @a start_index since 2.1.1 */ - static json from_cbor(wpi::raw_istream& is); - static json from_cbor(llvm::StringRef s); + static json from_cbor(raw_istream& is); + static json from_cbor(StringRef s); /*! @brief create a JSON value from a byte vector in MessagePack format @@ -6682,8 +6682,8 @@ class json @since version 2.0.9, parameter @a start_index since 2.1.1 */ - static json from_msgpack(wpi::raw_istream& is); - static json from_msgpack(llvm::StringRef s); + static json from_msgpack(raw_istream& is); + static json from_msgpack(StringRef s); /// @} @@ -6937,7 +6937,7 @@ class json Uses a JSON pointer to retrieve a reference to the respective JSON value. No bound checking is performed. Similar to @ref operator[]( - llvm::StringRef), `null` values are created in arrays and objects if + StringRef), `null` values are created in arrays and objects if necessary. In particular: @@ -7214,7 +7214,7 @@ if no parse error occurred. */ inline wpi::json operator "" _json(const char* s, std::size_t n) { - return wpi::json::parse(llvm::StringRef(s, n)); + return wpi::json::parse(wpi::StringRef(s, n)); } /*! diff --git a/wpiutil/src/main/native/include/support/leb128.h b/wpiutil/src/main/native/include/wpi/leb128.h similarity index 88% rename from wpiutil/src/main/native/include/support/leb128.h rename to wpiutil/src/main/native/include/wpi/leb128.h index 9f2c7f097d..d9498a6b12 100644 --- a/wpiutil/src/main/native/include/support/leb128.h +++ b/wpiutil/src/main/native/include/wpi/leb128.h @@ -10,14 +10,14 @@ #include -#include "llvm/SmallVector.h" +#include "wpi/SmallVector.h" namespace wpi { class raw_istream; uint64_t SizeUleb128(uint64_t val); -uint64_t WriteUleb128(llvm::SmallVectorImpl& dest, uint64_t val); +uint64_t WriteUleb128(SmallVectorImpl& dest, uint64_t val); uint64_t ReadUleb128(const char* addr, uint64_t* ret); bool ReadUleb128(raw_istream& is, uint64_t* ret); diff --git a/wpiutil/src/main/native/include/support/mutex.h b/wpiutil/src/main/native/include/wpi/mutex.h similarity index 100% rename from wpiutil/src/main/native/include/support/mutex.h rename to wpiutil/src/main/native/include/wpi/mutex.h diff --git a/wpiutil/src/main/native/include/support/priority_condition_variable.h b/wpiutil/src/main/native/include/wpi/priority_condition_variable.h similarity index 100% rename from wpiutil/src/main/native/include/support/priority_condition_variable.h rename to wpiutil/src/main/native/include/wpi/priority_condition_variable.h diff --git a/wpiutil/src/main/native/include/support/priority_mutex.h b/wpiutil/src/main/native/include/wpi/priority_mutex.h similarity index 100% rename from wpiutil/src/main/native/include/support/priority_mutex.h rename to wpiutil/src/main/native/include/wpi/priority_mutex.h diff --git a/wpiutil/src/main/native/include/support/raw_istream.h b/wpiutil/src/main/native/include/wpi/raw_istream.h similarity index 90% rename from wpiutil/src/main/native/include/support/raw_istream.h rename to wpiutil/src/main/native/include/wpi/raw_istream.h index d25617967a..3e4353732b 100644 --- a/wpiutil/src/main/native/include/support/raw_istream.h +++ b/wpiutil/src/main/native/include/wpi/raw_istream.h @@ -12,9 +12,9 @@ #include #include -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" -#include "llvm/Twine.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" +#include "wpi/Twine.h" namespace wpi { @@ -56,7 +56,7 @@ class raw_istream { // @param buf Buffer for output // @param maxLen Maximum length // @return Line - llvm::StringRef getline(llvm::SmallVectorImpl& buf, int maxLen); + StringRef getline(SmallVectorImpl& buf, int maxLen); virtual void close() = 0; virtual size_t in_avail() const = 0; @@ -78,7 +78,7 @@ class raw_istream { class raw_mem_istream : public raw_istream { public: - explicit raw_mem_istream(llvm::StringRef mem); + explicit raw_mem_istream(StringRef mem); raw_mem_istream(const char* mem, size_t len) : m_cur(mem), m_left(len) {} void close() override; size_t in_avail() const override; @@ -92,7 +92,7 @@ class raw_mem_istream : public raw_istream { class raw_fd_istream : public raw_istream { public: - raw_fd_istream(const llvm::Twine& filename, std::error_code& ec, + raw_fd_istream(const Twine& filename, std::error_code& ec, size_t bufSize = 4096); raw_fd_istream(int fd, bool shouldClose, size_t bufSize = 4096); ~raw_fd_istream() override; diff --git a/wpiutil/src/main/native/include/llvm/raw_os_ostream.h b/wpiutil/src/main/native/include/wpi/raw_os_ostream.h similarity index 94% rename from wpiutil/src/main/native/include/llvm/raw_os_ostream.h rename to wpiutil/src/main/native/include/wpi/raw_os_ostream.h index 22dfa59ca5..c9ba2868d9 100644 --- a/wpiutil/src/main/native/include/llvm/raw_os_ostream.h +++ b/wpiutil/src/main/native/include/wpi/raw_os_ostream.h @@ -14,10 +14,10 @@ #ifndef LLVM_SUPPORT_RAW_OS_OSTREAM_H #define LLVM_SUPPORT_RAW_OS_OSTREAM_H -#include "llvm/raw_ostream.h" +#include "wpi/raw_ostream.h" #include -namespace llvm { +namespace wpi { /// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a /// simple adaptor class. It does not check for output errors; clients should @@ -37,6 +37,6 @@ public: ~raw_os_ostream() override; }; -} // end llvm namespace +} // end wpi namespace #endif diff --git a/wpiutil/src/main/native/include/llvm/raw_ostream.h b/wpiutil/src/main/native/include/wpi/raw_ostream.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/raw_ostream.h rename to wpiutil/src/main/native/include/wpi/raw_ostream.h index 119463bd86..b4479c4bd6 100644 --- a/wpiutil/src/main/native/include/llvm/raw_ostream.h +++ b/wpiutil/src/main/native/include/wpi/raw_ostream.h @@ -14,13 +14,13 @@ #ifndef LLVM_SUPPORT_RAW_OSTREAM_H #define LLVM_SUPPORT_RAW_OSTREAM_H -#include "llvm/FileSystem.h" -#include "llvm/SmallVector.h" -#include "llvm/StringRef.h" +#include "wpi/FileSystem.h" +#include "wpi/SmallVector.h" +#include "wpi/StringRef.h" #include #include -namespace llvm { +namespace wpi { class format_object_base; class FormattedString; class FormattedNumber; @@ -179,7 +179,7 @@ public: return write(Str.data(), Str.length()); } - raw_ostream &operator<<(const llvm::SmallVectorImpl &Str) { + raw_ostream &operator<<(const wpi::SmallVectorImpl &Str) { return write(Str.data(), Str.size()); } @@ -510,6 +510,6 @@ public: ~buffer_ostream() override { OS << str(); } }; -} // end llvm namespace +} // end wpi namespace #endif // LLVM_SUPPORT_RAW_OSTREAM_H diff --git a/wpiutil/src/main/native/include/support/raw_socket_istream.h b/wpiutil/src/main/native/include/wpi/raw_socket_istream.h similarity index 96% rename from wpiutil/src/main/native/include/support/raw_socket_istream.h rename to wpiutil/src/main/native/include/wpi/raw_socket_istream.h index 06fe1efea8..8bd4e3b344 100644 --- a/wpiutil/src/main/native/include/support/raw_socket_istream.h +++ b/wpiutil/src/main/native/include/wpi/raw_socket_istream.h @@ -8,7 +8,7 @@ #ifndef WPIUTIL_SUPPORT_RAW_SOCKET_ISTREAM_H_ #define WPIUTIL_SUPPORT_RAW_SOCKET_ISTREAM_H_ -#include "support/raw_istream.h" +#include "wpi/raw_istream.h" namespace wpi { diff --git a/wpiutil/src/main/native/include/support/raw_socket_ostream.h b/wpiutil/src/main/native/include/wpi/raw_socket_ostream.h similarity index 93% rename from wpiutil/src/main/native/include/support/raw_socket_ostream.h rename to wpiutil/src/main/native/include/wpi/raw_socket_ostream.h index 9349e7518e..977ba9bf0a 100644 --- a/wpiutil/src/main/native/include/support/raw_socket_ostream.h +++ b/wpiutil/src/main/native/include/wpi/raw_socket_ostream.h @@ -8,13 +8,13 @@ #ifndef WPIUTIL_SUPPORT_RAW_SOCKET_OSTREAM_H_ #define WPIUTIL_SUPPORT_RAW_SOCKET_OSTREAM_H_ -#include "llvm/raw_ostream.h" +#include "wpi/raw_ostream.h" namespace wpi { class NetworkStream; -class raw_socket_ostream : public llvm::raw_ostream { +class raw_socket_ostream : public raw_ostream { public: raw_socket_ostream(NetworkStream& stream, bool shouldClose) : m_stream(stream), m_shouldClose(shouldClose) {} diff --git a/wpiutil/src/main/native/include/support/sha1.h b/wpiutil/src/main/native/include/wpi/sha1.h similarity index 79% rename from wpiutil/src/main/native/include/support/sha1.h rename to wpiutil/src/main/native/include/wpi/sha1.h index 9871393b1b..8a883b5aac 100644 --- a/wpiutil/src/main/native/include/support/sha1.h +++ b/wpiutil/src/main/native/include/wpi/sha1.h @@ -24,25 +24,21 @@ #include -#include "llvm/StringRef.h" - -namespace llvm { -template -class SmallVectorImpl; -} // namespace llvm +#include "wpi/StringRef.h" namespace wpi { - +template +class SmallVectorImpl; class raw_istream; class SHA1 { public: SHA1(); - void Update(llvm::StringRef s); + void Update(StringRef s); void Update(raw_istream& is); std::string Final(); - llvm::StringRef Final(llvm::SmallVectorImpl& buf); - static std::string FromFile(llvm::StringRef filename); + StringRef Final(SmallVectorImpl& buf); + static std::string FromFile(StringRef filename); private: uint32_t digest[5]; diff --git a/wpiutil/src/main/native/include/support/timestamp.h b/wpiutil/src/main/native/include/wpi/timestamp.h similarity index 100% rename from wpiutil/src/main/native/include/support/timestamp.h rename to wpiutil/src/main/native/include/wpi/timestamp.h diff --git a/wpiutil/src/main/native/include/llvm/type_traits.h b/wpiutil/src/main/native/include/wpi/type_traits.h similarity index 98% rename from wpiutil/src/main/native/include/llvm/type_traits.h rename to wpiutil/src/main/native/include/wpi/type_traits.h index d8ce4fa976..a293948b50 100644 --- a/wpiutil/src/main/native/include/llvm/type_traits.h +++ b/wpiutil/src/main/native/include/wpi/type_traits.h @@ -17,9 +17,9 @@ #include #include -#include "llvm/Compiler.h" +#include "wpi/Compiler.h" -namespace llvm { +namespace wpi { /// isPodLike - This is a type trait that is used to determine whether a given /// type can be copied around with memcpy instead of running ctors etc. @@ -90,6 +90,6 @@ struct add_const_past_pointer< typedef const typename std::remove_pointer::type *type; }; -} // namespace llvm +} // namespace wpi #endif diff --git a/wpiutil/src/test/native/cpp/Base64Test.cpp b/wpiutil/src/test/native/cpp/Base64Test.cpp index 33dfdfa91f..99aecb965b 100644 --- a/wpiutil/src/test/native/cpp/Base64Test.cpp +++ b/wpiutil/src/test/native/cpp/Base64Test.cpp @@ -6,8 +6,8 @@ /*----------------------------------------------------------------------------*/ #include "gtest/gtest.h" -#include "llvm/SmallString.h" -#include "support/Base64.h" +#include "wpi/Base64.h" +#include "wpi/SmallString.h" namespace wpi { @@ -26,11 +26,11 @@ std::ostream& operator<<(std::ostream& os, const Base64TestParam& param) { class Base64Test : public ::testing::TestWithParam { protected: - llvm::StringRef GetPlain() { + StringRef GetPlain() { if (GetParam().plain_len < 0) - return llvm::StringRef(GetParam().plain); + return StringRef(GetParam().plain); else - return llvm::StringRef(GetParam().plain, GetParam().plain_len); + return StringRef(GetParam().plain, GetParam().plain_len); } }; @@ -45,7 +45,7 @@ TEST_P(Base64Test, EncodeStdString) { } TEST_P(Base64Test, EncodeSmallString) { - llvm::SmallString<128> buf; + SmallString<128> buf; ASSERT_EQ(GetParam().encoded, Base64Encode(GetPlain(), buf)); // reuse buf ASSERT_EQ(GetParam().encoded, Base64Encode(GetPlain(), buf)); @@ -53,7 +53,7 @@ TEST_P(Base64Test, EncodeSmallString) { TEST_P(Base64Test, DecodeStdString) { std::string s; - llvm::StringRef encoded = GetParam().encoded; + StringRef encoded = GetParam().encoded; EXPECT_EQ(encoded.size(), Base64Decode(encoded, &s)); ASSERT_EQ(GetPlain(), s); @@ -63,10 +63,10 @@ TEST_P(Base64Test, DecodeStdString) { } TEST_P(Base64Test, DecodeSmallString) { - llvm::SmallString<128> buf; - llvm::StringRef encoded = GetParam().encoded; + SmallString<128> buf; + StringRef encoded = GetParam().encoded; size_t len; - llvm::StringRef plain = Base64Decode(encoded, &len, buf); + StringRef plain = Base64Decode(encoded, &len, buf); EXPECT_EQ(encoded.size(), len); ASSERT_EQ(GetPlain(), plain); diff --git a/wpiutil/src/test/native/cpp/hostname.cpp b/wpiutil/src/test/native/cpp/hostname.cpp index 805274be4e..f1047a81be 100644 --- a/wpiutil/src/test/native/cpp/hostname.cpp +++ b/wpiutil/src/test/native/cpp/hostname.cpp @@ -5,16 +5,16 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "support/hostname.h" +#include "wpi/hostname.h" #include "gtest/gtest.h" -#include "llvm/SmallString.h" -#include "llvm/SmallVector.h" +#include "wpi/SmallString.h" +#include "wpi/SmallVector.h" namespace wpi { -TEST(HostNameTest, HostNameNotEmpty) { ASSERT_NE(wpi::GetHostname(), ""); } +TEST(HostNameTest, HostNameNotEmpty) { ASSERT_NE(GetHostname(), ""); } TEST(HostNameTest, HostNameNotEmptySmallVector) { - llvm::SmallVector name; - ASSERT_NE(wpi::GetHostname(name), ""); + SmallVector name; + ASSERT_NE(GetHostname(name), ""); } } // namespace wpi diff --git a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp index 4f2785dcba..b668b3b5bf 100644 --- a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp @@ -735,7 +735,7 @@ TEST(CborFloatTest, Number) TEST(CborFloatTest, HalfInfinity) { - json j = json::from_cbor(llvm::StringRef("\xf9\x7c\x00", 3)); + json j = json::from_cbor(wpi::StringRef("\xf9\x7c\x00", 3)); json::number_float_t d = j; EXPECT_FALSE(std::isfinite(d)); EXPECT_EQ(j.dump(), "null"); @@ -1138,31 +1138,31 @@ TEST(CborErrorTest, TooShortByteVector) "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); EXPECT_THROW_MSG(json::from_cbor("\x19"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x19\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x19\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); EXPECT_THROW_MSG(json::from_cbor("\x1a"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1a\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1a\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1a\x00\x00", 3)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1a\x00\x00", 3)), json::parse_error, "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1a\x00\x00\x00", 4)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1a\x00\x00\x00", 4)), json::parse_error, "[json.exception.parse_error.110] parse error at 5: unexpected end of input"); EXPECT_THROW_MSG(json::from_cbor("\x1b"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00", 3)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00", 3)), json::parse_error, "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00\x00", 4)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00\x00", 4)), json::parse_error, "[json.exception.parse_error.110] parse error at 5: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00\x00\x00", 5)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00\x00\x00", 5)), json::parse_error, "[json.exception.parse_error.110] parse error at 6: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00\x00\x00\x00", 6)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00\x00\x00\x00", 6)), json::parse_error, "[json.exception.parse_error.110] parse error at 7: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00\x00\x00\x00\x00", 7)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00\x00\x00\x00\x00", 7)), json::parse_error, "[json.exception.parse_error.110] parse error at 8: unexpected end of input"); - EXPECT_THROW_MSG(json::from_cbor(llvm::StringRef("\x1b\x00\x00\x00\x00\x00\x00\x00", 8)), json::parse_error, + EXPECT_THROW_MSG(json::from_cbor(wpi::StringRef("\x1b\x00\x00\x00\x00\x00\x00\x00", 8)), json::parse_error, "[json.exception.parse_error.110] parse error at 9: unexpected end of input"); } @@ -1547,7 +1547,7 @@ TEST(CborFirstBytesTest, Unsupported) try { - json::from_cbor(llvm::StringRef(&byte, 1)); + json::from_cbor(wpi::StringRef(&byte, 1)); } catch (const json::parse_error& e) { @@ -1571,7 +1571,7 @@ TEST(CborFirstBytesTest, Unsupported) namespace { struct CborRoundtripTestParam { const char* plain; - llvm::StringRef encoded; + wpi::StringRef encoded; bool test_encode; }; } // anonymous namespace @@ -1589,7 +1589,7 @@ TEST_P(CborRoundtripTest, Case) } static const CborRoundtripTestParam rfc7049_appendix_a_numbers[] = { - {"0", llvm::StringRef("\x00", 1), true}, + {"0", wpi::StringRef("\x00", 1), true}, {"1", "\x01", true}, {"10", "\x0a", true}, {"23", "\x17", true}, @@ -1597,38 +1597,38 @@ static const CborRoundtripTestParam rfc7049_appendix_a_numbers[] = { {"25", "\x18\x19", true}, {"100", "\x18\x64", true}, {"1000", "\x19\x03\xe8", true}, - {"1000000", llvm::StringRef("\x1a\x00\x0f\x42\x40", 5), true}, - {"1000000000000", llvm::StringRef("\x1b\x00\x00\x00\xe8\xd4\xa5\x10\x00", 9), true}, + {"1000000", wpi::StringRef("\x1a\x00\x0f\x42\x40", 5), true}, + {"1000000000000", wpi::StringRef("\x1b\x00\x00\x00\xe8\xd4\xa5\x10\x00", 9), true}, {"18446744073709551615", "\x1b\xff\xff\xff\xff\xff\xff\xff\xff", true}, // positive bignum is not supported - //{"18446744073709551616", llvm::StringRef("\xc2\x49\x01\x00\x00\x00\x00\x00\x00\x00\x00", 11), true}, + //{"18446744073709551616", wpi::StringRef("\xc2\x49\x01\x00\x00\x00\x00\x00\x00\x00\x00", 11), true}, //{"-18446744073709551616", "\x3b\xff\xff\xff\xff\xff\xff\xff\xff", true}, // negative bignum is not supported - //{"-18446744073709551617", llvm::StringRef("\xc3\x49\x01\x00\x00\x00\x00\x00\x00\x00\x00", 11), true}, + //{"-18446744073709551617", wpi::StringRef("\xc3\x49\x01\x00\x00\x00\x00\x00\x00\x00\x00", 11), true}, {"-1", "\x20", true}, {"-10", "\x29", true}, {"-100", "\x38\x63", true}, {"-1000", "\x39\x03\xe7", true}, // half-precision float - {"0.0", llvm::StringRef("\xf9\x00\x00", 3), false}, + {"0.0", wpi::StringRef("\xf9\x00\x00", 3), false}, // half-precision float - {"-0.0", llvm::StringRef("\xf9\x80\x00", 3), false}, + {"-0.0", wpi::StringRef("\xf9\x80\x00", 3), false}, // half-precision float - {"1.0", llvm::StringRef("\xf9\x3c\x00", 3), false}, + {"1.0", wpi::StringRef("\xf9\x3c\x00", 3), false}, {"1.1", "\xfb\x3f\xf1\x99\x99\x99\x99\x99\x9a", true}, // half-precision float - {"1.5", llvm::StringRef("\xf9\x3e\x00", 3), false}, + {"1.5", wpi::StringRef("\xf9\x3e\x00", 3), false}, // half-precision float {"65504.0", "\xf9\x7b\xff", false}, - {"100000.0", llvm::StringRef("\xfa\x47\xc3\x50\x00", 5), false}, + {"100000.0", wpi::StringRef("\xfa\x47\xc3\x50\x00", 5), false}, {"3.4028234663852886e+38", "\xfa\x7f\x7f\xff\xff", false}, - {"1.0e+300", llvm::StringRef("\xfb\x7e\x37\xe4\x3c\x88\x00\x75\x9c", 9), true}, + {"1.0e+300", wpi::StringRef("\xfb\x7e\x37\xe4\x3c\x88\x00\x75\x9c", 9), true}, // half-precision float - {"5.960464477539063e-8", llvm::StringRef("\xf9\x00\x01", 3), false}, + {"5.960464477539063e-8", wpi::StringRef("\xf9\x00\x01", 3), false}, // half-precision float - {"0.00006103515625", llvm::StringRef("\xf9\x04\x00", 3), false}, + {"0.00006103515625", wpi::StringRef("\xf9\x04\x00", 3), false}, // half-precision float - {"-4.0", llvm::StringRef("\xf9\xc4\x00", 3), false}, + {"-4.0", wpi::StringRef("\xf9\xc4\x00", 3), false}, {"-4.1", "\xfb\xc0\x10\x66\x66\x66\x66\x66\x66", true}, }; diff --git a/wpiutil/src/test/native/cpp/json/unit-convenience.cpp b/wpiutil/src/test/native/cpp/json/unit-convenience.cpp index 1ce647d1ee..1f4a0dcc34 100644 --- a/wpiutil/src/test/native/cpp/json/unit-convenience.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-convenience.cpp @@ -34,11 +34,10 @@ SOFTWARE. #include "gtest/gtest.h" -#include "llvm/SmallString.h" +#include "wpi/SmallString.h" #include "unit-json.h" - -#include "support/json_serializer.h" +#include "json_serializer.h" using wpi::json; @@ -68,11 +67,11 @@ class JsonStringEscapeTest : public ::testing::TestWithParam> {}; TEST_P(JsonStringEscapeTest, Case) { - llvm::SmallString<32> buf; - llvm::raw_svector_ostream ss(buf); + wpi::SmallString<32> buf; + wpi::raw_svector_ostream ss(buf); json::serializer s(ss); s.dump_escaped(GetParam().first); - EXPECT_EQ(ss.str(), llvm::StringRef(GetParam().second)); + EXPECT_EQ(ss.str(), wpi::StringRef(GetParam().second)); } static const std::pair string_escape_cases[] = { diff --git a/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp b/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp index 625cc545ef..12ac280948 100644 --- a/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include "gtest/gtest.h" #include "unit-json.h" -#include "support/raw_istream.h" +#include "wpi/raw_istream.h" using wpi::json; #include diff --git a/wpiutil/src/test/native/cpp/json/unit-json.h b/wpiutil/src/test/native/cpp/json/unit-json.h index 9e7ddd29c1..5a764b723a 100644 --- a/wpiutil/src/test/native/cpp/json/unit-json.h +++ b/wpiutil/src/test/native/cpp/json/unit-json.h @@ -8,7 +8,7 @@ #include -#include "support/json.h" +#include "wpi/json.h" namespace wpi { diff --git a/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp b/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp index 798bbba9ad..e4c63a7f3b 100644 --- a/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp @@ -1008,31 +1008,31 @@ TEST(MessagePackErrorTest, TooShortByteVector) "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); EXPECT_THROW_MSG(json::from_msgpack("\xcd"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcd\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcd\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); EXPECT_THROW_MSG(json::from_msgpack("\xce"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xce\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xce\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xce\x00\x00", 3)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xce\x00\x00", 3)), json::parse_error, "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xce\x00\x00\x00", 4)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xce\x00\x00\x00", 4)), json::parse_error, "[json.exception.parse_error.110] parse error at 5: unexpected end of input"); EXPECT_THROW_MSG(json::from_msgpack("\xcf"), json::parse_error, "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00", 2)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00", 2)), json::parse_error, "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00", 3)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00", 3)), json::parse_error, "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00\x00", 4)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00\x00", 4)), json::parse_error, "[json.exception.parse_error.110] parse error at 5: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00\x00\x00", 5)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00\x00\x00", 5)), json::parse_error, "[json.exception.parse_error.110] parse error at 6: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00\x00\x00\x00", 6)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00\x00\x00\x00", 6)), json::parse_error, "[json.exception.parse_error.110] parse error at 7: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00\x00\x00\x00\x00", 7)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00\x00\x00\x00\x00", 7)), json::parse_error, "[json.exception.parse_error.110] parse error at 8: unexpected end of input"); - EXPECT_THROW_MSG(json::from_msgpack(llvm::StringRef("\xcf\x00\x00\x00\x00\x00\x00\x00", 8)), json::parse_error, + EXPECT_THROW_MSG(json::from_msgpack(wpi::StringRef("\xcf\x00\x00\x00\x00\x00\x00\x00", 8)), json::parse_error, "[json.exception.parse_error.110] parse error at 9: unexpected end of input"); } diff --git a/wpiutil/src/test/native/cpp/json/unit-readme.cpp b/wpiutil/src/test/native/cpp/json/unit-readme.cpp index e088773bbb..eb7a212dff 100644 --- a/wpiutil/src/test/native/cpp/json/unit-readme.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-readme.cpp @@ -124,14 +124,14 @@ TEST(JsonReadmeTest, FromToString) // explicit conversion to string std::string s; - llvm::raw_string_ostream os(s); + wpi::raw_string_ostream os(s); j.dump(os); // {\"happy\":true,\"pi\":3.141} EXPECT_EQ(os.str(), "{\"happy\":true,\"pi\":3.141}"); // serialization with pretty printing // pass in the amount of spaces to indent std::string s2; - llvm::raw_string_ostream os2(s2); + wpi::raw_string_ostream os2(s2); j2.dump(os2, 4); EXPECT_EQ(os2.str(), "{\n \"happy\": true,\n \"pi\": 3.141\n}"); // { @@ -149,7 +149,7 @@ TEST(JsonReadmeTest, Basic2) j.push_back(true); std::string s; - llvm::raw_string_ostream os(s); + wpi::raw_string_ostream os(s); // iterate the array for (json::iterator it = j.begin(); it != j.end(); ++it) @@ -198,7 +198,7 @@ TEST(JsonReadmeTest, OtherContainer) { std::vector c_vector {1, 2, 3, 4}; json j_vec(c_vector); - json j_vec2(llvm::makeArrayRef(c_vector)); + json j_vec2(wpi::makeArrayRef(c_vector)); // [1, 2, 3, 4] std::deque c_deque {1.2f, 2.3f, 3.4f, 5.6f}; diff --git a/wpiutil/src/test/native/cpp/json/unit-unicode.cpp b/wpiutil/src/test/native/cpp/json/unit-unicode.cpp index 1c4546a822..b07edd0ed1 100644 --- a/wpiutil/src/test/native/cpp/json/unit-unicode.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-unicode.cpp @@ -37,8 +37,8 @@ SOFTWARE. #include "unit-json.h" using wpi::json; -#include "llvm/Format.h" -#include "llvm/StringExtras.h" +#include "wpi/Format.h" +#include "wpi/StringExtras.h" #include @@ -90,18 +90,18 @@ using wpi::json; error: auto result = ::testing::AssertionFailure(); - result << basemsg << " with {" << llvm::utohexstr(byte1); + result << basemsg << " with {" << wpi::utohexstr(byte1); if (byte2 != -1) { - result << ',' << llvm::utohexstr(byte2); + result << ',' << wpi::utohexstr(byte2); } if (byte3 != -1) { - result << ',' << llvm::utohexstr(byte3); + result << ',' << wpi::utohexstr(byte3); } if (byte4 != -1) { - result << ',' << llvm::utohexstr(byte4); + result << ',' << wpi::utohexstr(byte4); } result << '}'; return result; @@ -919,8 +919,8 @@ static std::string codepoint_to_unicode(std::size_t cp) // by four hexadecimal digits that encode the character's code // point std::string s; - llvm::raw_string_ostream ss(s); - ss << "\\u" << llvm::format_hex_no_prefix(cp, 4); + wpi::raw_string_ostream ss(s); + ss << "\\u" << wpi::format_hex_no_prefix(cp, 4); ss.flush(); return s; } diff --git a/wpiutil/src/test/native/cpp/leb128Test.cpp b/wpiutil/src/test/native/cpp/leb128Test.cpp index df659da6d4..a3a7ed0eac 100644 --- a/wpiutil/src/test/native/cpp/leb128Test.cpp +++ b/wpiutil/src/test/native/cpp/leb128Test.cpp @@ -19,21 +19,21 @@ #include #include "gtest/gtest.h" -#include "llvm/SmallString.h" -#include "llvm/StringRef.h" -#include "support/leb128.h" -#include "support/raw_istream.h" +#include "wpi/SmallString.h" +#include "wpi/StringRef.h" +#include "wpi/leb128.h" +#include "wpi/raw_istream.h" namespace wpi { TEST(LEB128Test, WriteUleb128) { -#define EXPECT_ULEB128_EQ(EXPECTED, VALUE, PAD) \ - do { \ - llvm::StringRef expected(EXPECTED, sizeof(EXPECTED) - 1); \ - llvm::SmallString<32> buf; \ - size_t size = WriteUleb128(buf, VALUE); \ - EXPECT_EQ(size, buf.size()); \ - EXPECT_EQ(expected, buf.str()); \ +#define EXPECT_ULEB128_EQ(EXPECTED, VALUE, PAD) \ + do { \ + StringRef expected(EXPECTED, sizeof(EXPECTED) - 1); \ + SmallString<32> buf; \ + size_t size = WriteUleb128(buf, VALUE); \ + EXPECT_EQ(size, buf.size()); \ + EXPECT_EQ(expected, buf.str()); \ } while (0) // Write ULEB128 diff --git a/wpiutil/src/test/native/cpp/priority_condition_variable_test.cpp b/wpiutil/src/test/native/cpp/priority_condition_variable_test.cpp index cb4031c79b..dc10bdb11c 100644 --- a/wpiutil/src/test/native/cpp/priority_condition_variable_test.cpp +++ b/wpiutil/src/test/native/cpp/priority_condition_variable_test.cpp @@ -5,8 +5,8 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include -#include +#include +#include #include #include diff --git a/wpiutil/src/test/native/cpp/priority_mutex_test.cpp b/wpiutil/src/test/native/cpp/priority_mutex_test.cpp index a5ac183c2f..c5c86b64b9 100644 --- a/wpiutil/src/test/native/cpp/priority_mutex_test.cpp +++ b/wpiutil/src/test/native/cpp/priority_mutex_test.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include // NOLINT(build/include_order) +#include // NOLINT(build/include_order) #include #include diff --git a/wpiutil/src/test/native/cpp/sha1Test.cpp b/wpiutil/src/test/native/cpp/sha1Test.cpp index 58dac210bb..08d85fec43 100644 --- a/wpiutil/src/test/native/cpp/sha1Test.cpp +++ b/wpiutil/src/test/native/cpp/sha1Test.cpp @@ -25,7 +25,7 @@ #include #include "gtest/gtest.h" -#include "support/sha1.h" +#include "wpi/sha1.h" namespace wpi {