diff --git a/DevTools/IPCCompiler/main.cpp b/DevTools/IPCCompiler/main.cpp index d0212ec489..5b092e9335 100644 --- a/DevTools/IPCCompiler/main.cpp +++ b/DevTools/IPCCompiler/main.cpp @@ -200,7 +200,7 @@ int main(int argc, char** argv) parse_endpoint(); out() << "#pragma once"; - out() << "#include "; + out() << "#include "; out() << "#include "; out() << "#include "; out() << "#include "; @@ -278,7 +278,7 @@ int main(int argc, char** argv) out() << " virtual i32 message_id() const override { return (int)MessageID::" << name << "; }"; out() << " static i32 static_message_id() { return (int)MessageID::" << name << "; }"; out() << " virtual const char* message_name() const override { return \"" << endpoint.name << "::" << name << "\"; }"; - out() << " static OwnPtr<" << name << "> decode(BufferStream& stream, size_t& size_in_bytes)"; + out() << " static OwnPtr<" << name << "> decode(InputMemoryStream& stream, size_t& size_in_bytes)"; out() << " {"; out() << " IPC::Decoder decoder(stream);"; @@ -349,10 +349,10 @@ int main(int argc, char** argv) out() << " virtual String name() const override { return \"" << endpoint.name << "\"; };"; out() << " static OwnPtr decode_message(const ByteBuffer& buffer, size_t& size_in_bytes)"; out() << " {"; - out() << " BufferStream stream(const_cast(buffer));"; + out() << " InputMemoryStream stream { buffer };"; out() << " i32 message_endpoint_magic = 0;"; out() << " stream >> message_endpoint_magic;"; - out() << " if (stream.handle_read_failure()) {"; + out() << " if (stream.handle_any_error()) {"; #ifdef GENERATE_DEBUG_CODE out() << " dbg() << \"Failed to read message endpoint magic\";"; #endif @@ -366,7 +366,7 @@ int main(int argc, char** argv) out() << " }"; out() << " i32 message_id = 0;"; out() << " stream >> message_id;"; - out() << " if (stream.handle_read_failure()) {"; + out() << " if (stream.handle_any_error()) {"; #ifdef GENERATE_DEBUG_CODE out() << " dbg() << \"Failed to read message ID\";"; #endif @@ -391,7 +391,7 @@ int main(int argc, char** argv) out() << " return nullptr;"; out() << " }"; - out() << " if (stream.handle_read_failure()) {"; + out() << " if (stream.handle_any_error()) {"; #ifdef GENERATE_DEBUG_CODE out() << " dbg() << \"Failed to read the message\";"; #endif diff --git a/Libraries/LibIPC/Decoder.cpp b/Libraries/LibIPC/Decoder.cpp index 83c2af0fbb..ba24206057 100644 --- a/Libraries/LibIPC/Decoder.cpp +++ b/Libraries/LibIPC/Decoder.cpp @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include @@ -34,68 +34,68 @@ namespace IPC { bool Decoder::decode(bool& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(u8& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(u16& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(u32& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(u64& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(i8& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(i16& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(i32& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(i64& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(float& value) { m_stream >> value; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(String& value) { i32 length = 0; m_stream >> length; - if (m_stream.handle_read_failure()) + if (m_stream.handle_any_error()) return false; if (length < 0) { value = {}; @@ -107,11 +107,9 @@ bool Decoder::decode(String& value) } char* text_buffer = nullptr; auto text_impl = StringImpl::create_uninitialized(static_cast(length), text_buffer); - for (size_t i = 0; i < static_cast(length); ++i) { - m_stream >> text_buffer[i]; - } + m_stream >> Bytes { text_buffer, static_cast(length) }; value = *text_impl; - return !m_stream.handle_read_failure(); + return !m_stream.handle_any_error(); } bool Decoder::decode(URL& value) @@ -127,7 +125,7 @@ bool Decoder::decode(Dictionary& dictionary) { u64 size = 0; m_stream >> size; - if (m_stream.handle_read_failure()) + if (m_stream.handle_any_error()) return false; if (size >= NumericLimits::max()) { ASSERT_NOT_REACHED(); diff --git a/Libraries/LibIPC/Decoder.h b/Libraries/LibIPC/Decoder.h index 56bd674cba..1f366f5d3f 100644 --- a/Libraries/LibIPC/Decoder.h +++ b/Libraries/LibIPC/Decoder.h @@ -43,7 +43,7 @@ inline bool decode(Decoder&, T&) class Decoder { public: - explicit Decoder(BufferStream& stream) + explicit Decoder(InputMemoryStream& stream) : m_stream(stream) { } @@ -101,7 +101,7 @@ public: } private: - BufferStream& m_stream; + InputMemoryStream& m_stream; }; } diff --git a/Libraries/LibIPC/Encoder.h b/Libraries/LibIPC/Encoder.h index ead9d5541a..da88d889ac 100644 --- a/Libraries/LibIPC/Encoder.h +++ b/Libraries/LibIPC/Encoder.h @@ -32,10 +32,9 @@ namespace IPC { template -bool encode(BufferStream&, T&) +bool encode(Encoder&, T&) { ASSERT_NOT_REACHED(); - return false; } class Encoder {