mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09: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: 24a0354ce8
9 changed files with 26 additions and 19 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
|
#include <LibIPC/Decoder.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -386,11 +387,10 @@ const LogStream& operator<<(const LogStream& stream, Color value)
|
||||||
return stream << value.to_string();
|
return stream << value.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IPC::decode(BufferStream& stream, Color& color)
|
bool IPC::decode(IPC::Decoder& decoder, Color& color)
|
||||||
{
|
{
|
||||||
u32 rgba = 0;
|
u32 rgba = 0;
|
||||||
stream >> rgba;
|
if (!decoder.decode(rgba))
|
||||||
if (stream.handle_read_failure())
|
|
||||||
return false;
|
return false;
|
||||||
color = Color::from_rgba(rgba);
|
color = Color::from_rgba(rgba);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <LibIPC/Forward.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -280,5 +281,5 @@ const LogStream& operator<<(const LogStream&, Color);
|
||||||
using Gfx::Color;
|
using Gfx::Color;
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
bool decode(BufferStream&, Gfx::Color&);
|
bool decode(Decoder&, Gfx::Color&);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <AK/BufferStream.h>
|
#include <AK/BufferStream.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
|
#include <LibIPC/Decoder.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -44,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Point& value)
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
bool decode(BufferStream& stream, Gfx::Point& point)
|
bool decode(Decoder& decoder, Gfx::Point& point)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
stream >> x;
|
if (!decoder.decode(x))
|
||||||
stream >> y;
|
return false;
|
||||||
if (stream.handle_read_failure())
|
if (!decoder.decode(y))
|
||||||
return false;
|
return false;
|
||||||
point = { x, y };
|
point = { x, y };
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <LibGfx/Orientation.h>
|
#include <LibGfx/Orientation.h>
|
||||||
|
#include <LibIPC/Forward.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -162,5 +163,5 @@ const LogStream& operator<<(const LogStream&, const Point&);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
bool decode(BufferStream&, Gfx::Point&);
|
bool decode(Decoder&, Gfx::Point&);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
#include <LibIPC/Decoder.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -145,13 +146,13 @@ const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
bool decode(BufferStream& stream, Gfx::Rect& rect)
|
bool decode(Decoder& decoder, Gfx::Rect& rect)
|
||||||
{
|
{
|
||||||
Gfx::Point point;
|
Gfx::Point point;
|
||||||
Gfx::Size size;
|
Gfx::Size size;
|
||||||
if (!decode(stream, point))
|
if (!decoder.decode(point))
|
||||||
return false;
|
return false;
|
||||||
if (!decode(stream, size))
|
if (!decoder.decode(size))
|
||||||
return false;
|
return false;
|
||||||
rect = { point, size };
|
rect = { point, size };
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
#include <LibGfx/Size.h>
|
#include <LibGfx/Size.h>
|
||||||
#include <LibGfx/TextAlignment.h>
|
#include <LibGfx/TextAlignment.h>
|
||||||
|
#include <LibIPC/Forward.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -337,5 +338,5 @@ const LogStream& operator<<(const LogStream&, const Rect&);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
bool decode(BufferStream&, Gfx::Rect&);
|
bool decode(Decoder&, Gfx::Rect&);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <AK/BufferStream.h>
|
#include <AK/BufferStream.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibGfx/Size.h>
|
#include <LibGfx/Size.h>
|
||||||
|
#include <LibIPC/Decoder.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -44,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Size& value)
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
bool decode(BufferStream& stream, Gfx::Size& size)
|
bool decode(Decoder& decoder, Gfx::Size& size)
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
stream >> width;
|
if (!decoder.decode(width))
|
||||||
stream >> height;
|
return false;
|
||||||
if (stream.handle_read_failure())
|
if (!decoder.decode(height))
|
||||||
return false;
|
return false;
|
||||||
size = { width, height };
|
size = { width, height };
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <LibGfx/Orientation.h>
|
#include <LibGfx/Orientation.h>
|
||||||
|
#include <LibIPC/Forward.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -113,5 +114,5 @@ const LogStream& operator<<(const LogStream&, const Size&);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
bool decode(BufferStream&, Gfx::Size&);
|
bool decode(Decoder&, Gfx::Size&);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool decode(T& value)
|
bool decode(T& value)
|
||||||
{
|
{
|
||||||
return IPC::decode(m_stream, value);
|
return IPC::decode(*this, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue