Bug 176456 - Add modern decoders for POD types
Summary: Add modern decoders for POD types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-06 08:19 PDT by Alex Christensen
Modified: 2017-09-27 12:38 PDT (History)
3 users (show)

See Also:


Attachments
Patch (7.49 KB, patch)
2017-09-06 08:20 PDT, Alex Christensen
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2017-09-06 08:19:43 PDT
Add modern decoders for POD types
Comment 1 Alex Christensen 2017-09-06 08:20:42 PDT
Created attachment 320019 [details]
Patch
Comment 2 Geoffrey Garen 2017-09-06 10:04:58 PDT
Comment on attachment 320019 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=320019&action=review

r=me

> Source/WebKit/Platform/IPC/Decoder.cpp:241
> +Decoder& Decoder::operator>>(std::optional<bool>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<uint8_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<uint16_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<uint32_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<uint64_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<int32_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<int64_t>& optional)
> +{
> +    return getOptional(optional);
> +}
> +
> +Decoder& Decoder::operator>>(std::optional<float>& optional)
> +{
> +    return getOptional(optional);
> +}

Kind of weird that our idiom is to use overloading instead of a template parameter for these >> functions and for our decode functions.

If we're just trying to verify that our type is a POD type, we can use std::is_pod.
Comment 3 Alex Christensen 2017-09-06 10:19:37 PDT
With enums (which are also POD types) we also check to see if they are valid enums.  I think the intent was once to only have certain types serializable, but since that list has grown so much maybe we should clean this up a bit.
Comment 4 Alex Christensen 2017-09-06 13:26:58 PDT
http://trac.webkit.org/r221698
Comment 5 Darin Adler 2017-09-06 15:26:06 PDT
Seems like we should find a way to allow any type to be optional and not write out each function like this.
Comment 6 Radar WebKit Bug Importer 2017-09-27 12:38:53 PDT
<rdar://problem/34693681>