SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -20,12 +20,12 @@
#include "wpi/util/print.hpp"
#include "wpi/util/timestamp.h"
namespace uv = wpi::uv;
namespace uv = wpi::net::uv;
static uint64_t startTime = wpi::Now();
static uint64_t startTime = wpi::util::Now();
static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len,
wpi::SmallVectorImpl<uv::Buffer>& bufs, bool tcp,
wpi::util::SmallVectorImpl<uv::Buffer>& bufs, bool tcp,
uint16_t tcpSeq) {
// scan for last newline
std::string_view str(buf.base, len);
@@ -37,12 +37,12 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len,
}
// build output
wpi::raw_uv_ostream out(bufs, 4096);
std::string_view toCopy = wpi::slice(str, 0, idx + 1);
wpi::net::raw_uv_ostream out(bufs, 4096);
std::string_view toCopy = wpi::util::slice(str, 0, idx + 1);
if (tcp) {
// Header is 2 byte len, 1 byte type, 4 byte timestamp, 2 byte sequence num
uint32_t ts =
std::bit_cast<uint32_t, float>((wpi::Now() - startTime) * 1.0e-6);
std::bit_cast<uint32_t, float>((wpi::util::Now() - startTime) * 1.0e-6);
uint16_t len = rem.size() + toCopy.size() + 1 + 4 + 2;
const uint8_t header[] = {static_cast<uint8_t>((len >> 8) & 0xff),
static_cast<uint8_t>(len & 0xff),
@@ -58,7 +58,7 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len,
out << rem << toCopy;
// reset remainder
rem = wpi::slice(str, idx + 1, std::string_view::npos);
rem = wpi::util::slice(str, idx + 1, std::string_view::npos);
return true;
}
@@ -80,7 +80,7 @@ static void CopyUdp(uv::Stream& in, std::shared_ptr<uv::Udp> out, int port,
[rem = std::make_shared<std::string>(), outPtr = out.get(), addr](
uv::Buffer& buf, size_t len) {
// build buffers
wpi::SmallVector<uv::Buffer, 4> bufs;
wpi::util::SmallVector<uv::Buffer, 4> bufs;
if (!NewlineBuffer(*rem, buf, len, bufs, false, 0)) {
return;
}
@@ -104,7 +104,7 @@ static void CopyTcp(uv::Stream& in, std::shared_ptr<uv::Stream> out) {
[data = std::make_shared<StreamData>(), outPtr = out.get()](
uv::Buffer& buf, size_t len) {
// build buffers
wpi::SmallVector<uv::Buffer, 4> bufs;
wpi::util::SmallVector<uv::Buffer, 4> bufs;
if (!NewlineBuffer(data->rem, buf, len, bufs, true, data->seq++)) {
return;
}
@@ -150,14 +150,14 @@ int main(int argc, char* argv[]) {
++arg;
std::optional<int> portValue;
if (arg >= argc || argv[arg][0] == '-' ||
!(portValue = wpi::parse_integer<int>(argv[arg], 10))) {
!(portValue = wpi::util::parse_integer<int>(argv[arg], 10))) {
std::fputs("-p must be followed by port number\n", stderr);
err = true;
} else if (portValue) {
port = portValue.value();
}
} else {
wpi::print(stderr, "unrecognized command line option {}\n", argv[arg]);
wpi::util::print(stderr, "unrecognized command line option {}\n", argv[arg]);
err = true;
}
++arg;
@@ -176,7 +176,7 @@ int main(int argc, char* argv[]) {
auto loop = uv::Loop::Create();
loop->error.connect(
[](uv::Error err) { wpi::print(stderr, "uv ERROR: {}\n", err.str()); });
[](uv::Error err) { wpi::util::print(stderr, "uv ERROR: {}\n", err.str()); });
// create ttys
auto stdinTty = uv::Tty::Create(loop, 0, true);
@@ -213,7 +213,7 @@ int main(int argc, char* argv[]) {
}
// close on error
tcp->error.connect([s = tcp.get()](wpi::uv::Error err) { s->Close(); });
tcp->error.connect([s = tcp.get()](wpi::net::uv::Error err) { s->Close(); });
// tee
CopyTcp(*stdinTty, tcp);