Bug 257581

Summary: Add support to GeneratedSerializers for move-only types
Product: WebKit Reporter: Matt Woodrow <mattwoodrow>
Component: WebKit2Assignee: Matt Woodrow <mattwoodrow>
Status: RESOLVED FIXED    
Severity: Normal CC: don.olmstead, kkinnunen, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=258608
Bug Depends on:    
Bug Blocks: 257580    

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>