Bug 136297

Summary: Web Replay: code generator should be able to encode/decode ViewState::Flags
Product: WebKit Reporter: Brian Burg <burg>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Severity: Normal CC: bburg, joepeck
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 136312    
Bug Blocks: 129694    
Description Flags
WIP none

Description Brian Burg 2014-08-27 11:04:54 PDT
ViewState::(enum) is an anonymous enum inside of a struct (ViewState). ViewState::Flags is a typedef for uint32_t, and the enum values are used to bitwise-construct and query a uint32_t containing several flags.

For replay we still want to serialize ViewState with string names, since ViewState::Flags could change in the future and we don't want reordering the flags to break serialization.
But, since the enum is un-named and ViewState::Flags is a uint32_t, the existing code will try to define new EncodingTraits specializations for uint32_t, which isn't allowed.

To sidestep this, I'll generate a wrapper class for each framework, so multiple specializations can exist for the same underlying type. Cases like ViewState will use a new flag in the inputs file to opt-in to this code generation behavior.


enum class JSEnum { FooBar, BarBaz };

template <JSEnum EnumName, typename StorageType>
class UncheckedJSEnum {
    UncheckedJSEnum(StorageType value) : m_value(value) { }
    StorageType m_value;
template<> struct EncodingTraits<UncheckedJSEnum<JSEnum::FooBar,uint32_t>> {
Comment 1 Brian Burg 2014-08-27 11:59:58 PDT
Even simpler:

enum class WebEnums { FooBar, BarBaz };
struct ViewState {
    typedef uint32_t Flags;
template <typename EnumType, EnumType tag>
class Phantom { };
template<> struct EncodingTraits<Phantom<JSEnums,JSEnums::FooBar>> {
    typedef ViewState::Flags DecodedType;
    static EncodedValue encodeValue(const DecodedType&);
    static bool decodeValue(EncodedValue&, const DecodedType&);
Comment 2 Brian Burg 2014-09-24 16:36:44 PDT
Created attachment 238625 [details]
Comment 3 BJ Burg 2017-07-10 13:59:36 PDT
Closing web replay-related bugs until we resume working on the feature again.