Changeset 167174 in webkit


Ignore:
Timestamp:
Apr 11, 2014 5:25:06 PM (10 years ago)
Author:
Brian Burg
Message:

Web Replay: code generator should consider enclosing class when computing duplicate type names
https://bugs.webkit.org/show_bug.cgi?id=131554

Reviewed by Timothy Hatcher.

We need to prepend an enum's enclosing class, if any, so that multiple enums with the same name
can coexist without triggering a "duplicate types" error. Now, such enums must be referenced
by the enclosing class and enum name.

Added tests for the new syntax, and rebaselined one test to reflect a previous patch's change.

  • replay/scripts/CodeGeneratorReplayInputs.py:

(Type.type_name): Prepend the enclosing class name.
(Type.type_name.is):

  • replay/scripts/tests/expected/fail-on-duplicate-enum-type.json-error: Added.
  • replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp: Added.
  • replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h: Added.
  • replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h: Rebaseline.
  • replay/scripts/tests/fail-on-duplicate-enum-type.json: Added.
  • replay/scripts/tests/generate-enums-with-same-base-name.json: Added.
Location:
trunk/Source/JavaScriptCore
Files:
4 added
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r167165 r167174  
     12014-04-11  Brian J. Burg  <burg@cs.washington.edu>
     2
     3        Web Replay: code generator should consider enclosing class when computing duplicate type names
     4        https://bugs.webkit.org/show_bug.cgi?id=131554
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        We need to prepend an enum's enclosing class, if any, so that multiple enums with the same name
     9        can coexist without triggering a "duplicate types" error. Now, such enums must be referenced
     10        by the enclosing class and enum name.
     11
     12        Added tests for the new syntax, and rebaselined one test to reflect a previous patch's change.
     13
     14        * replay/scripts/CodeGeneratorReplayInputs.py:
     15        (Type.type_name): Prepend the enclosing class name.
     16        (Type.type_name.is):
     17        * replay/scripts/tests/expected/fail-on-duplicate-enum-type.json-error: Added.
     18        * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp: Added.
     19        * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h: Added.
     20        * replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h: Rebaseline.
     21        * replay/scripts/tests/fail-on-duplicate-enum-type.json: Added.
     22        * replay/scripts/tests/generate-enums-with-same-base-name.json: Added.
     23
    1242014-04-11  Gavin Barraclough  <baraclough@apple.com>
    225
  • trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py

    r165521 r167174  
    331331
    332332    def type_name(self, qualified=False):
    333         return "%s%s" % (self.qualified_prefix(), self._name) if qualified else self._name
     333        if qualified:
     334            return "%s%s" % (self.qualified_prefix(), self._name)
     335        elif self.enclosing_class is not None:
     336            return "%s::%s" % (self.enclosing_class, self._name)
     337        else:
     338            return self._name
    334339
    335340    def storage_type(self, qualified=False):
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h

    r167173 r167174  
    2525 */
    2626
    27 // DO NOT EDIT THIS FILE. It is automatically generated from generate-input-with-vector-members.json
     27// DO NOT EDIT THIS FILE. It is automatically generated from generate-enums-with-same-base-name.json
    2828// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py
    2929
    30 #ifndef generate_input_with_vector_members_json_TestReplayInputs_h
    31 #define generate_input_with_vector_members_json_TestReplayInputs_h
     30#ifndef generate_enums_with_same_base_name_json_TestReplayInputs_h
     31#define generate_enums_with_same_base_name_json_TestReplayInputs_h
    3232
    3333#if ENABLE(WEB_REPLAY)
    3434#include "InternalNamespaceHeaderIncludeDummy.h"
    3535#include <platform/ExternalNamespaceHeaderIncludeDummy.h>
     36#include <replay/FormData.h>
     37#include <replay/PlatformEvent.h>
    3638
    37 namespace WebCore {
    38 class WebThing;
    39 }
    40 
    41 namespace JSC {
    42 class JSThing;
    43 }
    4439
    4540
    4641namespace Test {
    47 class ArrayOfThings;
     42class FormCombo;
    4843} // namespace Test
    4944
    5045namespace JSC {
    51 template<> struct InputTraits<Test::ArrayOfThings> {
     46template<> struct InputTraits<Test::FormCombo> {
    5247    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    5348    static const AtomicString& type();
    5449
    55     static void encode(JSC::EncodedValue&, const Test::ArrayOfThings&);
    56     static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::ArrayOfThings>&);
     50    static void encode(JSC::EncodedValue&, const Test::FormCombo&);
     51    static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::FormCombo>&);
     52};
     53template<> struct EncodingTraits<WebCore::FormData::Type> {
     54    typedef WebCore::FormData::Type DecodedType;
     55
     56    static EncodedValue encodeValue(const WebCore::FormData::Type& value);
     57    static bool decodeValue(EncodedValue&, WebCore::FormData::Type& value);
    5758};
    5859
     60template<> struct EncodingTraits<PlatformEvent::Type> {
     61    typedef PlatformEvent::Type DecodedType;
     62
     63    static EncodedValue encodeValue(const PlatformEvent::Type& value);
     64    static bool decodeValue(EncodedValue&, PlatformEvent::Type& value);
     65};
    5966} // namespace JSC
    6067
    6168namespace Test {
    62 class ArrayOfThings : public NondeterministicInput<ArrayOfThings> {
     69class FormCombo : public NondeterministicInput<FormCombo> {
    6370public:
    64     ArrayOfThings(Vector<double>& doubles, Vector<JSThing>& jsthings, Vector<WebThing>& webthings);
    65     virtual ~ArrayOfThings();
     71    FormCombo(PlatformEvent::Type eventType, FormData::Type formType);
     72    virtual ~FormCombo();
    6673
    67     const Vector<double>& doubles() const { return m_doubles; }
    68     const Vector<JSThing>& jsthings() const { return m_jsthings; }
    69     const Vector<WebThing>& webthings() const { return m_webthings; }
     74    PlatformEvent::Type eventType() const { return m_eventType; }
     75    FormData::Type formType() const { return m_formType; }
    7076private:
    71     Vector<double> m_doubles;
    72     Vector<JSThing> m_jsthings;
    73     Vector<WebThing> m_webthings;
     77    PlatformEvent::Type m_eventType;
     78    FormData::Type m_formType;
    7479};
    7580} // namespace Test
    7681
    7782#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \
    78     macro(ArrayOfThings) \
     83    macro(FormCombo) \
    7984    \
    8085// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH
     
    8287#endif // ENABLE(WEB_REPLAY)
    8388
    84 #endif // generate-input-with-vector-members.json-TestReplayInputs_h
     89#endif // generate-enums-with-same-base-name.json-TestReplayInputs_h
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h

    r163918 r167174  
    3535#include <platform/ExternalNamespaceHeaderIncludeDummy.h>
    3636
    37 namespace WebCore {
    38 class WebThing;
    39 }
    40 
    41 namespace JSC {
    42 class JSThing;
    43 }
    4437
    4538
Note: See TracChangeset for help on using the changeset viewer.