Title: [239846] trunk/Source/_javascript_Core
Revision
239846
Author
bb...@apple.com
Date
2019-01-10 14:36:56 -0800 (Thu, 10 Jan 2019)

Log Message

Web Inspector: incorrect type signature used for protocol enums in async command results
https://bugs.webkit.org/show_bug.cgi?id=193331

Reviewed by Devin Rousso.

When an enum is returned by an async command, the type signature should be that of the
Inspector::Protocol::* generated enum, rather than the underlying primitive type (i.e., String).

* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.cpp_type_for_formal_async_parameter):
* inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
Rebaseline generator test results.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (239845 => 239846)


--- trunk/Source/_javascript_Core/ChangeLog	2019-01-10 22:31:10 UTC (rev 239845)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-01-10 22:36:56 UTC (rev 239846)
@@ -1,5 +1,20 @@
 2019-01-10  Brian Burg  <bb...@apple.com>
 
+        Web Inspector: incorrect type signature used for protocol enums in async command results
+        https://bugs.webkit.org/show_bug.cgi?id=193331
+
+        Reviewed by Devin Rousso.
+
+        When an enum is returned by an async command, the type signature should be that of the
+        Inspector::Protocol::* generated enum, rather than the underlying primitive type (i.e., String).
+
+        * inspector/scripts/codegen/cpp_generator.py:
+        (CppGenerator.cpp_type_for_formal_async_parameter):
+        * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
+        Rebaseline generator test results.
+
+2019-01-10  Brian Burg  <bb...@apple.com>
+
         Rebaseline inspector generator test results after recent changes.
 
         Unreviewed test gardening.

Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/cpp_generator.py (239845 => 239846)


--- trunk/Source/_javascript_Core/inspector/scripts/codegen/cpp_generator.py	2019-01-10 22:31:10 UTC (rev 239845)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/cpp_generator.py	2019-01-10 22:36:56 UTC (rev 239846)
@@ -229,9 +229,6 @@
         if isinstance(_type, AliasedType):
             _type = _type.aliased_type  # Fall through.
 
-        if isinstance(_type, EnumType):
-            _type = _type.primitive_type  # Fall through.
-
         if isinstance(_type, (ObjectType, ArrayType)):
             return 'RefPtr<%s>&&' % CppGenerator.cpp_protocol_type_for_type(_type)
         if isinstance(_type, PrimitiveType):
@@ -244,7 +241,17 @@
                 return 'const %s&' % cpp_name
             else:
                 return cpp_name
+        if isinstance(_type, EnumType):
+            if _type.is_anonymous:
+                cpp_name = '%sBackendDispatcherHandler::%s' % (_type.type_domain().domain_name, ucfirst(parameter.parameter_name))
+            else:
+                cpp_name = 'Inspector::Protocol::%s::%s' % (_type.type_domain().domain_name, _type.raw_name())
 
+            if parameter.is_optional:
+                return "Optional<%s>" % cpp_name
+            else:
+                return cpp_name
+
         raise ValueError("Unknown formal async parameter type.")
 
     # In-parameters don't use builder types, because they could be passed

Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result (239845 => 239846)


--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result	2019-01-10 22:31:10 UTC (rev 239845)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result	2019-01-10 22:36:56 UTC (rev 239846)
@@ -161,7 +161,7 @@
     class ExecuteSQLAsyncOptionalReturnValuesCallback : public BackendDispatcher::CallbackBase {
     public:
         ExecuteSQLAsyncOptionalReturnValuesCallback(Ref<BackendDispatcher>&&, int id);
-        void sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, Optional<String>& notes, Optional<double>& timestamp, Optional<JSON::Object>& values, Optional<JSON::Value>& payload, Optional<int>& databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Optional<String>& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Optional<String>& printColor);
+        void sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, Optional<String>& notes, Optional<double>& timestamp, Optional<JSON::Object>& values, Optional<JSON::Value>& payload, Optional<int>& databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Optional<Inspector::Protocol::Database::PrimaryColors> screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Optional<DatabaseBackendDispatcherHandler::PrintColor> printColor);
     };
     virtual void executeSQLAsyncOptionalReturnValues(int in_databaseId, const String& in_query, Ref<ExecuteSQLAsyncOptionalReturnValuesCallback>&& callback) = 0;
     virtual void executeSQLSync(ErrorString&, int in_databaseId, const String& in_query, RefPtr<JSON::ArrayOf<String>>& out_columnNames, String* out_notes, double* out_timestamp, JSON::Object* out_values, JSON::Value* out_payload, int* out_databaseId, RefPtr<Inspector::Protocol::Database::Error>& out_sqlError, RefPtr<Inspector::Protocol::Database::ColorList>& out_alternateColors, Inspector::Protocol::Database::PrimaryColors* out_screenColor, DatabaseBackendDispatcherHandler::PrintColor* out_printColor) = 0;
@@ -168,7 +168,7 @@
     class ExecuteSQLAsyncCallback : public BackendDispatcher::CallbackBase {
     public:
         ExecuteSQLAsyncCallback(Ref<BackendDispatcher>&&, int id);
-        void sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, const String& notes, double timestamp, JSON::Object values, JSON::Value payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, const String& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, const String& printColor);
+        void sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, const String& notes, double timestamp, JSON::Object values, JSON::Value payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Inspector::Protocol::Database::PrimaryColors screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, DatabaseBackendDispatcherHandler::PrintColor printColor);
     };
     virtual void executeSQLAsync(int in_databaseId, const String& in_query, Ref<ExecuteSQLAsyncCallback>&& callback) = 0;
 protected:
@@ -336,7 +336,7 @@
 
 DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::ExecuteSQLAsyncOptionalReturnValuesCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { }
 
-void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, Optional<String>& notes, Optional<double>& timestamp, Optional<JSON::Object>& values, Optional<JSON::Value>& payload, Optional<int>& databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Optional<String>& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Optional<String>& printColor)
+void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, Optional<String>& notes, Optional<double>& timestamp, Optional<JSON::Object>& values, Optional<JSON::Value>& payload, Optional<int>& databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Optional<Inspector::Protocol::Database::PrimaryColors> screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Optional<DatabaseBackendDispatcherHandler::PrintColor> printColor)
 {
     Ref<JSON::Object> jsonMessage = JSON::Object::create();
     if (columnNames)
@@ -433,7 +433,7 @@
 
 DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::ExecuteSQLAsyncCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { }
 
-void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, const String& notes, double timestamp, JSON::Object values, JSON::Value payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, const String& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, const String& printColor)
+void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, const String& notes, double timestamp, JSON::Object values, JSON::Value payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Inspector::Protocol::Database::PrimaryColors screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, DatabaseBackendDispatcherHandler::PrintColor printColor)
 {
     Ref<JSON::Object> jsonMessage = JSON::Object::create();
     jsonMessage->setArray("columnNames"_s, columnNames);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to