Title: [106469] trunk/Source/WebCore
Revision
106469
Author
commit-qu...@webkit.org
Date
2012-02-01 09:22:02 -0800 (Wed, 01 Feb 2012)

Log Message

Web Inspector: CodeGeneratorInspector.py: move type builder code to dedicated InspectorTypeBuilder .h/.cpp
https://bugs.webkit.org/show_bug.cgi?id=77471

Patch by Peter Rybin <peter.ry...@gmail.com> on 2012-02-01
Reviewed by Yury Semikhatsky.

Code is moved physically to other file -- generator is changed accrodingly.

* inspector/CodeGeneratorInspector.py:
(String):
(provides):
(typename):
(Array):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106468 => 106469)


--- trunk/Source/WebCore/ChangeLog	2012-02-01 17:03:16 UTC (rev 106468)
+++ trunk/Source/WebCore/ChangeLog	2012-02-01 17:22:02 UTC (rev 106469)
@@ -1,3 +1,18 @@
+2012-02-01  Peter Rybin  <peter.ry...@gmail.com>
+
+        Web Inspector: CodeGeneratorInspector.py: move type builder code to dedicated InspectorTypeBuilder .h/.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=77471
+
+        Reviewed by Yury Semikhatsky.
+
+        Code is moved physically to other file -- generator is changed accrodingly.
+
+        * inspector/CodeGeneratorInspector.py:
+        (String):
+        (provides):
+        (typename):
+        (Array):
+
 2012-02-01  Yury Semikhatsky  <yu...@chromium.org>
 
         Web Inspector: debugger reports wrong sources when paused in inline script on page reload

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (106468 => 106469)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-02-01 17:03:16 UTC (rev 106468)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-02-01 17:22:02 UTC (rev 106469)
@@ -1643,80 +1643,6 @@
 
 #if ENABLE(INSPECTOR)
 
-namespace TypeBuilder {
-
-// This class provides "Traits" type for the input type T. It is programmed using C++ template specialization
-// technique. By default it simply takes "ItemTraits" type from T, but it doesn't work with the base types.
-template<typename T>
-struct ArrayItemHelper {
-    typedef typename T::ItemTraits Traits;
-};
-
-template<typename T>
-class Array : public InspectorArray {
-private:
-    Array() { }
-
-public:
-    void addItem(PassRefPtr<T> value)
-    {
-        ArrayItemHelper<T>::Traits::pushRefPtr(this, value);
-    }
-
-    void addItem(T value)
-    {
-        ArrayItemHelper<T>::Traits::pushRaw(this, value);
-    }
-
-    static PassRefPtr<Array<T> > create()
-    {
-        return adoptRef(new Array<T>());
-    }
-
-#if """ + VALIDATOR_IFDEF_NAME + """
-    static void assertCorrectValue(InspectorValue* value);
-#endif // """ + VALIDATOR_IFDEF_NAME + """
-};
-
-struct StructItemTraits {
-    static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)
-    {
-        array->pushObject(value);
-    }
-
-    template<typename T>
-    static void assertCorrectValue(InspectorValue* value) {
-        T::assertCorrectValue(value);
-    }
-};
-
-template<>
-struct ArrayItemHelper<String> {
-    struct Traits {
-        static void pushRaw(InspectorArray* array, const String& value)
-        {
-            array->pushString(value);
-        }
-    };
-};
-
-template<>
-struct ArrayItemHelper<InspectorObject> {
-    struct Traits {
-        static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)
-        {
-            array->pushObject(value);
-        }
-    };
-};
-
-${forwards}
-
-String getEnumConstantValue(int code);
-
-${typeBuilders}
-} // namespace TypeBuilder
-
 class InspectorFrontend {
 public:
     InspectorFrontend(InspectorFrontendChannel*);
@@ -2179,53 +2105,103 @@
 
 $methods
 
-namespace TypeBuilder {
+} // namespace WebCore
 
-const char* const enum_constant_values[] = {
-$enumConstantValues};
+#endif // ENABLE(INSPECTOR)
+""")
 
-String getEnumConstantValue(int code) {
-    // Test variable from generated sources, declared in InspectorTypeBuilder.h and defined in InspectorTypeBuilder.cpp
-    ASSERT(typeBuilderTestVariable);
-    return enum_constant_values[code];
-}
+    typebuilder_h = string.Template(file_header_ +
+"""
+#ifndef InspectorTypeBuilder_h
+#define InspectorTypeBuilder_h
 
-} // namespace TypeBuilder
+#if ENABLE(INSPECTOR)
 
-#if """ + VALIDATOR_IFDEF_NAME + """
+#include "InspectorValues.h"
+#include <PlatformString.h>
+#include <wtf/PassRefPtr.h>
 
+namespace WebCore {
+
+namespace TypeBuilder {
+
+// This class provides "Traits" type for the input type T. It is programmed using C++ template specialization
+// technique. By default it simply takes "ItemTraits" type from T, but it doesn't work with the base types.
 template<typename T>
-void TypeBuilder::Array<T>::assertCorrectValue(InspectorValue* value)
-{
-    RefPtr<InspectorArray> array;
-    bool castRes = value->asArray(&array);
-    ASSERT_UNUSED(castRes, castRes);
-    for (unsigned i = 0; i < array->length(); i++)
-        ArrayItemHelper<T>::Traits::template assertCorrectValue<T>(array->get(i).get());
-}
+struct ArrayItemHelper {
+    typedef typename T::ItemTraits Traits;
+};
 
-$validatorCode
+template<typename T>
+class Array : public InspectorArray {
+private:
+    Array() { }
 
+public:
+    void addItem(PassRefPtr<T> value)
+    {
+        ArrayItemHelper<T>::Traits::pushRefPtr(this, value);
+    }
+
+    void addItem(T value)
+    {
+        ArrayItemHelper<T>::Traits::pushRaw(this, value);
+    }
+
+    static PassRefPtr<Array<T> > create()
+    {
+        return adoptRef(new Array<T>());
+    }
+
+#if """ + VALIDATOR_IFDEF_NAME + """
+    static void assertCorrectValue(InspectorValue* value);
 #endif // """ + VALIDATOR_IFDEF_NAME + """
+};
 
-} // namespace WebCore
+struct StructItemTraits {
+    static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)
+    {
+        array->pushObject(value);
+    }
 
-#endif // ENABLE(INSPECTOR)
-""")
+    template<typename T>
+    static void assertCorrectValue(InspectorValue* value) {
+        T::assertCorrectValue(value);
+    }
+};
 
-    typebuilder_h = string.Template(file_header_ +
-"""
-#ifndef InspectorTypeBuilder_h
-#define InspectorTypeBuilder_h
+template<>
+struct ArrayItemHelper<String> {
+    struct Traits {
+        static void pushRaw(InspectorArray* array, const String& value)
+        {
+            array->pushString(value);
+        }
+    };
+};
 
-namespace WebCore {
+template<>
+struct ArrayItemHelper<InspectorObject> {
+    struct Traits {
+        static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorObject> value)
+        {
+            array->pushObject(value);
+        }
+    };
+};
 
-// FIXME: move here TypeBuilder namespace from InspectorFrontend.h
+${forwards}
 
-// FIXME: Used to test that we don't miss .cpp file. Remove once tested.
-extern bool typeBuilderTestVariable;
+String getEnumConstantValue(int code);
 
+${typeBuilders}
+} // namespace TypeBuilder
+
+
 } // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+
 #endif // !defined(InspectorTypeBuilder_h)
 
 """)
@@ -2240,11 +2216,33 @@
 
 namespace WebCore {
 
-// FIXME: move here TypeBuilder namespace from InspectorFrontend.cpp
+namespace TypeBuilder {
 
-// FIXME: Used to test that we don't miss .cpp file. Remove once tested.
-bool typeBuilderTestVariable = true;
+const char* const enum_constant_values[] = {
+$enumConstantValues};
 
+String getEnumConstantValue(int code) {
+    return enum_constant_values[code];
+}
+
+} // namespace TypeBuilder
+
+#if """ + VALIDATOR_IFDEF_NAME + """
+
+template<typename T>
+void TypeBuilder::Array<T>::assertCorrectValue(InspectorValue* value)
+{
+    RefPtr<InspectorArray> array;
+    bool castRes = value->asArray(&array);
+    ASSERT_UNUSED(castRes, castRes);
+    for (unsigned i = 0; i < array->length(); i++)
+        ArrayItemHelper<T>::Traits::template assertCorrectValue<T>(array->get(i).get());
+}
+
+$validatorCode
+
+#endif // """ + VALIDATOR_IFDEF_NAME + """
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
@@ -2818,21 +2816,21 @@
     messageHandlers=join(Generator.method_handler_list, "\n")))
 
 frontend_h_file.write(Templates.frontend_h.substitute(None,
-         fieldDeclarations=join(Generator.frontend_class_field_lines, ""),
-         domainClassList=join(Generator.frontend_domain_class_lines, ""),
-         typeBuilders=join(flatten_list(Generator.type_builder_fragments), ""),
-         forwards=join(Generator.type_builder_forwards, "")))
+    fieldDeclarations=join(Generator.frontend_class_field_lines, ""),
+    domainClassList=join(Generator.frontend_domain_class_lines, "")))
 
 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None,
     constructorInit=join(Generator.frontend_constructor_init_list, ""),
-    methods=join(Generator.frontend_method_list, "\n"),
+    methods=join(Generator.frontend_method_list, "\n")))
+
+typebuilder_h_file.write(Templates.typebuilder_h.substitute(None,
+    typeBuilders=join(flatten_list(Generator.type_builder_fragments), ""),
+    forwards=join(Generator.type_builder_forwards, "")))
+
+typebuilder_cpp_file.write(Templates.typebuilder_cpp.substitute(None,
     enumConstantValues=EnumConstants.get_enum_constant_code(),
     validatorCode=join(flatten_list(Generator.validator_impl_list), "")))
 
-typebuilder_h_file.write(Templates.typebuilder_h.substitute(None))
-
-typebuilder_cpp_file.write(Templates.typebuilder_cpp.substitute(None))
-
 backend_js_file.write(Templates.backend_js.substitute(None,
     domainInitializers=join(Generator.backend_js_domain_initializer_list, "")))
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to