Title: [102541] trunk/Source/WebCore
Revision
102541
Author
loi...@chromium.org
Date
2011-12-11 12:44:19 -0800 (Sun, 11 Dec 2011)

Log Message

Web Inspector: [protocol] alter some type names generated from Inspector.json
https://bugs.webkit.org/show_bug.cgi?id=74247

Patch by Peter Rybin <peter.ry...@gmail.com> on 2011-12-11
Reviewed by Pavel Feldman.

Manually-filled map added that contains problem type names and its replacement.

* inspector/CodeGeneratorInspector.py:
(fix_type_name.Result):
(fix_type_name.Result.output_comment):
(fix_type_name):
(TypeBindings.create_for_named_type_declaration.write_doc):
(TypeBindings.create_for_named_type_declaration.EnumBinding.generate_type_builder):
(TypeBindings.create_for_named_type_declaration.PlainString.generate_type_builder):
(TypeBindings):
(TypeBindings.create_for_named_type_declaration.ClassBinding.generate_type_builder):
(Generator.process_types):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102540 => 102541)


--- trunk/Source/WebCore/ChangeLog	2011-12-11 19:38:49 UTC (rev 102540)
+++ trunk/Source/WebCore/ChangeLog	2011-12-11 20:44:19 UTC (rev 102541)
@@ -1,3 +1,23 @@
+2011-12-11  Peter Rybin  <peter.ry...@gmail.com>
+
+        Web Inspector: [protocol] alter some type names generated from Inspector.json
+        https://bugs.webkit.org/show_bug.cgi?id=74247
+
+        Reviewed by Pavel Feldman.
+
+        Manually-filled map added that contains problem type names and its replacement.
+
+        * inspector/CodeGeneratorInspector.py:
+        (fix_type_name.Result):
+        (fix_type_name.Result.output_comment):
+        (fix_type_name):
+        (TypeBindings.create_for_named_type_declaration.write_doc):
+        (TypeBindings.create_for_named_type_declaration.EnumBinding.generate_type_builder):
+        (TypeBindings.create_for_named_type_declaration.PlainString.generate_type_builder):
+        (TypeBindings):
+        (TypeBindings.create_for_named_type_declaration.ClassBinding.generate_type_builder):
+        (Generator.process_types):
+
 2011-12-11  Andreas Kling  <kl...@webkit.org>
 
         WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (102540 => 102541)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2011-12-11 19:38:49 UTC (rev 102540)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2011-12-11 20:44:19 UTC (rev 102541)
@@ -48,6 +48,12 @@
 }
 
 
+# Manually-filled map of type name replacements.
+TYPE_NAME_FIX_MAP = {
+    "RGBA": "Rgba",  # RGBA is reported to be conflicting with a define name in Windows CE.
+}
+
+
 cmdline_parser = optparse.OptionParser()
 cmdline_parser.add_option("--defines")
 cmdline_parser.add_option("--output_h_dir")
@@ -439,9 +445,40 @@
 INSPECTOR_OBJECT_SETTER_NAMES = frozenset(["setValue", "setBoolean", "setNumber", "setString", "setValue", "setObject", "setArray"])
 
 
+def fix_type_name(json_name):
+    if json_name in TYPE_NAME_FIX_MAP:
+        fixed = TYPE_NAME_FIX_MAP[json_name]
+
+        class Result(object):
+            class_name = fixed
+
+            @staticmethod
+            def output_comment(output):
+                output.append("// Type originally was named '%s'.\n" % json_name)
+    else:
+
+        class Result(object):
+            class_name = json_name
+
+            @staticmethod
+            def output_comment(output):
+                pass
+
+    return Result
+
+
+
 class TypeBindings:
     @staticmethod
     def create_for_named_type_declaration(json_type, context_domain_name):
+        fixed_type_name = fix_type_name(json_type["id"])
+
+        def write_doc(output):
+            if "description" in json_type:
+                output.append("/* ")
+                output.append(json_type["description"])
+                output.append(" */\n")
+
         if json_type["type"] == "string":
             if "enum" in json_type:
 
@@ -449,9 +486,11 @@
                     @staticmethod
                     def generate_type_builder(output, forward_listener):
                         enum = json_type["enum"]
-                        # TODO: doc
+                        write_doc(output)
+                        enum_name = fixed_type_name.class_name
+                        fixed_type_name.output_comment(output)
                         output.append("namespace ")
-                        output.append(json_type["id"])
+                        output.append(enum_name)
                         output.append(" {\n")
                         for enum_item in enum:
                             item_c_name = enum_item.replace('-', '_')
@@ -461,7 +500,7 @@
                             output.append(enum_item)
                             output.append("\";\n")
                         output.append("} // namespace ")
-                        output.append(json_type["id"])
+                        output.append(enum_name)
                         output.append("\n\n")
 
                 return EnumBinding
@@ -470,12 +509,10 @@
                 class PlainString:
                     @staticmethod
                     def generate_type_builder(output, forward_listener):
-                        if "description" in json_type:
-                            output.append("/* ")
-                            output.append(json_type["description"])
-                            output.append(" */\n")
+                        write_doc(output)
+                        fixed_type_name.output_comment(output)
                         output.append("typedef String ")
-                        output.append(json_type["id"])
+                        output.append(fixed_type_name.class_name)
                         output.append(";\n\n")
                 return PlainString
 
@@ -485,9 +522,10 @@
                 class ClassBinding:
                     @staticmethod
                     def generate_type_builder(output, forward_listener):
-                        # TODO: doc
+                        write_doc(output)
+                        class_name = fixed_type_name.class_name
+                        fixed_type_name.output_comment(output)
                         output.append("class ")
-                        class_name = json_type["id"]
                         output.append(class_name)
                         output.append(" : public InspectorObject {\n")
                         output.append("public:\n")
@@ -1493,7 +1531,7 @@
 
             output.append("} // ")
             output.append(domain_data.name())
-            output.append("\n")
+            output.append("\n\n")
 
 Generator.go()
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to