<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174863] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174863">174863</a></dd>
<dt>Author</dt> <dd>burg@cs.washington.edu</dd>
<dt>Date</dt> <dd>2014-10-18 11:13:05 -0700 (Sat, 18 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Replay: code generator shouldn't complain about enums without a storage type if they are in an enclosing scope
https://bugs.webkit.org/show_bug.cgi?id=137084

Reviewed by Joseph Pecoraro.

In order to generate encode/decode method declarations without pulling in lots of headers,
the generator must forward declare enums (for enum classes or enums with explicit sizes).

Change the generator to not require an explicit size if an enum is declared inside a struct
or class definition. In that case, it must pull in headers since scoped enums can't be
forward declared.

This patch also fixes some chained if-statements that should be if-else statements.

Test: updated replay/scripts/tests/generate-enum-encoding-helpers.json to cover the new case.

* replay/scripts/CodeGeneratorReplayInputs.py:
(InputsModel.parse_type_with_framework_name.is):
(InputsModel.parse_type_with_framework_name.is.must):
(Generator.generate_enum_trait_implementation):
(InputsModel.parse_type_with_framework_name): Deleted.
* replay/scripts/CodeGeneratorReplayInputsTemplates.py:
* replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error:
* replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp:
(JSC::EncodingTraits&lt;WebCore::MouseButton&gt;::decodeValue):
* replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp:
(JSC::EncodingTraits&lt;WebCore::MouseButton&gt;::decodeValue):
(JSC::EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::encodeValue):
(JSC::EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::decodeValue):
* replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h:
* replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp:
(JSC::EncodingTraits&lt;WebCore::FormData1::Type&gt;::decodeValue):
(JSC::EncodingTraits&lt;PlatformEvent1::Type&gt;::decodeValue):
* replay/scripts/tests/generate-enum-encoding-helpers.json: Added a new input to cover this case.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptsCodeGeneratorReplayInputspy">trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptsCodeGeneratorReplayInputsTemplatespy">trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedfailoncstyleenumnostoragejsonerror">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelperswithguardedvaluesjsonTestReplayInputscpp">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelpersjsonTestReplayInputscpp">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelpersjsonTestReplayInputsh">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumwithguardjsonTestReplayInputscpp">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumswithsamebasenamejsonTestReplayInputscpp">trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorereplayscriptstestsgenerateenumencodinghelpersjson">trunk/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2014-10-18  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
+
+        Web Replay: code generator shouldn't complain about enums without a storage type if they are in an enclosing scope
+        https://bugs.webkit.org/show_bug.cgi?id=137084
+
+        Reviewed by Joseph Pecoraro.
+
+        In order to generate encode/decode method declarations without pulling in lots of headers,
+        the generator must forward declare enums (for enum classes or enums with explicit sizes).
+
+        Change the generator to not require an explicit size if an enum is declared inside a struct
+        or class definition. In that case, it must pull in headers since scoped enums can't be
+        forward declared.
+
+        This patch also fixes some chained if-statements that should be if-else statements.
+
+        Test: updated replay/scripts/tests/generate-enum-encoding-helpers.json to cover the new case.
+
+        * replay/scripts/CodeGeneratorReplayInputs.py:
+        (InputsModel.parse_type_with_framework_name.is):
+        (InputsModel.parse_type_with_framework_name.is.must):
+        (Generator.generate_enum_trait_implementation):
+        (InputsModel.parse_type_with_framework_name): Deleted.
+        * replay/scripts/CodeGeneratorReplayInputsTemplates.py:
+        * replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error:
+        * replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp:
+        (JSC::EncodingTraits&lt;WebCore::MouseButton&gt;::decodeValue):
+        * replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp:
+        (JSC::EncodingTraits&lt;WebCore::MouseButton&gt;::decodeValue):
+        (JSC::EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::encodeValue):
+        (JSC::EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::decodeValue):
+        * replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h:
+        * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp:
+        (JSC::EncodingTraits&lt;WebCore::FormData1::Type&gt;::decodeValue):
+        (JSC::EncodingTraits&lt;PlatformEvent1::Type&gt;::decodeValue):
+        * replay/scripts/tests/generate-enum-encoding-helpers.json: Added a new input to cover this case.
+
</ins><span class="cx"> 2014-10-17  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Process crash when starting the web inspector after r174025.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptsCodeGeneratorReplayInputspy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -454,8 +454,8 @@
</span><span class="cx">             if not isinstance(json['values'], list) or len(_type.values) == 0:
</span><span class="cx">                 raise ParseException(&quot;Malformed specification: enum %s does not supply a list of values&quot; % type_name)
</span><span class="cx"> 
</span><del>-            if _type.is_enum() and &quot;storage&quot; not in json:
-                raise ParseException(&quot;Could not parse enum %s: C-style enums must also specify their storage type so they can be forward declared.&quot; % type_name)
</del><ins>+            if _type.is_enum() and enclosing_class is None and type_storage is None:
+                raise ParseException(&quot;Could not parse enum %s: C-style enums not enclosed by a class must specify their storage type so they can be forward declared.&quot; % type_name)
</ins><span class="cx"> 
</span><span class="cx">         self.types.append(_type)
</span><span class="cx"> 
</span><span class="lines">@@ -835,8 +835,10 @@
</span><span class="cx"> 
</span><span class="cx">         # Generate body for decode.
</span><span class="cx">         decodeLines = []
</span><del>-        for _value in _type.values:
</del><ins>+        for i, _value in enumerate(_type.values):
+
</ins><span class="cx">             template_arguments = {
</span><ins>+                'branchKeyword': &quot;else if&quot; if i &gt; 0 else &quot;if&quot;,
</ins><span class="cx">                 'enumStringValue': _value,
</span><span class="cx">                 'qualifiedEnumValue': &quot;%s%s&quot; % (enum_prefix, _value),
</span><span class="cx">                 'qualifiedEnumName': _type.type_name(qualified=should_qualify_type)
</span><span class="lines">@@ -845,8 +847,9 @@
</span><span class="cx"> 
</span><span class="cx">         for guard, guard_values in _type.guard_values_map.iteritems():
</span><span class="cx">             guardedLines = []
</span><del>-            for guard_value in guard_values:
</del><ins>+            for i, guard_value in enumerate(guard_values):
</ins><span class="cx">                 template_arguments = {
</span><ins>+                    'branchKeyword': &quot;else if&quot; if i &gt; 0 else &quot;if&quot;,
</ins><span class="cx">                     'enumStringValue': guard_value,
</span><span class="cx">                     'qualifiedEnumValue': &quot;%s%s&quot; % (enum_prefix, guard_value),
</span><span class="cx">                     'qualifiedEnumName': _type.type_name(qualified=should_qualify_type)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptsCodeGeneratorReplayInputsTemplatespy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx"> ${decodeCases}
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -224,7 +224,7 @@
</span><span class="cx">     }&quot;&quot;&quot;)
</span><span class="cx"> 
</span><span class="cx">     EnumDecodeCase = (
</span><del>-    &quot;&quot;&quot;        if (enumString == &quot;${enumStringValue}&quot;)
</del><ins>+    &quot;&quot;&quot;        ${branchKeyword} (enumString == &quot;${enumStringValue}&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;${qualifiedEnumName}&gt;(enumValue | ${qualifiedEnumValue});&quot;&quot;&quot;)
</span><span class="cx"> 
</span><span class="cx">     InputClassImplementation = (
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedfailoncstyleenumnostoragejsonerror"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -1 +1 @@
</span><del>-ERROR: Could not parse enum MouseButton: C-style enums must also specify their storage type so they can be forward declared.
</del><ins>+ERROR: Could not parse enum MouseButton: C-style enums not enclosed by a class must specify their storage type so they can be forward declared.
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelperswithguardedvaluesjsonTestReplayInputscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -119,19 +119,19 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx">         if (enumString == &quot;NoButton&quot;)
</span><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::NoButton);
</span><del>-        if (enumString == &quot;LeftButton&quot;)
</del><ins>+        else if (enumString == &quot;LeftButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::LeftButton);
</span><del>-        if (enumString == &quot;MiddleButton&quot;)
</del><ins>+        else if (enumString == &quot;MiddleButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::MiddleButton);
</span><del>-        if (enumString == &quot;RightButton&quot;)
</del><ins>+        else if (enumString == &quot;RightButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::RightButton);
</span><span class="cx"> #if ENABLE(SIDE_BUTTONS)
</span><span class="cx">         if (enumString == &quot;LeftSideButton&quot;)
</span><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::LeftSideButton);
</span><del>-        if (enumString == &quot;RightSideButton&quot;)
</del><ins>+        else if (enumString == &quot;RightSideButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::RightSideButton);
</span><span class="cx"> #endif // ENABLE(SIDE_BUTTONS)
</span><span class="cx"> #if PLATFORM(WINDOWS)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelpersjsonTestReplayInputscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -129,19 +129,65 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx">         if (enumString == &quot;NoButton&quot;)
</span><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::NoButton);
</span><del>-        if (enumString == &quot;LeftButton&quot;)
</del><ins>+        else if (enumString == &quot;LeftButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::LeftButton);
</span><del>-        if (enumString == &quot;MiddleButton&quot;)
</del><ins>+        else if (enumString == &quot;MiddleButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::MiddleButton);
</span><del>-        if (enumString == &quot;RightButton&quot;)
</del><ins>+        else if (enumString == &quot;RightButton&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::MouseButton&gt;(enumValue | WebCore::RightButton);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><ins>+
+EncodedValue EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::encodeValue(const WebCore::PlatformEvent::Type&amp; enumValue)
+{
+    EncodedValue encodedValue = EncodedValue::createArray();
+    if (enumValue &amp; WebCore::PlatformEvent::Mouse) {
+        encodedValue.append&lt;String&gt;(ASCIILiteral(&quot;Mouse&quot;));
+        if (enumValue == WebCore::PlatformEvent::Mouse)
+            return encodedValue;
+    }
+    if (enumValue &amp; WebCore::PlatformEvent::Key) {
+        encodedValue.append&lt;String&gt;(ASCIILiteral(&quot;Key&quot;));
+        if (enumValue == WebCore::PlatformEvent::Key)
+            return encodedValue;
+    }
+    if (enumValue &amp; WebCore::PlatformEvent::Touch) {
+        encodedValue.append&lt;String&gt;(ASCIILiteral(&quot;Touch&quot;));
+        if (enumValue == WebCore::PlatformEvent::Touch)
+            return encodedValue;
+    }
+    if (enumValue &amp; WebCore::PlatformEvent::Wheel) {
+        encodedValue.append&lt;String&gt;(ASCIILiteral(&quot;Wheel&quot;));
+        if (enumValue == WebCore::PlatformEvent::Wheel)
+            return encodedValue;
+    }
+    return encodedValue;
+}
+
+bool EncodingTraits&lt;WebCore::PlatformEvent::Type&gt;::decodeValue(EncodedValue&amp; encodedValue, WebCore::PlatformEvent::Type&amp; enumValue)
+{
+    Vector&lt;String&gt; enumStrings;
+    if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
+        return false;
+
+    for (const String&amp; enumString : enumStrings) {
+        if (enumString == &quot;Mouse&quot;)
+            enumValue = static_cast&lt;WebCore::PlatformEvent::Type&gt;(enumValue | WebCore::PlatformEvent::Mouse);
+        else if (enumString == &quot;Key&quot;)
+            enumValue = static_cast&lt;WebCore::PlatformEvent::Type&gt;(enumValue | WebCore::PlatformEvent::Key);
+        else if (enumString == &quot;Touch&quot;)
+            enumValue = static_cast&lt;WebCore::PlatformEvent::Type&gt;(enumValue | WebCore::PlatformEvent::Touch);
+        else if (enumString == &quot;Wheel&quot;)
+            enumValue = static_cast&lt;WebCore::PlatformEvent::Type&gt;(enumValue | WebCore::PlatformEvent::Wheel);
+    }
+
+    return true;
+}
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEB_REPLAY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumencodinghelpersjsonTestReplayInputsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #if ENABLE(WEB_REPLAY)
</span><span class="cx"> #include &quot;InternalNamespaceHeaderIncludeDummy.h&quot;
</span><span class="cx"> #include &lt;platform/ExternalNamespaceHeaderIncludeDummy.h&gt;
</span><ins>+#include &lt;platform/PlatformEvent.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> enum MouseButton : unsigned;
</span><span class="lines">@@ -68,6 +69,13 @@
</span><span class="cx">     static EncodedValue encodeValue(const WebCore::MouseButton&amp; value);
</span><span class="cx">     static bool decodeValue(EncodedValue&amp;, WebCore::MouseButton&amp; value);
</span><span class="cx"> };
</span><ins>+
+template&lt;&gt; struct EncodingTraits&lt;WebCore::PlatformEvent::Type&gt; {
+    typedef WebCore::PlatformEvent::Type DecodedType;
+
+    static EncodedValue encodeValue(const WebCore::PlatformEvent::Type&amp; value);
+    static bool decodeValue(EncodedValue&amp;, WebCore::PlatformEvent::Type&amp; value);
+};
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> namespace Test {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumwithguardjsonTestReplayInputscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx">         if (enumString == &quot;PlatformWheelEventPhaseNone&quot;)
</span><span class="cx">             enumValue = static_cast&lt;WebCore::PlatformWheelEventPhase&gt;(enumValue | WebCore::PlatformWheelEventPhaseNone);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsexpectedgenerateenumswithsamebasenamejsonTestReplayInputscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -107,10 +107,10 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx">         if (enumString == &quot;Text&quot;)
</span><span class="cx">             enumValue = static_cast&lt;WebCore::FormData1::Type&gt;(enumValue | WebCore::FormData1::Text);
</span><del>-        if (enumString == &quot;Blob&quot;)
</del><ins>+        else if (enumString == &quot;Blob&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;WebCore::FormData1::Type&gt;(enumValue | WebCore::FormData1::Blob);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -162,10 +162,10 @@
</span><span class="cx">     if (!EncodingTraits&lt;Vector&lt;String&gt;&gt;::decodeValue(encodedValue, enumStrings))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (String enumString : enumStrings) {
</del><ins>+    for (const String&amp; enumString : enumStrings) {
</ins><span class="cx">         if (enumString == &quot;Mouse&quot;)
</span><span class="cx">             enumValue = static_cast&lt;PlatformEvent1::Type&gt;(enumValue | PlatformEvent1::Mouse);
</span><del>-        if (enumString == &quot;Keyboard&quot;)
</del><ins>+        else if (enumString == &quot;Keyboard&quot;)
</ins><span class="cx">             enumValue = static_cast&lt;PlatformEvent1::Type&gt;(enumValue | PlatformEvent1::Keyboard);
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorereplayscriptstestsgenerateenumencodinghelpersjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json (174862 => 174863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json        2014-10-18 17:05:24 UTC (rev 174862)
+++ trunk/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json        2014-10-18 18:13:05 UTC (rev 174863)
</span><span class="lines">@@ -14,6 +14,13 @@
</span><span class="cx">                 &quot;flags&quot;: [&quot;ENUM&quot;],
</span><span class="cx">                 &quot;values&quot;: [&quot;NoButton&quot;, &quot;LeftButton&quot;, &quot;MiddleButton&quot;, &quot;RightButton&quot;],
</span><span class="cx">                 &quot;header&quot;: &quot;platform/PlatformMouseEvent.h&quot;
</span><ins>+            },
+            {
+                &quot;name&quot;: &quot;Type&quot;, &quot;mode&quot;: &quot;SCALAR&quot;,
+                &quot;flags&quot;: [&quot;ENUM&quot;],
+                &quot;enclosing_class&quot;: &quot;PlatformEvent&quot;,
+                &quot;values&quot;: [&quot;Mouse&quot;, &quot;Key&quot;, &quot;Touch&quot;, &quot;Wheel&quot;],
+                &quot;header&quot;: &quot;platform/PlatformEvent.h&quot;
</ins><span class="cx">             }
</span><span class="cx">         ]
</span><span class="cx">     },
</span></span></pre>
</div>
</div>

</body>
</html>