mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
LibIPC+IPCCompiler: Add IPC::Decoder, let classes decode themselves
This shaves ~5 seconds off of a full build, not too bad. Also it just seems nicer to push this logic out to classes. It could be better but it's a start. :^)
This commit is contained in:
parent
dc417ada6d
commit
a4d857e3c5
12 changed files with 272 additions and 61 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/BufferStream.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Color.h>
|
||||
|
@ -344,7 +345,17 @@ Optional<Color> Color::from_string(const StringView& string)
|
|||
}
|
||||
}
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, Color value)
|
||||
const LogStream& operator<<(const LogStream& stream, Color value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
bool IPC::decode(BufferStream& stream, Color& color)
|
||||
{
|
||||
u32 rgba;
|
||||
stream >> rgba;
|
||||
if (stream.handle_read_failure())
|
||||
return false;
|
||||
color = Color::from_rgba(rgba);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue