Skip to content

Commit

Permalink
change std::span/std::as_bytes to pw::span/pw::as_bytes to make pigwe…
Browse files Browse the repository at this point in the history
…ed polyfill happy
  • Loading branch information
andy31415 committed Jun 30, 2022
1 parent cecc911 commit 42e39d7
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions examples/common/pigweed/RpcService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ChipRpcChannelOutput : public pw::rpc::ChannelOutput
pw::rpc::ChannelOutput(channel_name), mWriter(writer), mAddress(address)
{}

pw::Status Send(std::span<const std::byte> buffer) override
pw::Status Send(pw::span<const std::byte> buffer) override
{
if (buffer.empty())
{
Expand Down Expand Up @@ -102,7 +102,7 @@ void Start(void (*RegisterServices)(pw::rpc::Server &), ::chip::rpc::Mutex * uar
{
uart_mutex->Lock();
}
pw::hdlc::WriteUIFrame(1, std::as_bytes(std::span(log)), sysIoWriter);
pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), sysIoWriter);
if (uart_mutex)
{
uart_mutex->Unlock();
Expand Down
4 changes: 2 additions & 2 deletions examples/common/pigweed/mbed/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ Thread * Init()

ChipLogProgress(NotSpecified, "RPC service starting...\r\n");

auto error = rpcThread.start(RunRpcService);
long error = rpcThread.start(RunRpcService);
if (error != osOK)
{
ChipLogError(NotSpecified, "Run RPC service failed[%d]", error);
ChipLogError(NotSpecified, "Run RPC service failed[%ld]", error);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/common/pigweed/system_rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Init()
{
// Send log messages to HDLC address 1. This prevents logs from interfering
// with pw_rpc communications.
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, std::as_bytes(std::span(log)), writer); });
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, pw::as_bytes(std::span(log)), writer); });
}

rpc::Server & Server()
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/ameba/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/ameba/pw_sys_io/sys_io_ameba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/bouffalolab/bl602/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/efr32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/efr32/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/esp32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/esp32/pw_sys_io/sys_io_esp32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/mbed/pw_sys_io/sys_io_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/mbed/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ char sWriteBuffer[kWriteBufferSize];

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/nrfconnect/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool sIsPanicMode;

void flush()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/qpg/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/qpg/pw_sys_io/sys_io_qpg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down

0 comments on commit 42e39d7

Please sign in to comment.