Bug 257581 - Add support to GeneratedSerializers for move-only types
Summary: Add support to GeneratedSerializers for move-only types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matt Woodrow
URL:
Keywords: InRadar
Depends on:
Blocks: 257580
  Show dependency treegraph
 
Reported: 2023-05-31 19:18 PDT by Matt Woodrow
Modified: 2023-06-27 23:44 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Woodrow 2023-05-31 19:18:08 PDT
We should be able to define types as being move-only, and generate appropriate serialisers for them.
Comment 1 Kimmo Kinnunen 2023-05-31 23:16:49 PDT
This should not need much of additional markup in the .serializers.in file.
The fix should be to use different pattern to decode

std::optional<Ref<WebCore::TimingFunction>> ArgumentCoder<WebCore::TimingFunction>::decode(Decoder& decoder)
{
    std::optional<WebCore_TimingFunction_Subclass> type;
    decoder >> type;
    if (!type)
        return std::nullopt;

    if (type == WebCore_TimingFunction_Subclass::LinearTimingFunction) {
        std::optional<Ref<WebCore::LinearTimingFunction>> result;
        decoder >> result;
        if (!result)
            return std::nullopt;
        return WTFMove(*result);
    }


should be

std::optional<Ref<WebCore::TimingFunction>> ArgumentCoder<WebCore::TimingFunction>::decode(Decoder& decoder)
{
    auto type = decoder.decode<WebCore_TimingFunction_Subclass>();
    if (UNLIKELY(!decoder.isValid()))
        return std::nullopt;

    if (type == WebCore_TimingFunction_Subclass::LinearTimingFunction) {
        auto result = decoder.decode<Ref<WebCore::LinearTimingFunction>>()
        if (UNLIKELY(!decoder.isValid()))
            return std::nullopt;
        return WTFMove(*result);
    }
Comment 2 Matt Woodrow 2023-06-04 15:04:12 PDT
Pull request: https://github.com/WebKit/WebKit/pull/14658
Comment 3 EWS 2023-06-06 15:38:39 PDT
Committed 264912@main (6b8b65111faf): <https://commits.webkit.org/264912@main>

Reviewed commits have been landed. Closing PR #14658 and removing active labels.
Comment 4 Radar WebKit Bug Importer 2023-06-06 15:39:16 PDT
<rdar://problem/110350309>