1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +00:00

Userland: Properly define IPC::encode and IPC::decode specializations

In order to avoid the base encode/decode methods from being used (and
failing a static assertion), we must be sure to declare/define the
custom type implementations as template specializations.

After this, LibIPC is no longer sensitive to include order.
This commit is contained in:
Timothy Flynn 2022-11-15 11:24:59 -05:00 committed by Tim Flynn
parent b1ea418d14
commit 05f41382bb
25 changed files with 75 additions and 2 deletions

View file

@ -394,12 +394,14 @@ bool ScreenLayout::try_auto_add_display_connector(String const& device_path)
namespace IPC {
bool encode(Encoder& encoder, const WindowServer::ScreenLayout::Screen& screen)
template<>
bool encode(Encoder& encoder, WindowServer::ScreenLayout::Screen const& screen)
{
encoder << screen.mode << screen.device << screen.location << screen.resolution << screen.scale_factor;
return true;
}
template<>
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout::Screen& screen)
{
WindowServer::ScreenLayout::Screen::Mode mode;
@ -416,12 +418,14 @@ ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout::Screen& scree
return {};
}
bool encode(Encoder& encoder, const WindowServer::ScreenLayout& screen_layout)
template<>
bool encode(Encoder& encoder, WindowServer::ScreenLayout const& screen_layout)
{
encoder << screen_layout.screens << screen_layout.main_screen_index;
return true;
}
template<>
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout& screen_layout)
{
Vector<WindowServer::ScreenLayout::Screen> screens;