Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (171682 => 171683)
--- trunk/Source/_javascript_Core/ChangeLog 2014-07-28 19:21:15 UTC (rev 171682)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-07-28 19:22:43 UTC (rev 171683)
@@ -1,5 +1,28 @@
2014-07-28 Brian J. Burg <b...@cs.washington.edu>
+ Web Replay: incorrect serialization code generated for enum classes inside class scope
+ https://bugs.webkit.org/show_bug.cgi?id=135342
+
+ Reviewed by Timothy Hatcher.
+
+ If an enum class is defined inside of a class scope, then the enum class
+ cannot be forward-declared and the relevant header should be included.
+ Some generated code used incorrectly-scoped enum values in this situation.
+
+ * replay/scripts/CodeGeneratorReplayInputs.py:
+ (Generator.generate_includes.declaration.is):
+ (Generator.generate_enum_trait_implementation.is):
+ (Generator.generate_enum_trait_implementation):
+
+ Tests:
+
+ * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp: Rebaselined.
+ * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h: Rebaselined.
+ * replay/scripts/tests/generate-enums-with-same-base-name.json: Add enum
+ class types to this test case.
+
+2014-07-28 Brian J. Burg <b...@cs.washington.edu>
+
Web Replay: vectors of characters should be base64-encoded
https://bugs.webkit.org/show_bug.cgi?id=135341
Modified: trunk/Source/_javascript_Core/replay/scripts/CodeGeneratorReplayInputs.py (171682 => 171683)
--- trunk/Source/_javascript_Core/replay/scripts/CodeGeneratorReplayInputs.py 2014-07-28 19:21:15 UTC (rev 171682)
+++ trunk/Source/_javascript_Core/replay/scripts/CodeGeneratorReplayInputs.py 2014-07-28 19:22:43 UTC (rev 171683)
@@ -635,7 +635,7 @@
include_for_destructor = _type.mode is TypeModes.SHARED
# Enums within classes cannot be forward declared, so we include
# headers with the relevant class declaration.
- include_for_enclosing_class = _type.is_enum() and _type.enclosing_class is not None
+ include_for_enclosing_class = _type.enclosing_class is not None
# Include headers for types like URL and String which are copied, not owned or shared.
include_for_copyable_member = _type.mode is TypeModes.HEAVY_SCALAR
if (not includes_for_types) ^ (include_for_destructor or include_for_enclosing_class or include_for_copyable_member):
@@ -801,10 +801,10 @@
prefix_components = []
if should_qualify_type:
prefix_components.append(_type.framework.setting('namespace'))
- if _type.is_enum_class():
- prefix_components.append(_type.type_name())
- if _type.enclosing_class is not None:
+ if _type.is_enum() and _type.enclosing_class is not None:
prefix_components.append(_type.enclosing_class)
+ elif _type.is_enum_class():
+ prefix_components.append(_type.type_name(qualified=False))
prefix_components.append("")
enum_prefix = "::".join(prefix_components)
encodeLines = []
Modified: trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp (171682 => 171683)
--- trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp 2014-07-28 19:21:15 UTC (rev 171682)
+++ trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp 2014-07-28 19:22:43 UTC (rev 171683)
@@ -35,10 +35,12 @@
#include <platform/ExternalNamespaceImplIncludeDummy.h>
namespace Test {
-FormCombo::FormCombo(PlatformEvent::Type eventType, FormData::Type formType)
+FormCombo::FormCombo(PlatformEvent1::Type eventType1, PlatformEvent2::Type eventType2, FormData1::Type formType1, FormData2::Type formType2)
: NondeterministicInput<FormCombo>()
- , m_eventType(eventType)
- , m_formType(formType)
+ , m_eventType1(eventType1)
+ , m_eventType2(eventType2)
+ , m_formType1(formType1)
+ , m_formType2(formType2)
{
}
@@ -56,40 +58,50 @@
void InputTraits<Test::FormCombo>::encode(EncodedValue& encodedValue, const Test::FormCombo& input)
{
- encodedValue.put<PlatformEvent::Type>(ASCIILiteral("eventType"), input.eventType());
- encodedValue.put<WebCore::FormData::Type>(ASCIILiteral("formType"), input.formType());
+ encodedValue.put<PlatformEvent1::Type>(ASCIILiteral("eventType1"), input.eventType1());
+ encodedValue.put<PlatformEvent2::Type>(ASCIILiteral("eventType2"), input.eventType2());
+ encodedValue.put<WebCore::FormData1::Type>(ASCIILiteral("formType1"), input.formType1());
+ encodedValue.put<WebCore::FormData2::Type>(ASCIILiteral("formType2"), input.formType2());
}
bool InputTraits<Test::FormCombo>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::FormCombo>& input)
{
- PlatformEvent::Type eventType;
- if (!encodedValue.get<PlatformEvent::Type>(ASCIILiteral("eventType"), eventType))
+ PlatformEvent1::Type eventType1;
+ if (!encodedValue.get<PlatformEvent1::Type>(ASCIILiteral("eventType1"), eventType1))
return false;
- WebCore::FormData::Type formType;
- if (!encodedValue.get<WebCore::FormData::Type>(ASCIILiteral("formType"), formType))
+ PlatformEvent2::Type eventType2;
+ if (!encodedValue.get<PlatformEvent2::Type>(ASCIILiteral("eventType2"), eventType2))
return false;
- input = std::make_unique<Test::FormCombo>(eventType, formType);
+ WebCore::FormData1::Type formType1;
+ if (!encodedValue.get<WebCore::FormData1::Type>(ASCIILiteral("formType1"), formType1))
+ return false;
+
+ WebCore::FormData2::Type formType2;
+ if (!encodedValue.get<WebCore::FormData2::Type>(ASCIILiteral("formType2"), formType2))
+ return false;
+
+ input = std::make_unique<Test::FormCombo>(eventType1, eventType2, formType1, formType2);
return true;
}
-EncodedValue EncodingTraits<WebCore::FormData::Type>::encodeValue(const WebCore::FormData::Type& enumValue)
+EncodedValue EncodingTraits<WebCore::FormData1::Type>::encodeValue(const WebCore::FormData1::Type& enumValue)
{
EncodedValue encodedValue = EncodedValue::createArray();
- if (enumValue & WebCore::FormData::Text) {
+ if (enumValue & WebCore::FormData1::Text) {
encodedValue.append<String>(ASCIILiteral("Text"));
- if (enumValue == WebCore::FormData::Text)
+ if (enumValue == WebCore::FormData1::Text)
return encodedValue;
}
- if (enumValue & WebCore::FormData::Blob) {
+ if (enumValue & WebCore::FormData1::Blob) {
encodedValue.append<String>(ASCIILiteral("Blob"));
- if (enumValue == WebCore::FormData::Blob)
+ if (enumValue == WebCore::FormData1::Blob)
return encodedValue;
}
return encodedValue;
}
-bool EncodingTraits<WebCore::FormData::Type>::decodeValue(EncodedValue& encodedValue, WebCore::FormData::Type& enumValue)
+bool EncodingTraits<WebCore::FormData1::Type>::decodeValue(EncodedValue& encodedValue, WebCore::FormData1::Type& enumValue)
{
Vector<String> enumStrings;
if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings))
@@ -97,31 +109,54 @@
for (String enumString : enumStrings) {
if (enumString == "Text")
- enumValue = static_cast<WebCore::FormData::Type>(enumValue | WebCore::FormData::Text);
+ enumValue = static_cast<WebCore::FormData1::Type>(enumValue | WebCore::FormData1::Text);
if (enumString == "Blob")
- enumValue = static_cast<WebCore::FormData::Type>(enumValue | WebCore::FormData::Blob);
+ enumValue = static_cast<WebCore::FormData1::Type>(enumValue | WebCore::FormData1::Blob);
}
return true;
}
-EncodedValue EncodingTraits<PlatformEvent::Type>::encodeValue(const PlatformEvent::Type& enumValue)
+EncodedValue EncodingTraits<WebCore::FormData2::Type>::encodeValue(const WebCore::FormData2::Type& enumValue)
{
+ switch (enumValue) {
+ case WebCore::FormData2::Type::Text: return EncodedValue::createString("Text");
+ case WebCore::FormData2::Type::Blob: return EncodedValue::createString("Blob");
+ default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!");
+ }
+}
+
+bool EncodingTraits<WebCore::FormData2::Type>::decodeValue(EncodedValue& encodedValue, WebCore::FormData2::Type& enumValue)
+{
+ String enumString = encodedValue.convertTo<String>();
+ if (enumString == "Text") {
+ enumValue = WebCore::FormData2::Type::Text;
+ return true;
+ }
+ if (enumString == "Blob") {
+ enumValue = WebCore::FormData2::Type::Blob;
+ return true;
+ }
+ return false;
+}
+
+EncodedValue EncodingTraits<PlatformEvent1::Type>::encodeValue(const PlatformEvent1::Type& enumValue)
+{
EncodedValue encodedValue = EncodedValue::createArray();
- if (enumValue & PlatformEvent::Mouse) {
+ if (enumValue & PlatformEvent1::Mouse) {
encodedValue.append<String>(ASCIILiteral("Mouse"));
- if (enumValue == PlatformEvent::Mouse)
+ if (enumValue == PlatformEvent1::Mouse)
return encodedValue;
}
- if (enumValue & PlatformEvent::Keyboard) {
+ if (enumValue & PlatformEvent1::Keyboard) {
encodedValue.append<String>(ASCIILiteral("Keyboard"));
- if (enumValue == PlatformEvent::Keyboard)
+ if (enumValue == PlatformEvent1::Keyboard)
return encodedValue;
}
return encodedValue;
}
-bool EncodingTraits<PlatformEvent::Type>::decodeValue(EncodedValue& encodedValue, PlatformEvent::Type& enumValue)
+bool EncodingTraits<PlatformEvent1::Type>::decodeValue(EncodedValue& encodedValue, PlatformEvent1::Type& enumValue)
{
Vector<String> enumStrings;
if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings))
@@ -129,13 +164,36 @@
for (String enumString : enumStrings) {
if (enumString == "Mouse")
- enumValue = static_cast<PlatformEvent::Type>(enumValue | PlatformEvent::Mouse);
+ enumValue = static_cast<PlatformEvent1::Type>(enumValue | PlatformEvent1::Mouse);
if (enumString == "Keyboard")
- enumValue = static_cast<PlatformEvent::Type>(enumValue | PlatformEvent::Keyboard);
+ enumValue = static_cast<PlatformEvent1::Type>(enumValue | PlatformEvent1::Keyboard);
}
return true;
}
+
+EncodedValue EncodingTraits<PlatformEvent2::Type>::encodeValue(const PlatformEvent2::Type& enumValue)
+{
+ switch (enumValue) {
+ case PlatformEvent2::Type::Mouse: return EncodedValue::createString("Mouse");
+ case PlatformEvent2::Type::Keyboard: return EncodedValue::createString("Keyboard");
+ default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!");
+ }
+}
+
+bool EncodingTraits<PlatformEvent2::Type>::decodeValue(EncodedValue& encodedValue, PlatformEvent2::Type& enumValue)
+{
+ String enumString = encodedValue.convertTo<String>();
+ if (enumString == "Mouse") {
+ enumValue = PlatformEvent2::Type::Mouse;
+ return true;
+ }
+ if (enumString == "Keyboard") {
+ enumValue = PlatformEvent2::Type::Keyboard;
+ return true;
+ }
+ return false;
+}
} // namespace JSC
#endif // ENABLE(WEB_REPLAY)
Modified: trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h (171682 => 171683)
--- trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h 2014-07-28 19:21:15 UTC (rev 171682)
+++ trunk/Source/_javascript_Core/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h 2014-07-28 19:22:43 UTC (rev 171683)
@@ -33,7 +33,8 @@
#if ENABLE(WEB_REPLAY)
#include "InternalNamespaceHeaderIncludeDummy.h"
#include <platform/ExternalNamespaceHeaderIncludeDummy.h>
-#include <replay/FormData.h>
+#include <replay/FormData1.h>
+#include <replay/FormData2.h>
#include <replay/PlatformEvent.h>
@@ -50,32 +51,50 @@
static void encode(JSC::EncodedValue&, const Test::FormCombo&);
static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::FormCombo>&);
};
-template<> struct EncodingTraits<WebCore::FormData::Type> {
- typedef WebCore::FormData::Type DecodedType;
+template<> struct EncodingTraits<WebCore::FormData1::Type> {
+ typedef WebCore::FormData1::Type DecodedType;
- static EncodedValue encodeValue(const WebCore::FormData::Type& value);
- static bool decodeValue(EncodedValue&, WebCore::FormData::Type& value);
+ static EncodedValue encodeValue(const WebCore::FormData1::Type& value);
+ static bool decodeValue(EncodedValue&, WebCore::FormData1::Type& value);
};
-template<> struct EncodingTraits<PlatformEvent::Type> {
- typedef PlatformEvent::Type DecodedType;
+template<> struct EncodingTraits<WebCore::FormData2::Type> {
+ typedef WebCore::FormData2::Type DecodedType;
- static EncodedValue encodeValue(const PlatformEvent::Type& value);
- static bool decodeValue(EncodedValue&, PlatformEvent::Type& value);
+ static EncodedValue encodeValue(const WebCore::FormData2::Type& value);
+ static bool decodeValue(EncodedValue&, WebCore::FormData2::Type& value);
};
+
+template<> struct EncodingTraits<PlatformEvent1::Type> {
+ typedef PlatformEvent1::Type DecodedType;
+
+ static EncodedValue encodeValue(const PlatformEvent1::Type& value);
+ static bool decodeValue(EncodedValue&, PlatformEvent1::Type& value);
+};
+
+template<> struct EncodingTraits<PlatformEvent2::Type> {
+ typedef PlatformEvent2::Type DecodedType;
+
+ static EncodedValue encodeValue(const PlatformEvent2::Type& value);
+ static bool decodeValue(EncodedValue&, PlatformEvent2::Type& value);
+};
} // namespace JSC
namespace Test {
class FormCombo : public NondeterministicInput<FormCombo> {
public:
- FormCombo(PlatformEvent::Type eventType, FormData::Type formType);
+ FormCombo(PlatformEvent1::Type eventType1, PlatformEvent2::Type eventType2, FormData1::Type formType1, FormData2::Type formType2);
virtual ~FormCombo();
- PlatformEvent::Type eventType() const { return m_eventType; }
- FormData::Type formType() const { return m_formType; }
+ PlatformEvent1::Type eventType1() const { return m_eventType1; }
+ PlatformEvent2::Type eventType2() const { return m_eventType2; }
+ FormData1::Type formType1() const { return m_formType1; }
+ FormData2::Type formType2() const { return m_formType2; }
private:
- PlatformEvent::Type m_eventType;
- FormData::Type m_formType;
+ PlatformEvent1::Type m_eventType1;
+ PlatformEvent2::Type m_eventType2;
+ FormData1::Type m_formType1;
+ FormData2::Type m_formType2;
};
} // namespace Test
Modified: trunk/Source/_javascript_Core/replay/scripts/tests/generate-enums-with-same-base-name.json (171682 => 171683)
--- trunk/Source/_javascript_Core/replay/scripts/tests/generate-enums-with-same-base-name.json 2014-07-28 19:21:15 UTC (rev 171682)
+++ trunk/Source/_javascript_Core/replay/scripts/tests/generate-enums-with-same-base-name.json 2014-07-28 19:22:43 UTC (rev 171683)
@@ -3,19 +3,33 @@
"_javascript_Core": [
{
"name": "Type", "mode": "SCALAR", "storage": "uint64_t",
- "enclosing_class": "PlatformEvent",
+ "enclosing_class": "PlatformEvent1",
"flags": ["ENUM"],
"values": ["Mouse", "Keyboard"],
"header": "replay/PlatformEvent.h"
+ },
+ {
+ "name": "Type", "mode": "SCALAR",
+ "enclosing_class": "PlatformEvent2",
+ "flags": ["ENUM_CLASS"],
+ "values": ["Mouse", "Keyboard"],
+ "header": "replay/PlatformEvent.h"
}
],
"WebCore": [
{
"name": "Type", "mode": "SCALAR", "storage": "uint64_t",
- "enclosing_class": "FormData",
+ "enclosing_class": "FormData1",
"flags": ["ENUM"],
"values": ["Text", "Blob"],
- "header": "replay/FormData.h"
+ "header": "replay/FormData1.h"
+ },
+ {
+ "name": "Type", "mode": "SCALAR",
+ "enclosing_class": "FormData2",
+ "flags": ["ENUM_CLASS"],
+ "values": ["Text", "Blob"],
+ "header": "replay/FormData2.h"
}
]
},
@@ -26,8 +40,10 @@
"description": "Combines an event type and form data type.",
"queue": "SCRIPT_MEMOIZED",
"members": [
- { "name": "eventType", "type": "PlatformEvent::Type" },
- { "name": "formType", "type": "FormData::Type" }
+ { "name": "eventType1", "type": "PlatformEvent1::Type" },
+ { "name": "eventType2", "type": "PlatformEvent2::Type" },
+ { "name": "formType1", "type": "FormData1::Type" },
+ { "name": "formType2", "type": "FormData2::Type" }
]
}
]