LibIPC+Everywhere: Change IPC decoders to construct values in-place
Currently, the generated IPC decoders will default-construct the type to be decoded, then pass that value by reference to the concrete decoder. This, of course, requires that the type is default-constructible. This was an issue for decoding Variants, which had to require the first type in the Variant list is Empty, to ensure it is default constructible. Further, this made it possible for values to become uninitialized in user-defined decoders. This patch makes the decoder interface such that the concrete decoders themselves contruct the decoded type upon return from the decoder. To do so, the default decoders in IPC::Decoder had to be moved to the IPC namespace scope, as these decoders are now specializations instead of overloaded methods (C++ requires specializations to be in a namespace scope).
This commit is contained in:
parent
765c5b416f
commit
9b483625e6
Notes:
sideshowbarker
2024-07-17 02:35:55 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/9b483625e6 Pull-request: https://github.com/SerenityOS/serenity/pull/16637
31 changed files with 437 additions and 519 deletions
|
@ -369,8 +369,7 @@ public:)~~~");
|
||||||
parameter_generator.set("parameter.initial_value", "{}");
|
parameter_generator.set("parameter.initial_value", "{}");
|
||||||
|
|
||||||
parameter_generator.appendln(R"~~~(
|
parameter_generator.appendln(R"~~~(
|
||||||
@parameter.type@ @parameter.name@ = @parameter.initial_value@;
|
auto @parameter.name@ = TRY((decoder.decode<@parameter.type@>()));)~~~");
|
||||||
TRY(decoder.decode(@parameter.name@));)~~~");
|
|
||||||
|
|
||||||
if (parameter.attributes.contains_slow("UTF8")) {
|
if (parameter.attributes.contains_slow("UTF8")) {
|
||||||
parameter_generator.appendln(R"~~~(
|
parameter_generator.appendln(R"~~~(
|
||||||
|
|
|
@ -27,14 +27,15 @@ inline bool encode(Encoder& encoder, CodeComprehension::AutocompleteResultEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline ErrorOr<void> decode(Decoder& decoder, CodeComprehension::AutocompleteResultEntry& response)
|
inline ErrorOr<CodeComprehension::AutocompleteResultEntry> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(response.completion));
|
auto completion = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(response.partial_input_length));
|
auto partial_input_length = TRY(decoder.decode<size_t>());
|
||||||
TRY(decoder.decode(response.language));
|
auto language = TRY(decoder.decode<CodeComprehension::Language>());
|
||||||
TRY(decoder.decode(response.display_text));
|
auto display_text = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(response.hide_autocomplete_after_applying));
|
auto hide_autocomplete_after_applying = TRY(decoder.decode<CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying>());
|
||||||
return {};
|
|
||||||
|
return CodeComprehension::AutocompleteResultEntry { move(completion), partial_input_length, language, move(display_text), hide_autocomplete_after_applying };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -47,12 +48,13 @@ inline bool encode(Encoder& encoder, CodeComprehension::ProjectLocation const& l
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline ErrorOr<void> decode(Decoder& decoder, CodeComprehension::ProjectLocation& location)
|
inline ErrorOr<CodeComprehension::ProjectLocation> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(location.file));
|
auto file = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(location.line));
|
auto line = TRY(decoder.decode<size_t>());
|
||||||
TRY(decoder.decode(location.column));
|
auto column = TRY(decoder.decode<size_t>());
|
||||||
return {};
|
|
||||||
|
return CodeComprehension::ProjectLocation { move(file), line, column };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -67,13 +69,14 @@ inline bool encode(Encoder& encoder, CodeComprehension::Declaration const& decla
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline ErrorOr<void> decode(Decoder& decoder, CodeComprehension::Declaration& declaration)
|
inline ErrorOr<CodeComprehension::Declaration> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(declaration.name));
|
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(declaration.position));
|
auto position = TRY(decoder.decode<CodeComprehension::ProjectLocation>());
|
||||||
TRY(decoder.decode(declaration.type));
|
auto type = TRY(decoder.decode<CodeComprehension::DeclarationType>());
|
||||||
TRY(decoder.decode(declaration.scope));
|
auto scope = TRY(decoder.decode<DeprecatedString>());
|
||||||
return {};
|
|
||||||
|
return CodeComprehension::Declaration { move(name), position, type, move(scope) };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -87,13 +90,14 @@ inline bool encode(Encoder& encoder, CodeComprehension::TodoEntry const& entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline ErrorOr<void> decode(Decoder& decoder, CodeComprehension::TodoEntry& entry)
|
inline ErrorOr<CodeComprehension::TodoEntry> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(entry.content));
|
auto content = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(entry.filename));
|
auto filename = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(entry.line));
|
auto line = TRY(decoder.decode<size_t>());
|
||||||
TRY(decoder.decode(entry.column));
|
auto column = TRY(decoder.decode<size_t>());
|
||||||
return {};
|
|
||||||
|
return CodeComprehension::TodoEntry { move(content), move(filename), line, column };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -109,18 +113,15 @@ inline bool encode(Encoder& encoder, CodeComprehension::TokenInfo const& locatio
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline ErrorOr<void> decode(Decoder& decoder, CodeComprehension::TokenInfo& entry)
|
inline ErrorOr<CodeComprehension::TokenInfo> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
u32 semantic_type { 0 };
|
auto type = TRY(decoder.decode<CodeComprehension::TokenInfo::SemanticType>());
|
||||||
static_assert(sizeof(semantic_type) == sizeof(entry.type));
|
auto start_line = TRY(decoder.decode<size_t>());
|
||||||
|
auto start_column = TRY(decoder.decode<size_t>());
|
||||||
|
auto end_line = TRY(decoder.decode<size_t>());
|
||||||
|
auto end_column = TRY(decoder.decode<size_t>());
|
||||||
|
|
||||||
TRY(decoder.decode(semantic_type));
|
return CodeComprehension::TokenInfo { type, start_line, start_column, end_line, end_column };
|
||||||
entry.type = static_cast<CodeComprehension::TokenInfo::SemanticType>(semantic_type);
|
|
||||||
TRY(decoder.decode(entry.start_line));
|
|
||||||
TRY(decoder.decode(entry.start_column));
|
|
||||||
TRY(decoder.decode(entry.end_line));
|
|
||||||
TRY(decoder.decode(entry.end_column));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,6 @@ template<>
|
||||||
bool encode(Encoder&, Core::AnonymousBuffer const&);
|
bool encode(Encoder&, Core::AnonymousBuffer const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Core::AnonymousBuffer&);
|
ErrorOr<Core::AnonymousBuffer> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,6 @@ template<>
|
||||||
bool encode(Encoder&, Core::DateTime const&);
|
bool encode(Encoder&, Core::DateTime const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Core::DateTime&);
|
ErrorOr<Core::DateTime> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,6 @@ template<>
|
||||||
bool encode(Encoder&, Core::ProxyData const&);
|
bool encode(Encoder&, Core::ProxyData const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Core::ProxyData&);
|
ErrorOr<Core::ProxyData> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,21 +108,16 @@ bool encode(Encoder& encoder, DNS::Answer const& answer)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, DNS::Answer& answer)
|
ErrorOr<DNS::Answer> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
DeprecatedString name;
|
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(name));
|
auto record_type = TRY(decoder.decode<DNS::RecordType>());
|
||||||
u16 record_type, class_code;
|
auto class_code = TRY(decoder.decode<DNS::RecordClass>());
|
||||||
TRY(decoder.decode(record_type));
|
auto ttl = TRY(decoder.decode<u32>());
|
||||||
TRY(decoder.decode(class_code));
|
auto record_data = TRY(decoder.decode<DeprecatedString>());
|
||||||
u32 ttl;
|
auto cache_flush = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(ttl));
|
|
||||||
DeprecatedString record_data;
|
return DNS::Answer { name, record_type, class_code, ttl, record_data, cache_flush };
|
||||||
TRY(decoder.decode(record_data));
|
|
||||||
bool cache_flush;
|
|
||||||
TRY(decoder.decode(cache_flush));
|
|
||||||
answer = { { name }, (DNS::RecordType)record_type, (DNS::RecordClass)class_code, ttl, record_data, cache_flush };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,6 @@ template<>
|
||||||
bool encode(Encoder&, DNS::Answer const&);
|
bool encode(Encoder&, DNS::Answer const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, DNS::Answer&);
|
ErrorOr<DNS::Answer> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,12 +374,10 @@ bool IPC::encode(Encoder& encoder, Color const& color)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> IPC::decode(Decoder& decoder, Color& color)
|
ErrorOr<Gfx::Color> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
u32 rgba;
|
auto rgba = TRY(decoder.decode<u32>());
|
||||||
TRY(decoder.decode(rgba));
|
return Gfx::Color::from_argb(rgba);
|
||||||
color = Color::from_argb(rgba);
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color value)
|
ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color value)
|
||||||
|
|
|
@ -577,6 +577,6 @@ template<>
|
||||||
bool encode(Encoder&, Gfx::Color const&);
|
bool encode(Encoder&, Gfx::Color const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Gfx::Color&);
|
ErrorOr<Gfx::Color> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,14 +59,11 @@ bool encode(Encoder& encoder, Gfx::IntPoint const& point)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Gfx::IntPoint& point)
|
ErrorOr<Gfx::IntPoint> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
int x = 0;
|
auto x = TRY(decoder.decode<int>());
|
||||||
int y = 0;
|
auto y = TRY(decoder.decode<int>());
|
||||||
TRY(decoder.decode(x));
|
return Gfx::IntPoint { x, y };
|
||||||
TRY(decoder.decode(y));
|
|
||||||
point = { x, y };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ template<>
|
||||||
bool encode(Encoder&, Gfx::IntPoint const&);
|
bool encode(Encoder&, Gfx::IntPoint const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Gfx::IntPoint&);
|
ErrorOr<Gfx::IntPoint> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,11 @@ bool encode(Encoder& encoder, Gfx::IntRect const& rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Gfx::IntRect& rect)
|
ErrorOr<Gfx::IntRect> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
Gfx::IntPoint point;
|
auto point = TRY(decoder.decode<Gfx::IntPoint>());
|
||||||
Gfx::IntSize size;
|
auto size = TRY(decoder.decode<Gfx::IntSize>());
|
||||||
TRY(decoder.decode(point));
|
return Gfx::IntRect { point, size };
|
||||||
TRY(decoder.decode(size));
|
|
||||||
rect = { point, size };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1036,6 +1036,6 @@ template<>
|
||||||
bool encode(Encoder&, Gfx::IntRect const&);
|
bool encode(Encoder&, Gfx::IntRect const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Gfx::IntRect&);
|
ErrorOr<Gfx::IntRect> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool encode(Encoder& encoder, Gfx::ShareableBitmap const& shareable_bitmap)
|
||||||
encoder << IPC::File(bitmap.anonymous_buffer().fd());
|
encoder << IPC::File(bitmap.anonymous_buffer().fd());
|
||||||
encoder << bitmap.size();
|
encoder << bitmap.size();
|
||||||
encoder << static_cast<u32>(bitmap.scale());
|
encoder << static_cast<u32>(bitmap.scale());
|
||||||
encoder << (u32)bitmap.format();
|
encoder << static_cast<u32>(bitmap.format());
|
||||||
if (bitmap.is_indexed()) {
|
if (bitmap.is_indexed()) {
|
||||||
auto palette = bitmap.palette_to_vector();
|
auto palette = bitmap.palette_to_vector();
|
||||||
encoder << palette;
|
encoder << palette;
|
||||||
|
@ -41,33 +41,28 @@ bool encode(Encoder& encoder, Gfx::ShareableBitmap const& shareable_bitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
|
ErrorOr<Gfx::ShareableBitmap> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
bool valid = false;
|
if (auto valid = TRY(decoder.decode<bool>()); !valid)
|
||||||
TRY(decoder.decode(valid));
|
return Gfx::ShareableBitmap {};
|
||||||
if (!valid) {
|
|
||||||
shareable_bitmap = {};
|
auto anon_file = TRY(decoder.decode<IPC::File>());
|
||||||
return {};
|
auto size = TRY(decoder.decode<Gfx::IntSize>());
|
||||||
}
|
auto scale = TRY(decoder.decode<u32>());
|
||||||
IPC::File anon_file;
|
auto raw_bitmap_format = TRY(decoder.decode<u32>());
|
||||||
TRY(decoder.decode(anon_file));
|
|
||||||
Gfx::IntSize size;
|
|
||||||
TRY(decoder.decode(size));
|
|
||||||
u32 scale;
|
|
||||||
TRY(decoder.decode(scale));
|
|
||||||
u32 raw_bitmap_format;
|
|
||||||
TRY(decoder.decode(raw_bitmap_format));
|
|
||||||
if (!Gfx::is_valid_bitmap_format(raw_bitmap_format))
|
if (!Gfx::is_valid_bitmap_format(raw_bitmap_format))
|
||||||
return Error::from_string_literal("IPC: Invalid Gfx::ShareableBitmap format");
|
return Error::from_string_literal("IPC: Invalid Gfx::ShareableBitmap format");
|
||||||
auto bitmap_format = (Gfx::BitmapFormat)raw_bitmap_format;
|
|
||||||
|
auto bitmap_format = static_cast<Gfx::BitmapFormat>(raw_bitmap_format);
|
||||||
|
|
||||||
Vector<Gfx::ARGB32> palette;
|
Vector<Gfx::ARGB32> palette;
|
||||||
if (Gfx::Bitmap::is_indexed(bitmap_format)) {
|
if (Gfx::Bitmap::is_indexed(bitmap_format))
|
||||||
TRY(decoder.decode(palette));
|
palette = TRY(decoder.decode<decltype(palette)>());
|
||||||
}
|
|
||||||
auto buffer = TRY(Core::AnonymousBuffer::create_from_anon_fd(anon_file.take_fd(), Gfx::Bitmap::size_in_bytes(Gfx::Bitmap::minimum_pitch(size.width() * scale, bitmap_format), size.height() * scale)));
|
auto buffer = TRY(Core::AnonymousBuffer::create_from_anon_fd(anon_file.take_fd(), Gfx::Bitmap::size_in_bytes(Gfx::Bitmap::minimum_pitch(size.width() * scale, bitmap_format), size.height() * scale)));
|
||||||
auto bitmap = TRY(Gfx::Bitmap::try_create_with_anonymous_buffer(bitmap_format, move(buffer), size, scale, palette));
|
auto bitmap = TRY(Gfx::Bitmap::try_create_with_anonymous_buffer(bitmap_format, move(buffer), size, scale, palette));
|
||||||
shareable_bitmap = Gfx::ShareableBitmap { move(bitmap), Gfx::ShareableBitmap::ConstructWithKnownGoodBitmap };
|
|
||||||
return {};
|
return Gfx::ShareableBitmap { move(bitmap), Gfx::ShareableBitmap::ConstructWithKnownGoodBitmap };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/Size.h>
|
#include <LibGfx/Size.h>
|
||||||
|
#include <LibIPC/Forward.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -38,6 +39,6 @@ template<>
|
||||||
bool encode(Encoder&, Gfx::ShareableBitmap const&);
|
bool encode(Encoder&, Gfx::ShareableBitmap const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Gfx::ShareableBitmap&);
|
ErrorOr<Gfx::ShareableBitmap> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,11 @@ bool encode(Encoder& encoder, Gfx::IntSize const& size)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Gfx::IntSize& size)
|
ErrorOr<Gfx::IntSize> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
int width = 0;
|
auto width = TRY(decoder.decode<int>());
|
||||||
int height = 0;
|
auto height = TRY(decoder.decode<int>());
|
||||||
TRY(decoder.decode(width));
|
return Gfx::IntSize { width, height };
|
||||||
TRY(decoder.decode(height));
|
|
||||||
size = { width, height };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,6 @@ template<>
|
||||||
bool encode(Encoder&, Gfx::IntSize const&);
|
bool encode(Encoder&, Gfx::IntSize const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Gfx::IntSize&);
|
ErrorOr<Gfx::IntSize> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
72
Userland/Libraries/LibIPC/Concepts.h
Normal file
72
Userland/Libraries/LibIPC/Concepts.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/HashMap.h>
|
||||||
|
#include <AK/Optional.h>
|
||||||
|
#include <AK/Variant.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
|
#include <LibCore/SharedCircularQueue.h>
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// These concepts are used to help the compiler distinguish between specializations that would be
|
||||||
|
// ambiguous otherwise. For example, if the specializations for int and Vector<T> were declared as
|
||||||
|
// follows:
|
||||||
|
//
|
||||||
|
// template<> ErrorOr<int> decode(Decoder& decoder);
|
||||||
|
// template<typename T> ErrorOr<Vector<T>> decode(Decoder& decoder);
|
||||||
|
//
|
||||||
|
// Then decode<int>() would be ambiguous because either declaration could work (the compiler would
|
||||||
|
// not be able to distinguish if you wanted to decode an int or a Vector of int).
|
||||||
|
namespace IPC::Concepts {
|
||||||
|
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsHashMap = false;
|
||||||
|
template<typename K, typename V>
|
||||||
|
constexpr inline bool IsHashMap<HashMap<K, V>> = true;
|
||||||
|
template<typename K, typename V>
|
||||||
|
constexpr inline bool IsHashMap<OrderedHashMap<K, V>> = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsOptional = false;
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsOptional<Optional<T>> = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsSharedSingleProducerCircularQueue = false;
|
||||||
|
template<typename T, size_t Size>
|
||||||
|
constexpr inline bool IsSharedSingleProducerCircularQueue<Core::SharedSingleProducerCircularQueue<T, Size>> = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsVariant = false;
|
||||||
|
template<typename... Ts>
|
||||||
|
constexpr inline bool IsVariant<Variant<Ts...>> = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsVector = false;
|
||||||
|
template<typename T>
|
||||||
|
constexpr inline bool IsVector<Vector<T>> = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept HashMap = Detail::IsHashMap<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept Optional = Detail::IsOptional<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept SharedSingleProducerCircularQueue = Detail::IsSharedSingleProducerCircularQueue<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept Variant = Detail::IsVariant<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept Vector = Detail::IsVector<T>;
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/JsonValue.h>
|
#include <AK/JsonValue.h>
|
||||||
#include <AK/MemoryStream.h>
|
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/AnonymousBuffer.h>
|
#include <LibCore/AnonymousBuffer.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
|
@ -17,201 +16,110 @@
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(bool& value)
|
template<>
|
||||||
|
ErrorOr<DeprecatedString> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
m_stream >> value;
|
auto length = TRY(decoder.decode<i32>());
|
||||||
return m_stream.try_handle_any_error();
|
if (length < 0)
|
||||||
}
|
return DeprecatedString {};
|
||||||
|
if (length == 0)
|
||||||
|
return DeprecatedString::empty();
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(u8& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(u16& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(unsigned& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(unsigned long& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(unsigned long long& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(i8& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(i16& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(i32& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(i64& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(float& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(double& value)
|
|
||||||
{
|
|
||||||
m_stream >> value;
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(DeprecatedString& value)
|
|
||||||
{
|
|
||||||
i32 length;
|
|
||||||
TRY(decode(length));
|
|
||||||
|
|
||||||
if (length < 0) {
|
|
||||||
value = {};
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
if (length == 0) {
|
|
||||||
value = DeprecatedString::empty();
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
char* text_buffer = nullptr;
|
char* text_buffer = nullptr;
|
||||||
auto text_impl = StringImpl::create_uninitialized(static_cast<size_t>(length), text_buffer);
|
auto text_impl = StringImpl::create_uninitialized(static_cast<size_t>(length), text_buffer);
|
||||||
m_stream >> Bytes { text_buffer, static_cast<size_t>(length) };
|
|
||||||
value = *text_impl;
|
Bytes bytes { text_buffer, static_cast<size_t>(length) };
|
||||||
return m_stream.try_handle_any_error();
|
TRY(decoder.decode_into(bytes));
|
||||||
|
|
||||||
|
return DeprecatedString { *text_impl };
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(ByteBuffer& value)
|
template<>
|
||||||
|
ErrorOr<ByteBuffer> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
i32 length;
|
auto length = TRY(decoder.decode<i32>());
|
||||||
TRY(decode(length));
|
if (length <= 0)
|
||||||
|
return ByteBuffer {};
|
||||||
|
|
||||||
if (length < 0) {
|
auto buffer = TRY(ByteBuffer::create_uninitialized(length));
|
||||||
value = {};
|
auto bytes = buffer.bytes();
|
||||||
return {};
|
|
||||||
}
|
|
||||||
if (length == 0) {
|
|
||||||
value = {};
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
value = TRY(ByteBuffer::create_uninitialized(length));
|
TRY(decoder.decode_into(bytes));
|
||||||
|
return buffer;
|
||||||
m_stream >> value.bytes();
|
|
||||||
return m_stream.try_handle_any_error();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(JsonValue& value)
|
template<>
|
||||||
|
ErrorOr<JsonValue> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
DeprecatedString string;
|
auto json = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decode(string));
|
return JsonValue::from_string(json);
|
||||||
value = TRY(JsonValue::from_string(string));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(URL& value)
|
template<>
|
||||||
|
ErrorOr<URL> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
DeprecatedString string;
|
auto url = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decode(string));
|
return URL { url };
|
||||||
value = URL(string);
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode(Dictionary& dictionary)
|
template<>
|
||||||
|
ErrorOr<Dictionary> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
u64 size;
|
auto size = TRY(decoder.decode<u64>());
|
||||||
TRY(decode(size));
|
if (size >= NumericLimits<i32>::max())
|
||||||
if (size >= (size_t)NumericLimits<i32>::max())
|
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
||||||
|
Dictionary dictionary {};
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
DeprecatedString key;
|
auto key = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decode(key));
|
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||||
DeprecatedString value;
|
|
||||||
TRY(decode(value));
|
|
||||||
dictionary.add(move(key), move(value));
|
dictionary.add(move(key), move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return dictionary;
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Decoder::decode([[maybe_unused]] File& file)
|
|
||||||
{
|
|
||||||
int fd = TRY(m_socket.receive_fd(O_CLOEXEC));
|
|
||||||
file = File(fd, File::ConstructWithReceivedFileDescriptor);
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Core::AnonymousBuffer& buffer)
|
ErrorOr<File> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
bool valid;
|
int fd = TRY(decoder.socket().receive_fd(O_CLOEXEC));
|
||||||
TRY(decoder.decode(valid));
|
return File { fd, File::ConstructWithReceivedFileDescriptor };
|
||||||
if (!valid) {
|
|
||||||
buffer = {};
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
u32 size;
|
|
||||||
TRY(decoder.decode(size));
|
|
||||||
IPC::File anon_file;
|
|
||||||
TRY(decoder.decode(anon_file));
|
|
||||||
|
|
||||||
buffer = TRY(Core::AnonymousBuffer::create_from_anon_fd(anon_file.take_fd(), size));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Core::DateTime& datetime)
|
ErrorOr<Empty> decode(Decoder&)
|
||||||
{
|
{
|
||||||
i64 timestamp;
|
return Empty {};
|
||||||
TRY(decoder.decode(timestamp));
|
|
||||||
datetime = Core::DateTime::from_timestamp(static_cast<time_t>(timestamp));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, Core::ProxyData& data)
|
ErrorOr<Core::AnonymousBuffer> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
UnderlyingType<decltype(data.type)> type;
|
if (auto valid = TRY(decoder.decode<bool>()); !valid)
|
||||||
TRY(decoder.decode(type));
|
return Core::AnonymousBuffer {};
|
||||||
data.type = static_cast<Core::ProxyData::Type>(type);
|
|
||||||
TRY(decoder.decode(data.host_ipv4));
|
auto size = TRY(decoder.decode<u32>());
|
||||||
TRY(decoder.decode(data.port));
|
auto anon_file = TRY(decoder.decode<IPC::File>());
|
||||||
return {};
|
|
||||||
|
return Core::AnonymousBuffer::create_from_anon_fd(anon_file.take_fd(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No-op.
|
template<>
|
||||||
ErrorOr<void> Decoder::decode(AK::Empty&)
|
ErrorOr<Core::DateTime> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
return {};
|
auto timestamp = TRY(decoder.decode<i64>());
|
||||||
|
return Core::DateTime::from_timestamp(static_cast<time_t>(timestamp));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<Core::ProxyData> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto type = TRY(decoder.decode<Core::ProxyData::Type>());
|
||||||
|
auto host_ipv4 = TRY(decoder.decode<u32>());
|
||||||
|
auto port = TRY(decoder.decode<int>());
|
||||||
|
|
||||||
|
return Core::ProxyData { type, host_ipv4, port };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <AK/Concepts.h>
|
#include <AK/Concepts.h>
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
|
#include <AK/MemoryStream.h>
|
||||||
#include <AK/NumericLimits.h>
|
#include <AK/NumericLimits.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/Try.h>
|
#include <AK/Try.h>
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
#include <LibCore/SharedCircularQueue.h>
|
#include <LibCore/SharedCircularQueue.h>
|
||||||
#include <LibCore/Stream.h>
|
#include <LibCore/Stream.h>
|
||||||
|
#include <LibIPC/Concepts.h>
|
||||||
#include <LibIPC/File.h>
|
#include <LibIPC/File.h>
|
||||||
#include <LibIPC/Forward.h>
|
#include <LibIPC/Forward.h>
|
||||||
#include <LibIPC/Message.h>
|
#include <LibIPC/Message.h>
|
||||||
|
@ -23,7 +25,7 @@
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ErrorOr<void> decode(Decoder&, T&)
|
inline ErrorOr<T> decode(Decoder&)
|
||||||
{
|
{
|
||||||
static_assert(DependentFalse<T>, "Base IPC::decoder() instantiated");
|
static_assert(DependentFalse<T>, "Base IPC::decoder() instantiated");
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -37,151 +39,144 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> decode(bool&);
|
template<typename T>
|
||||||
ErrorOr<void> decode(u8&);
|
ErrorOr<T> decode();
|
||||||
ErrorOr<void> decode(u16&);
|
|
||||||
ErrorOr<void> decode(unsigned&);
|
|
||||||
ErrorOr<void> decode(unsigned long&);
|
|
||||||
ErrorOr<void> decode(unsigned long long&);
|
|
||||||
ErrorOr<void> decode(i8&);
|
|
||||||
ErrorOr<void> decode(i16&);
|
|
||||||
ErrorOr<void> decode(i32&);
|
|
||||||
ErrorOr<void> decode(i64&);
|
|
||||||
ErrorOr<void> decode(float&);
|
|
||||||
ErrorOr<void> decode(double&);
|
|
||||||
ErrorOr<void> decode(DeprecatedString&);
|
|
||||||
ErrorOr<void> decode(ByteBuffer&);
|
|
||||||
ErrorOr<void> decode(JsonValue&);
|
|
||||||
ErrorOr<void> decode(URL&);
|
|
||||||
ErrorOr<void> decode(Dictionary&);
|
|
||||||
ErrorOr<void> decode(File&);
|
|
||||||
ErrorOr<void> decode(AK::Empty&);
|
|
||||||
template<typename K, typename V>
|
|
||||||
ErrorOr<void> decode(HashMap<K, V>& hashmap)
|
|
||||||
{
|
|
||||||
u32 size;
|
|
||||||
TRY(decode(size));
|
|
||||||
if (size > NumericLimits<i32>::max())
|
|
||||||
return Error::from_string_literal("IPC: Invalid HashMap size");
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i) {
|
|
||||||
K key;
|
|
||||||
TRY(decode(key));
|
|
||||||
V value;
|
|
||||||
TRY(decode(value));
|
|
||||||
TRY(hashmap.try_set(move(key), move(value)));
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename K, typename V>
|
|
||||||
ErrorOr<void> decode(OrderedHashMap<K, V>& hashmap)
|
|
||||||
{
|
|
||||||
u32 size;
|
|
||||||
TRY(decode(size));
|
|
||||||
if (size > NumericLimits<i32>::max())
|
|
||||||
return Error::from_string_literal("IPC: Invalid HashMap size");
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i) {
|
|
||||||
K key;
|
|
||||||
TRY(decode(key));
|
|
||||||
V value;
|
|
||||||
TRY(decode(value));
|
|
||||||
TRY(hashmap.try_set(move(key), move(value)));
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Enum T>
|
|
||||||
ErrorOr<void> decode(T& enum_value)
|
|
||||||
{
|
|
||||||
UnderlyingType<T> inner_value;
|
|
||||||
TRY(decode(inner_value));
|
|
||||||
enum_value = T(inner_value);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ErrorOr<void> decode(T& value)
|
ErrorOr<void> decode_into(T& value)
|
||||||
{
|
{
|
||||||
return IPC::decode(*this, value);
|
m_stream >> value;
|
||||||
}
|
TRY(m_stream.try_handle_any_error());
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
ErrorOr<void> decode(Vector<T>& vector)
|
|
||||||
{
|
|
||||||
u64 size;
|
|
||||||
TRY(decode(size));
|
|
||||||
if (size > NumericLimits<i32>::max())
|
|
||||||
return Error::from_string_literal("IPC: Invalid Vector size");
|
|
||||||
VERIFY(vector.is_empty());
|
|
||||||
TRY(vector.try_ensure_capacity(size));
|
|
||||||
for (size_t i = 0; i < size; ++i) {
|
|
||||||
T value;
|
|
||||||
TRY(decode(value));
|
|
||||||
vector.template unchecked_append(move(value));
|
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, size_t Size>
|
Core::Stream::LocalSocket& socket() { return m_socket; }
|
||||||
ErrorOr<void> decode(Core::SharedSingleProducerCircularQueue<T, Size>& queue)
|
|
||||||
{
|
|
||||||
// FIXME: We don't support decoding into valid queues.
|
|
||||||
VERIFY(!queue.is_valid());
|
|
||||||
|
|
||||||
IPC::File anon_file;
|
|
||||||
TRY(decode(anon_file));
|
|
||||||
queue = TRY((Core::SharedSingleProducerCircularQueue<T, Size>::try_create(anon_file.take_fd())));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... VariantTypes>
|
|
||||||
ErrorOr<void> decode(Variant<VariantTypes...>& variant)
|
|
||||||
{
|
|
||||||
typename AK::Variant<VariantTypes...>::IndexType type_index;
|
|
||||||
TRY(decode(type_index));
|
|
||||||
if (type_index >= sizeof...(VariantTypes))
|
|
||||||
return Error::from_string_literal("IPC: Invalid variant index");
|
|
||||||
|
|
||||||
TRY((decode_variant<0, sizeof...(VariantTypes), VariantTypes...>(type_index, variant)));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
ErrorOr<void> decode(Optional<T>& optional)
|
|
||||||
{
|
|
||||||
bool has_value;
|
|
||||||
TRY(decode(has_value));
|
|
||||||
if (!has_value) {
|
|
||||||
optional = {};
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
T value;
|
|
||||||
TRY(decode(value));
|
|
||||||
optional = move(value);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<size_t CurrentIndex, size_t Max, typename... VariantTypes>
|
|
||||||
ErrorOr<void> decode_variant(size_t index, Variant<VariantTypes...>& variant)
|
|
||||||
{
|
|
||||||
if constexpr (CurrentIndex < Max) {
|
|
||||||
if (index == CurrentIndex) {
|
|
||||||
typename TypeList<VariantTypes...>::template Type<CurrentIndex> element;
|
|
||||||
TRY(decode(element));
|
|
||||||
variant.set(move(element));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return decode_variant<CurrentIndex + 1, Max, VariantTypes...>(index, variant);
|
|
||||||
} else {
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
InputMemoryStream& m_stream;
|
InputMemoryStream& m_stream;
|
||||||
Core::Stream::LocalSocket& m_socket;
|
Core::Stream::LocalSocket& m_socket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<Arithmetic T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
T value { 0 };
|
||||||
|
TRY(decoder.decode_into(value));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Enum T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto value = TRY(decoder.decode<UnderlyingType<T>>());
|
||||||
|
return static_cast<T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<DeprecatedString> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<ByteBuffer> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<JsonValue> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<URL> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<Dictionary> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<File> decode(Decoder&);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ErrorOr<Empty> decode(Decoder&);
|
||||||
|
|
||||||
|
template<Concepts::Vector T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto size = TRY(decoder.decode<u64>());
|
||||||
|
if (size > NumericLimits<i32>::max())
|
||||||
|
return Error::from_string_literal("IPC: Invalid Vector size");
|
||||||
|
|
||||||
|
T vector;
|
||||||
|
TRY(vector.try_ensure_capacity(size));
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size; ++i) {
|
||||||
|
auto value = TRY(decoder.decode<typename T::ValueType>());
|
||||||
|
vector.template unchecked_append(move(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Concepts::HashMap T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto size = TRY(decoder.decode<u32>());
|
||||||
|
if (size > NumericLimits<i32>::max())
|
||||||
|
return Error::from_string_literal("IPC: Invalid HashMap size");
|
||||||
|
|
||||||
|
T hashmap;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size; ++i) {
|
||||||
|
auto key = TRY(decoder.decode<typename T::KeyType>());
|
||||||
|
auto value = TRY(decoder.decode<typename T::ValueType>());
|
||||||
|
TRY(hashmap.try_set(move(key), move(value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Concepts::SharedSingleProducerCircularQueue T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto anon_file = TRY(decoder.decode<IPC::File>());
|
||||||
|
return T::try_create(anon_file.take_fd());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Concepts::Optional T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
if (auto has_value = TRY(decoder.decode<bool>()); !has_value)
|
||||||
|
return T {};
|
||||||
|
return T { TRY(decoder.decode<typename T::ValueType>()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
template<Concepts::Variant T, size_t Index = 0>
|
||||||
|
ErrorOr<T> decode_variant(Decoder& decoder, size_t index)
|
||||||
|
{
|
||||||
|
using ElementList = TypeList<T>;
|
||||||
|
|
||||||
|
if constexpr (Index < ElementList::size) {
|
||||||
|
if (index == Index) {
|
||||||
|
using ElementType = typename ElementList::template Type<Index>;
|
||||||
|
return T { TRY(decoder.decode<ElementType>()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
return decode_variant<T, Index + 1>(decoder, index);
|
||||||
|
} else {
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Concepts::Variant T>
|
||||||
|
ErrorOr<T> decode(Decoder& decoder)
|
||||||
|
{
|
||||||
|
auto index = TRY(decoder.decode<typename T::IndexType>());
|
||||||
|
return Detail::decode_variant<T>(decoder, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be last so that it knows about the above specializations.
|
||||||
|
template<typename T>
|
||||||
|
ErrorOr<T> Decoder::decode()
|
||||||
|
{
|
||||||
|
return IPC::decode<T>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@ template<typename T>
|
||||||
bool encode(Encoder&, T const&);
|
bool encode(Encoder&, T const&);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ErrorOr<void> decode(Decoder&, T&);
|
ErrorOr<T> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -847,82 +847,58 @@ bool IPC::encode(Encoder& encoder, SQL::Value const& value)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static ErrorOr<void> decode_scalar(IPC::Decoder& decoder, SQL::Value& value)
|
|
||||||
{
|
|
||||||
T decoded {};
|
|
||||||
TRY(decoder.decode(decoded));
|
|
||||||
value = move(decoded);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> IPC::decode(Decoder& decoder, SQL::Value& value)
|
ErrorOr<SQL::Value> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
u8 type_flags { 0 };
|
auto type_flags = TRY(decoder.decode<u8>());
|
||||||
TRY(decoder.decode(type_flags));
|
|
||||||
|
|
||||||
auto type_data = static_cast<SQL::TypeData>(type_flags & 0xf0);
|
auto type_data = static_cast<SQL::TypeData>(type_flags & 0xf0);
|
||||||
auto type = static_cast<SQL::SQLType>(type_flags & 0x0f);
|
auto type = static_cast<SQL::SQLType>(type_flags & 0x0f);
|
||||||
|
|
||||||
if (type_data == SQL::TypeData::Null) {
|
if (type_data == SQL::TypeData::Null)
|
||||||
value = SQL::Value(type);
|
return SQL::Value { type };
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SQL::SQLType::Null:
|
case SQL::SQLType::Null:
|
||||||
break;
|
return SQL::Value {};
|
||||||
case SQL::SQLType::Text:
|
case SQL::SQLType::Text:
|
||||||
TRY(decode_scalar<DeprecatedString>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<DeprecatedString>()) };
|
||||||
break;
|
|
||||||
case SQL::SQLType::Integer:
|
case SQL::SQLType::Integer:
|
||||||
switch (type_data) {
|
switch (type_data) {
|
||||||
case SQL::TypeData::Int8:
|
case SQL::TypeData::Int8:
|
||||||
TRY(decode_scalar<i8>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<i8>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Int16:
|
case SQL::TypeData::Int16:
|
||||||
TRY(decode_scalar<i16>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<i16>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Int32:
|
case SQL::TypeData::Int32:
|
||||||
TRY(decode_scalar<i32>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<i32>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Int64:
|
case SQL::TypeData::Int64:
|
||||||
TRY(decode_scalar<i64>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<i64>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Uint8:
|
case SQL::TypeData::Uint8:
|
||||||
TRY(decode_scalar<u8>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<u8>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Uint16:
|
case SQL::TypeData::Uint16:
|
||||||
TRY(decode_scalar<u16>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<u16>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Uint32:
|
case SQL::TypeData::Uint32:
|
||||||
TRY(decode_scalar<u32>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<u32>()) };
|
||||||
break;
|
|
||||||
case SQL::TypeData::Uint64:
|
case SQL::TypeData::Uint64:
|
||||||
TRY(decode_scalar<u64>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<u64>()) };
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SQL::SQLType::Float:
|
case SQL::SQLType::Float:
|
||||||
TRY(decode_scalar<double>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<double>()) };
|
||||||
break;
|
|
||||||
case SQL::SQLType::Boolean:
|
case SQL::SQLType::Boolean:
|
||||||
TRY(decode_scalar<bool>(decoder, value));
|
return SQL::Value { TRY(decoder.decode<bool>()) };
|
||||||
break;
|
|
||||||
case SQL::SQLType::Tuple: {
|
case SQL::SQLType::Tuple: {
|
||||||
Vector<SQL::Value> tuple;
|
auto tuple = TRY(decoder.decode<Vector<SQL::Value>>());
|
||||||
TRY(decoder.decode(tuple));
|
auto value = SQL::Value::create_tuple(move(tuple));
|
||||||
|
|
||||||
if (auto result = value.assign_tuple(move(tuple)); result.is_error())
|
if (value.is_error())
|
||||||
return Error::from_errno(to_underlying(result.error().error()));
|
return Error::from_errno(to_underlying(value.error().error()));
|
||||||
|
|
||||||
break;
|
return value.release_value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,6 +194,6 @@ template<>
|
||||||
bool encode(Encoder&, SQL::Value const&);
|
bool encode(Encoder&, SQL::Value const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, SQL::Value&);
|
ErrorOr<SQL::Value> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,19 +58,20 @@ bool IPC::encode(Encoder& encoder, Web::Cookie::Cookie const& cookie)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> IPC::decode(Decoder& decoder, Web::Cookie::Cookie& cookie)
|
ErrorOr<Web::Cookie::Cookie> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(cookie.name));
|
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.value));
|
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.domain));
|
auto domain = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.path));
|
auto path = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.creation_time));
|
auto creation_time = TRY(decoder.decode<Core::DateTime>());
|
||||||
TRY(decoder.decode(cookie.expiry_time));
|
auto expiry_time = TRY(decoder.decode<Core::DateTime>());
|
||||||
TRY(decoder.decode(cookie.host_only));
|
auto host_only = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.http_only));
|
auto http_only = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.last_access_time));
|
auto last_access_time = TRY(decoder.decode<Core::DateTime>());
|
||||||
TRY(decoder.decode(cookie.persistent));
|
auto persistent = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.secure));
|
auto secure = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.same_site));
|
auto same_site = TRY(decoder.decode<Web::Cookie::SameSite>());
|
||||||
return {};
|
|
||||||
|
return Web::Cookie::Cookie { move(name), move(value), same_site, move(creation_time), move(last_access_time), move(expiry_time), move(domain), move(path), secure, http_only, host_only, persistent };
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,6 @@ template<>
|
||||||
bool encode(Encoder&, Web::Cookie::Cookie const&);
|
bool encode(Encoder&, Web::Cookie::Cookie const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Web::Cookie::Cookie&);
|
ErrorOr<Web::Cookie::Cookie> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,16 +364,17 @@ bool IPC::encode(Encoder& encoder, Web::Cookie::ParsedCookie const& cookie)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> IPC::decode(Decoder& decoder, Web::Cookie::ParsedCookie& cookie)
|
ErrorOr<Web::Cookie::ParsedCookie> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
TRY(decoder.decode(cookie.name));
|
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.value));
|
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(cookie.expiry_time_from_expires_attribute));
|
auto expiry_time_from_expires_attribute = TRY(decoder.decode<Optional<Core::DateTime>>());
|
||||||
TRY(decoder.decode(cookie.expiry_time_from_max_age_attribute));
|
auto expiry_time_from_max_age_attribute = TRY(decoder.decode<Optional<Core::DateTime>>());
|
||||||
TRY(decoder.decode(cookie.domain));
|
auto domain = TRY(decoder.decode<Optional<DeprecatedString>>());
|
||||||
TRY(decoder.decode(cookie.path));
|
auto path = TRY(decoder.decode<Optional<DeprecatedString>>());
|
||||||
TRY(decoder.decode(cookie.secure_attribute_present));
|
auto secure_attribute_present = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.http_only_attribute_present));
|
auto http_only_attribute_present = TRY(decoder.decode<bool>());
|
||||||
TRY(decoder.decode(cookie.same_site_attribute));
|
auto same_site_attribute = TRY(decoder.decode<Web::Cookie::SameSite>());
|
||||||
return {};
|
|
||||||
|
return Web::Cookie::ParsedCookie { move(name), move(value), same_site_attribute, move(expiry_time_from_expires_attribute), move(expiry_time_from_max_age_attribute), move(domain), move(path), secure_attribute_present, http_only_attribute_present };
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,6 @@ template<>
|
||||||
bool encode(Encoder&, Web::Cookie::ParsedCookie const&);
|
bool encode(Encoder&, Web::Cookie::ParsedCookie const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Web::Cookie::ParsedCookie&);
|
ErrorOr<Web::Cookie::ParsedCookie> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,31 +48,23 @@ bool IPC::encode(Encoder& encoder, Web::WebDriver::Response const& response)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> IPC::decode(Decoder& decoder, Web::WebDriver::Response& response)
|
ErrorOr<Web::WebDriver::Response> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
ResponseType type {};
|
auto type = TRY(decoder.decode<ResponseType>());
|
||||||
TRY(decoder.decode(type));
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ResponseType::Success: {
|
case ResponseType::Success:
|
||||||
JsonValue value;
|
return TRY(decoder.decode<JsonValue>());
|
||||||
TRY(decoder.decode(value));
|
|
||||||
|
|
||||||
response = move(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ResponseType::Error: {
|
case ResponseType::Error: {
|
||||||
Web::WebDriver::Error error {};
|
auto http_status = TRY(decoder.decode<unsigned>());
|
||||||
TRY(decoder.decode(error.http_status));
|
auto error = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(error.error));
|
auto message = TRY(decoder.decode<DeprecatedString>());
|
||||||
TRY(decoder.decode(error.message));
|
auto data = TRY(decoder.decode<Optional<JsonValue>>());
|
||||||
TRY(decoder.decode(error.data));
|
|
||||||
|
|
||||||
response = move(error);
|
return Web::WebDriver::Error { http_status, move(error), move(message), move(data) };
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,6 @@ template<>
|
||||||
bool encode(Encoder&, Web::WebDriver::Response const&);
|
bool encode(Encoder&, Web::WebDriver::Response const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, Web::WebDriver::Response&);
|
ErrorOr<Web::WebDriver::Response> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,12 +77,12 @@ template<>
|
||||||
bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&);
|
bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout::Screen&);
|
ErrorOr<WindowServer::ScreenLayout::Screen> decode(Decoder&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool encode(Encoder&, WindowServer::ScreenLayout const&);
|
bool encode(Encoder&, WindowServer::ScreenLayout const&);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout&);
|
ErrorOr<WindowServer::ScreenLayout> decode(Decoder&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ bool ScreenLayout::is_valid(DeprecatedString* error_msg) const
|
||||||
*error_msg = "Screen layout has not been normalized";
|
*error_msg = "Screen layout has not been normalized";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Vector<const Screen*, 16> reachable_screens { &screens[main_screen_index] };
|
Vector<Screen const*, 16> reachable_screens { &screens[main_screen_index] };
|
||||||
bool did_reach_another_screen;
|
bool did_reach_another_screen;
|
||||||
do {
|
do {
|
||||||
did_reach_another_screen = false;
|
did_reach_another_screen = false;
|
||||||
|
@ -225,7 +225,7 @@ bool ScreenLayout::normalize()
|
||||||
return did_change;
|
return did_change;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenLayout::load_config(const Core::ConfigFile& config_file, DeprecatedString* error_msg)
|
bool ScreenLayout::load_config(Core::ConfigFile const& config_file, DeprecatedString* error_msg)
|
||||||
{
|
{
|
||||||
screens.clear_with_capacity();
|
screens.clear_with_capacity();
|
||||||
main_screen_index = config_file.read_num_entry("Screens", "MainScreen", 0);
|
main_screen_index = config_file.read_num_entry("Screens", "MainScreen", 0);
|
||||||
|
@ -290,7 +290,7 @@ bool ScreenLayout::save_config(Core::ConfigFile& config_file, bool sync) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenLayout::operator!=(const ScreenLayout& other) const
|
bool ScreenLayout::operator!=(ScreenLayout const& other) const
|
||||||
{
|
{
|
||||||
if (this == &other)
|
if (this == &other)
|
||||||
return false;
|
return false;
|
||||||
|
@ -400,20 +400,15 @@ bool encode(Encoder& encoder, WindowServer::ScreenLayout::Screen const& screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout::Screen& screen)
|
ErrorOr<WindowServer::ScreenLayout::Screen> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
WindowServer::ScreenLayout::Screen::Mode mode;
|
auto mode = TRY(decoder.decode<WindowServer::ScreenLayout::Screen::Mode>());
|
||||||
TRY(decoder.decode(mode));
|
auto device = TRY(decoder.decode<Optional<DeprecatedString>>());
|
||||||
Optional<DeprecatedString> device;
|
auto location = TRY(decoder.decode<Gfx::IntPoint>());
|
||||||
TRY(decoder.decode(device));
|
auto resolution = TRY(decoder.decode<Gfx::IntSize>());
|
||||||
Gfx::IntPoint location;
|
auto scale_factor = TRY(decoder.decode<int>());
|
||||||
TRY(decoder.decode(location));
|
|
||||||
Gfx::IntSize resolution;
|
return WindowServer::ScreenLayout::Screen { mode, device, location, resolution, scale_factor };
|
||||||
TRY(decoder.decode(resolution));
|
|
||||||
int scale_factor = 0;
|
|
||||||
TRY(decoder.decode(scale_factor));
|
|
||||||
screen = { mode, device, location, resolution, scale_factor };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -424,14 +419,12 @@ bool encode(Encoder& encoder, WindowServer::ScreenLayout const& screen_layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
ErrorOr<void> decode(Decoder& decoder, WindowServer::ScreenLayout& screen_layout)
|
ErrorOr<WindowServer::ScreenLayout> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
Vector<WindowServer::ScreenLayout::Screen> screens;
|
auto screens = TRY(decoder.decode<Vector<WindowServer::ScreenLayout::Screen>>());
|
||||||
TRY(decoder.decode(screens));
|
auto main_screen_index = TRY(decoder.decode<unsigned>());
|
||||||
unsigned main_screen_index = 0;
|
|
||||||
TRY(decoder.decode(main_screen_index));
|
return WindowServer::ScreenLayout { move(screens), main_screen_index };
|
||||||
screen_layout = { move(screens), main_screen_index };
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue