Title: [112706] trunk/Source/WebCore
Revision
112706
Author
vse...@chromium.org
Date
2012-03-30 11:54:04 -0700 (Fri, 30 Mar 2012)

Log Message

Web Inspector: CodeGeneratorInspector.py: add missing runtime assert method for InspectorObject
https://bugs.webkit.org/show_bug.cgi?id=82753

Patch by Peter Rybin <peter.ry...@gmail.com> on 2012-03-30
Reviewed by Vsevolod Vlasov.

Type validator generator is extended to support missing InspectorObject type and
made more accurate for "int" type.

Strict types are enabled for 2 more domains.

* inspector/CodeGeneratorInspector.py:
(RawTypes.BaseType.generate_validate_method):
(RawTypes.String.get_validate_method_params.ValidateMethodParams):
(RawTypes.Int):
(RawTypes.Int.generate_validate_method):
(RawTypes.Int.get_raw_validator_call_text):
(RawTypes.Number.get_validate_method_params.ValidateMethodParams):
(RawTypes.Bool.get_validate_method_params.ValidateMethodParams):
(RawTypes.Object.get_validate_method_params.ValidateMethodParams):
(RawTypes.Object.get_validate_method_params):
(TypeBindings.create_type_declaration_.ClassBinding.request_internal_runtime_cast):
(PlainObjectBinding.request_internal_runtime_cast):
(PlainObjectBinding.get_validator_call_text):
(ArrayBinding.request_internal_runtime_cast):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112705 => 112706)


--- trunk/Source/WebCore/ChangeLog	2012-03-30 18:49:40 UTC (rev 112705)
+++ trunk/Source/WebCore/ChangeLog	2012-03-30 18:54:04 UTC (rev 112706)
@@ -1,3 +1,30 @@
+2012-03-30  Peter Rybin  <peter.ry...@gmail.com>
+
+        Web Inspector: CodeGeneratorInspector.py: add missing runtime assert method for InspectorObject
+        https://bugs.webkit.org/show_bug.cgi?id=82753
+
+        Reviewed by Vsevolod Vlasov.
+
+        Type validator generator is extended to support missing InspectorObject type and
+        made more accurate for "int" type.
+
+        Strict types are enabled for 2 more domains.
+
+        * inspector/CodeGeneratorInspector.py:
+        (RawTypes.BaseType.generate_validate_method):
+        (RawTypes.String.get_validate_method_params.ValidateMethodParams):
+        (RawTypes.Int):
+        (RawTypes.Int.generate_validate_method):
+        (RawTypes.Int.get_raw_validator_call_text):
+        (RawTypes.Number.get_validate_method_params.ValidateMethodParams):
+        (RawTypes.Bool.get_validate_method_params.ValidateMethodParams):
+        (RawTypes.Object.get_validate_method_params.ValidateMethodParams):
+        (RawTypes.Object.get_validate_method_params):
+        (TypeBindings.create_type_declaration_.ClassBinding.request_internal_runtime_cast):
+        (PlainObjectBinding.request_internal_runtime_cast):
+        (PlainObjectBinding.get_validator_call_text):
+        (ArrayBinding.request_internal_runtime_cast):
+
 2012-03-30  Ian Vollick  <voll...@chromium.org>
 
         [chromium] assertion being hit in CCLayerAnimationController

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (112705 => 112706)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-03-30 18:49:40 UTC (rev 112705)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-03-30 18:54:04 UTC (rev 112706)
@@ -59,7 +59,8 @@
 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor",
                                          "Debugger.FunctionDetails", "Debugger.CallFrame"])
 
-STRICT_ENABLED_DOMAINS = ["CSS", "Debugger", "DOM", "Network", "Page", "Runtime"]
+STRICT_ENABLED_DOMAINS = ["Console", "DOMDebugger",
+                          "CSS", "Debugger", "DOM", "Network", "Page", "Runtime"]
 
 
 cmdline_parser = optparse.OptionParser()
@@ -237,9 +238,7 @@
             params = cls.get_validate_method_params()
             writer.newline("static void assert%s(InspectorValue* value)\n" % params.name)
             writer.newline("{\n")
-            writer.newline("    %s v;\n" % params.var_type)
-            writer.newline("    bool castRes = value->as%s(&v);\n" % params.as_method_name)
-            writer.newline("    ASSERT_UNUSED(castRes, castRes);\n")
+            writer.newline("    ASSERT(value->type() == InspectorValue::Type%s);\n" % params.as_method_name)
             writer.newline("}\n\n\n")
 
         @classmethod
@@ -274,7 +273,6 @@
         def get_validate_method_params():
             class ValidateMethodParams:
                 name = "String"
-                var_type = "String"
                 as_method_name = "String"
             return ValidateMethodParams
 
@@ -311,14 +309,20 @@
         def get_js_bind_type():
             return "number"
 
-        @staticmethod
-        def get_validate_method_params():
-            class ValidateMethodParams:
-                name = "Int"
-                var_type = "int"
-                as_method_name = "Number"
-            return ValidateMethodParams
+        @classmethod
+        def generate_validate_method(cls, writer):
+            writer.newline("static void assertInt(InspectorValue* value)\n")
+            writer.newline("{\n")
+            writer.newline("    double v;\n")
+            writer.newline("    bool castRes = value->asNumber(&v);\n")
+            writer.newline("    ASSERT_UNUSED(castRes, castRes);\n")
+            writer.newline("    ASSERT(static_cast<double>(static_cast<int>(v)) == v);\n")
+            writer.newline("}\n\n\n")
 
+        @classmethod
+        def get_raw_validator_call_text(cls):
+            return "assertInt"
+
         @staticmethod
         def get_output_pass_model():
             return RawTypes.OutputPassModel.ByPointer
@@ -356,7 +360,6 @@
         def get_validate_method_params():
             class ValidateMethodParams:
                 name = "Double"
-                var_type = "double"
                 as_method_name = "Number"
             return ValidateMethodParams
 
@@ -395,7 +398,6 @@
         def get_validate_method_params():
             class ValidateMethodParams:
                 name = "Boolean"
-                var_type = "bool"
                 as_method_name = "Boolean"
             return ValidateMethodParams
 
@@ -436,7 +438,10 @@
 
         @staticmethod
         def get_validate_method_params():
-            raise Exception("TODO")
+            class ValidateMethodParams:
+                name = "Object"
+                as_method_name = "Object"
+            return ValidateMethodParams
 
         @staticmethod
         def get_output_pass_model():
@@ -1120,6 +1125,8 @@
 
                     @classmethod
                     def request_internal_runtime_cast(cls):
+                        if cls.need_internal_runtime_cast_:
+                            return
                         cls.need_internal_runtime_cast_ = True
                         for p in cls.resolve_data_.main_properties:
                             p.param_type_binding.request_internal_runtime_cast()
@@ -1386,7 +1393,7 @@
 
                     @staticmethod
                     def request_internal_runtime_cast():
-                        pass
+                        RawTypes.Object.request_raw_internal_runtime_cast()
 
                     @staticmethod
                     def get_code_generator():
@@ -1394,7 +1401,7 @@
 
                     @staticmethod
                     def get_validator_call_text():
-                        raise Exception("Unsupported")
+                        return "assertObject"
 
                     @classmethod
                     def get_array_item_c_type_text(cls):
@@ -1456,6 +1463,8 @@
 
                     @classmethod
                     def request_internal_runtime_cast(cls):
+                        if cls.need_internal_runtime_cast_:
+                            return
                         cls.need_internal_runtime_cast_ = True
                         cls.resolve_data_.item_type_binding.request_internal_runtime_cast()
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to