Web Inspector: protocol generator shouldn't generate enums for parameters with non...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Mar 2016 01:43:06 +0000 (01:43 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Mar 2016 01:43:06 +0000 (01:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155610
<rdar://problem/25229878>

Reviewed by Joseph Pecoraro.

If a command parameter has an anonymous enum type, the backend dispatcher generator
makes a C++ enum for the parameter. However, if the parameter references a named enum
type specified in a domain's 'type' section, then there's no need to generate an enum.

* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
Add a missing check for the is_anonymous flag. Type references to named enums are resolved
to the underlying aliased EnumType instead of an AliasedType, so we have to check the flag.

Rebaseline tests.

* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198373 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py
Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-async-attribute.json-result
Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result

index 27106e8..063470c 100644 (file)
@@ -1,3 +1,25 @@
+2016-03-17  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: protocol generator shouldn't generate enums for parameters with non-anonymous enum types
+        https://bugs.webkit.org/show_bug.cgi?id=155610
+        <rdar://problem/25229878>
+
+        Reviewed by Joseph Pecoraro.
+
+        If a command parameter has an anonymous enum type, the backend dispatcher generator
+        makes a C++ enum for the parameter. However, if the parameter references a named enum
+        type specified in a domain's 'type' section, then there's no need to generate an enum.
+
+        * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
+        (CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
+        Add a missing check for the is_anonymous flag. Type references to named enums are resolved
+        to the underlying aliased EnumType instead of an AliasedType, so we have to check the flag.
+
+        Rebaseline tests.
+
+        * inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
+        * inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
+
 2016-03-17  Filip Pizlo  <fpizlo@apple.com>
 
         Replace all of the various non-working and non-compiling sampling profiler hacks with a single super hack
index 17c8102..5ebd82f 100755 (executable)
@@ -134,7 +134,7 @@ class CppBackendDispatcherHeaderGenerator(Generator):
 
             parameters.append("%s %s" % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(_parameter), parameter_name))
 
-            if isinstance(_parameter.type, EnumType) and _parameter.parameter_name not in used_enum_names:
+            if isinstance(_parameter.type, EnumType) and _parameter.type.is_anonymous and _parameter.parameter_name not in used_enum_names:
                 lines.append(self._generate_anonymous_enum_for_parameter(_parameter, command))
                 used_enum_names.add(_parameter.parameter_name)
 
@@ -144,7 +144,7 @@ class CppBackendDispatcherHeaderGenerator(Generator):
                 parameter_name = 'opt_' + parameter_name
             parameters.append("%s %s" % (CppGenerator.cpp_type_for_formal_out_parameter(_parameter), parameter_name))
 
-            if isinstance(_parameter.type, EnumType) and _parameter.parameter_name not in used_enum_names:
+            if isinstance(_parameter.type, EnumType) and _parameter.type.is_anonymous and _parameter.parameter_name not in used_enum_names:
                 lines.append(self._generate_anonymous_enum_for_parameter(_parameter, command))
                 used_enum_names.add(_parameter.parameter_name)
 
index 97b74a4..5b3be04 100644 (file)
@@ -154,12 +154,6 @@ class AlternateDatabaseBackendDispatcher;
 
 class DatabaseBackendDispatcherHandler {
 public:
-    // Named after parameter 'screenColor' while generating command/event executeSQLSyncOptionalReturnValues.
-    enum class ScreenColor {
-        Red = 0,
-        Green = 1,
-        Blue = 2,
-    }; // enum class ScreenColor
     // Named after parameter 'printColor' while generating command/event executeSQLSyncOptionalReturnValues.
     enum class PrintColor {
         Cyan = 3,
index e1c8bc4..968cced 100644 (file)
@@ -149,12 +149,6 @@ class AlternateDatabaseBackendDispatcher;
 
 class DatabaseBackendDispatcherHandler {
 public:
-    // Named after parameter 'screenColor' while generating command/event executeAllOptionalParameters.
-    enum class ScreenColor {
-        Red = 0,
-        Green = 1,
-        Blue = 2,
-    }; // enum class ScreenColor
     // Named after parameter 'printColor' while generating command/event executeAllOptionalParameters.
     enum class PrintColor {
         Cyan = 3,