mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibIPC+LibGfx: Pass the IPC::Decoder to decoding helpers
Instead of passing the BufferStream, pass the Decoder. I'd like to stop using BufferStream eventually anyway, so it's good to get it out of any API's where it's in currently.
This commit is contained in:
parent
01ff36a2f4
commit
24a0354ce8
Notes:
sideshowbarker
2024-07-19 08:04:04 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/24a0354ce84
9 changed files with 26 additions and 19 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -386,11 +387,10 @@ const LogStream& operator<<(const LogStream& stream, Color value)
|
|||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
bool IPC::decode(BufferStream& stream, Color& color)
|
||||
bool IPC::decode(IPC::Decoder& decoder, Color& color)
|
||||
{
|
||||
u32 rgba = 0;
|
||||
stream >> rgba;
|
||||
if (stream.handle_read_failure())
|
||||
if (!decoder.decode(rgba))
|
||||
return false;
|
||||
color = Color::from_rgba(rgba);
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -280,5 +281,5 @@ const LogStream& operator<<(const LogStream&, Color);
|
|||
using Gfx::Color;
|
||||
|
||||
namespace IPC {
|
||||
bool decode(BufferStream&, Gfx::Color&);
|
||||
bool decode(Decoder&, Gfx::Color&);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <AK/BufferStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -44,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Point& value)
|
|||
|
||||
namespace IPC {
|
||||
|
||||
bool decode(BufferStream& stream, Gfx::Point& point)
|
||||
bool decode(Decoder& decoder, Gfx::Point& point)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
stream >> x;
|
||||
stream >> y;
|
||||
if (stream.handle_read_failure())
|
||||
if (!decoder.decode(x))
|
||||
return false;
|
||||
if (!decoder.decode(y))
|
||||
return false;
|
||||
point = { x, y };
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <AK/Forward.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -162,5 +163,5 @@ const LogStream& operator<<(const LogStream&, const Point&);
|
|||
}
|
||||
|
||||
namespace IPC {
|
||||
bool decode(BufferStream&, Gfx::Point&);
|
||||
bool decode(Decoder&, Gfx::Point&);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -145,13 +146,13 @@ const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
|||
|
||||
namespace IPC {
|
||||
|
||||
bool decode(BufferStream& stream, Gfx::Rect& rect)
|
||||
bool decode(Decoder& decoder, Gfx::Rect& rect)
|
||||
{
|
||||
Gfx::Point point;
|
||||
Gfx::Size size;
|
||||
if (!decode(stream, point))
|
||||
if (!decoder.decode(point))
|
||||
return false;
|
||||
if (!decode(stream, size))
|
||||
if (!decoder.decode(size))
|
||||
return false;
|
||||
rect = { point, size };
|
||||
return true;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibGfx/TextAlignment.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -337,5 +338,5 @@ const LogStream& operator<<(const LogStream&, const Rect&);
|
|||
}
|
||||
|
||||
namespace IPC {
|
||||
bool decode(BufferStream&, Gfx::Rect&);
|
||||
bool decode(Decoder&, Gfx::Rect&);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <AK/BufferStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -44,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Size& value)
|
|||
|
||||
namespace IPC {
|
||||
|
||||
bool decode(BufferStream& stream, Gfx::Size& size)
|
||||
bool decode(Decoder& decoder, Gfx::Size& size)
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
stream >> width;
|
||||
stream >> height;
|
||||
if (stream.handle_read_failure())
|
||||
if (!decoder.decode(width))
|
||||
return false;
|
||||
if (!decoder.decode(height))
|
||||
return false;
|
||||
size = { width, height };
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -113,5 +114,5 @@ const LogStream& operator<<(const LogStream&, const Size&);
|
|||
}
|
||||
|
||||
namespace IPC {
|
||||
bool decode(BufferStream&, Gfx::Size&);
|
||||
bool decode(Decoder&, Gfx::Size&);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
template<typename T>
|
||||
bool decode(T& value)
|
||||
{
|
||||
return IPC::decode(m_stream, value);
|
||||
return IPC::decode(*this, value);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue