From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- .../JavaScriptCore/inspector/AsyncStackTrace.cpp | 194 ++ Source/JavaScriptCore/inspector/AsyncStackTrace.h | 72 + Source/JavaScriptCore/inspector/ConsoleMessage.cpp | 284 +++ Source/JavaScriptCore/inspector/ConsoleMessage.h | 94 + .../inspector/ContentSearchUtilities.cpp | 107 +- .../inspector/ContentSearchUtilities.h | 17 +- Source/JavaScriptCore/inspector/EventLoop.cpp | 73 + Source/JavaScriptCore/inspector/EventLoop.h | 55 + .../inspector/IdentifiersFactory.cpp | 62 + .../JavaScriptCore/inspector/IdentifiersFactory.h | 44 + Source/JavaScriptCore/inspector/InjectedScript.cpp | 194 +- Source/JavaScriptCore/inspector/InjectedScript.h | 41 +- .../inspector/InjectedScriptBase.cpp | 80 +- .../JavaScriptCore/inspector/InjectedScriptBase.h | 16 +- .../inspector/InjectedScriptHost.cpp | 46 +- .../JavaScriptCore/inspector/InjectedScriptHost.h | 23 +- .../inspector/InjectedScriptManager.cpp | 93 +- .../inspector/InjectedScriptManager.h | 20 +- .../inspector/InjectedScriptModule.cpp | 18 +- .../inspector/InjectedScriptModule.h | 14 +- .../inspector/InjectedScriptSource.js | 1475 ++++++----- .../JavaScriptCore/inspector/InspectorAgentBase.h | 46 +- .../inspector/InspectorAgentRegistry.cpp | 47 +- .../inspector/InspectorAgentRegistry.h | 38 +- .../inspector/InspectorBackendDispatcher.cpp | 371 +-- .../inspector/InspectorBackendDispatcher.h | 97 +- .../inspector/InspectorEnvironment.h | 22 +- .../inspector/InspectorFrontendChannel.h | 21 +- .../inspector/InspectorFrontendRouter.cpp | 101 + .../inspector/InspectorFrontendRouter.h | 56 + .../inspector/InspectorProtocolTypes.h | 180 ++ .../inspector/InspectorTypeBuilder.h | 337 --- .../JavaScriptCore/inspector/InspectorValues.cpp | 491 ++-- Source/JavaScriptCore/inspector/InspectorValues.h | 322 +-- .../inspector/JSGlobalObjectConsoleClient.cpp | 174 ++ .../inspector/JSGlobalObjectConsoleClient.h | 71 + .../JSGlobalObjectInspectorController.cpp | 315 +++ .../inspector/JSGlobalObjectInspectorController.h | 133 + .../inspector/JSGlobalObjectScriptDebugServer.cpp | 65 + .../inspector/JSGlobalObjectScriptDebugServer.h | 57 + .../inspector/JSInjectedScriptHost.cpp | 496 +++- .../inspector/JSInjectedScriptHost.h | 36 +- .../inspector/JSInjectedScriptHostPrototype.cpp | 200 +- .../inspector/JSInjectedScriptHostPrototype.h | 13 +- .../inspector/JSJavaScriptCallFrame.cpp | 148 +- .../inspector/JSJavaScriptCallFrame.h | 34 +- .../inspector/JSJavaScriptCallFramePrototype.cpp | 199 +- .../inspector/JSJavaScriptCallFramePrototype.h | 13 +- .../inspector/JavaScriptCallFrame.cpp | 9 +- .../JavaScriptCore/inspector/JavaScriptCallFrame.h | 25 +- .../inspector/PerGlobalObjectWrapperWorld.cpp | 52 + .../inspector/PerGlobalObjectWrapperWorld.h | 45 + .../JavaScriptCore/inspector/ScriptArguments.cpp | 118 + Source/JavaScriptCore/inspector/ScriptArguments.h | 73 + Source/JavaScriptCore/inspector/ScriptBreakpoint.h | 24 +- .../JavaScriptCore/inspector/ScriptCallFrame.cpp | 78 + Source/JavaScriptCore/inspector/ScriptCallFrame.h | 65 + .../JavaScriptCore/inspector/ScriptCallStack.cpp | 116 + Source/JavaScriptCore/inspector/ScriptCallStack.h | 69 + .../inspector/ScriptCallStackFactory.cpp | 179 ++ .../inspector/ScriptCallStackFactory.h | 53 + .../JavaScriptCore/inspector/ScriptDebugListener.h | 46 +- .../JavaScriptCore/inspector/ScriptDebugServer.cpp | 259 +- .../JavaScriptCore/inspector/ScriptDebugServer.h | 65 +- .../inspector/agents/InspectorAgent.cpp | 95 +- .../inspector/agents/InspectorAgent.h | 55 +- .../inspector/agents/InspectorConsoleAgent.cpp | 238 ++ .../inspector/agents/InspectorConsoleAgent.h | 94 + .../inspector/agents/InspectorDebuggerAgent.cpp | 969 +++++--- .../inspector/agents/InspectorDebuggerAgent.h | 180 +- .../inspector/agents/InspectorHeapAgent.cpp | 314 +++ .../inspector/agents/InspectorHeapAgent.h | 82 + .../inspector/agents/InspectorRuntimeAgent.cpp | 277 ++- .../inspector/agents/InspectorRuntimeAgent.h | 65 +- .../agents/InspectorScriptProfilerAgent.cpp | 258 ++ .../agents/InspectorScriptProfilerAgent.h | 84 + .../agents/JSGlobalObjectConsoleAgent.cpp | 46 + .../inspector/agents/JSGlobalObjectConsoleAgent.h | 45 + .../agents/JSGlobalObjectDebuggerAgent.cpp | 63 + .../inspector/agents/JSGlobalObjectDebuggerAgent.h | 55 + .../agents/JSGlobalObjectRuntimeAgent.cpp | 61 + .../inspector/agents/JSGlobalObjectRuntimeAgent.h | 55 + .../augmentable/AlternateDispatchableAgent.h | 70 + .../augmentable/AugmentableInspectorController.h | 54 + .../AugmentableInspectorControllerClient.h | 42 + .../inspector/protocol/ApplicationCache.json | 87 + Source/JavaScriptCore/inspector/protocol/CSS.json | 457 ++++ .../JavaScriptCore/inspector/protocol/Console.json | 105 + Source/JavaScriptCore/inspector/protocol/DOM.json | 581 +++++ .../inspector/protocol/DOMDebugger.json | 73 + .../inspector/protocol/DOMStorage.json | 88 + .../inspector/protocol/Database.json | 71 + .../inspector/protocol/Debugger.json | 115 +- Source/JavaScriptCore/inspector/protocol/Heap.json | 100 + .../inspector/protocol/IndexedDB.json | 143 ++ .../inspector/protocol/Inspector.json | 51 + .../inspector/protocol/InspectorDomain.json | 41 - .../inspector/protocol/LayerTree.json | 114 + .../JavaScriptCore/inspector/protocol/Memory.json | 70 + .../JavaScriptCore/inspector/protocol/Network.json | 315 +++ .../inspector/protocol/OverlayTypes.json | 130 + Source/JavaScriptCore/inspector/protocol/Page.json | 305 +++ .../JavaScriptCore/inspector/protocol/Replay.json | 264 ++ .../JavaScriptCore/inspector/protocol/Runtime.json | 196 +- .../inspector/protocol/ScriptProfiler.json | 99 + .../inspector/protocol/Timeline.json | 118 + .../JavaScriptCore/inspector/protocol/Worker.json | 52 + .../inspector/remote/RemoteAutomationTarget.cpp | 47 + .../inspector/remote/RemoteAutomationTarget.h | 56 + .../inspector/remote/RemoteConnectionToTarget.h | 114 + .../inspector/remote/RemoteControllableTarget.cpp | 52 + .../inspector/remote/RemoteControllableTarget.h | 74 + .../inspector/remote/RemoteInspectionTarget.cpp | 72 + .../inspector/remote/RemoteInspectionTarget.h | 79 + .../inspector/remote/RemoteInspector.cpp | 224 ++ .../inspector/remote/RemoteInspector.h | 183 ++ .../inspector/remote/RemoteInspectorConstants.h | 102 + .../inspector/scripts/CodeGeneratorInspector.py | 2613 -------------------- .../scripts/CodeGeneratorInspectorStrings.py | 342 --- .../inspector/scripts/codegen/__init__.py | 25 + .../inspector/scripts/codegen/cpp_generator.py | 319 +++ .../scripts/codegen/cpp_generator_templates.py | 258 ++ ...rate_cpp_alternate_backend_dispatcher_header.py | 93 + .../generate_cpp_backend_dispatcher_header.py | 217 ++ ...nerate_cpp_backend_dispatcher_implementation.py | 324 +++ .../generate_cpp_frontend_dispatcher_header.py | 116 + ...erate_cpp_frontend_dispatcher_implementation.py | 125 + .../codegen/generate_cpp_protocol_types_header.py | 424 ++++ .../generate_cpp_protocol_types_implementation.py | 260 ++ .../codegen/generate_js_backend_commands.py | 145 ++ .../generate_objc_backend_dispatcher_header.py | 106 + ...erate_objc_backend_dispatcher_implementation.py | 210 ++ .../codegen/generate_objc_configuration_header.py | 85 + .../generate_objc_configuration_implementation.py | 147 ++ ...rate_objc_frontend_dispatcher_implementation.py | 154 ++ .../scripts/codegen/generate_objc_header.py | 245 ++ .../codegen/generate_objc_internal_header.py | 74 + ...nerate_objc_protocol_type_conversions_header.py | 165 ++ ...bjc_protocol_type_conversions_implementation.py | 138 ++ .../generate_objc_protocol_types_implementation.py | 215 ++ .../inspector/scripts/codegen/generator.py | 274 ++ .../scripts/codegen/generator_templates.py | 61 + .../inspector/scripts/codegen/models.py | 680 +++++ .../inspector/scripts/codegen/objc_generator.py | 554 +++++ .../scripts/codegen/objc_generator_templates.py | 155 ++ Source/JavaScriptCore/inspector/scripts/cssmin.py | 44 - .../scripts/generate-combined-inspector-json.py | 68 - .../generate-inspector-protocol-bindings.py | 270 ++ .../inline-and-minify-stylesheets-and-scripts.py | 81 - Source/JavaScriptCore/inspector/scripts/jsmin.py | 238 -- .../tests/all/definitions-with-mac-platform.json | 28 + .../definitions-with-mac-platform.json-result | 1203 +++++++++ .../generic/commands-with-async-attribute.json | 109 + ...mands-with-optional-call-return-parameters.json | 85 + .../generic/definitions-with-mac-platform.json | 28 + .../scripts/tests/generic/domain-availability.json | 11 + .../domains-with-varying-command-sizes.json | 54 + .../scripts/tests/generic/enum-values.json | 35 + .../generic/events-with-optional-parameters.json | 59 + .../commands-with-async-attribute.json-result | 1780 +++++++++++++ ...ith-optional-call-return-parameters.json-result | 1643 ++++++++++++ .../definitions-with-mac-platform.json-result | 866 +++++++ .../expected/domain-availability.json-result | 1120 +++++++++ .../domains-with-varying-command-sizes.json-result | 1399 +++++++++++ .../tests/generic/expected/enum-values.json-result | 1208 +++++++++ .../events-with-optional-parameters.json-result | 1210 +++++++++ ...ail-on-command-with-invalid-platform.json-error | 1 + .../fail-on-domain-availability.json-error | 1 + ...plicate-command-call-parameter-names.json-error | 1 + ...icate-command-return-parameter-names.json-error | 1 + ...l-on-duplicate-event-parameter-names.json-error | 1 + .../fail-on-duplicate-type-declarations.json-error | 1 + .../fail-on-duplicate-type-member-names.json-error | 1 + .../fail-on-enum-with-no-values.json-error | 1 + ...number-typed-optional-parameter-flag.json-error | 1 + ...on-number-typed-optional-type-member.json-error | 1 + ...string-typed-optional-parameter-flag.json-error | 1 + ...on-string-typed-optional-type-member.json-error | 1 + ...ype-declaration-using-type-reference.json-error | 1 + ...-on-type-reference-as-primitive-type.json-error | 1 + .../fail-on-type-with-invalid-platform.json-error | 1 + .../fail-on-type-with-lowercase-name.json-error | 1 + ...n-type-reference-in-type-declaration.json-error | 1 + ...nknown-type-reference-in-type-member.json-error | 1 + ...enerate-domains-with-feature-guards.json-result | 1230 +++++++++ .../same-type-id-different-domain.json-result | 910 +++++++ .../shadowed-optional-type-setters.json-result | 1119 +++++++++ ...-declaration-aliased-primitive-type.json-result | 887 +++++++ .../type-declaration-array-type.json-result | 1055 ++++++++ .../type-declaration-enum-type.json-result | 1064 ++++++++ .../type-declaration-object-type.json-result | 2012 +++++++++++++++ .../type-requiring-runtime-casts.json-result | 1617 ++++++++++++ .../expected/worker-supported-domains.json-result | 1121 +++++++++ .../fail-on-command-with-invalid-platform.json | 16 + .../tests/generic/fail-on-domain-availability.json | 9 + ...-on-duplicate-command-call-parameter-names.json | 16 + ...n-duplicate-command-return-parameter-names.json | 16 + .../fail-on-duplicate-event-parameter-names.json | 12 + .../fail-on-duplicate-type-declarations.json | 15 + .../fail-on-duplicate-type-member-names.json | 15 + .../tests/generic/fail-on-enum-with-no-values.json | 10 + ...il-on-number-typed-optional-parameter-flag.json | 18 + .../fail-on-number-typed-optional-type-member.json | 16 + ...il-on-string-typed-optional-parameter-flag.json | 18 + .../fail-on-string-typed-optional-type-member.json | 16 + ...l-on-type-declaration-using-type-reference.json | 13 + .../fail-on-type-reference-as-primitive-type.json | 18 + .../fail-on-type-with-invalid-platform.json | 11 + .../generic/fail-on-type-with-lowercase-name.json | 10 + ...unknown-type-reference-in-type-declaration.json | 12 + ...l-on-unknown-type-reference-in-type-member.json | 15 + .../generate-domains-with-feature-guards.json | 36 + .../generic/same-type-id-different-domain.json | 22 + .../generic/shadowed-optional-type-setters.json | 31 + .../type-declaration-aliased-primitive-type.json | 10 + .../tests/generic/type-declaration-array-type.json | 50 + .../tests/generic/type-declaration-enum-type.json | 15 + .../generic/type-declaration-object-type.json | 83 + .../generic/type-requiring-runtime-casts.json | 51 + .../tests/generic/worker-supported-domains.json | 11 + Source/JavaScriptCore/inspector/scripts/xxd.pl | 45 - 221 files changed, 41463 insertions(+), 6404 deletions(-) create mode 100644 Source/JavaScriptCore/inspector/AsyncStackTrace.cpp create mode 100644 Source/JavaScriptCore/inspector/AsyncStackTrace.h create mode 100644 Source/JavaScriptCore/inspector/ConsoleMessage.cpp create mode 100644 Source/JavaScriptCore/inspector/ConsoleMessage.h create mode 100644 Source/JavaScriptCore/inspector/EventLoop.cpp create mode 100644 Source/JavaScriptCore/inspector/EventLoop.h create mode 100644 Source/JavaScriptCore/inspector/IdentifiersFactory.cpp create mode 100644 Source/JavaScriptCore/inspector/IdentifiersFactory.h create mode 100644 Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp create mode 100644 Source/JavaScriptCore/inspector/InspectorFrontendRouter.h create mode 100644 Source/JavaScriptCore/inspector/InspectorProtocolTypes.h delete mode 100644 Source/JavaScriptCore/inspector/InspectorTypeBuilder.h create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp create mode 100644 Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h create mode 100644 Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp create mode 100644 Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h create mode 100644 Source/JavaScriptCore/inspector/ScriptArguments.cpp create mode 100644 Source/JavaScriptCore/inspector/ScriptArguments.h create mode 100644 Source/JavaScriptCore/inspector/ScriptCallFrame.cpp create mode 100644 Source/JavaScriptCore/inspector/ScriptCallFrame.h create mode 100644 Source/JavaScriptCore/inspector/ScriptCallStack.cpp create mode 100644 Source/JavaScriptCore/inspector/ScriptCallStack.h create mode 100644 Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp create mode 100644 Source/JavaScriptCore/inspector/ScriptCallStackFactory.h create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.h create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.h create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp create mode 100644 Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h create mode 100644 Source/JavaScriptCore/inspector/augmentable/AlternateDispatchableAgent.h create mode 100644 Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorController.h create mode 100644 Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorControllerClient.h create mode 100644 Source/JavaScriptCore/inspector/protocol/ApplicationCache.json create mode 100644 Source/JavaScriptCore/inspector/protocol/CSS.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Console.json create mode 100644 Source/JavaScriptCore/inspector/protocol/DOM.json create mode 100644 Source/JavaScriptCore/inspector/protocol/DOMDebugger.json create mode 100644 Source/JavaScriptCore/inspector/protocol/DOMStorage.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Database.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Heap.json create mode 100644 Source/JavaScriptCore/inspector/protocol/IndexedDB.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Inspector.json delete mode 100644 Source/JavaScriptCore/inspector/protocol/InspectorDomain.json create mode 100644 Source/JavaScriptCore/inspector/protocol/LayerTree.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Memory.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Network.json create mode 100644 Source/JavaScriptCore/inspector/protocol/OverlayTypes.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Page.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Replay.json create mode 100644 Source/JavaScriptCore/inspector/protocol/ScriptProfiler.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Timeline.json create mode 100644 Source/JavaScriptCore/inspector/protocol/Worker.json create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteAutomationTarget.cpp create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteAutomationTarget.h create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.h create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.cpp create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.h create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteInspector.cpp create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteInspector.h create mode 100644 Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h delete mode 100755 Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspector.py delete mode 100644 Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspectorStrings.py create mode 100644 Source/JavaScriptCore/inspector/scripts/codegen/__init__.py create mode 100644 Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py create mode 100644 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/generator.py create mode 100644 Source/JavaScriptCore/inspector/scripts/codegen/generator_templates.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/models.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py create mode 100755 Source/JavaScriptCore/inspector/scripts/codegen/objc_generator_templates.py delete mode 100644 Source/JavaScriptCore/inspector/scripts/cssmin.py delete mode 100755 Source/JavaScriptCore/inspector/scripts/generate-combined-inspector-json.py create mode 100755 Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py delete mode 100755 Source/JavaScriptCore/inspector/scripts/inline-and-minify-stylesheets-and-scripts.py delete mode 100644 Source/JavaScriptCore/inspector/scripts/jsmin.py create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json create mode 100644 Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json delete mode 100644 Source/JavaScriptCore/inspector/scripts/xxd.pl (limited to 'Source/JavaScriptCore/inspector') diff --git a/Source/JavaScriptCore/inspector/AsyncStackTrace.cpp b/Source/JavaScriptCore/inspector/AsyncStackTrace.cpp new file mode 100644 index 000000000..4002964ac --- /dev/null +++ b/Source/JavaScriptCore/inspector/AsyncStackTrace.cpp @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2017 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "AsyncStackTrace.h" + +#include "InspectorValues.h" +#include "ScriptCallStack.h" + +namespace Inspector { + +RefPtr AsyncStackTrace::create(Ref&& callStack, bool singleShot, RefPtr parent) +{ + ASSERT(callStack->size()); + return adoptRef(*new AsyncStackTrace(WTFMove(callStack), singleShot, WTFMove(parent))); +} + +AsyncStackTrace::AsyncStackTrace(Ref&& callStack, bool singleShot, RefPtr parent) + : m_callStack(WTFMove(callStack)) + , m_parent(parent) + , m_singleShot(singleShot) +{ + if (m_parent) + m_parent->m_childCount++; +} + +AsyncStackTrace::~AsyncStackTrace() +{ + if (m_parent) + remove(); + ASSERT(!m_childCount); +} + +bool AsyncStackTrace::isPending() const +{ + return m_state == State::Pending; +} + +bool AsyncStackTrace::isLocked() const +{ + return m_state == State::Pending || m_state == State::Active || m_childCount > 1; +} + +void AsyncStackTrace::willDispatchAsyncCall(size_t maxDepth) +{ + ASSERT(m_state == State::Pending); + m_state = State::Active; + + truncate(maxDepth); +} + +void AsyncStackTrace::didDispatchAsyncCall() +{ + ASSERT(m_state == State::Active || m_state == State::Canceled); + + if (m_state == State::Active && !m_singleShot) { + m_state = State::Pending; + return; + } + + m_state = State::Dispatched; + + if (!m_childCount) + remove(); +} + +void AsyncStackTrace::didCancelAsyncCall() +{ + if (m_state == State::Canceled) + return; + + if (m_state == State::Pending && !m_childCount) + remove(); + + m_state = State::Canceled; +} + +RefPtr AsyncStackTrace::buildInspectorObject() const +{ + RefPtr topStackTrace; + RefPtr previousStackTrace; + + auto* stackTrace = this; + while (stackTrace) { + auto& callStack = stackTrace->m_callStack; + ASSERT(callStack->size()); + + RefPtr protocolObject = Inspector::Protocol::Console::StackTrace::create() + .setCallFrames(callStack->buildInspectorArray()) + .release(); + + if (stackTrace->m_truncated) + protocolObject->setTruncated(true); + if (callStack->at(0).isNative()) + protocolObject->setTopCallFrameIsBoundary(true); + + if (!topStackTrace) + topStackTrace = protocolObject; + + if (previousStackTrace) + previousStackTrace->setParentStackTrace(protocolObject); + + previousStackTrace = protocolObject; + stackTrace = stackTrace->m_parent.get(); + } + + return topStackTrace; +} + +void AsyncStackTrace::truncate(size_t maxDepth) +{ + AsyncStackTrace* lastUnlockedAncestor = nullptr; + size_t depth = 0; + + auto* newStackTraceRoot = this; + while (newStackTraceRoot) { + depth += newStackTraceRoot->m_callStack->size(); + if (depth >= maxDepth) + break; + + auto* parent = newStackTraceRoot->m_parent.get(); + if (!lastUnlockedAncestor && parent && parent->isLocked()) + lastUnlockedAncestor = newStackTraceRoot; + + newStackTraceRoot = parent; + } + + if (!newStackTraceRoot || !newStackTraceRoot->m_parent) + return; + + if (!lastUnlockedAncestor) { + // No locked nodes belong to the trace. The subtree at the new root + // is moved to a new tree, and marked as truncated if necessary. + newStackTraceRoot->m_truncated = true; + newStackTraceRoot->remove(); + return; + } + + // The new root has a locked descendent. Since truncating a stack trace + // cannot mutate locked nodes or their ancestors, a new tree is created by + // cloning the locked portion of the trace (the path from the locked node + // to the new root). The subtree rooted at the last unlocked ancestor is + // then appended to the new tree. + auto* currentNode = lastUnlockedAncestor; + while (currentNode->m_parent) { + auto& parentNode = currentNode->m_parent; + currentNode->m_parent = AsyncStackTrace::create(parentNode->m_callStack.copyRef(), true, parentNode->m_parent); + currentNode = currentNode->m_parent.get(); + + if (parentNode.get() == newStackTraceRoot) + break; + } + + currentNode->m_truncated = true; + currentNode->remove(); + + // Decrement the child count of the first locked ancestor after removing its subtree. + auto& firstLockedAncestor = lastUnlockedAncestor->m_parent; + firstLockedAncestor->m_childCount--; +} + +void AsyncStackTrace::remove() +{ + if (!m_parent) + return; + + ASSERT(m_parent->m_childCount); + m_parent->m_childCount--; + m_parent = nullptr; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/AsyncStackTrace.h b/Source/JavaScriptCore/inspector/AsyncStackTrace.h new file mode 100644 index 000000000..a618fe7af --- /dev/null +++ b/Source/JavaScriptCore/inspector/AsyncStackTrace.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2017 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorProtocolObjects.h" +#include +#include + +namespace Inspector { + +class ScriptCallStack; + +class JS_EXPORT_PRIVATE AsyncStackTrace : public RefCounted { +public: + enum class State { + Pending, + Active, + Dispatched, + Canceled, + }; + + static RefPtr create(Ref&&, bool singleShot, RefPtr parent); + + bool isPending() const; + bool isLocked() const; + + void willDispatchAsyncCall(size_t maxDepth); + void didDispatchAsyncCall(); + void didCancelAsyncCall(); + + RefPtr buildInspectorObject() const; + + ~AsyncStackTrace(); + +private: + AsyncStackTrace(Ref&&, bool, RefPtr); + + void truncate(size_t maxDepth); + void remove(); + + Ref m_callStack; + RefPtr m_parent; + unsigned m_childCount { 0 }; + State m_state { State::Pending }; + bool m_truncated { false }; + bool m_singleShot { true }; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ConsoleMessage.cpp b/Source/JavaScriptCore/inspector/ConsoleMessage.cpp new file mode 100644 index 000000000..ef09fcc1e --- /dev/null +++ b/Source/JavaScriptCore/inspector/ConsoleMessage.cpp @@ -0,0 +1,284 @@ +/* + * Copyright (C) 2007, 2008, 2014, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2008 Matt Lilek + * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ConsoleMessage.h" + +#include "IdentifiersFactory.h" +#include "InjectedScript.h" +#include "InjectedScriptManager.h" +#include "InspectorValues.h" +#include "ScriptArguments.h" +#include "ScriptCallFrame.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" +#include "ScriptValue.h" + +namespace Inspector { + +ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned long requestIdentifier) + : m_source(source) + , m_type(type) + , m_level(level) + , m_message(message) + , m_url() + , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) +{ +} + +ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* state, unsigned long requestIdentifier) + : m_source(source) + , m_type(type) + , m_level(level) + , m_message(message) + , m_url(url) + , m_line(line) + , m_column(column) + , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) +{ + autogenerateMetadata(state); +} + +ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref&& callStack, unsigned long requestIdentifier) + : m_source(source) + , m_type(type) + , m_level(level) + , m_message(message) + , m_callStack(WTFMove(callStack)) + , m_url() + , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) +{ + const ScriptCallFrame* frame = m_callStack ? m_callStack->firstNonNativeCallFrame() : nullptr; + if (frame) { + m_url = frame->sourceURL(); + m_line = frame->lineNumber(); + m_column = frame->columnNumber(); + } +} + +ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref&& arguments, JSC::ExecState* state, unsigned long requestIdentifier) + : m_source(source) + , m_type(type) + , m_level(level) + , m_message(message) + , m_arguments(WTFMove(arguments)) + , m_url() + , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) +{ + autogenerateMetadata(state); +} + +ConsoleMessage::~ConsoleMessage() +{ +} + +void ConsoleMessage::autogenerateMetadata(JSC::ExecState* state) +{ + if (!state) + return; + + if (m_type == MessageType::EndGroup) + return; + + // FIXME: Should this really be using "for console" in the generic ConsoleMessage autogeneration? This can skip the first frame. + m_callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture); + + if (const ScriptCallFrame* frame = m_callStack->firstNonNativeCallFrame()) { + m_url = frame->sourceURL(); + m_line = frame->lineNumber(); + m_column = frame->columnNumber(); + return; + } +} + +static Inspector::Protocol::Console::ConsoleMessage::Source messageSourceValue(MessageSource source) +{ + switch (source) { + case MessageSource::XML: return Inspector::Protocol::Console::ConsoleMessage::Source::XML; + case MessageSource::JS: return Inspector::Protocol::Console::ConsoleMessage::Source::Javascript; + case MessageSource::Network: return Inspector::Protocol::Console::ConsoleMessage::Source::Network; + case MessageSource::ConsoleAPI: return Inspector::Protocol::Console::ConsoleMessage::Source::ConsoleAPI; + case MessageSource::Storage: return Inspector::Protocol::Console::ConsoleMessage::Source::Storage; + case MessageSource::AppCache: return Inspector::Protocol::Console::ConsoleMessage::Source::Appcache; + case MessageSource::Rendering: return Inspector::Protocol::Console::ConsoleMessage::Source::Rendering; + case MessageSource::CSS: return Inspector::Protocol::Console::ConsoleMessage::Source::CSS; + case MessageSource::Security: return Inspector::Protocol::Console::ConsoleMessage::Source::Security; + case MessageSource::ContentBlocker: return Inspector::Protocol::Console::ConsoleMessage::Source::ContentBlocker; + case MessageSource::Other: return Inspector::Protocol::Console::ConsoleMessage::Source::Other; + } + return Inspector::Protocol::Console::ConsoleMessage::Source::Other; +} + +static Inspector::Protocol::Console::ConsoleMessage::Type messageTypeValue(MessageType type) +{ + switch (type) { + case MessageType::Log: return Inspector::Protocol::Console::ConsoleMessage::Type::Log; + case MessageType::Clear: return Inspector::Protocol::Console::ConsoleMessage::Type::Clear; + case MessageType::Dir: return Inspector::Protocol::Console::ConsoleMessage::Type::Dir; + case MessageType::DirXML: return Inspector::Protocol::Console::ConsoleMessage::Type::DirXML; + case MessageType::Table: return Inspector::Protocol::Console::ConsoleMessage::Type::Table; + case MessageType::Trace: return Inspector::Protocol::Console::ConsoleMessage::Type::Trace; + case MessageType::StartGroup: return Inspector::Protocol::Console::ConsoleMessage::Type::StartGroup; + case MessageType::StartGroupCollapsed: return Inspector::Protocol::Console::ConsoleMessage::Type::StartGroupCollapsed; + case MessageType::EndGroup: return Inspector::Protocol::Console::ConsoleMessage::Type::EndGroup; + case MessageType::Assert: return Inspector::Protocol::Console::ConsoleMessage::Type::Assert; + case MessageType::Timing: return Inspector::Protocol::Console::ConsoleMessage::Type::Timing; + case MessageType::Profile: return Inspector::Protocol::Console::ConsoleMessage::Type::Profile; + case MessageType::ProfileEnd: return Inspector::Protocol::Console::ConsoleMessage::Type::ProfileEnd; + } + return Inspector::Protocol::Console::ConsoleMessage::Type::Log; +} + +static Inspector::Protocol::Console::ConsoleMessage::Level messageLevelValue(MessageLevel level) +{ + switch (level) { + case MessageLevel::Log: return Inspector::Protocol::Console::ConsoleMessage::Level::Log; + case MessageLevel::Info: return Inspector::Protocol::Console::ConsoleMessage::Level::Info; + case MessageLevel::Warning: return Inspector::Protocol::Console::ConsoleMessage::Level::Warning; + case MessageLevel::Error: return Inspector::Protocol::Console::ConsoleMessage::Level::Error; + case MessageLevel::Debug: return Inspector::Protocol::Console::ConsoleMessage::Level::Debug; + } + return Inspector::Protocol::Console::ConsoleMessage::Level::Log; +} + +void ConsoleMessage::addToFrontend(ConsoleFrontendDispatcher& consoleFrontendDispatcher, InjectedScriptManager& injectedScriptManager, bool generatePreview) +{ + Ref jsonObj = Inspector::Protocol::Console::ConsoleMessage::create() + .setSource(messageSourceValue(m_source)) + .setLevel(messageLevelValue(m_level)) + .setText(m_message) + .release(); + + // FIXME: only send out type for ConsoleAPI source messages. + jsonObj->setType(messageTypeValue(m_type)); + jsonObj->setLine(static_cast(m_line)); + jsonObj->setColumn(static_cast(m_column)); + jsonObj->setUrl(m_url); + jsonObj->setRepeatCount(static_cast(m_repeatCount)); + + if (m_source == MessageSource::Network && !m_requestId.isEmpty()) + jsonObj->setNetworkRequestId(m_requestId); + + if (m_arguments && m_arguments->argumentCount()) { + InjectedScript injectedScript = injectedScriptManager.injectedScriptFor(m_arguments->globalState()); + if (!injectedScript.hasNoValue()) { + Ref> jsonArgs = Inspector::Protocol::Array::create(); + if (m_type == MessageType::Table && generatePreview && m_arguments->argumentCount()) { + Deprecated::ScriptValue table = m_arguments->argumentAt(0); + Deprecated::ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : Deprecated::ScriptValue(); + RefPtr inspectorValue = injectedScript.wrapTable(table, columns); + if (!inspectorValue) { + ASSERT_NOT_REACHED(); + return; + } + jsonArgs->addItem(inspectorValue.copyRef()); + if (m_arguments->argumentCount() > 1) + jsonArgs->addItem(injectedScript.wrapObject(columns, ASCIILiteral("console"), true)); + } else { + for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { + RefPtr inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), ASCIILiteral("console"), generatePreview); + if (!inspectorValue) { + ASSERT_NOT_REACHED(); + return; + } + jsonArgs->addItem(inspectorValue.copyRef()); + } + } + jsonObj->setParameters(WTFMove(jsonArgs)); + } + } + + if (m_callStack) + jsonObj->setStackTrace(m_callStack->buildInspectorArray()); + + consoleFrontendDispatcher.messageAdded(WTFMove(jsonObj)); +} + +void ConsoleMessage::updateRepeatCountInConsole(ConsoleFrontendDispatcher& consoleFrontendDispatcher) +{ + consoleFrontendDispatcher.messageRepeatCountUpdated(m_repeatCount); +} + +bool ConsoleMessage::isEqual(ConsoleMessage* msg) const +{ + if (m_arguments) { + if (!m_arguments->isEqual(msg->m_arguments.get())) + return false; + + // Never treat objects as equal - their properties might change over time. + for (size_t i = 0; i < m_arguments->argumentCount(); ++i) { + if (m_arguments->argumentAt(i).isObject()) + return false; + } + } else if (msg->m_arguments) + return false; + + if (m_callStack) { + if (!m_callStack->isEqual(msg->m_callStack.get())) + return false; + } else if (msg->m_callStack) + return false; + + return msg->m_source == m_source + && msg->m_type == m_type + && msg->m_level == m_level + && msg->m_message == m_message + && msg->m_line == m_line + && msg->m_column == m_column + && msg->m_url == m_url + && msg->m_requestId == m_requestId; +} + +void ConsoleMessage::clear() +{ + if (!m_message) + m_message = ASCIILiteral(""); + + if (m_arguments) + m_arguments = nullptr; +} + +JSC::ExecState* ConsoleMessage::scriptState() const +{ + if (m_arguments) + return m_arguments->globalState(); + + return nullptr; +} + +unsigned ConsoleMessage::argumentCount() const +{ + if (m_arguments) + return m_arguments->argumentCount(); + + return 0; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ConsoleMessage.h b/Source/JavaScriptCore/inspector/ConsoleMessage.h new file mode 100644 index 000000000..a4d18b882 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ConsoleMessage.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2008 Matt Lilek + * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "ConsoleTypes.h" +#include "InspectorFrontendDispatchers.h" +#include + +namespace JSC { +class ExecState; +} + +namespace Inspector { + +class InjectedScriptManager; +class ScriptArguments; +class ScriptCallStack; + +class JS_EXPORT_PRIVATE ConsoleMessage { + WTF_MAKE_NONCOPYABLE(ConsoleMessage); + WTF_MAKE_FAST_ALLOCATED; +public: + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned long requestIdentifier = 0); + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref&&, unsigned long requestIdentifier = 0); + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref&&, JSC::ExecState*, unsigned long requestIdentifier = 0); + ~ConsoleMessage(); + + void addToFrontend(ConsoleFrontendDispatcher&, InjectedScriptManager&, bool generatePreview); + void updateRepeatCountInConsole(ConsoleFrontendDispatcher&); + + MessageSource source() const { return m_source; } + MessageType type() const { return m_type; } + MessageLevel level() const { return m_level; } + const String& message() const { return m_message; } + const String& url() const { return m_url; } + unsigned line() const { return m_line; } + unsigned column() const { return m_column; } + + JSC::ExecState* scriptState() const; + + void incrementCount() { ++m_repeatCount; } + + unsigned argumentCount() const; + + bool isEqual(ConsoleMessage* msg) const; + + void clear(); + +private: + void autogenerateMetadata(JSC::ExecState* = nullptr); + + MessageSource m_source; + MessageType m_type; + MessageLevel m_level; + String m_message; + RefPtr m_arguments; + RefPtr m_callStack; + String m_url; + unsigned m_line { 0 }; + unsigned m_column { 0 }; + unsigned m_repeatCount { 1 }; + String m_requestId; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp b/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp index 8f1f91cf1..7f4504235 100644 --- a/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp +++ b/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp @@ -29,14 +29,13 @@ #include "config.h" #include "ContentSearchUtilities.h" -#if ENABLE(INSPECTOR) - -#include "InspectorJSTypeBuilders.h" #include "InspectorValues.h" #include "RegularExpression.h" #include "Yarr.h" +#include "YarrInterpreter.h" #include #include +#include using namespace JSC::Yarr; @@ -47,17 +46,16 @@ static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|"; static String createSearchRegexSource(const String& text) { - String result; - const UChar* characters = text.deprecatedCharacters(); - String specials(regexSpecialCharacters); + StringBuilder result; for (unsigned i = 0; i < text.length(); i++) { - if (specials.find(characters[i]) != notFound) - result.append("\\"); - result.append(characters[i]); + UChar character = text[i]; + if (isASCII(character) && strchr(regexSpecialCharacters, character)) + result.append('\\'); + result.append(character); } - return result; + return result.toString(); } static inline size_t sizetExtractor(const size_t* value) @@ -67,60 +65,64 @@ static inline size_t sizetExtractor(const size_t* value) TextPosition textPositionFromOffset(size_t offset, const Vector& lineEndings) { - const size_t* foundLineEnding = approximateBinarySearch(lineEndings, lineEndings.size(), offset, sizetExtractor); - size_t lineIndex = foundLineEnding - &lineEndings.at(0); - if (offset > *foundLineEnding) + const size_t* foundNextStart = approximateBinarySearch(lineEndings, lineEndings.size(), offset, sizetExtractor); + size_t lineIndex = foundNextStart - &lineEndings.at(0); + if (offset >= *foundNextStart) ++lineIndex; - size_t lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0; + size_t lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) : 0; size_t column = offset - lineStartOffset; return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumber::fromZeroBasedInt(column)); } -static Vector> getRegularExpressionMatchesByLines(const JSC::Yarr::RegularExpression& regex, const String& text) +static Vector> getRegularExpressionMatchesByLines(const JSC::Yarr::RegularExpression& regex, const String& text) { - Vector> result; + Vector> result; if (text.isEmpty()) return result; - OwnPtr> endings(lineEndings(text)); + std::unique_ptr> endings(lineEndings(text)); size_t size = endings->size(); - unsigned start = 0; + size_t start = 0; + for (size_t lineNumber = 0; lineNumber < size; ++lineNumber) { - size_t lineEnd = endings->at(lineNumber); - String line = text.substring(start, lineEnd - start); - if (line.endsWith('\r')) - line = line.left(line.length() - 1); + size_t nextStart = endings->at(lineNumber); + String line = text.substring(start, nextStart - start); int matchLength; if (regex.match(line, 0, &matchLength) != -1) - result.append(std::pair(lineNumber, line)); + result.append(std::pair(lineNumber, line)); - start = lineEnd + 1; + start = nextStart; } + return result; } -PassOwnPtr> lineEndings(const String& text) +std::unique_ptr> lineEndings(const String& text) { - OwnPtr> result(adoptPtr(new Vector())); + auto result = std::make_unique>(); - unsigned start = 0; + size_t start = 0; while (start < text.length()) { - size_t lineEnd = text.find('\n', start); - if (lineEnd == notFound) + size_t nextStart = text.find('\n', start); + if (nextStart == notFound || nextStart == (text.length() - 1)) { + result->append(text.length()); break; + } - result->append(lineEnd); - start = lineEnd + 1; + nextStart += 1; + result->append(nextStart); + start = nextStart; } + result->append(text.length()); - return result.release(); + return result; } -static PassRefPtr buildObjectForSearchMatch(int lineNumber, const String& lineContent) +static Ref buildObjectForSearchMatch(size_t lineNumber, const String& lineContent) { - return Inspector::TypeBuilder::GenericTypes::SearchMatch::create() + return Inspector::Protocol::GenericTypes::SearchMatch::create() .setLineNumber(lineNumber) .setLineContent(lineContent) .release(); @@ -151,25 +153,21 @@ int countRegularExpressionMatches(const JSC::Yarr::RegularExpression& regex, con return result; } -PassRefPtr> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) +Ref> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { - RefPtr> result = Inspector::TypeBuilder::Array::create(); + Ref> result = Inspector::Protocol::Array::create(); JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex); - Vector> matches = getRegularExpressionMatchesByLines(regex, text); + Vector> matches = getRegularExpressionMatchesByLines(regex, text); - for (Vector>::const_iterator it = matches.begin(); it != matches.end(); ++it) - result->addItem(buildObjectForSearchMatch(it->first, it->second)); + for (const auto& match : matches) { + Ref matchObject = buildObjectForSearchMatch(match.first, match.second); + result->addItem(WTFMove(matchObject)); + } return result; } -static String scriptCommentPattern(const String& name) -{ - // "//# =" and deprecated "//@" - return "//[#@][\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$"; -} - static String stylesheetCommentPattern(const String& name) { // "/*# = */" and deprecated "/*@" @@ -178,11 +176,12 @@ static String stylesheetCommentPattern(const String& name) static String findMagicComment(const String& content, const String& patternString) { + ASSERT(!content.isNull()); const char* error = nullptr; - JSC::Yarr::YarrPattern pattern(patternString, false, true, &error); + JSC::Yarr::YarrPattern pattern(patternString, JSC::RegExpFlags::FlagMultiline, &error); ASSERT(!error); BumpPointerAllocator regexAllocator; - OwnPtr bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator); + auto bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator); ASSERT(bytecodePattern); ASSERT(pattern.m_numSubpatterns == 1); @@ -196,22 +195,10 @@ static String findMagicComment(const String& content, const String& patternStrin return content.substring(matches[2], matches[3] - matches[2]); } -String findScriptSourceURL(const String& content) -{ - return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceURL"))); -} - -String findScriptSourceMapURL(const String& content) -{ - return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceMappingURL"))); -} - String findStylesheetSourceMapURL(const String& content) { return findMagicComment(content, stylesheetCommentPattern(ASCIILiteral("sourceMappingURL"))); } } // namespace ContentSearchUtilities -} // namespace WebCore - -#endif // ENABLE(INSPECTOR) +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ContentSearchUtilities.h b/Source/JavaScriptCore/inspector/ContentSearchUtilities.h index 3eaa06641..7c01b90da 100644 --- a/Source/JavaScriptCore/inspector/ContentSearchUtilities.h +++ b/Source/JavaScriptCore/inspector/ContentSearchUtilities.h @@ -26,12 +26,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ContentSearchUtilities_h -#define ContentSearchUtilities_h +#pragma once -#if ENABLE(INSPECTOR) - -#include "InspectorJSTypeBuilders.h" +#include "InspectorProtocolObjects.h" #include #include #include @@ -46,18 +43,12 @@ namespace ContentSearchUtilities { JS_EXPORT_PRIVATE JSC::Yarr::RegularExpression createSearchRegex(const String& query, bool caseSensitive, bool isRegex); JS_EXPORT_PRIVATE int countRegularExpressionMatches(const JSC::Yarr::RegularExpression&, const String&); -JS_EXPORT_PRIVATE PassRefPtr> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex); +JS_EXPORT_PRIVATE Ref> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex); JS_EXPORT_PRIVATE TextPosition textPositionFromOffset(size_t offset, const Vector& lineEndings); -JS_EXPORT_PRIVATE PassOwnPtr> lineEndings(const String&); +JS_EXPORT_PRIVATE std::unique_ptr> lineEndings(const String&); -JS_EXPORT_PRIVATE String findScriptSourceURL(const String& content); -JS_EXPORT_PRIVATE String findScriptSourceMapURL(const String& content); JS_EXPORT_PRIVATE String findStylesheetSourceMapURL(const String& content); } // namespace ContentSearchUtilities } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(ContentSearchUtilities_h) diff --git a/Source/JavaScriptCore/inspector/EventLoop.cpp b/Source/JavaScriptCore/inspector/EventLoop.cpp new file mode 100644 index 000000000..1995b1d70 --- /dev/null +++ b/Source/JavaScriptCore/inspector/EventLoop.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EventLoop.h" + +#if OS(WINDOWS) +#include +#elif PLATFORM(GTK) +#include +#endif + +namespace Inspector { + +#if USE(CF) && !OS(WINDOWS) +CFStringRef EventLoop::remoteInspectorRunLoopMode() +{ + return CFSTR("com.apple.JavaScriptCore.remote-inspector-runloop-mode"); +} +#endif + +void EventLoop::cycle() +{ +#if OS(WINDOWS) + MSG msg; + if (!GetMessage(&msg, 0, 0, 0)) { + m_ended = true; + return; + } + TranslateMessage(&msg); + DispatchMessage(&msg); +#elif PLATFORM(WATCHOS) + // FIXME: . In order for auto-attach to work, we need to + // run in the default run loop mode otherwise we do not receive the XPC messages + // necessary to setup the relay connection and negotiate an auto-attach debugger. + CFTimeInterval timeInterval = 0.05; + CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeInterval, true); +#elif USE(CF) + // Run the RunLoop in a custom run loop mode to prevent default observers + // to run and potentially evaluate JavaScript in this context while we are + // nested. Only the debugger should control things until we continue. + // FIXME: This is not a perfect solution, as background threads are not + // paused and can still access and evalute script in the JSContext. + CFTimeInterval timeInterval = 0.05; + CFRunLoopRunInMode(remoteInspectorRunLoopMode(), timeInterval, true); +#elif PLATFORM(GTK) + g_main_context_iteration(NULL, FALSE); +#endif +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/EventLoop.h b/Source/JavaScriptCore/inspector/EventLoop.h new file mode 100644 index 000000000..1625a6b6b --- /dev/null +++ b/Source/JavaScriptCore/inspector/EventLoop.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +#if USE(CF) && !OS(WINDOWS) +#include +#endif + +namespace Inspector { + +class EventLoop { + WTF_MAKE_NONCOPYABLE(EventLoop); +public: + EventLoop() + : m_ended(false) + { + } + + void cycle(); + bool ended() const { return m_ended; } + +#if USE(CF) && !OS(WINDOWS) + static CFStringRef remoteInspectorRunLoopMode(); +#endif + +private: + bool m_ended; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp b/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp new file mode 100644 index 000000000..7e145be3e --- /dev/null +++ b/Source/JavaScriptCore/inspector/IdentifiersFactory.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IdentifiersFactory.h" + +#include + +namespace Inspector { + +namespace { +static long s_lastUsedIdentifier = 0; +} + +long IdentifiersFactory::s_processId = 0; + +String IdentifiersFactory::createIdentifier() +{ + return addProcessIdPrefixTo(String::number(++s_lastUsedIdentifier)); +} + +String IdentifiersFactory::requestId(unsigned long identifier) +{ + if (identifier) + return addProcessIdPrefixTo(String::number(identifier)); + return String(); +} + +String IdentifiersFactory::addProcessIdPrefixTo(const String& id) +{ + StringBuilder builder; + builder.appendNumber(s_processId); + builder.append('.'); + builder.append(id); + return builder.toString(); +} + +} // namespace Inspector + diff --git a/Source/JavaScriptCore/inspector/IdentifiersFactory.h b/Source/JavaScriptCore/inspector/IdentifiersFactory.h new file mode 100644 index 000000000..3a3b75ab9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/IdentifiersFactory.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +namespace Inspector { + +class JS_EXPORT_PRIVATE IdentifiersFactory { +public: + static void setProcessId(long processId) { s_processId = processId; } + static String createIdentifier(); + static String requestId(unsigned long identifier); + +private: + static String addProcessIdPrefixTo(const String& id); + + static long s_processId; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp index a02f85fb4..f7691afa4 100644 --- a/Source/JavaScriptCore/inspector/InjectedScript.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp @@ -32,14 +32,13 @@ #include "config.h" #include "InjectedScript.h" -#if ENABLE(INSPECTOR) - #include "InspectorValues.h" +#include "JSCInlines.h" #include "ScriptFunctionCall.h" #include "ScriptObject.h" #include -using Inspector::TypeBuilder::Array; +using Inspector::Protocol::Array; namespace Inspector { @@ -57,7 +56,7 @@ InjectedScript::~InjectedScript() { } -void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr* result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InjectedScript::evaluate(ErrorString& errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr* result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluate"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(expression); @@ -65,10 +64,11 @@ void InjectedScript::evaluate(ErrorString* errorString, const String& expression function.appendArgument(includeCommandLineAPI); function.appendArgument(returnByValue); function.appendArgument(generatePreview); - makeEvalCall(errorString, function, result, wasThrown); + function.appendArgument(saveResult); + makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); } -void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr* result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr* result, Inspector::Protocol::OptOutput* wasThrown) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("callFunctionOn"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); @@ -79,7 +79,7 @@ void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje makeEvalCall(errorString, function, result, wasThrown); } -void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr* result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, JSC::JSValue callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr* result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluateOnCallFrame"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(callFrames); @@ -89,75 +89,147 @@ void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Depreca function.appendArgument(includeCommandLineAPI); function.appendArgument(returnByValue); function.appendArgument(generatePreview); - makeEvalCall(errorString, function, result, wasThrown); + function.appendArgument(saveResult); + makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); } -void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr* result) +void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr* result) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getFunctionDetails"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(functionId); RefPtr resultValue; makeCall(function, &resultValue); - if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { + if (!resultValue || resultValue->type() != InspectorValue::Type::Object) { if (!resultValue->asString(errorString)) - *errorString = ASCIILiteral("Internal error"); + errorString = ASCIILiteral("Internal error"); return; } - *result = Inspector::TypeBuilder::Debugger::FunctionDetails::runtimeCast(resultValue); + *result = BindingTraits::runtimeCast(WTFMove(resultValue)); } -void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr>* properties) +void InjectedScript::functionDetails(ErrorString& errorString, JSC::JSValue value, RefPtr* result) +{ + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("functionDetails"), inspectorEnvironment()->functionCallHandler()); + function.appendArgument(value); + function.appendArgument(true); // Preview only. + + RefPtr resultValue; + makeCall(function, &resultValue); + if (!resultValue || resultValue->type() != InspectorValue::Type::Object) { + if (!resultValue->asString(errorString)) + errorString = ASCIILiteral("Internal error"); + return; + } + + *result = BindingTraits::runtimeCast(WTFMove(resultValue)); +} + +void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool generatePreview, RefPtr>* properties) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); function.appendArgument(ownProperties); + function.appendArgument(generatePreview); RefPtr result; makeCall(function, &result); - if (!result || result->type() != InspectorValue::TypeArray) { - *errorString = ASCIILiteral("Internal error"); + if (!result || result->type() != InspectorValue::Type::Array) { + errorString = ASCIILiteral("Internal error"); return; } - *properties = Array::runtimeCast(result); + *properties = BindingTraits>::runtimeCast(WTFMove(result)); } -void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr>* properties) +void InjectedScript::getDisplayableProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr>* properties) +{ + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getDisplayableProperties"), inspectorEnvironment()->functionCallHandler()); + function.appendArgument(objectId); + function.appendArgument(generatePreview); + + RefPtr result; + makeCall(function, &result); + if (!result || result->type() != InspectorValue::Type::Array) { + errorString = ASCIILiteral("Internal error"); + return; + } + + *properties = BindingTraits>::runtimeCast(WTFMove(result)); +} + +void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr>* properties) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); + function.appendArgument(generatePreview); RefPtr result; makeCall(function, &result); - if (!result || result->type() != InspectorValue::TypeArray) { - *errorString = ASCIILiteral("Internal error"); + if (!result || result->type() != InspectorValue::Type::Array) { + errorString = ASCIILiteral("Internal error"); return; } - RefPtr> array = Array::runtimeCast(result); - if (array->length() > 0) - *properties = array; + auto array = BindingTraits>::runtimeCast(WTFMove(result)); + *properties = array->length() > 0 ? array : nullptr; } -PassRefPtr> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames) +void InjectedScript::getCollectionEntries(ErrorString& errorString, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr>* entries) +{ + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getCollectionEntries"), inspectorEnvironment()->functionCallHandler()); + function.appendArgument(objectId); + function.appendArgument(objectGroup); + function.appendArgument(startIndex); + function.appendArgument(numberToFetch); + + RefPtr result; + makeCall(function, &result); + if (!result || result->type() != InspectorValue::Type::Array) { + errorString = ASCIILiteral("Internal error"); + return; + } + + *entries = BindingTraits>::runtimeCast(WTFMove(result)); +} + +void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, Inspector::Protocol::OptOutput* savedResultIndex) +{ + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("saveResult"), inspectorEnvironment()->functionCallHandler()); + function.appendArgument(callArgumentJSON); + + RefPtr result; + makeCall(function, &result); + if (!result || result->type() != InspectorValue::Type::Integer) { + errorString = ASCIILiteral("Internal error"); + return; + } + + int savedResultIndexInt = 0; + if (result->asInteger(savedResultIndexInt) && savedResultIndexInt > 0) + *savedResultIndex = savedResultIndexInt; +} + +Ref> InjectedScript::wrapCallFrames(JSC::JSValue callFrames) const { ASSERT(!hasNoValue()); Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(callFrames); bool hadException = false; - Deprecated::ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException); + auto callFramesValue = callFunctionWithEvalEnabled(function, hadException); + if (!callFramesValue) + return Array::create(); ASSERT(!hadException); - RefPtr result = callFramesValue.toInspectorValue(scriptState()); - if (result->type() == InspectorValue::TypeArray) - return Array::runtimeCast(result); + RefPtr result = toInspectorValue(*scriptState(), callFramesValue); + if (result->type() == InspectorValue::Type::Array) + return BindingTraits>::runtimeCast(WTFMove(result)).releaseNonNull(); - return Array::create(); + return Array::create(); } -PassRefPtr InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const +RefPtr InjectedScript::wrapObject(JSC::JSValue value, const String& groupName, bool generatePreview) const { ASSERT(!hasNoValue()); Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapObject"), inspectorEnvironment()->functionCallHandler()); @@ -167,48 +239,89 @@ PassRefPtr InjectedScript::wrapOb wrapFunction.appendArgument(generatePreview); bool hadException = false; - Deprecated::ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); + auto r = callFunctionWithEvalEnabled(wrapFunction, hadException); if (hadException) return nullptr; - RefPtr rawResult = r.toInspectorValue(scriptState())->asObject(); - return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); + RefPtr resultObject; + bool castSucceeded = toInspectorValue(*scriptState(), r)->asObject(resultObject); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + return BindingTraits::runtimeCast(resultObject); } -PassRefPtr InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const +RefPtr InjectedScript::wrapTable(JSC::JSValue table, JSC::JSValue columns) const { ASSERT(!hasNoValue()); Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapTable"), inspectorEnvironment()->functionCallHandler()); wrapFunction.appendArgument(hasAccessToInspectedScriptState()); wrapFunction.appendArgument(table); - if (columns.hasNoValue()) + if (!columns) wrapFunction.appendArgument(false); else wrapFunction.appendArgument(columns); bool hadException = false; - Deprecated::ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); + auto r = callFunctionWithEvalEnabled(wrapFunction, hadException); + if (hadException) + return nullptr; + + RefPtr resultObject; + bool castSucceeded = toInspectorValue(*scriptState(), r)->asObject(resultObject); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + return BindingTraits::runtimeCast(resultObject); +} + +RefPtr InjectedScript::previewValue(JSC::JSValue value) const +{ + ASSERT(!hasNoValue()); + Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("previewValue"), inspectorEnvironment()->functionCallHandler()); + wrapFunction.appendArgument(value); + + bool hadException = false; + auto r = callFunctionWithEvalEnabled(wrapFunction, hadException); if (hadException) return nullptr; - RefPtr rawResult = r.toInspectorValue(scriptState())->asObject(); - return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); + RefPtr resultObject; + bool castSucceeded = toInspectorValue(*scriptState(), r)->asObject(resultObject); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + return BindingTraits::runtimeCast(resultObject); +} + +void InjectedScript::setExceptionValue(JSC::JSValue value) +{ + ASSERT(!hasNoValue()); + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("setExceptionValue"), inspectorEnvironment()->functionCallHandler()); + function.appendArgument(value); + RefPtr result; + makeCall(function, &result); +} + +void InjectedScript::clearExceptionValue() +{ + ASSERT(!hasNoValue()); + Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("clearExceptionValue"), inspectorEnvironment()->functionCallHandler()); + RefPtr result; + makeCall(function, &result); } -Deprecated::ScriptValue InjectedScript::findObjectById(const String& objectId) const +JSC::JSValue InjectedScript::findObjectById(const String& objectId) const { ASSERT(!hasNoValue()); Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("findObjectById"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); bool hadException = false; - Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException); + auto resultValue = callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); return resultValue; } -void InjectedScript::inspectObject(Deprecated::ScriptValue value) +void InjectedScript::inspectObject(JSC::JSValue value) { ASSERT(!hasNoValue()); Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("inspectObject"), inspectorEnvironment()->functionCallHandler()); @@ -238,4 +351,3 @@ void InjectedScript::releaseObjectGroup(const String& objectGroup) } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/InjectedScript.h b/Source/JavaScriptCore/inspector/InjectedScript.h index 4c58b19e5..4d227114e 100644 --- a/Source/JavaScriptCore/inspector/InjectedScript.h +++ b/Source/JavaScriptCore/inspector/InjectedScript.h @@ -29,16 +29,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InjectedScript_h -#define InjectedScript_h - -#if ENABLE(INSPECTOR) +#pragma once #include "InjectedScriptBase.h" -#include "InspectorJSTypeBuilders.h" #include #include -#include #include namespace Deprecated { @@ -56,19 +51,27 @@ public: InjectedScript(Deprecated::ScriptObject, InspectorEnvironment*); virtual ~InjectedScript(); - void evaluate(ErrorString*, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr* result, TypeBuilder::OptOutput* wasThrown); - void callFunctionOn(ErrorString*, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr* result, TypeBuilder::OptOutput* wasThrown); - void evaluateOnCallFrame(ErrorString*, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr* result, TypeBuilder::OptOutput* wasThrown); - void getFunctionDetails(ErrorString*, const String& functionId, RefPtr* result); - void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr>* result); - void getInternalProperties(ErrorString*, const String& objectId, RefPtr>* result); + void evaluate(ErrorString&, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr* result, Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex); + void callFunctionOn(ErrorString&, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr* result, Protocol::OptOutput* wasThrown); + void evaluateOnCallFrame(ErrorString&, JSC::JSValue callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr* result, Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex); + void getFunctionDetails(ErrorString&, const String& functionId, RefPtr* result); + void functionDetails(ErrorString&, JSC::JSValue, RefPtr* result); + void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool generatePreview, RefPtr>* result); + void getDisplayableProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr>* result); + void getInternalProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr>* result); + void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr>* entries); + void saveResult(ErrorString&, const String& callArgumentJSON, Inspector::Protocol::OptOutput* savedResultIndex); + + Ref> wrapCallFrames(JSC::JSValue) const; + RefPtr wrapObject(JSC::JSValue, const String& groupName, bool generatePreview = false) const; + RefPtr wrapTable(JSC::JSValue table, JSC::JSValue columns) const; + RefPtr previewValue(JSC::JSValue) const; - PassRefPtr> wrapCallFrames(const Deprecated::ScriptValue&); - PassRefPtr wrapObject(const Deprecated::ScriptValue&, const String& groupName, bool generatePreview = false) const; - PassRefPtr wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const; + void setExceptionValue(JSC::JSValue); + void clearExceptionValue(); - Deprecated::ScriptValue findObjectById(const String& objectId) const; - void inspectObject(Deprecated::ScriptValue); + JSC::JSValue findObjectById(const String& objectId) const; + void inspectObject(JSC::JSValue); void releaseObject(const String& objectId); void releaseObjectGroup(const String& objectGroup); @@ -77,7 +80,3 @@ private: }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // InjectedScript_h diff --git a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp index c2a494728..9caa4eb93 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp @@ -32,9 +32,9 @@ #include "config.h" #include "InjectedScriptBase.h" -#if ENABLE(INSPECTOR) - +#include "DebuggerEvalEnabler.h" #include "InspectorValues.h" +#include "JSCInlines.h" #include "JSGlobalObject.h" #include "ScriptFunctionCall.h" #include @@ -58,12 +58,6 @@ InjectedScriptBase::~InjectedScriptBase() { } -void InjectedScriptBase::initialize(Deprecated::ScriptObject injectedScriptObject, InspectorEnvironment* environment) -{ - m_injectedScriptObject = injectedScriptObject; - m_environment = environment; -} - bool InjectedScriptBase::hasAccessToInspectedScriptState() const { return m_environment && m_environment->canAccessInspectedScriptState(m_injectedScriptObject.scriptState()); @@ -74,29 +68,11 @@ const Deprecated::ScriptObject& InjectedScriptBase::injectedScriptObject() const return m_injectedScriptObject; } -Deprecated::ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall& function, bool& hadException) const +JSC::JSValue InjectedScriptBase::callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall& function, bool& hadException) const { - if (m_environment) - m_environment->willCallInjectedScriptFunction(m_injectedScriptObject.scriptState(), name(), 1); - JSC::ExecState* scriptState = m_injectedScriptObject.scriptState(); - bool evalIsDisabled = false; - if (scriptState) { - evalIsDisabled = !scriptState->lexicalGlobalObject()->evalEnabled(); - // Temporarily enable allow evals for inspector. - if (evalIsDisabled) - scriptState->lexicalGlobalObject()->setEvalEnabled(true); - } - - Deprecated::ScriptValue resultValue = function.call(hadException); - - if (evalIsDisabled) - scriptState->lexicalGlobalObject()->setEvalEnabled(false); - - if (m_environment) - m_environment->didCallInjectedScriptFunction(); - - return resultValue; + JSC::DebuggerEvalEnabler evalEnabler(scriptState); + return function.call(hadException); } void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefPtr* result) @@ -107,49 +83,59 @@ void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefP } bool hadException = false; - Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException); + auto resultValue = callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); if (!hadException) { - *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); + *result = toInspectorValue(*m_injectedScriptObject.scriptState(), resultValue); if (!*result) - *result = InspectorString::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth)); + *result = InspectorValue::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth)); } else - *result = InspectorString::create("Exception while making a call."); + *result = InspectorValue::create("Exception while making a call."); } -void InjectedScriptBase::makeEvalCall(ErrorString* errorString, Deprecated::ScriptFunctionCall& function, RefPtr* objectResult, TypeBuilder::OptOutput* wasThrown) +void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr* objectResult, Protocol::OptOutput* wasThrown, Protocol::OptOutput* savedResultIndex) { RefPtr result; makeCall(function, &result); if (!result) { - *errorString = ASCIILiteral("Internal error: result value is empty"); + errorString = ASCIILiteral("Internal error: result value is empty"); return; } - if (result->type() == InspectorValue::TypeString) { + if (result->type() == InspectorValue::Type::String) { result->asString(errorString); - ASSERT(errorString->length()); + ASSERT(errorString.length()); return; } - RefPtr resultPair = result->asObject(); - if (!resultPair) { - *errorString = ASCIILiteral("Internal error: result is not an Object"); + RefPtr resultTuple; + if (!result->asObject(resultTuple)) { + errorString = ASCIILiteral("Internal error: result is not an Object"); return; } - RefPtr resultObj = resultPair->getObject(ASCIILiteral("result")); - bool wasThrownVal = false; - if (!resultObj || !resultPair->getBoolean(ASCIILiteral("wasThrown"), &wasThrownVal)) { - *errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag"); + RefPtr resultObject; + if (!resultTuple->getObject(ASCIILiteral("result"), resultObject)) { + errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag"); return; } - *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj); - *wasThrown = wasThrownVal; + bool wasThrownValue = false; + if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) { + errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag"); + return; + } + + *objectResult = BindingTraits::runtimeCast(resultObject); + *wasThrown = wasThrownValue; + + if (savedResultIndex) { + int savedIndex = 0; + if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedIndex)) + *savedResultIndex = savedIndex; + } } } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptBase.h b/Source/JavaScriptCore/inspector/InjectedScriptBase.h index 034e0c20a..55dd0e57d 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptBase.h +++ b/Source/JavaScriptCore/inspector/InjectedScriptBase.h @@ -29,13 +29,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InjectedScriptBase_h -#define InjectedScriptBase_h - -#if ENABLE(INSPECTOR) +#pragma once #include "InspectorEnvironment.h" -#include "InspectorJSTypeBuilders.h" +#include "InspectorProtocolObjects.h" #include "bindings/ScriptObject.h" #include #include @@ -62,13 +59,12 @@ protected: InspectorEnvironment* inspectorEnvironment() const { return m_environment; } - void initialize(Deprecated::ScriptObject, InspectorEnvironment*); bool hasAccessToInspectedScriptState() const; const Deprecated::ScriptObject& injectedScriptObject() const; - Deprecated::ScriptValue callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall&, bool& hadException) const; + JSC::JSValue callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall&, bool& hadException) const; void makeCall(Deprecated::ScriptFunctionCall&, RefPtr* result); - void makeEvalCall(ErrorString*, Deprecated::ScriptFunctionCall&, RefPtr* result, TypeBuilder::OptOutput* wasThrown); + void makeEvalCall(ErrorString&, Deprecated::ScriptFunctionCall&, RefPtr* result, Protocol::OptOutput* wasThrown, Protocol::OptOutput* savedResult = nullptr); private: String m_name; @@ -77,7 +73,3 @@ private: }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // InjectedScriptBase_h diff --git a/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp b/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp index 46b3c4e37..433174ff9 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp @@ -26,8 +26,7 @@ #include "config.h" #include "InjectedScriptHost.h" -#if ENABLE(INSPECTOR) - +#include "JSCInlines.h" #include "JSInjectedScriptHost.h" using namespace JSC; @@ -38,46 +37,23 @@ InjectedScriptHost::~InjectedScriptHost() { } -JSValue InjectedScriptHost::jsWrapper(ExecState* exec, JSGlobalObject* globalObject) +JSValue InjectedScriptHost::wrapper(ExecState* exec, JSGlobalObject* globalObject) { - auto key = std::make_pair(exec, globalObject); - auto it = m_wrappers.find(key); - if (it != m_wrappers.end()) - return it->value.get(); - - JSValue jsValue = toJS(exec, globalObject, this); - if (!jsValue.isObject()) - return jsValue; - - JSObject* jsObject = jsValue.toObject(exec, globalObject); - Strong wrapper(exec->vm(), jsObject); - m_wrappers.add(key, wrapper); - - return jsValue; -} + JSValue value = m_wrappers.getWrapper(globalObject); + if (value) + return value; -static void clearWrapperFromValue(JSValue value) -{ - JSInjectedScriptHost* jsInjectedScriptHost = toJSInjectedScriptHost(value); - ASSERT(jsInjectedScriptHost); - if (jsInjectedScriptHost) - jsInjectedScriptHost->releaseImpl(); -} + JSObject* prototype = JSInjectedScriptHost::createPrototype(exec->vm(), globalObject); + Structure* structure = JSInjectedScriptHost::createStructure(exec->vm(), globalObject, prototype); + JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, makeRef(*this)); + m_wrappers.addWrapper(globalObject, injectedScriptHost); -void InjectedScriptHost::clearWrapper(ExecState* exec, JSGlobalObject* globalObject) -{ - auto key = std::make_pair(exec, globalObject); - clearWrapperFromValue(m_wrappers.take(key).get()); + return injectedScriptHost; } void InjectedScriptHost::clearAllWrappers() { - for (auto wrapper : m_wrappers) - clearWrapperFromValue(wrapper.value.get()); - - m_wrappers.clear(); + m_wrappers.clearAllWrappers(); } } // namespace Inspector - -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptHost.h b/Source/JavaScriptCore/inspector/InjectedScriptHost.h index db93f8631..d58d97d59 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptHost.h +++ b/Source/JavaScriptCore/inspector/InjectedScriptHost.h @@ -23,14 +23,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InjectedScriptHost_h -#define InjectedScriptHost_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSCJSValueInlines.h" -#include "Strong.h" -#include "StrongInlines.h" +#include "inspector/PerGlobalObjectWrapperWorld.h" #include #include @@ -38,22 +34,17 @@ namespace Inspector { class JS_EXPORT_PRIVATE InjectedScriptHost : public RefCounted { public: - static PassRefPtr create() { return adoptRef(new InjectedScriptHost); } + static Ref create() { return adoptRef(*new InjectedScriptHost); } virtual ~InjectedScriptHost(); - virtual JSC::JSValue type(JSC::ExecState*, JSC::JSValue) { return JSC::jsUndefined(); } - virtual bool isHTMLAllCollection(JSC::JSValue) { return false; } + virtual JSC::JSValue subtype(JSC::ExecState*, JSC::JSValue) { return JSC::jsUndefined(); } + virtual bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) { return false; } - JSC::JSValue jsWrapper(JSC::ExecState*, JSC::JSGlobalObject*); - void clearWrapper(JSC::ExecState*, JSC::JSGlobalObject*); + JSC::JSValue wrapper(JSC::ExecState*, JSC::JSGlobalObject*); void clearAllWrappers(); private: - HashMap, JSC::Strong> m_wrappers; + PerGlobalObjectWrapperWorld m_wrappers; }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(InjectedScriptHost_h) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp index 72d20df3e..097615b10 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,12 +31,11 @@ #include "config.h" #include "InjectedScriptManager.h" -#if ENABLE(INSPECTOR) - #include "Completion.h" #include "InjectedScriptHost.h" #include "InjectedScriptSource.h" #include "InspectorValues.h" +#include "JSCInlines.h" #include "JSInjectedScriptHost.h" #include "JSLock.h" #include "ScriptObject.h" @@ -46,9 +45,9 @@ using namespace JSC; namespace Inspector { -InjectedScriptManager::InjectedScriptManager(InspectorEnvironment& environment, PassRefPtr injectedScriptHost) +InjectedScriptManager::InjectedScriptManager(InspectorEnvironment& environment, Ref&& injectedScriptHost) : m_environment(environment) - , m_injectedScriptHost(injectedScriptHost) + , m_injectedScriptHost(WTFMove(injectedScriptHost)) , m_nextInjectedScriptId(1) { } @@ -60,10 +59,16 @@ InjectedScriptManager::~InjectedScriptManager() void InjectedScriptManager::disconnect() { discardInjectedScripts(); - m_injectedScriptHost = nullptr; } -InjectedScriptHost* InjectedScriptManager::injectedScriptHost() +void InjectedScriptManager::discardInjectedScripts() +{ + m_injectedScriptHost->clearAllWrappers(); + m_idToInjectedScript.clear(); + m_scriptStateToId.clear(); +} + +InjectedScriptHost& InjectedScriptManager::injectedScriptHost() { return m_injectedScriptHost.get(); } @@ -95,64 +100,67 @@ int InjectedScriptManager::injectedScriptIdFor(ExecState* scriptState) InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& objectId) { - RefPtr parsedObjectId = InspectorValue::parseJSON(objectId); - if (parsedObjectId && parsedObjectId->type() == InspectorValue::TypeObject) { - long injectedScriptId = 0; - bool success = parsedObjectId->asObject()->getNumber(ASCIILiteral("injectedScriptId"), &injectedScriptId); - if (success) - return m_idToInjectedScript.get(injectedScriptId); - } + RefPtr parsedObjectId; + if (!InspectorValue::parseJSON(objectId, parsedObjectId)) + return InjectedScript(); - return InjectedScript(); + RefPtr resultObject; + if (!parsedObjectId->asObject(resultObject)) + return InjectedScript(); + + long injectedScriptId = 0; + if (!resultObject->getInteger(ASCIILiteral("injectedScriptId"), injectedScriptId)) + return InjectedScript(); + + return m_idToInjectedScript.get(injectedScriptId); } -void InjectedScriptManager::discardInjectedScripts() +void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) { - m_injectedScriptHost->clearAllWrappers(); - m_idToInjectedScript.clear(); - m_scriptStateToId.clear(); + for (auto& injectedScript : m_idToInjectedScript.values()) + injectedScript.releaseObjectGroup(objectGroup); } -void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) +void InjectedScriptManager::clearExceptionValue() { - for (auto it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it) - it->value.releaseObjectGroup(objectGroup); + for (auto& injectedScript : m_idToInjectedScript.values()) + injectedScript.clearExceptionValue(); } String InjectedScriptManager::injectedScriptSource() { - return String(reinterpret_cast(InjectedScriptSource_js), sizeof(InjectedScriptSource_js)); + return StringImpl::createWithoutCopying(InjectedScriptSource_js, sizeof(InjectedScriptSource_js)); } -Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const String& source, ExecState* scriptState, int id) +JSC::JSObject* InjectedScriptManager::createInjectedScript(const String& source, ExecState* scriptState, int id) { - JSLockHolder lock(scriptState); + VM& vm = scriptState->vm(); + JSLockHolder lock(vm); + auto scope = DECLARE_CATCH_SCOPE(vm); - SourceCode sourceCode = makeSource(source); + SourceCode sourceCode = makeSource(source, { }); JSGlobalObject* globalObject = scriptState->lexicalGlobalObject(); JSValue globalThisValue = scriptState->globalThisValue(); - JSValue evaluationException; + NakedPtr evaluationException; InspectorEvaluateHandler evaluateHandler = m_environment.evaluateHandler(); - JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, &evaluationException); + JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, evaluationException); if (evaluationException) - return Deprecated::ScriptObject(); + return nullptr; CallData callData; CallType callType = getCallData(functionValue, callData); - if (callType == CallTypeNone) - return Deprecated::ScriptObject(); + if (callType == CallType::None) + return nullptr; MarkedArgumentBuffer args; - args.append(m_injectedScriptHost->jsWrapper(scriptState, globalObject)); + args.append(m_injectedScriptHost->wrapper(scriptState, globalObject)); args.append(globalThisValue); args.append(jsNumber(id)); JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args); - if (result.isObject()) - return Deprecated::ScriptObject(scriptState, result.getObject()); - - return Deprecated::ScriptObject(); + scope.clearException(); + return result.getObject(); } InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExecState) @@ -168,18 +176,23 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExec return InjectedScript(); int id = injectedScriptIdFor(inspectedExecState); - Deprecated::ScriptObject injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedExecState, id); - InjectedScript result(injectedScriptObject, &m_environment); + auto injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedExecState, id); + if (!injectedScriptObject) { + WTFLogAlways("Failed to parse/execute InjectedScriptSource.js!"); + WTFLogAlways("%s\n", injectedScriptSource().ascii().data()); + RELEASE_ASSERT_NOT_REACHED(); + } + + InjectedScript result({ inspectedExecState, injectedScriptObject }, &m_environment); m_idToInjectedScript.set(id, result); didCreateInjectedScript(result); return result; } -void InjectedScriptManager::didCreateInjectedScript(InjectedScript) +void InjectedScriptManager::didCreateInjectedScript(const InjectedScript&) { // Intentionally empty. This allows for subclasses to inject additional scripts. } } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.h b/Source/JavaScriptCore/inspector/InjectedScriptManager.h index bcc64e2a4..8475e42f7 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptManager.h +++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.h @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,8 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InjectedScriptManager_h -#define InjectedScriptManager_h +#pragma once #include "InjectedScript.h" #include "InjectedScriptHost.h" @@ -50,36 +49,35 @@ namespace Inspector { class JS_EXPORT_PRIVATE InjectedScriptManager { WTF_MAKE_NONCOPYABLE(InjectedScriptManager); WTF_MAKE_FAST_ALLOCATED; public: - InjectedScriptManager(InspectorEnvironment&, PassRefPtr); + InjectedScriptManager(InspectorEnvironment&, Ref&&); virtual ~InjectedScriptManager(); virtual void disconnect(); + virtual void discardInjectedScripts(); - InjectedScriptHost* injectedScriptHost(); + InjectedScriptHost& injectedScriptHost(); InspectorEnvironment& inspectorEnvironment() const { return m_environment; } InjectedScript injectedScriptFor(JSC::ExecState*); InjectedScript injectedScriptForId(int); int injectedScriptIdFor(JSC::ExecState*); InjectedScript injectedScriptForObjectId(const String& objectId); - void discardInjectedScripts(); void releaseObjectGroup(const String& objectGroup); + void clearExceptionValue(); protected: - virtual void didCreateInjectedScript(InjectedScript); + virtual void didCreateInjectedScript(const InjectedScript&); HashMap m_idToInjectedScript; HashMap m_scriptStateToId; private: String injectedScriptSource(); - Deprecated::ScriptObject createInjectedScript(const String& source, JSC::ExecState*, int id); + JSC::JSObject* createInjectedScript(const String& source, JSC::ExecState*, int id); InspectorEnvironment& m_environment; - RefPtr m_injectedScriptHost; + Ref m_injectedScriptHost; int m_nextInjectedScriptId; }; } // namespace Inspector - -#endif // !defined(InjectedScriptManager_h) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp b/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp index f2b29d255..7e05fc90b 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp @@ -32,8 +32,6 @@ #include "config.h" #include "InjectedScriptModule.h" -#if ENABLE(INSPECTOR) - #include "InjectedScript.h" #include "InjectedScriptManager.h" #include "ScriptFunctionCall.h" @@ -56,36 +54,30 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM ensureInjected(injectedScriptManager, injectedScript); } -void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript) +void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, const InjectedScript& injectedScript) { ASSERT(!injectedScript.hasNoValue()); if (injectedScript.hasNoValue()) return; // FIXME: Make the InjectedScript a module itself. + JSC::JSLockHolder locker(injectedScript.scriptState()); Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("module"), injectedScriptManager->inspectorEnvironment().functionCallHandler()); function.appendArgument(name()); bool hadException = false; - Deprecated::ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException); + auto resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); - if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) { + if (hadException || !resultValue || !resultValue.isObject()) { Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("injectModule"), injectedScriptManager->inspectorEnvironment().functionCallHandler()); function.appendArgument(name()); function.appendArgument(source()); function.appendArgument(host(injectedScriptManager, injectedScript.scriptState())); resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException); - if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) { + if (hadException) { ASSERT_NOT_REACHED(); return; } } - - if (returnsObject()) { - Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue); - initialize(moduleObject, &injectedScriptManager->inspectorEnvironment()); - } } } // namespace Inspector - -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/InjectedScriptModule.h b/Source/JavaScriptCore/inspector/InjectedScriptModule.h index a170e798d..1efc0acd8 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptModule.h +++ b/Source/JavaScriptCore/inspector/InjectedScriptModule.h @@ -29,14 +29,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InjectedScriptModule_h -#define InjectedScriptModule_h +#pragma once #include "InjectedScriptBase.h" #include -#if ENABLE(INSPECTOR) - namespace JSC { class JSValue; } @@ -51,19 +48,14 @@ public: virtual ~InjectedScriptModule(); virtual String source() const = 0; virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const = 0; - virtual bool returnsObject() const = 0; protected: // Do not expose constructor in the child classes as well. Instead provide // a static factory method that would create a new instance of the class // and call its ensureInjected() method immediately. - InjectedScriptModule(const String& name); + explicit InjectedScriptModule(const String& name); void ensureInjected(InjectedScriptManager*, JSC::ExecState*); - void ensureInjected(InjectedScriptManager*, InjectedScript); + void ensureInjected(InjectedScriptManager*, const InjectedScript&); }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // InjectedScriptModule_h diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js index 7bff7f6d4..1ef43ebcc 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js +++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js @@ -1,5 +1,6 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2014-2015 Apple Inc. All rights reserved. + * Copyright (C) 2013 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -26,21 +27,46 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//# sourceURL=__WebInspectorInjectedScript__ +//# sourceURL=__InjectedScript_InjectedScriptSource.js -/** - * @param {InjectedScriptHost} InjectedScriptHost - * @param {GlobalObject} inspectedGlobalObject - * @param {number} injectedScriptId - */ (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) { -// Protect against Object overwritten by the user code. +// FIXME: Web Inspector: Parse InjectedScriptSource as a built-in to get guaranteed non-user-overriden built-ins + var Object = {}.constructor; -/** - * @constructor - */ +function toString(obj) +{ + return String(obj); +} + +function toStringDescription(obj) +{ + if (obj === 0 && 1 / obj < 0) + return "-0"; + + return toString(obj); +} + +function isUInt32(obj) +{ + if (typeof obj === "number") + return obj >>> 0 === obj && (obj > 0 || 1 / obj > 0); + return "" + (obj >>> 0) === obj; +} + +function isSymbol(obj) +{ + return typeof obj === "symbol"; +} + +function isEmptyObject(object) +{ + for (let key in object) + return false; + return true; +} + var InjectedScript = function() { this._lastBoundObjectId = 1; @@ -48,37 +74,60 @@ var InjectedScript = function() this._idToObjectGroupName = {}; this._objectGroups = {}; this._modules = {}; + this._nextSavedResultIndex = 1; + this._savedResults = []; } -/** - * @type {Object.} - * @const - */ InjectedScript.primitiveTypes = { undefined: true, boolean: true, number: true, - string: true + string: true, +} + +InjectedScript.CollectionMode = { + OwnProperties: 1 << 0, // own properties. + NativeGetterProperties: 1 << 1, // native getter properties in the prototype chain. + AllProperties: 1 << 2, // all properties in the prototype chain. } InjectedScript.prototype = { - /** - * @param {*} object - * @return {boolean} - */ isPrimitiveValue: function(object) { // FIXME(33716): typeof document.all is always 'undefined'. return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllCollection(object); }, - /** - * @param {*} object - * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject - * @param {boolean} generatePreview - * @return {!RuntimeAgent.RemoteObject} - */ + previewValue: function(value) + { + return InjectedScript.RemoteObject.createObjectPreviewForValue(value, true); + }, + + functionDetails: function(func, previewOnly) + { + var details = InjectedScriptHost.functionDetails(func); + if (!details) + return "Cannot resolve function details."; + + // FIXME: provide function scope data in "scopesRaw" property when JSC supports it. + // [JSC] expose function (closure) inner context to debugger + if ("rawScopes" in details) { + if (previewOnly) + delete details.rawScopes; + else { + var objectGroupName = this._idToObjectGroupName[parsedFunctionId.id]; + var rawScopes = details.rawScopes; + var scopes = []; + delete details.rawScopes; + for (var i = 0; i < rawScopes.length; i++) + scopes.push(InjectedScript.CallFrameProxy._createScopeJson(rawScopes[i].type, rawScopes[i].object, objectGroupName)); + details.scopeChain = scopes; + } + } + + return details; + }, + wrapObject: function(object, groupName, canAccessInspectedGlobalObject, generatePreview) { if (canAccessInspectedGlobalObject) @@ -86,10 +135,16 @@ InjectedScript.prototype = { return this._fallbackWrapper(object); }, - /** - * @param {*} object - * @return {!RuntimeAgent.RemoteObject} - */ + setExceptionValue: function(value) + { + this._exceptionValue = value; + }, + + clearExceptionValue: function() + { + delete this._exceptionValue; + }, + _fallbackWrapper: function(object) { var result = {}; @@ -97,50 +152,38 @@ InjectedScript.prototype = { if (this.isPrimitiveValue(object)) result.value = object; else - result.description = this._toString(object); - return /** @type {!RuntimeAgent.RemoteObject} */ (result); + result.description = toString(object); + return result; }, - /** - * @param {boolean} canAccessInspectedGlobalObject - * @param {Object} table - * @param {Array.|string|boolean} columns - * @return {!RuntimeAgent.RemoteObject} - */ wrapTable: function(canAccessInspectedGlobalObject, table, columns) { if (!canAccessInspectedGlobalObject) return this._fallbackWrapper(table); + + // FIXME: Currently columns are ignored. Instead, the frontend filters all + // properties based on the provided column names and in the provided order. + // We could filter here to avoid sending very large preview objects. + var columnNames = null; if (typeof columns === "string") columns = [columns]; - if (InjectedScriptHost.type(columns) == "array") { + + if (InjectedScriptHost.subtype(columns) === "array") { columnNames = []; for (var i = 0; i < columns.length; ++i) - columnNames.push(String(columns[i])); + columnNames.push(toString(columns[i])); } + return this._wrapObject(table, "console", false, true, columnNames); }, - /** - * @param {*} object - */ inspectObject: function(object) { if (this._commandLineAPIImpl) this._commandLineAPIImpl.inspect(object); }, - /** - * This method cannot throw. - * @param {*} object - * @param {string=} objectGroupName - * @param {boolean=} forceValueType - * @param {boolean=} generatePreview - * @param {?Array.=} columnNames - * @return {!RuntimeAgent.RemoteObject} - * @suppress {checkTypes} - */ _wrapObject: function(object, objectGroupName, forceValueType, generatePreview, columnNames) { try { @@ -155,11 +198,6 @@ InjectedScript.prototype = { } }, - /** - * @param {*} object - * @param {string=} objectGroupName - * @return {string} - */ _bind: function(object, objectGroupName) { var id = this._lastBoundObjectId++; @@ -177,39 +215,34 @@ InjectedScript.prototype = { return objectId; }, - /** - * @param {string} objectId - * @return {Object} - */ _parseObjectId: function(objectId) { return InjectedScriptHost.evaluate("(" + objectId + ")"); }, - /** - * @param {string} objectGroupName - */ releaseObjectGroup: function(objectGroupName) { + if (objectGroupName === "console") { + delete this._lastResult; + this._nextSavedResultIndex = 1; + this._savedResults = []; + } + var group = this._objectGroups[objectGroupName]; if (!group) return; + for (var i = 0; i < group.length; i++) this._releaseObject(group[i]); + delete this._objectGroups[objectGroupName]; }, - /** - * @param {string} methodName - * @param {string} args - * @return {*} - */ dispatch: function(methodName, args) { var argsArray = InjectedScriptHost.evaluate("(" + args + ")"); var result = this[methodName].apply(this, argsArray); if (typeof result === "undefined") { - // FIXME: JS Context inspection currently does not have a global.console object. if (inspectedGlobalObject.console) inspectedGlobalObject.console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName); result = null; @@ -217,12 +250,7 @@ InjectedScript.prototype = { return result; }, - /** - * @param {string} objectId - * @param {boolean} ownProperties - * @return {Array.|boolean} - */ - getProperties: function(objectId, ownProperties) + _getProperties: function(objectId, collectionMode, generatePreview, nativeGettersAsValues) { var parsedObjectId = this._parseObjectId(objectId); var object = this._objectForId(parsedObjectId); @@ -230,7 +258,11 @@ InjectedScript.prototype = { if (!this._isDefined(object)) return false; - var descriptors = this._propertyDescriptors(object, ownProperties); + + if (isSymbol(object)) + return false; + + var descriptors = this._propertyDescriptors(object, collectionMode, nativeGettersAsValues); // Go over properties, wrap object values. for (var i = 0; i < descriptors.length; ++i) { @@ -240,156 +272,119 @@ InjectedScript.prototype = { if ("set" in descriptor) descriptor.set = this._wrapObject(descriptor.set, objectGroupName); if ("value" in descriptor) - descriptor.value = this._wrapObject(descriptor.value, objectGroupName); + descriptor.value = this._wrapObject(descriptor.value, objectGroupName, false, generatePreview); if (!("configurable" in descriptor)) descriptor.configurable = false; if (!("enumerable" in descriptor)) descriptor.enumerable = false; + if ("symbol" in descriptor) + descriptor.symbol = this._wrapObject(descriptor.symbol, objectGroupName); } + return descriptors; }, - /** - * @param {string} objectId - * @return {Array.|boolean} - */ - getInternalProperties: function(objectId, ownProperties) + getProperties: function(objectId, ownProperties, generatePreview) + { + var nativeGettersAsValues = false; + var collectionMode = ownProperties ? InjectedScript.CollectionMode.OwnProperties : InjectedScript.CollectionMode.AllProperties; + return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues); + }, + + getDisplayableProperties: function(objectId, generatePreview) + { + var nativeGettersAsValues = true; + var collectionMode = InjectedScript.CollectionMode.OwnProperties | InjectedScript.CollectionMode.NativeGetterProperties; + return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues); + }, + + getInternalProperties: function(objectId, generatePreview) { var parsedObjectId = this._parseObjectId(objectId); var object = this._objectForId(parsedObjectId); var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; + if (!this._isDefined(object)) return false; - var descriptors = []; - var internalProperties = InjectedScriptHost.getInternalProperties(object); - if (internalProperties) { - for (var i = 0; i < internalProperties.length; i++) { - var property = internalProperties[i]; - var descriptor = { - name: property.name, - value: this._wrapObject(property.value, objectGroupName) - }; - descriptors.push(descriptor); - } + + if (isSymbol(object)) + return false; + + var descriptors = this._internalPropertyDescriptors(object); + if (!descriptors) + return []; + + // Go over properties, wrap object values. + for (var i = 0; i < descriptors.length; ++i) { + var descriptor = descriptors[i]; + if ("value" in descriptor) + descriptor.value = this._wrapObject(descriptor.value, objectGroupName, false, generatePreview); } + return descriptors; }, - /** - * @param {string} functionId - * @return {!DebuggerAgent.FunctionDetails|string} - */ + getCollectionEntries: function(objectId, objectGroupName, startIndex, numberToFetch) + { + var parsedObjectId = this._parseObjectId(objectId); + var object = this._objectForId(parsedObjectId); + var objectGroupName = objectGroupName || this._idToObjectGroupName[parsedObjectId.id]; + + if (!this._isDefined(object)) + return; + + if (typeof object !== "object") + return; + + var entries = this._entries(object, InjectedScriptHost.subtype(object), startIndex, numberToFetch); + return entries.map(function(entry) { + entry.value = injectedScript._wrapObject(entry.value, objectGroupName, false, true); + if ("key" in entry) + entry.key = injectedScript._wrapObject(entry.key, objectGroupName, false, true); + return entry; + }); + }, + + saveResult: function(callArgumentJSON) + { + this._savedResultIndex = 0; + + try { + var callArgument = InjectedScriptHost.evaluate("(" + callArgumentJSON + ")"); + var value = this._resolveCallArgument(callArgument); + this._saveResult(value); + } catch (e) {} + + return this._savedResultIndex; + }, + getFunctionDetails: function(functionId) { var parsedFunctionId = this._parseObjectId(functionId); var func = this._objectForId(parsedFunctionId); if (typeof func !== "function") return "Cannot resolve function by id."; - var details = InjectedScriptHost.functionDetails(func); - if (!details) - return "Cannot resolve function details."; - if ("rawScopes" in details) { - var objectGroupName = this._idToObjectGroupName[parsedFunctionId.id]; - var rawScopes = details.rawScopes; - var scopes = []; - delete details.rawScopes; - for (var i = 0; i < rawScopes.length; i++) - scopes.push(InjectedScript.CallFrameProxy._createScopeJson(rawScopes[i].type, rawScopes[i].object, objectGroupName)); - details.scopeChain = scopes; - } - return details; + return injectedScript.functionDetails(func); }, - /** - * @param {string} objectId - */ releaseObject: function(objectId) { var parsedObjectId = this._parseObjectId(objectId); this._releaseObject(parsedObjectId.id); }, - /** - * @param {string} id - */ _releaseObject: function(id) { delete this._idToWrappedObject[id]; delete this._idToObjectGroupName[id]; }, - /** - * @param {Object} object - * @param {boolean} ownProperties - * @return {Array.} - */ - _propertyDescriptors: function(object, ownProperties) + evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult) { - var descriptors = []; - var nameProcessed = {}; - nameProcessed["__proto__"] = null; - for (var o = object; this._isDefined(o); o = o.__proto__) { - var names = Object.getOwnPropertyNames(/** @type {!Object} */ (o)); - for (var i = 0; i < names.length; ++i) { - var name = names[i]; - if (nameProcessed[name]) - continue; - - try { - nameProcessed[name] = true; - var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */ (object), name); - if (!descriptor) { - // Not all bindings provide proper descriptors. Fall back to the writable, configurable property. - try { - descriptor = { name: name, value: object[name], writable: false, configurable: false, enumerable: false}; - if (o === object) - descriptor.isOwn = true; - descriptors.push(descriptor); - } catch (e) { - // Silent catch. - } - continue; - } - } catch (e) { - var descriptor = {}; - descriptor.value = e; - descriptor.wasThrown = true; - } - - descriptor.name = name; - if (o === object) - descriptor.isOwn = true; - descriptors.push(descriptor); - } - if (ownProperties) { - if (object.__proto__) - descriptors.push({ name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true}); - break; - } - } - return descriptors; - }, - - /** - * @param {string} expression - * @param {string} objectGroup - * @param {boolean} injectCommandLineAPI - * @param {boolean} returnByValue - * @param {boolean} generatePreview - * @return {*} - */ - evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview) - { - return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview); + return this._evaluateAndWrap(InjectedScriptHost.evaluateWithScopeExtension, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, saveResult); }, - /** - * @param {string} objectId - * @param {string} expression - * @param {boolean} returnByValue - * @return {Object|string} - */ - callFunctionOn: function(objectId, expression, args, returnByValue) + callFunctionOn: function(objectId, expression, args, returnByValue, generatePreview) { var parsedObjectId = this._parseObjectId(objectId); var object = this._objectForId(parsedObjectId); @@ -398,15 +393,13 @@ InjectedScript.prototype = { if (args) { var resolvedArgs = []; - args = InjectedScriptHost.evaluate(args); - for (var i = 0; i < args.length; ++i) { - var resolvedCallArgument; + var callArgs = InjectedScriptHost.evaluate(args); + for (var i = 0; i < callArgs.length; ++i) { try { - resolvedCallArgument = this._resolveCallArgument(args[i]); + resolvedArgs[i] = this._resolveCallArgument(callArgs[i]); } catch (e) { return String(e); } - resolvedArgs.push(resolvedCallArgument) } } @@ -416,21 +409,21 @@ InjectedScript.prototype = { if (typeof func !== "function") return "Given expression does not evaluate to a function"; - return { wasThrown: false, - result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue) }; + return { + wasThrown: false, + result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue, generatePreview) + }; } catch (e) { return this._createThrownValue(e, objectGroup); } }, - /** - * Resolves a value from CallArgument description. - * @param {RuntimeAgent.CallArgument} callArgumentJson - * @return {*} resolved value - * @throws {string} error message - */ - _resolveCallArgument: function(callArgumentJson) { - var objectId = callArgumentJson.objectId; + _resolveCallArgument: function(callArgumentJSON) + { + if ("value" in callArgumentJSON) + return callArgumentJSON.value; + + var objectId = callArgumentJSON.objectId; if (objectId) { var parsedArgId = this._parseObjectId(objectId); if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScriptId) @@ -441,140 +434,58 @@ InjectedScript.prototype = { throw "Could not find object with given id"; return resolvedArg; - } else if ("value" in callArgumentJson) - return callArgumentJson.value; - else - return undefined; + } + + return undefined; }, - /** - * @param {Function} evalFunction - * @param {Object} object - * @param {string} objectGroup - * @param {boolean} isEvalOnCallFrame - * @param {boolean} injectCommandLineAPI - * @param {boolean} returnByValue - * @param {boolean} generatePreview - * @return {*} - */ - _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview) + _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, saveResult) { try { - return { wasThrown: false, - result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue, generatePreview) }; + this._savedResultIndex = 0; + + var returnObject = { + wasThrown: false, + result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, saveResult), objectGroup, returnByValue, generatePreview) + }; + + if (saveResult && this._savedResultIndex) + returnObject.savedResultIndex = this._savedResultIndex; + + return returnObject; } catch (e) { return this._createThrownValue(e, objectGroup); } }, - /** - * @param {*} value - * @param {string} objectGroup - * @return {Object} - */ _createThrownValue: function(value, objectGroup) { var remoteObject = this._wrapObject(value, objectGroup); try { - remoteObject.description = this._toString(value); + remoteObject.description = toStringDescription(value); } catch (e) {} - return { wasThrown: true, - result: remoteObject }; + return { + wasThrown: true, + result: remoteObject + }; }, - /** - * @param {Function} evalFunction - * @param {Object} object - * @param {string} objectGroup - * @param {string} expression - * @param {boolean} isEvalOnCallFrame - * @param {boolean} injectCommandLineAPI - * @return {*} - */ - _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI) + _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, saveResult) { var commandLineAPI = null; if (injectCommandLineAPI) { if (this.CommandLineAPI) commandLineAPI = new this.CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null); else - commandLineAPI = new BasicCommandLineAPI; + commandLineAPI = new BasicCommandLineAPI(isEvalOnCallFrame ? object : null); } - if (isEvalOnCallFrame) { - // We can only use this approach if the evaluate function is the true 'eval'. That allows us to use it with - // the 'eval' identifier when calling it. Using 'eval' grants access to the local scope of the closure we - // create that provides the command line APIs. - - var parameters = [InjectedScriptHost.evaluate, expression]; - var expressionFunctionBody = "" + - "var global = Function('return this')() || (1, eval)('this');" + - "var __originalEval = global.eval; global.eval = __eval;" + - "try { return eval(__currentExpression); }" + - "finally { global.eval = __originalEval; }"; - - if (commandLineAPI) { - // To avoid using a 'with' statement (which fails in strict mode and requires injecting the API object) - // we instead create a closure where we evaluate the expression. The command line APIs are passed as - // parameters to the closure so they are in scope but not injected. This allows the code evaluated in - // the console to stay in strict mode (if is was already set), or to get strict mode by prefixing - // expressions with 'use strict';. - - var parameterNames = Object.getOwnPropertyNames(commandLineAPI); - for (var i = 0; i < parameterNames.length; ++i) - parameters.push(commandLineAPI[parameterNames[i]]); - - var expressionFunctionString = "(function(__eval, __currentExpression, " + parameterNames.join(", ") + ") { " + expressionFunctionBody + " })"; - } else { - // Use a closure in this case too to keep the same behavior of 'var' being captured by the closure instead - // of leaking out into the calling scope. - var expressionFunctionString = "(function(__eval, __currentExpression) { " + expressionFunctionBody + " })"; - } - - // Bind 'this' to the function expression using another closure instead of Function.prototype.bind. This ensures things will work if the page replaces bind. - var boundExpressionFunctionString = "(function(__function, __thisObject) { return function() { return __function.apply(__thisObject, arguments) }; })(" + expressionFunctionString + ", this)"; - var expressionFunction = evalFunction.call(object, boundExpressionFunctionString); - var result = expressionFunction.apply(null, parameters); - - if (objectGroup === "console") - this._lastResult = result; - - return result; - } - - // When not evaluating on a call frame we use a 'with' statement to allow var and function statements to leak - // into the global scope. This allow them to stick around between evaluations. - - // FIXME: JS Context inspection currently does not have a global.console object. - try { - if (commandLineAPI) { - if (inspectedGlobalObject.console) - inspectedGlobalObject.console.__commandLineAPI = commandLineAPI; - else - inspectedGlobalObject.__commandLineAPI = commandLineAPI; - expression = "with ((this && (this.console ? this.console.__commandLineAPI : this.__commandLineAPI)) || {}) { " + expression + "\n}"; - } - - var result = evalFunction.call(inspectedGlobalObject, expression); - - if (objectGroup === "console") - this._lastResult = result; - - return result; - } finally { - if (commandLineAPI) { - if (inspectedGlobalObject.console) - delete inspectedGlobalObject.console.__commandLineAPI; - else - delete inspectedGlobalObject.__commandLineAPI; - } - } + var result = evalFunction.call(object, expression, commandLineAPI); + if (saveResult) + this._saveResult(result); + return result; }, - /** - * @param {Object} callFrame - * @return {Array.|boolean} - */ wrapCallFrames: function(callFrame) { if (!callFrame) @@ -589,29 +500,14 @@ InjectedScript.prototype = { return result; }, - /** - * @param {Object} topCallFrame - * @param {string} callFrameId - * @param {string} expression - * @param {string} objectGroup - * @param {boolean} injectCommandLineAPI - * @param {boolean} returnByValue - * @param {boolean} generatePreview - * @return {*} - */ - evaluateOnCallFrame: function(topCallFrame, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview) + evaluateOnCallFrame: function(topCallFrame, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult) { var callFrame = this._callFrameForId(topCallFrame, callFrameId); if (!callFrame) return "Could not find call frame with given id"; - return this._evaluateAndWrap(callFrame.evaluate, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview); + return this._evaluateAndWrap(callFrame.evaluateWithScopeExtension, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview, saveResult); }, - /** - * @param {Object} topCallFrame - * @param {string} callFrameId - * @return {Object} - */ _callFrameForId: function(topCallFrame, callFrameId) { var parsedCallFrameId = InjectedScriptHost.evaluate("(" + callFrameId + ")"); @@ -622,89 +518,215 @@ InjectedScript.prototype = { return callFrame; }, - /** - * @param {Object} objectId - * @return {Object} - */ _objectForId: function(objectId) { return this._idToWrappedObject[objectId.id]; }, - /** - * @param {string} objectId - * @return {Object} - */ findObjectById: function(objectId) { var parsedObjectId = this._parseObjectId(objectId); return this._objectForId(parsedObjectId); }, - /** - * @param {string} name - * @return {Object} - */ module: function(name) { return this._modules[name]; }, - /** - * @param {string} name - * @param {string} source - * @return {Object} - */ injectModule: function(name, source, host) { delete this._modules[name]; + var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")"); if (typeof moduleFunction !== "function") { - // FIXME: JS Context inspection currently does not have a global.console object. if (inspectedGlobalObject.console) inspectedGlobalObject.console.error("Web Inspector error: A function was expected for module %s evaluation", name); return null; } + var module = moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this, host); this._modules[name] = module; return module; }, - /** - * @param {*} object - * @return {boolean} - */ + _internalPropertyDescriptors: function(object, completeDescriptor) + { + var internalProperties = InjectedScriptHost.getInternalProperties(object); + if (!internalProperties) + return null; + + var descriptors = []; + for (var i = 0; i < internalProperties.length; i++) { + var property = internalProperties[i]; + var descriptor = {name: property.name, value: property.value}; + if (completeDescriptor) { + descriptor.writable = false; + descriptor.configurable = false; + descriptor.enumerable = false; + descriptor.isOwn = true; + } + descriptors.push(descriptor); + } + return descriptors; + }, + + _propertyDescriptors: function(object, collectionMode, nativeGettersAsValues) + { + if (InjectedScriptHost.subtype(object) === "proxy") + return []; + + var descriptors = []; + var nameProcessed = new Set; + + function createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, possibleNativeBindingGetter) + { + try { + var descriptor = {name, value: object[name], writable: descriptor.writable || false, configurable: descriptor.configurable || false, enumerable: descriptor.enumerable || false}; + if (possibleNativeBindingGetter) + descriptor.nativeGetter = true; + if (isOwnProperty) + descriptor.isOwn = true; + if (symbol) + descriptor.symbol = symbol; + return descriptor; + } catch (e) { + var errorDescriptor = {name, value: e, wasThrown: true}; + if (isOwnProperty) + errorDescriptor.isOwn = true; + if (symbol) + errorDescriptor.symbol = symbol; + return errorDescriptor; + } + } + + function processDescriptor(descriptor, isOwnProperty, possibleNativeBindingGetter) + { + // All properties. + if (collectionMode & InjectedScript.CollectionMode.AllProperties) { + descriptors.push(descriptor); + return; + } + + // Own properties. + if (collectionMode & InjectedScript.CollectionMode.OwnProperties && isOwnProperty) { + descriptors.push(descriptor); + return; + } + + // Native Getter properties. + if (collectionMode & InjectedScript.CollectionMode.NativeGetterProperties) { + if (possibleNativeBindingGetter) { + descriptors.push(descriptor); + return; + } + } + } + + function processProperties(o, properties, isOwnProperty) + { + for (var i = 0; i < properties.length; ++i) { + var property = properties[i]; + if (nameProcessed.has(property) || property === "__proto__") + continue; + + nameProcessed.add(property); + + var name = toString(property); + var symbol = isSymbol(property) ? property : null; + + var descriptor = Object.getOwnPropertyDescriptor(o, property); + if (!descriptor) { + // FIXME: Bad descriptor. Can we get here? + // Fall back to very restrictive settings. + var fakeDescriptor = createFakeValueDescriptor(name, symbol, {writable: false, configurable: false, enumerable: false}, isOwnProperty); + processDescriptor(fakeDescriptor, isOwnProperty); + continue; + } + + if (nativeGettersAsValues) { + if (String(descriptor.get).endsWith("[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) { + // Developers may create such a descriptor, so we should be resilient: + // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p") + var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true); + processDescriptor(fakeDescriptor, isOwnProperty, true); + continue; + } + } + + descriptor.name = name; + if (isOwnProperty) + descriptor.isOwn = true; + if (symbol) + descriptor.symbol = symbol; + processDescriptor(descriptor, isOwnProperty); + } + } + + function arrayIndexPropertyNames(o, length) + { + var array = []; + for (var i = 0; i < length; ++i) { + if (i in o) + array.push("" + i); + } + return array; + } + + // FIXME: Web Inspector: Better handling for large collections in Object Trees + // For array types with a large length we attempt to skip getOwnPropertyNames and instead just sublist of indexes. + var isArrayLike = false; + try { + isArrayLike = injectedScript._subtype(object) === "array" && isFinite(object.length) && object.length > 0; + } catch(e) {} + + for (var o = object; this._isDefined(o); o = Object.getPrototypeOf(o)) { + var isOwnProperty = o === object; + + if (isArrayLike && isOwnProperty) + processProperties(o, arrayIndexPropertyNames(o, Math.min(object.length, 100)), isOwnProperty); + else { + processProperties(o, Object.getOwnPropertyNames(o), isOwnProperty); + if (Object.getOwnPropertySymbols) + processProperties(o, Object.getOwnPropertySymbols(o), isOwnProperty); + } + + if (collectionMode === InjectedScript.CollectionMode.OwnProperties) + break; + } + + // Always include __proto__ at the end. + try { + if (object.__proto__) + descriptors.push({name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true}); + } catch (e) {} + + return descriptors; + }, + _isDefined: function(object) { return !!object || this._isHTMLAllCollection(object); }, - /** - * @param {*} object - * @return {boolean} - */ _isHTMLAllCollection: function(object) { // document.all is reported as undefined, but we still want to process it. return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCollection(object); }, - /** - * @param {Object=} obj - * @return {string?} - */ _subtype: function(obj) { if (obj === null) return "null"; - if (this.isPrimitiveValue(obj)) + if (this.isPrimitiveValue(obj) || isSymbol(obj)) return null; if (this._isHTMLAllCollection(obj)) return "array"; - var preciseType = InjectedScriptHost.type(obj); + var preciseType = InjectedScriptHost.subtype(obj); if (preciseType) return preciseType; @@ -712,322 +734,663 @@ InjectedScript.prototype = { try { if (typeof obj.splice === "function" && isFinite(obj.length)) return "array"; - if (Object.prototype.toString.call(obj) === "[object Arguments]" && isFinite(obj.length)) // arguments. - return "array"; - } catch (e) { - } + } catch (e) {} - // If owning frame has navigated to somewhere else window properties will be undefined. return null; }, - /** - * @param {*} obj - * @return {string?} - */ + _classPreview: function(classConstructorValue) + { + return "class " + classConstructorValue.name; + }, + + _nodePreview: function(node) + { + var isXMLDocument = node.ownerDocument && !!node.ownerDocument.xmlVersion; + var nodeName = isXMLDocument ? node.nodeName : node.nodeName.toLowerCase(); + + switch (node.nodeType) { + case 1: // Node.ELEMENT_NODE + if (node.id) + return "<" + nodeName + " id=\"" + node.id + "\">"; + if (node.classList.length) + return "<" + nodeName + " class=\"" + node.classList.toString().replace(/\s+/, " ") + "\">"; + if (nodeName === "input" && node.type) + return "<" + nodeName + " type=\"" + node.type + "\">"; + return "<" + nodeName + ">"; + + case 3: // Node.TEXT_NODE + return nodeName + " \"" + node.nodeValue + "\""; + + case 8: // Node.COMMENT_NODE + return ""; + + case 10: // Node.DOCUMENT_TYPE_NODE + return ""; + + default: + return nodeName; + } + }, + _describe: function(obj) { if (this.isPrimitiveValue(obj)) return null; - obj = /** @type {Object} */ (obj); + if (isSymbol(obj)) + return toString(obj); - // Type is object, get subtype. var subtype = this._subtype(obj); if (subtype === "regexp") - return this._toString(obj); + return toString(obj); if (subtype === "date") - return this._toString(obj); - - if (subtype === "node") { - var description = obj.nodeName.toLowerCase(); - switch (obj.nodeType) { - case 1 /* Node.ELEMENT_NODE */: - description += obj.id ? "#" + obj.id : ""; - var className = obj.className; - description += className ? "." + className : ""; - break; - case 10 /*Node.DOCUMENT_TYPE_NODE */: - description = ""; - break; - } - return description; - } + return toString(obj); + + if (subtype === "error") + return toString(obj); + + if (subtype === "proxy") + return "Proxy"; + + if (subtype === "node") + return this._nodePreview(obj); var className = InjectedScriptHost.internalConstructorName(obj); - if (subtype === "array") { - if (typeof obj.length === "number") - className += "[" + obj.length + "]"; + if (subtype === "array") return className; - } + + if (subtype === "iterator" && Symbol.toStringTag in obj) + return obj[Symbol.toStringTag]; // NodeList in JSC is a function, check for array prior to this. if (typeof obj === "function") - return this._toString(obj); + return obj.toString(); + // If Object, try for a better name from the constructor. if (className === "Object") { - // In Chromium DOM wrapper prototypes will have Object as their constructor name, - // get the real DOM wrapper name from the constructor property. var constructorName = obj.constructor && obj.constructor.name; if (constructorName) return constructorName; } + return className; }, - /** - * @param {*} obj - * @return {string} - */ - _toString: function(obj) + _getSetEntries: function(object, skip, numberToFetch) + { + var entries = []; + + for (var value of object) { + if (skip > 0) { + skip--; + continue; + } + + entries.push({value}); + + if (numberToFetch && entries.length === numberToFetch) + break; + } + + return entries; + }, + + _getMapEntries: function(object, skip, numberToFetch) + { + var entries = []; + + for (var [key, value] of object) { + if (skip > 0) { + skip--; + continue; + } + + entries.push({key, value}); + + if (numberToFetch && entries.length === numberToFetch) + break; + } + + return entries; + }, + + _getWeakMapEntries: function(object, numberToFetch) + { + return InjectedScriptHost.weakMapEntries(object, numberToFetch); + }, + + _getWeakSetEntries: function(object, numberToFetch) + { + return InjectedScriptHost.weakSetEntries(object, numberToFetch); + }, + + _getIteratorEntries: function(object, numberToFetch) + { + return InjectedScriptHost.iteratorEntries(object, numberToFetch); + }, + + _entries: function(object, subtype, startIndex, numberToFetch) + { + if (subtype === "set") + return this._getSetEntries(object, startIndex, numberToFetch); + if (subtype === "map") + return this._getMapEntries(object, startIndex, numberToFetch); + if (subtype === "weakmap") + return this._getWeakMapEntries(object, numberToFetch); + if (subtype === "weakset") + return this._getWeakSetEntries(object, numberToFetch); + if (subtype === "iterator") + return this._getIteratorEntries(object, numberToFetch); + + throw "unexpected type"; + }, + + _saveResult: function(result) { - // We don't use String(obj) because inspectedGlobalObject.String is undefined if owning frame navigated to another page. - return "" + obj; + this._lastResult = result; + + if (result === undefined || result === null) + return; + + var existingIndex = this._savedResults.indexOf(result); + if (existingIndex !== -1) { + this._savedResultIndex = existingIndex; + return; + } + + this._savedResultIndex = this._nextSavedResultIndex; + this._savedResults[this._nextSavedResultIndex++] = result; + + // $n is limited from $1-$99. $0 is special. + if (this._nextSavedResultIndex >= 100) + this._nextSavedResultIndex = 1; + }, + + _savedResult: function(index) + { + return this._savedResults[index]; } } -/** - * @type {InjectedScript} - * @const - */ -var injectedScript = new InjectedScript(); - -/** - * @constructor - * @param {*} object - * @param {string=} objectGroupName - * @param {boolean=} forceValueType - * @param {boolean=} generatePreview - * @param {?Array.=} columnNames - */ +var injectedScript = new InjectedScript; + + InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, generatePreview, columnNames) { this.type = typeof object; + + if (this.type === "undefined" && injectedScript._isHTMLAllCollection(object)) + this.type = "object"; + if (injectedScript.isPrimitiveValue(object) || object === null || forceValueType) { // We don't send undefined values over JSON. - if (typeof object !== "undefined") + if (this.type !== "undefined") this.value = object; - // Null object is object with 'null' subtype' + // Null object is object with 'null' subtype. if (object === null) this.subtype = "null"; // Provide user-friendly number values. - if (typeof object === "number") - this.description = object + ""; + if (this.type === "number") + this.description = toStringDescription(object); return; } - object = /** @type {Object} */ (object); - this.objectId = injectedScript._bind(object, objectGroupName); + var subtype = injectedScript._subtype(object); if (subtype) this.subtype = subtype; + this.className = InjectedScriptHost.internalConstructorName(object); this.description = injectedScript._describe(object); - if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object))) - this.preview = this._generatePreview(object, undefined, columnNames); -} + if (subtype === "array") + this.size = typeof object.length === "number" ? object.length : 0; + else if (subtype === "set" || subtype === "map") + this.size = object.size; + else if (subtype === "weakmap") + this.size = InjectedScriptHost.weakMapSize(object); + else if (subtype === "weakset") + this.size = InjectedScriptHost.weakSetSize(object); + else if (subtype === "class") { + this.classPrototype = injectedScript._wrapObject(object.prototype, objectGroupName); + this.className = object.name; + } + + if (generatePreview && this.type === "object") { + if (subtype === "proxy") { + this.preview = this._generatePreview(InjectedScriptHost.proxyTargetValue(object)); + this.preview.lossless = false; + } else + this.preview = this._generatePreview(object, undefined, columnNames); + } +}; + +InjectedScript.RemoteObject.createObjectPreviewForValue = function(value, generatePreview, columnNames) +{ + var remoteObject = new InjectedScript.RemoteObject(value, undefined, false, generatePreview, columnNames); + if (remoteObject.objectId) + injectedScript.releaseObject(remoteObject.objectId); + if (remoteObject.classPrototype && remoteObject.classPrototype.objectId) + injectedScript.releaseObject(remoteObject.classPrototype.objectId); + return remoteObject.preview || remoteObject._emptyPreview(); +}; InjectedScript.RemoteObject.prototype = { - /** - * @param {Object} object - * @param {Array.=} firstLevelKeys - * @param {?Array.=} secondLevelKeys - * @return {Object} preview - */ - _generatePreview: function(object, firstLevelKeys, secondLevelKeys) + _initialPreview: function() { - var preview = {}; - preview.lossless = true; - preview.overflow = false; - preview.properties = []; + var preview = { + type: this.type, + description: this.description || toString(this.value), + lossless: true, + }; + if (this.subtype) { + preview.subtype = this.subtype; + if (this.subtype !== "null") { + preview.overflow = false; + preview.properties = []; + } + } + + if ("size" in this) + preview.size = this.size; + + return preview; + }, + + _emptyPreview: function() + { + var preview = this._initialPreview(); + + if (this.subtype === "map" || this.subtype === "set" || this.subtype === "weakmap" || this.subtype === "weakset" || this.subtype === "iterator") { + if (this.size) { + preview.entries = []; + preview.lossless = false; + preview.overflow = true; + } + } + + return preview; + }, + + _generatePreview: function(object, firstLevelKeys, secondLevelKeys) + { + var preview = this._initialPreview(); var isTableRowsRequest = secondLevelKeys === null || secondLevelKeys; var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; var propertiesThreshold = { properties: isTableRowsRequest ? 1000 : Math.max(5, firstLevelKeysCount), - indexes: isTableRowsRequest ? 1000 : Math.max(100, firstLevelKeysCount) + indexes: isTableRowsRequest ? 1000 : Math.max(10, firstLevelKeysCount) }; - for (var o = object; injectedScript._isDefined(o); o = o.__proto__) - this._generateProtoPreview(o, preview, propertiesThreshold, firstLevelKeys, secondLevelKeys); + + try { + // Maps, Sets, and Iterators have entries. + if (this.subtype === "map" || this.subtype === "set" || this.subtype === "weakmap" || this.subtype === "weakset" || this.subtype === "iterator") + this._appendEntryPreviews(object, preview); + + preview.properties = []; + + // Internal Properties. + var internalPropertyDescriptors = injectedScript._internalPropertyDescriptors(object, true); + if (internalPropertyDescriptors) { + this._appendPropertyPreviews(object, preview, internalPropertyDescriptors, true, propertiesThreshold, firstLevelKeys, secondLevelKeys); + if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) + return preview; + } + + if (preview.entries) + return preview; + + // Properties. + var nativeGettersAsValues = true; + var descriptors = injectedScript._propertyDescriptors(object, InjectedScript.CollectionMode.AllProperties, nativeGettersAsValues); + this._appendPropertyPreviews(object, preview, descriptors, false, propertiesThreshold, firstLevelKeys, secondLevelKeys); + if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) + return preview; + } catch (e) { + preview.lossless = false; + } + return preview; }, - /** - * @param {Object} object - * @param {Object} preview - * @param {Object} propertiesThreshold - * @param {Array.=} firstLevelKeys - * @param {Array.=} secondLevelKeys - */ - _generateProtoPreview: function(object, preview, propertiesThreshold, firstLevelKeys, secondLevelKeys) + _appendPropertyPreviews: function(object, preview, descriptors, internal, propertiesThreshold, firstLevelKeys, secondLevelKeys) { - var propertyNames = firstLevelKeys ? firstLevelKeys : Object.keys(/** @type {!Object} */(object)); - try { - for (var i = 0; i < propertyNames.length; ++i) { - if (!propertiesThreshold.properties || !propertiesThreshold.indexes) { - preview.overflow = true; - preview.lossless = false; - break; - } - var name = propertyNames[i]; - if (this.subtype === "array" && name === "length") - continue; + for (var descriptor of descriptors) { + // Seen enough. + if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) + break; + + // Error in descriptor. + if (descriptor.wasThrown) { + preview.lossless = false; + continue; + } - var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */(object), name); - if (!("value" in descriptor) || !descriptor.enumerable) { + // Do not show "__proto__" in preview. + var name = descriptor.name; + if (name === "__proto__") { + // Non basic __proto__ objects may have interesting, non-enumerable, methods to show. + if (descriptor.value && descriptor.value.constructor + && descriptor.value.constructor !== Object + && descriptor.value.constructor !== Array + && descriptor.value.constructor !== RegExp) preview.lossless = false; - continue; - } + continue; + } - var value = descriptor.value; - if (value === null) { - this._appendPropertyPreview(preview, { name: name, type: "object", value: "null" }, propertiesThreshold); - continue; - } + // For arrays, only allow indexes. + if (this.subtype === "array" && !isUInt32(name)) + continue; - const maxLength = 100; - var type = typeof value; + // Do not show non-enumerable non-own properties. + // Special case to allow array indexes that may be on the prototype. + // Special case to allow native getters on non-RegExp objects. + if (!descriptor.enumerable && !descriptor.isOwn && !(this.subtype === "array" || (this.subtype !== "regexp" && descriptor.nativeGetter))) + continue; - if (InjectedScript.primitiveTypes[type]) { - if (type === "string") { - if (value.length > maxLength) { - value = this._abbreviateString(value, maxLength, true); - preview.lossless = false; - } - value = value.replace(/\n/g, "\u21B5"); - } - this._appendPropertyPreview(preview, { name: name, type: type, value: value + "" }, propertiesThreshold); - continue; - } + // If we have a filter, only show properties in the filter. + // FIXME: Currently these filters do nothing on the backend. + if (firstLevelKeys && !firstLevelKeys.includes(name)) + continue; - if (secondLevelKeys === null || secondLevelKeys) { - var subPreview = this._generatePreview(value, secondLevelKeys || undefined); - var property = { name: name, type: type, valuePreview: subPreview }; - this._appendPropertyPreview(preview, property, propertiesThreshold); - if (!subPreview.lossless) - preview.lossless = false; - if (subPreview.overflow) - preview.overflow = true; - continue; + // Getter/setter. + if (!("value" in descriptor)) { + preview.lossless = false; + this._appendPropertyPreview(preview, internal, {name, type: "accessor"}, propertiesThreshold); + continue; + } + + // Null value. + var value = descriptor.value; + if (value === null) { + this._appendPropertyPreview(preview, internal, {name, type: "object", subtype: "null", value: "null"}, propertiesThreshold); + continue; + } + + // Ignore non-enumerable functions. + var type = typeof value; + if (!descriptor.enumerable && type === "function") + continue; + + // Fix type of document.all. + if (type === "undefined" && injectedScript._isHTMLAllCollection(value)) + type = "object"; + + // Primitive. + const maxLength = 100; + if (InjectedScript.primitiveTypes[type]) { + if (type === "string" && value.length > maxLength) { + value = this._abbreviateString(value, maxLength, true); + preview.lossless = false; } + this._appendPropertyPreview(preview, internal, {name, type, value: toStringDescription(value)}, propertiesThreshold); + continue; + } - preview.lossless = false; + // Symbol. + if (isSymbol(value)) { + var symbolString = toString(value); + if (symbolString.length > maxLength) { + symbolString = this._abbreviateString(symbolString, maxLength, true); + preview.lossless = false; + } + this._appendPropertyPreview(preview, internal, {name, type, value: symbolString}, propertiesThreshold); + continue; + } - var subtype = injectedScript._subtype(value); + // Object. + var property = {name, type}; + var subtype = injectedScript._subtype(value); + if (subtype) + property.subtype = subtype; + + // Second level. + if ((secondLevelKeys === null || secondLevelKeys) || this._isPreviewableObject(value, object)) { + // FIXME: If we want secondLevelKeys filter to continue we would need some refactoring. + var subPreview = InjectedScript.RemoteObject.createObjectPreviewForValue(value, value !== object, secondLevelKeys); + property.valuePreview = subPreview; + if (!subPreview.lossless) + preview.lossless = false; + if (subPreview.overflow) + preview.overflow = true; + } else { var description = ""; - if (type !== "function") - description = this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp"); - - var property = { name: name, type: type, value: description }; - if (subtype) - property.subtype = subtype; - this._appendPropertyPreview(preview, property, propertiesThreshold); + if (type !== "function" || subtype === "class") { + var fullDescription; + if (subtype === "class") + fullDescription = "class " + value.name; + else if (subtype === "node") + fullDescription = injectedScript._nodePreview(value); + else + fullDescription = injectedScript._describe(value); + description = this._abbreviateString(fullDescription, maxLength, subtype === "regexp"); + } + property.value = description; + preview.lossless = false; } - } catch (e) { + + this._appendPropertyPreview(preview, internal, property, propertiesThreshold); } }, - /** - * @param {Object} preview - * @param {Object} property - * @param {Object} propertiesThreshold - */ - _appendPropertyPreview: function(preview, property, propertiesThreshold) + _appendPropertyPreview: function(preview, internal, property, propertiesThreshold) { - if (isNaN(property.name)) - propertiesThreshold.properties--; - else + if (toString(property.name >>> 0) === property.name) propertiesThreshold.indexes--; + else + propertiesThreshold.properties--; + + if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) { + preview.overflow = true; + preview.lossless = false; + return; + } + + if (internal) + property.internal = true; + preview.properties.push(property); }, - /** - * @param {string} string - * @param {number} maxLength - * @param {boolean=} middle - * @returns - */ + _appendEntryPreviews: function(object, preview) + { + // Fetch 6, but only return 5, so we can tell if we overflowed. + var entries = injectedScript._entries(object, this.subtype, 0, 6); + if (!entries) + return; + + if (entries.length > 5) { + entries.pop(); + preview.overflow = true; + preview.lossless = false; + } + + function updateMainPreview(subPreview) { + if (!subPreview.lossless) + preview.lossless = false; + } + + preview.entries = entries.map(function(entry) { + entry.value = InjectedScript.RemoteObject.createObjectPreviewForValue(entry.value, entry.value !== object); + updateMainPreview(entry.value); + if ("key" in entry) { + entry.key = InjectedScript.RemoteObject.createObjectPreviewForValue(entry.key, entry.key !== object); + updateMainPreview(entry.key); + } + return entry; + }, this); + }, + + _isPreviewableObject: function(value, object) + { + return this._isPreviewableObjectInternal(value, new Set([object]), 1); + }, + + _isPreviewableObjectInternal: function(object, knownObjects, depth) + { + // Deep object. + if (depth > 3) + return false; + + // Primitive. + if (injectedScript.isPrimitiveValue(object) || isSymbol(object)) + return true; + + // Null. + if (object === null) + return true; + + // Cyclic objects. + if (knownObjects.has(object)) + return false; + + ++depth; + knownObjects.add(object); + + // Arrays are simple if they have 5 or less simple objects. + var subtype = injectedScript._subtype(object); + if (subtype === "array") { + var length = object.length; + if (length > 5) + return false; + for (var i = 0; i < length; ++i) { + if (!this._isPreviewableObjectInternal(object[i], knownObjects, depth)) + return false; + } + return true; + } + + // Not a basic object. + if (object.__proto__ && object.__proto__.__proto__) + return false; + + // Objects are simple if they have 3 or less simple properties. + var ownPropertyNames = Object.getOwnPropertyNames(object); + if (ownPropertyNames.length > 3) + return false; + for (var propertyName of ownPropertyNames) { + if (!this._isPreviewableObjectInternal(object[propertyName], knownObjects, depth)) + return false; + } + + return true; + }, + _abbreviateString: function(string, maxLength, middle) { if (string.length <= maxLength) return string; + if (middle) { var leftHalf = maxLength >> 1; var rightHalf = maxLength - leftHalf - 1; return string.substr(0, leftHalf) + "\u2026" + string.substr(string.length - rightHalf, rightHalf); } + return string.substr(0, maxLength) + "\u2026"; } } -/** - * @constructor - * @param {number} ordinal - * @param {Object} callFrame - */ + InjectedScript.CallFrameProxy = function(ordinal, callFrame) { this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + injectedScriptId + "}"; - this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); - this.location = { scriptId: String(callFrame.sourceID), lineNumber: callFrame.line, columnNumber: callFrame.column }; + this.functionName = callFrame.functionName; + this.location = {scriptId: String(callFrame.sourceID), lineNumber: callFrame.line, columnNumber: callFrame.column}; this.scopeChain = this._wrapScopeChain(callFrame); - this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); + this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace", false, true); + this.isTailDeleted = callFrame.isTailDeleted; } InjectedScript.CallFrameProxy.prototype = { - /** - * @param {Object} callFrame - * @return {!Array.} - */ _wrapScopeChain: function(callFrame) { var scopeChain = callFrame.scopeChain; + var scopeDescriptions = callFrame.scopeDescriptions(); + var scopeChainProxy = []; - for (var i = 0; i < scopeChain.length; i++) { - var scope = InjectedScript.CallFrameProxy._createScopeJson(callFrame.scopeType(i), scopeChain[i], "backtrace"); - scopeChainProxy.push(scope); - } + for (var i = 0; i < scopeChain.length; i++) + scopeChainProxy[i] = InjectedScript.CallFrameProxy._createScopeJson(scopeChain[i], scopeDescriptions[i], "backtrace"); return scopeChainProxy; } } -/** - * @param {number} scopeTypeCode - * @param {*} scopeObject - * @param {string} groupId - * @return {!DebuggerAgent.Scope} - */ -InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeObject, groupId) { - const GLOBAL_SCOPE = 0; - const LOCAL_SCOPE = 1; - const WITH_SCOPE = 2; - const CLOSURE_SCOPE = 3; - const CATCH_SCOPE = 4; - - /** @type {!Object.} */ - var scopeTypeNames = {}; - scopeTypeNames[GLOBAL_SCOPE] = "global"; - scopeTypeNames[LOCAL_SCOPE] = "local"; - scopeTypeNames[WITH_SCOPE] = "with"; - scopeTypeNames[CLOSURE_SCOPE] = "closure"; - scopeTypeNames[CATCH_SCOPE] = "catch"; - - return { - object: injectedScript._wrapObject(scopeObject, groupId), - type: /** @type {DebuggerAgent.ScopeType} */ (scopeTypeNames[scopeTypeCode]) +InjectedScript.CallFrameProxy._scopeTypeNames = { + 0: "global", // GLOBAL_SCOPE + 1: "with", // WITH_SCOPE + 2: "closure", // CLOSURE_SCOPE + 3: "catch", // CATCH_SCOPE + 4: "functionName", // FUNCTION_NAME_SCOPE + 5: "globalLexicalEnvironment", // GLOBAL_LEXICAL_ENVIRONMENT_SCOPE + 6: "nestedLexical", // NESTED_LEXICAL_SCOPE +}; + +InjectedScript.CallFrameProxy._createScopeJson = function(object, {name, type, location}, groupId) +{ + let scope = { + object: injectedScript._wrapObject(object, groupId), + type: InjectedScript.CallFrameProxy._scopeTypeNames[type], + }; + + if (name) + scope.name = name; + + if (location) + scope.location = location; + + if (isEmptyObject(object)) + scope.empty = true; + + return scope; +} + + +function bind(func, thisObject, ...outerArgs) +{ + return function(...innerArgs) { + return func.apply(thisObject, outerArgs.concat(innerArgs)); }; } -function BasicCommandLineAPI() +function BasicCommandLineAPI(callFrame) { this.$_ = injectedScript._lastResult; + this.$exception = injectedScript._exceptionValue; + + // $1-$99 + for (let i = 1; i <= injectedScript._savedResults.length; ++i) + this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); + + // Command Line API methods. + for (let method of BasicCommandLineAPI.methods) + this[method.name] = method; } +BasicCommandLineAPI.methods = [ + function dir() { return inspectedGlobalObject.console.dir(...arguments); }, + function clear() { return inspectedGlobalObject.console.clear(...arguments); }, + function table() { return inspectedGlobalObject.console.table(...arguments); }, + function profile() { return inspectedGlobalObject.console.profile(...arguments); }, + function profileEnd() { return inspectedGlobalObject.console.profileEnd(...arguments); }, + + function keys(object) { return Object.keys(object); }, + function values(object) { + let result = []; + for (let key in object) + result.push(object[key]); + return result; + }, +]; + +for (let method of BasicCommandLineAPI.methods) + method.toString = function() { return "function " + method.name + "() { [Command Line API] }"; }; + return injectedScript; }) diff --git a/Source/JavaScriptCore/inspector/InspectorAgentBase.h b/Source/JavaScriptCore/inspector/InspectorAgentBase.h index f6b6c55cb..4edf78305 100644 --- a/Source/JavaScriptCore/inspector/InspectorAgentBase.h +++ b/Source/JavaScriptCore/inspector/InspectorAgentBase.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,27 +24,53 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorAgentBase_h -#define InspectorAgentBase_h +#pragma once #include +namespace JSC { +class JSGlobalObject; +} + namespace Inspector { -class InspectorBackendDispatcher; -class InspectorFrontendChannel; +class BackendDispatcher; +class FrontendRouter; +class InjectedScriptManager; +class InspectorEnvironment; + +struct AgentContext { + InspectorEnvironment& environment; + InjectedScriptManager& injectedScriptManager; + FrontendRouter& frontendRouter; + BackendDispatcher& backendDispatcher; +}; + +struct JSAgentContext : public AgentContext { + JSAgentContext(AgentContext& context, JSC::JSGlobalObject& globalObject) + : AgentContext(context) + , inspectedGlobalObject(globalObject) + { + } -enum class InspectorDisconnectReason { + JSC::JSGlobalObject& inspectedGlobalObject; +}; + +enum class DisconnectReason { InspectedTargetDestroyed, InspectorDestroyed }; class InspectorAgentBase { + WTF_MAKE_FAST_ALLOCATED; public: virtual ~InspectorAgentBase() { } - virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) = 0; - virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason reason) = 0; + String domainName() const { return m_name; } + + virtual void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) = 0; + virtual void willDestroyFrontendAndBackend(DisconnectReason) = 0; + virtual void discardValues() { } virtual void discardAgent() { } protected: @@ -55,7 +81,5 @@ protected: String m_name; }; - -} // namespace Inspector -#endif // !defined(InspectorAgentBase_h) +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp index e0d9ede15..b5e34741c 100644 --- a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp +++ b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,39 +27,52 @@ #include "config.h" #include "InspectorAgentRegistry.h" -#if ENABLE(INSPECTOR) - #include "InspectorAgentBase.h" namespace Inspector { -InspectorAgentRegistry::InspectorAgentRegistry() +AgentRegistry::AgentRegistry() { } -void InspectorAgentRegistry::append(std::unique_ptr agent) +AgentRegistry::~AgentRegistry() { - m_agents.append(std::move(agent)); + // Allow agents to remove cross-references to other agents that would otherwise + // make it difficult to establish a correct destruction order for all agents. + for (auto& agent : m_agents) + agent->discardAgent(); } -void InspectorAgentRegistry::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher) +void AgentRegistry::append(std::unique_ptr agent) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->didCreateFrontendAndBackend(frontendChannel, backendDispatcher); + m_agents.append(WTFMove(agent)); } -void InspectorAgentRegistry::willDestroyFrontendAndBackend(InspectorDisconnectReason reason) +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +void AgentRegistry::appendExtraAgent(std::unique_ptr agent) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->willDestroyFrontendAndBackend(reason); + m_extraDomains.append(agent->domainName()); + + append(WTFMove(agent)); } +#endif -void InspectorAgentRegistry::discardAgents() +void AgentRegistry::didCreateFrontendAndBackend(FrontendRouter* frontendRouter, BackendDispatcher* backendDispatcher) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->discardAgent(); + for (auto& agent : m_agents) + agent->didCreateFrontendAndBackend(frontendRouter, backendDispatcher); } -} // namespace Inspector +void AgentRegistry::willDestroyFrontendAndBackend(DisconnectReason reason) +{ + for (auto& agent : m_agents) + agent->willDestroyFrontendAndBackend(reason); +} -#endif // ENABLE(INSPECTOR) +void AgentRegistry::discardValues() +{ + for (auto& agent : m_agents) + agent->discardValues(); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.h b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.h index 17d65e71a..7f7017c00 100644 --- a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.h +++ b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,37 +24,45 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorAgentRegistry_h -#define InspectorAgentRegistry_h +#pragma once #include +#include namespace Inspector { +class BackendDispatcher; +class FrontendRouter; class InspectorAgentBase; -class InspectorBackendDispatcher; -class InspectorFrontendChannel; -enum class InspectorDisconnectReason; -class JS_EXPORT_PRIVATE InspectorAgentRegistry { +enum class DisconnectReason; + +class JS_EXPORT_PRIVATE AgentRegistry { public: - InspectorAgentRegistry(); + AgentRegistry(); + ~AgentRegistry(); void append(std::unique_ptr); - void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*); - void willDestroyFrontendAndBackend(InspectorDisconnectReason reason); - void discardAgents(); + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*); + void willDestroyFrontendAndBackend(DisconnectReason); + void discardValues(); + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + void appendExtraAgent(std::unique_ptr); + Vector extraDomains() const { return m_extraDomains; } +#endif private: // These are declared here to avoid MSVC from trying to create default iplementations which would // involve generating a copy constructor and copy assignment operator for the Vector of std::unique_ptrs. - InspectorAgentRegistry(const InspectorAgentRegistry&) = delete; - InspectorAgentRegistry& operator=(const InspectorAgentRegistry&) = delete; + AgentRegistry(const AgentRegistry&) = delete; + AgentRegistry& operator=(const AgentRegistry&) = delete; Vector> m_agents; +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + Vector m_extraDomains; +#endif }; } // namespace Inspector - -#endif // !defined(InspectorAgentRegistry_h) diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp index 30a66f7b3..b1984a835 100644 --- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp +++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved. * Copyright (C) 2011 The Chromium Authors. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,133 +27,179 @@ #include "config.h" #include "InspectorBackendDispatcher.h" -#if ENABLE(INSPECTOR) - -#include "InspectorFrontendChannel.h" +#include "InspectorFrontendRouter.h" #include "InspectorValues.h" +#include #include #include namespace Inspector { -InspectorBackendDispatcher::CallbackBase::CallbackBase(PassRefPtr backendDispatcher, int id) +SupplementalBackendDispatcher::SupplementalBackendDispatcher(BackendDispatcher& backendDispatcher) : m_backendDispatcher(backendDispatcher) - , m_id(id) - , m_alreadySent(false) { } -bool InspectorBackendDispatcher::CallbackBase::isActive() const +SupplementalBackendDispatcher::~SupplementalBackendDispatcher() +{ +} + +BackendDispatcher::CallbackBase::CallbackBase(Ref&& backendDispatcher, long requestId) + : m_backendDispatcher(WTFMove(backendDispatcher)) + , m_requestId(requestId) +{ +} + +bool BackendDispatcher::CallbackBase::isActive() const { return !m_alreadySent && m_backendDispatcher->isActive(); } -void InspectorBackendDispatcher::CallbackBase::sendFailure(const ErrorString& error) +void BackendDispatcher::CallbackBase::sendFailure(const ErrorString& error) { ASSERT(error.length()); - sendIfActive(nullptr, error); + + if (m_alreadySent) + return; + + m_alreadySent = true; + + // Immediately send an error message since this is an async response with a single error. + m_backendDispatcher->reportProtocolError(m_requestId, ServerError, error); + m_backendDispatcher->sendPendingErrors(); } -void InspectorBackendDispatcher::CallbackBase::sendIfActive(PassRefPtr partialMessage, const ErrorString& invocationError) +void BackendDispatcher::CallbackBase::sendSuccess(RefPtr&& partialMessage) { if (m_alreadySent) return; - m_backendDispatcher->sendResponse(m_id, partialMessage, invocationError); m_alreadySent = true; + m_backendDispatcher->sendResponse(m_requestId, WTFMove(partialMessage)); } -PassRefPtr InspectorBackendDispatcher::create(InspectorFrontendChannel* inspectorFrontendChannel) +BackendDispatcher::BackendDispatcher(Ref&& router) + : m_frontendRouter(WTFMove(router)) { - return adoptRef(new InspectorBackendDispatcher(inspectorFrontendChannel)); } -void InspectorBackendDispatcher::registerDispatcherForDomain(const String& domain, InspectorSupplementalBackendDispatcher* dispatcher) +Ref BackendDispatcher::create(Ref&& router) { - auto result = m_dispatchers.add(domain, dispatcher); - ASSERT_UNUSED(result, result.isNewEntry); + return adoptRef(*new BackendDispatcher(WTFMove(router))); } -void InspectorBackendDispatcher::dispatch(const String& message) +bool BackendDispatcher::isActive() const { - Ref protect(*this); - - RefPtr parsedMessage = InspectorValue::parseJSON(message); - if (!parsedMessage) { - reportProtocolError(nullptr, ParseError, ASCIILiteral("Message must be in JSON format")); - return; - } - - RefPtr messageObject = parsedMessage->asObject(); - if (!messageObject) { - reportProtocolError(nullptr, InvalidRequest, ASCIILiteral("Message must be a JSONified object")); - return; - } - - RefPtr callIdValue = messageObject->get("id"); - if (!callIdValue) { - reportProtocolError(nullptr, InvalidRequest, ASCIILiteral("'id' property was not found")); - return; - } - - long callId = 0; - if (!callIdValue->asNumber(&callId)) { - reportProtocolError(nullptr, InvalidRequest, ASCIILiteral("The type of 'id' property must be number")); - return; - } - - RefPtr methodValue = messageObject->get("method"); - if (!methodValue) { - reportProtocolError(&callId, InvalidRequest, ASCIILiteral("'method' property wasn't found")); - return; - } - - String method; - if (!methodValue->asString(&method)) { - reportProtocolError(&callId, InvalidRequest, ASCIILiteral("The type of 'method' property must be string")); - return; - } - - size_t position = method.find('.'); - if (position == WTF::notFound) { - reportProtocolError(&callId, InvalidRequest, ASCIILiteral("The 'method' property was formatted incorrectly. It should be 'Domain.method'")); - return; - } + return m_frontendRouter->hasFrontends(); +} - String domain = method.substring(0, position); - InspectorSupplementalBackendDispatcher* domainDispatcher = m_dispatchers.get(domain); - if (!domainDispatcher) { - reportProtocolError(&callId, MethodNotFound, "'" + domain + "' domain was not found"); - return; - } +void BackendDispatcher::registerDispatcherForDomain(const String& domain, SupplementalBackendDispatcher* dispatcher) +{ + ASSERT_ARG(dispatcher, dispatcher); - String domainMethod = method.substring(position + 1); - domainDispatcher->dispatch(callId, domainMethod, messageObject.release()); + // FIXME: Agents should only register with the backend once, + // and we should re-add the assertion that only one dispatcher is registered per domain. + m_dispatchers.set(domain, dispatcher); } -void InspectorBackendDispatcher::sendResponse(long callId, PassRefPtr result, const ErrorString& invocationError) +void BackendDispatcher::dispatch(const String& message) { - if (!m_inspectorFrontendChannel) - return; - - if (invocationError.length()) { - reportProtocolError(&callId, ServerError, invocationError); - return; + Ref protect(*this); + + ASSERT(!m_protocolErrors.size()); + + long requestId = 0; + RefPtr messageObject; + + { + // In case this is a re-entrant call from a nested run loop, we don't want to lose + // the outer request's id just because the inner request is bogus. + SetForScope> scopedRequestId(m_currentRequestId, std::nullopt); + + RefPtr parsedMessage; + if (!InspectorValue::parseJSON(message, parsedMessage)) { + reportProtocolError(ParseError, ASCIILiteral("Message must be in JSON format")); + sendPendingErrors(); + return; + } + + if (!parsedMessage->asObject(messageObject)) { + reportProtocolError(InvalidRequest, ASCIILiteral("Message must be a JSONified object")); + sendPendingErrors(); + return; + } + + RefPtr requestIdValue; + if (!messageObject->getValue(ASCIILiteral("id"), requestIdValue)) { + reportProtocolError(InvalidRequest, ASCIILiteral("'id' property was not found")); + sendPendingErrors(); + return; + } + + if (!requestIdValue->asInteger(requestId)) { + reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'id' property must be integer")); + sendPendingErrors(); + return; + } } - RefPtr responseMessage = InspectorObject::create(); - responseMessage->setObject(ASCIILiteral("result"), result); - responseMessage->setNumber(ASCIILiteral("id"), callId); - m_inspectorFrontendChannel->sendMessageToFrontend(responseMessage->toJSONString()); + { + // We could be called re-entrantly from a nested run loop, so restore the previous id. + SetForScope> scopedRequestId(m_currentRequestId, requestId); + + RefPtr methodValue; + if (!messageObject->getValue(ASCIILiteral("method"), methodValue)) { + reportProtocolError(InvalidRequest, ASCIILiteral("'method' property wasn't found")); + sendPendingErrors(); + return; + } + + String methodString; + if (!methodValue->asString(methodString)) { + reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'method' property must be string")); + sendPendingErrors(); + return; + } + + Vector domainAndMethod; + methodString.split('.', true, domainAndMethod); + if (domainAndMethod.size() != 2 || !domainAndMethod[0].length() || !domainAndMethod[1].length()) { + reportProtocolError(InvalidRequest, ASCIILiteral("The 'method' property was formatted incorrectly. It should be 'Domain.method'")); + sendPendingErrors(); + return; + } + + String domain = domainAndMethod[0]; + SupplementalBackendDispatcher* domainDispatcher = m_dispatchers.get(domain); + if (!domainDispatcher) { + reportProtocolError(MethodNotFound, "'" + domain + "' domain was not found"); + sendPendingErrors(); + return; + } + + String method = domainAndMethod[1]; + domainDispatcher->dispatch(requestId, method, messageObject.releaseNonNull()); + + if (m_protocolErrors.size()) + sendPendingErrors(); + } } -void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode errorCode, const String& errorMessage) const +void BackendDispatcher::sendResponse(long requestId, RefPtr&& result) { - reportProtocolError(callId, errorCode, errorMessage, nullptr); + ASSERT(!m_protocolErrors.size()); + + // The JSON-RPC 2.0 specification requires that the "error" member have the value 'null' + // if no error occurred during an invocation, but we do not include it at all. + Ref responseMessage = InspectorObject::create(); + responseMessage->setObject(ASCIILiteral("result"), WTFMove(result)); + responseMessage->setInteger(ASCIILiteral("id"), requestId); + m_frontendRouter->sendResponse(responseMessage->toJSONString()); } -void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode errorCode, const String& errorMessage, PassRefPtr data) const +void BackendDispatcher::sendPendingErrors() { + // These error codes are specified in JSON-RPC 2.0, Section 5.1. static const int errorCodes[] = { -32700, // ParseError -32600, // InvalidRequest @@ -163,102 +209,141 @@ void InspectorBackendDispatcher::reportProtocolError(const long* const callId, C -32000, // ServerError }; - ASSERT(errorCode >= 0); - ASSERT((unsigned)errorCode < WTF_ARRAY_LENGTH(errorCodes)); - ASSERT(errorCodes[errorCode]); + // To construct the error object, only use the last error's code and message. + // Per JSON-RPC 2.0, Section 5.1, the 'data' member may contain nested errors, + // but only one top-level Error object should be sent per request. + CommonErrorCode errorCode = InternalError; + String errorMessage; + Ref payload = InspectorArray::create(); + + for (auto& data : m_protocolErrors) { + errorCode = std::get<0>(data); + errorMessage = std::get<1>(data); + + ASSERT_ARG(errorCode, (unsigned)errorCode < WTF_ARRAY_LENGTH(errorCodes)); + ASSERT_ARG(errorCode, errorCodes[errorCode]); + + Ref error = InspectorObject::create(); + error->setInteger(ASCIILiteral("code"), errorCodes[errorCode]); + error->setString(ASCIILiteral("message"), errorMessage); + payload->pushObject(WTFMove(error)); + } - if (!m_inspectorFrontendChannel) - return; + Ref topLevelError = InspectorObject::create(); + topLevelError->setInteger(ASCIILiteral("code"), errorCodes[errorCode]); + topLevelError->setString(ASCIILiteral("message"), errorMessage); + topLevelError->setArray(ASCIILiteral("data"), WTFMove(payload)); + + Ref message = InspectorObject::create(); + message->setObject(ASCIILiteral("error"), WTFMove(topLevelError)); + if (m_currentRequestId) + message->setInteger(ASCIILiteral("id"), m_currentRequestId.value()); + else { + // The 'null' value for an unknown id is specified in JSON-RPC 2.0, Section 5. + message->setValue(ASCIILiteral("id"), InspectorValue::null()); + } - RefPtr error = InspectorObject::create(); - error->setNumber(ASCIILiteral("code"), errorCodes[errorCode]); - error->setString(ASCIILiteral("message"), errorMessage); - if (data) - error->setArray(ASCIILiteral("data"), data); + m_frontendRouter->sendResponse(message->toJSONString()); - RefPtr message = InspectorObject::create(); - message->setObject(ASCIILiteral("error"), error.release()); - if (callId) - message->setNumber(ASCIILiteral("id"), *callId); - else - message->setValue(ASCIILiteral("id"), InspectorValue::null()); + m_protocolErrors.clear(); + m_currentRequestId = std::nullopt; +} + +void BackendDispatcher::reportProtocolError(CommonErrorCode errorCode, const String& errorMessage) +{ + reportProtocolError(m_currentRequestId, errorCode, errorMessage); +} + +void BackendDispatcher::reportProtocolError(std::optional relatedRequestId, CommonErrorCode errorCode, const String& errorMessage) +{ + ASSERT_ARG(errorCode, errorCode >= 0); + + // If the error was reported from an async callback, then no request id will be registered yet. + if (!m_currentRequestId) + m_currentRequestId = relatedRequestId; - m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString()); + m_protocolErrors.append(std::tuple(errorCode, errorMessage)); } -template -static ReturnValueType getPropertyValue(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors, DefaultValueType defaultValue, bool (*asMethod)(InspectorValue*, ValueType*), const char* typeName) +#if PLATFORM(MAC) +void BackendDispatcher::reportProtocolError(WTF::DeprecatedOptional relatedRequestId, CommonErrorCode errorCode, const String& errorMessage) { - ASSERT(protocolErrors); + if (relatedRequestId) + reportProtocolError(relatedRequestId.value(), errorCode, errorMessage); + else + reportProtocolError(std::nullopt, errorCode, errorMessage); +} +#endif - ValueType value = defaultValue; - if (valueFound) - *valueFound = false; +template +T BackendDispatcher::getPropertyValue(InspectorObject* object, const String& name, bool* out_optionalValueFound, T defaultValue, std::function asMethod, const char* typeName) +{ + T result(defaultValue); + // out_optionalValueFound signals to the caller whether an optional property was found. + // if out_optionalValueFound == nullptr, then this is a required property. + if (out_optionalValueFound) + *out_optionalValueFound = false; if (!object) { - if (!valueFound) - protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type '%s'.", name.utf8().data(), typeName)); - return value; + if (!out_optionalValueFound) + reportProtocolError(BackendDispatcher::InvalidParams, String::format("'params' object must contain required parameter '%s' with type '%s'.", name.utf8().data(), typeName)); + return result; } - InspectorObject::const_iterator end = object->end(); - InspectorObject::const_iterator valueIterator = object->find(name); - if (valueIterator == end) { - if (!valueFound) - protocolErrors->pushString(String::format("Parameter '%s' with type '%s' was not found.", name.utf8().data(), typeName)); - return value; + auto findResult = object->find(name); + if (findResult == object->end()) { + if (!out_optionalValueFound) + reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' with type '%s' was not found.", name.utf8().data(), typeName)); + return result; } - if (!asMethod(valueIterator->value.get(), &value)) { - protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be '%s'.", name.utf8().data(), typeName)); - return value; + if (!asMethod(*findResult->value, result)) { + reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' has wrong type. It must be '%s'.", name.utf8().data(), typeName)); + return result; } - if (valueFound) - *valueFound = true; + if (out_optionalValueFound) + *out_optionalValueFound = true; - return value; + return result; } -struct AsMethodBridges { - static bool asInt(InspectorValue* value, int* output) { return value->asNumber(output); } - static bool asDouble(InspectorValue* value, double* output) { return value->asNumber(output); } - static bool asString(InspectorValue* value, String* output) { return value->asString(output); } - static bool asBoolean(InspectorValue* value, bool* output) { return value->asBoolean(output); } - static bool asObject(InspectorValue* value, RefPtr* output) { return value->asObject(output); } - static bool asArray(InspectorValue* value, RefPtr* output) { return value->asArray(output); } -}; +static bool castToInteger(InspectorValue& value, int& result) { return value.asInteger(result); } +static bool castToNumber(InspectorValue& value, double& result) { return value.asDouble(result); } -int InspectorBackendDispatcher::getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +int BackendDispatcher::getInteger(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asInt, "Number"); + return getPropertyValue(object, name, valueFound, 0, &castToInteger, "Integer"); } -double InspectorBackendDispatcher::getDouble(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +double BackendDispatcher::getDouble(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asDouble, "Number"); + return getPropertyValue(object, name, valueFound, 0, &castToNumber, "Number"); } -String InspectorBackendDispatcher::getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +String BackendDispatcher::getString(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue(object, name, valueFound, protocolErrors, "", AsMethodBridges::asString, "String"); + return getPropertyValue(object, name, valueFound, "", &InspectorValue::asString, "String"); } -bool InspectorBackendDispatcher::getBoolean(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +bool BackendDispatcher::getBoolean(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue(object, name, valueFound, protocolErrors, false, AsMethodBridges::asBoolean, "Boolean"); + return getPropertyValue(object, name, valueFound, false, &InspectorValue::asBoolean, "Boolean"); } -PassRefPtr InspectorBackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +RefPtr BackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue, RefPtr, InspectorObject*>(object, name, valueFound, protocolErrors, nullptr, AsMethodBridges::asObject, "Object"); + return getPropertyValue>(object, name, valueFound, nullptr, &InspectorValue::asObject, "Object"); } -PassRefPtr InspectorBackendDispatcher::getArray(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) +RefPtr BackendDispatcher::getArray(InspectorObject* object, const String& name, bool* valueFound) { - return getPropertyValue, RefPtr, InspectorArray*>(object, name, valueFound, protocolErrors, nullptr, AsMethodBridges::asArray, "Array"); + return getPropertyValue>(object, name, valueFound, nullptr, &InspectorValue::asArray, "Array"); } -} // namespace Inspector +RefPtr BackendDispatcher::getValue(InspectorObject* object, const String& name, bool* valueFound) +{ + return getPropertyValue>(object, name, valueFound, nullptr, &InspectorValue::asValue, "Value"); +} -#endif // ENABLE(INSPECTOR) +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h index 0a55a1c96..db976bd96 100644 --- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h +++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved. * Copyright (C) 2011 The Chromium Authors. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,52 +24,53 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorBackendDispatcher_h -#define InspectorBackendDispatcher_h +#pragma once -#include "InspectorValues.h" -#include +#include "InspectorFrontendRouter.h" +#include "InspectorProtocolTypes.h" +#include +#include #include #include namespace Inspector { -class InspectorBackendDispatcher; -class InspectorFrontendChannel; +class BackendDispatcher; + typedef String ErrorString; -class InspectorSupplementalBackendDispatcher : public RefCounted { +class JS_EXPORT_PRIVATE SupplementalBackendDispatcher : public RefCounted { public: - InspectorSupplementalBackendDispatcher(InspectorBackendDispatcher* backendDispatcher) : m_backendDispatcher(backendDispatcher) { } - virtual ~InspectorSupplementalBackendDispatcher() { } - virtual void dispatch(long callId, const String& method, PassRefPtr message) = 0; + SupplementalBackendDispatcher(BackendDispatcher&); + virtual ~SupplementalBackendDispatcher(); + virtual void dispatch(long requestId, const String& method, Ref&& message) = 0; protected: - RefPtr m_backendDispatcher; + Ref m_backendDispatcher; }; -class JS_EXPORT_PRIVATE InspectorBackendDispatcher : public RefCounted { +class JS_EXPORT_PRIVATE BackendDispatcher : public RefCounted { public: - static PassRefPtr create(InspectorFrontendChannel*); + static Ref create(Ref&&); class JS_EXPORT_PRIVATE CallbackBase : public RefCounted { public: - CallbackBase(PassRefPtr, int id); + CallbackBase(Ref&&, long requestId); bool isActive() const; - void sendFailure(const ErrorString&); void disable() { m_alreadySent = true; } - protected: - void sendIfActive(PassRefPtr partialMessage, const ErrorString& invocationError); + void sendSuccess(RefPtr&&); + void sendFailure(const ErrorString&); private: - RefPtr m_backendDispatcher; - int m_id; - bool m_alreadySent; + Ref m_backendDispatcher; + long m_requestId; + bool m_alreadySent { false }; }; - void clearFrontend() { m_inspectorFrontendChannel = nullptr; } - bool isActive() const { return !!m_inspectorFrontendChannel; } + bool isActive() const; + + bool hasProtocolErrors() const { return m_protocolErrors.size() > 0; } enum CommonErrorCode { ParseError = 0, @@ -80,26 +81,46 @@ public: ServerError }; - void registerDispatcherForDomain(const String& domain, InspectorSupplementalBackendDispatcher*); + void registerDispatcherForDomain(const String& domain, SupplementalBackendDispatcher*); void dispatch(const String& message); - void sendResponse(long callId, PassRefPtr result, const ErrorString& invocationError); - void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage) const; - void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr data) const; - static int getInt(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); - static double getDouble(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); - static String getString(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); - static bool getBoolean(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); - static PassRefPtr getObject(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); - static PassRefPtr getArray(InspectorObject*, const String& name, bool* valueFound, InspectorArray* protocolErrors); + void sendResponse(long requestId, RefPtr&& result); + void sendPendingErrors(); + + void reportProtocolError(CommonErrorCode, const String& errorMessage); + void reportProtocolError(std::optional relatedRequestId, CommonErrorCode, const String& errorMessage); + + template + WTF_HIDDEN_DECLARATION + T getPropertyValue(InspectorObject*, const String& name, bool* out_optionalValueFound, T defaultValue, std::function, const char* typeName); + + int getInteger(InspectorObject*, const String& name, bool* valueFound); + double getDouble(InspectorObject*, const String& name, bool* valueFound); + String getString(InspectorObject*, const String& name, bool* valueFound); + bool getBoolean(InspectorObject*, const String& name, bool* valueFound); + RefPtr getValue(InspectorObject*, const String& name, bool* valueFound); + RefPtr getObject(InspectorObject*, const String& name, bool* valueFound); + RefPtr getArray(InspectorObject*, const String& name, bool* valueFound); private: - InspectorBackendDispatcher(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { } + BackendDispatcher(Ref&&); + +#if PLATFORM(MAC) + // This is necessary for some versions of Safari. Remove it when those versions of Safari are no longer supported. + void reportProtocolError(WTF::DeprecatedOptional relatedRequestId, CommonErrorCode, const String& errorMessage); +#endif + + Ref m_frontendRouter; + HashMap m_dispatchers; - InspectorFrontendChannel* m_inspectorFrontendChannel; - HashMap m_dispatchers; + // Protocol errors reported for the top-level request being processed. + // If processing a request triggers async responses, then any related errors will + // be attributed to the top-level request, but generate separate error messages. + Vector> m_protocolErrors; + + // For synchronously handled requests, avoid plumbing requestId through every + // call that could potentially fail with a protocol error. + std::optional m_currentRequestId { std::nullopt }; }; } // namespace Inspector - -#endif // !defined(InspectorBackendDispatcher_h) diff --git a/Source/JavaScriptCore/inspector/InspectorEnvironment.h b/Source/JavaScriptCore/inspector/InspectorEnvironment.h index 327a9f89a..3b60c1b4f 100644 --- a/Source/JavaScriptCore/inspector/InspectorEnvironment.h +++ b/Source/JavaScriptCore/inspector/InspectorEnvironment.h @@ -23,19 +23,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorEnvironment_h -#define InspectorEnvironment_h +#pragma once #include "CallData.h" +namespace WTF { +class Stopwatch; +} + namespace JSC { +class Exception; class SourceCode; +class VM; } namespace Inspector { -typedef JSC::JSValue (*InspectorFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args); -typedef JSC::JSValue (*InspectorEvaluateHandler)(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, JSC::JSValue* exception); +class ScriptDebugServer; +typedef JSC::JSValue (*InspectorFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr& returnedException); +typedef JSC::JSValue (*InspectorEvaluateHandler)(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, NakedPtr& returnedException); class InspectorEnvironment { public: @@ -44,10 +50,10 @@ public: virtual bool canAccessInspectedScriptState(JSC::ExecState*) const = 0; virtual InspectorFunctionCallHandler functionCallHandler() const = 0; virtual InspectorEvaluateHandler evaluateHandler() const = 0; - virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String& scriptName, int scriptLine) = 0; - virtual void didCallInjectedScriptFunction() = 0; + virtual void frontendInitialized() = 0; + virtual Ref executionStopwatch() = 0; + virtual ScriptDebugServer& scriptDebugServer() = 0; + virtual JSC::VM& vm() = 0; }; } // namespace Inspector - -#endif // !defined(InspectorEnvironment_h) diff --git a/Source/JavaScriptCore/inspector/InspectorFrontendChannel.h b/Source/JavaScriptCore/inspector/InspectorFrontendChannel.h index fa0a8eae8..3abc1d285 100644 --- a/Source/JavaScriptCore/inspector/InspectorFrontendChannel.h +++ b/Source/JavaScriptCore/inspector/InspectorFrontendChannel.h @@ -23,19 +23,26 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorFrontendChannel_h -#define InspectorFrontendChannel_h +#pragma once #include namespace Inspector { -class InspectorFrontendChannel { +// Represents a one-way connection from an Inspection or Automation target to +// a local or remote controller (such as a debugger or UI automation script). + +class FrontendChannel { public: - virtual ~InspectorFrontendChannel() { } - virtual bool sendMessageToFrontend(const String& message) = 0; + + enum class ConnectionType { + Remote, + Local + }; + + virtual ~FrontendChannel() { } + virtual ConnectionType connectionType() const = 0; + virtual void sendMessageToFrontend(const String& message) = 0; }; } // namespace Inspector - -#endif // !defined(InspectorFrontendChannel_h) diff --git a/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp new file mode 100644 index 000000000..65f8525a2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorFrontendRouter.h" + +#include "InspectorFrontendChannel.h" +#include + +namespace Inspector { + +Ref FrontendRouter::create() +{ + return adoptRef(*new FrontendRouter); +} + +void FrontendRouter::connectFrontend(FrontendChannel* connection) +{ + ASSERT_ARG(connection, connection); + + if (m_connections.contains(connection)) { + ASSERT_NOT_REACHED(); + return; + } + + m_connections.append(connection); +} + +void FrontendRouter::disconnectFrontend(FrontendChannel* connection) +{ + ASSERT_ARG(connection, connection); + + if (!m_connections.contains(connection)) { + ASSERT_NOT_REACHED(); + return; + } + + m_connections.removeFirst(connection); +} + +void FrontendRouter::disconnectAllFrontends() +{ + m_connections.clear(); +} + +bool FrontendRouter::hasLocalFrontend() const +{ + for (auto* connection : m_connections) { + if (connection->connectionType() == FrontendChannel::ConnectionType::Local) + return true; + } + + return false; +} + +bool FrontendRouter::hasRemoteFrontend() const +{ + for (auto* connection : m_connections) { + if (connection->connectionType() == FrontendChannel::ConnectionType::Remote) + return true; + } + + return false; +} + +void FrontendRouter::sendEvent(const String& message) const +{ + for (auto* connection : m_connections) + connection->sendMessageToFrontend(message); +} + +void FrontendRouter::sendResponse(const String& message) const +{ + // FIXME: send responses to the appropriate frontend. + for (auto* connection : m_connections) + connection->sendMessageToFrontend(message); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorFrontendRouter.h b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.h new file mode 100644 index 000000000..5872b6da8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/InspectorFrontendRouter.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include + +namespace Inspector { + +class FrontendChannel; + +class JS_EXPORT_PRIVATE FrontendRouter : public RefCounted { +public: + static Ref create(); + + bool hasFrontends() const { return !m_connections.isEmpty(); } + bool hasLocalFrontend() const; + bool hasRemoteFrontend() const; + + unsigned frontendCount() const { return m_connections.size(); } + + void connectFrontend(FrontendChannel*); + void disconnectFrontend(FrontendChannel*); + void disconnectAllFrontends(); + + void sendEvent(const String& message) const; + void sendResponse(const String& message) const; + +private: + Vector m_connections; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorProtocolTypes.h b/Source/JavaScriptCore/inspector/InspectorProtocolTypes.h new file mode 100644 index 000000000..248e58a96 --- /dev/null +++ b/Source/JavaScriptCore/inspector/InspectorProtocolTypes.h @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2011 The Chromium Authors. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorValues.h" +#include + +namespace Inspector { + +namespace Protocol { + +template struct BindingTraits; + +template +class OptOutput { +public: + OptOutput() : m_assigned(false) { } + + void operator=(T value) + { + m_value = value; + m_assigned = true; + } + + bool isAssigned() const { return m_assigned; } + + T getValue() + { + ASSERT(isAssigned()); + return m_value; + } + +private: + T m_value; + bool m_assigned; + + WTF_MAKE_NONCOPYABLE(OptOutput); +}; + +template +class Array : public InspectorArrayBase { +private: + Array() { } + + InspectorArray& openAccessors() + { + COMPILE_ASSERT(sizeof(InspectorArray) == sizeof(Array), cannot_cast); + return *static_cast(static_cast(this)); + } + +public: + void addItem(Ref&& value) + { + openAccessors().pushValue(&value.get()); + } + + void addItem(RefPtr&& value) + { + openAccessors().pushValue(WTFMove(value)); + } + + void addItem(const String& value) + { + openAccessors().pushString(value); + } + + void addItem(int value) + { + openAccessors().pushInteger(value); + } + + void addItem(double value) + { + openAccessors().pushDouble(value); + } + + static Ref> create() + { + return adoptRef(*new Array()); + } +}; + +// Helper methods for Protocol and other Inspector types are provided by +// specializations of BindingTraits. Some are generated for protocol types. + +template +struct BindingTraits { + typedef T BindingType; + + static void push(InspectorArray&, BindingType&); + static InspectorValue::Type typeTag(); + static RefPtr runtimeCast(RefPtr&&); +#if !ASSERT_DISABLED + static void assertValueHasExpectedType(InspectorValue*); +#endif // !ASSERT_DISABLED +}; + +template +struct PrimitiveBindingTraits { +#if !ASSERT_DISABLED + static void assertValueHasExpectedType(InspectorValue* value) + { + ASSERT_ARG(value, value && value->type() == TYPE); + } +#endif // !ASSERT_DISABLED +}; + +template +struct BindingTraits> { + static RefPtr> runtimeCast(RefPtr&& value) + { + ASSERT_ARG(value, value); + RefPtr array; + bool castSucceeded = value->asArray(array); + ASSERT_UNUSED(castSucceeded, castSucceeded); +#if !ASSERT_DISABLED + assertValueHasExpectedType(array.get()); +#endif // !ASSERT_DISABLED + COMPILE_ASSERT(sizeof(Array) == sizeof(InspectorArray), type_cast_problem); + return static_cast*>(static_cast(array.get())); + } + +#if !ASSERT_DISABLED + static void assertValueHasExpectedType(InspectorValue* value) + { + ASSERT_ARG(value, value); + RefPtr array; + bool castSucceeded = value->asArray(array); + ASSERT_UNUSED(castSucceeded, castSucceeded); + for (unsigned i = 0; i < array->length(); i++) + BindingTraits::assertValueHasExpectedType(array->get(i).get()); + } +#endif // !ASSERT_DISABLED +}; + +template<> +struct BindingTraits { +#if !ASSERT_DISABLED + static void assertValueHasExpectedType(InspectorValue*) + { + } +#endif // !ASSERT_DISABLED +}; + +template<> struct BindingTraits : public PrimitiveBindingTraits { }; +template<> struct BindingTraits : public PrimitiveBindingTraits { }; +template<> struct BindingTraits : public PrimitiveBindingTraits { }; +template<> struct BindingTraits : public PrimitiveBindingTraits { }; +template<> struct BindingTraits : public PrimitiveBindingTraits { }; +template<> struct BindingTraits : public PrimitiveBindingTraits { }; + +} // namespace Protocol + +using Protocol::BindingTraits; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorTypeBuilder.h b/Source/JavaScriptCore/inspector/InspectorTypeBuilder.h deleted file mode 100644 index 8ea76ec90..000000000 --- a/Source/JavaScriptCore/inspector/InspectorTypeBuilder.h +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * Copyright (C) 2011 The Chromium Authors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InspectorTypeBuilder_h -#define InspectorTypeBuilder_h - -#if ENABLE(INSPECTOR) - -#include "InspectorValues.h" -#include -#include - -namespace Inspector { - -namespace TypeBuilder { - -template -class OptOutput { -public: - OptOutput() : m_assigned(false) { } - - void operator=(T value) - { - m_value = value; - m_assigned = true; - } - - bool isAssigned() const { return m_assigned; } - - T getValue() - { - ASSERT(isAssigned()); - return m_value; - } - -private: - T m_value; - bool m_assigned; - - WTF_MAKE_NONCOPYABLE(OptOutput); -}; - - -// A small transient wrapper around int type, that can be used as a funciton parameter type -// cleverly disallowing C++ implicit casts from float or double. -class ExactlyInt { -public: - template - ExactlyInt(T t) : m_value(cast_to_int(t)) { } - ExactlyInt() { } - - operator int() { return m_value; } - -private: - int m_value; - - template - static int cast_to_int(T) { return T::default_case_cast_is_not_supported(); } -}; - -template<> -inline int ExactlyInt::cast_to_int(int i) { return i; } - -template<> -inline int ExactlyInt::cast_to_int(unsigned int i) { return i; } - -#if !ASSERT_DISABLED -class RuntimeCastHelper { -public: - template - static void assertType(InspectorValue* value) - { - ASSERT(value->type() == TYPE); - } - - static void assertAny(InspectorValue*) - { - } - - static void assertInt(InspectorValue* value) - { - double v; - bool castRes = value->asNumber(&v); - ASSERT_UNUSED(castRes, castRes); - ASSERT(static_cast(static_cast(v)) == v); - } -}; -#endif - - -// 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 -struct ArrayItemHelper { - typedef typename T::ItemTraits Traits; -}; - -template -class Array : public InspectorArrayBase { -private: - Array() { } - - InspectorArray* openAccessors() - { - COMPILE_ASSERT(sizeof(InspectorArray) == sizeof(Array), cannot_cast); - return static_cast(static_cast(this)); - } - -public: - void addItem(PassRefPtr value) - { - ArrayItemHelper::Traits::pushRefPtr(this->openAccessors(), value); - } - - void addItem(T value) - { - ArrayItemHelper::Traits::pushRaw(this->openAccessors(), value); - } - - static PassRefPtr> create() - { - return adoptRef(new Array()); - } - - static PassRefPtr> runtimeCast(PassRefPtr value) - { - RefPtr array; - bool castRes = value->asArray(&array); - ASSERT_UNUSED(castRes, castRes); -#if !ASSERT_DISABLED - assertCorrectValue(array.get()); -#endif // !ASSERT_DISABLED - COMPILE_ASSERT(sizeof(Array) == sizeof(InspectorArray), type_cast_problem); - return static_cast*>(static_cast(array.get())); - } - -#if !ASSERT_DISABLED - static void assertCorrectValue(InspectorValue* value) - { - RefPtr array; - bool castRes = value->asArray(&array); - ASSERT_UNUSED(castRes, castRes); - for (unsigned i = 0; i < array->length(); i++) - ArrayItemHelper::Traits::template assertCorrectValue(array->get(i).get()); - } -#endif // !ASSERT_DISABLED -}; - -struct StructItemTraits { - static void pushRefPtr(InspectorArray* array, PassRefPtr value) - { - array->pushValue(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - T::assertCorrectValue(value); - } -#endif // !ASSERT_DISABLED -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRaw(InspectorArray* array, const String& value) - { - array->pushString(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertType(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRaw(InspectorArray* array, int value) - { - array->pushInt(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertInt(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRaw(InspectorArray* array, double value) - { - array->pushNumber(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertType(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRaw(InspectorArray* array, bool value) - { - array->pushBoolean(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertType(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRefPtr(InspectorArray* array, PassRefPtr value) - { - array->pushValue(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertAny(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRefPtr(InspectorArray* array, PassRefPtr value) - { - array->pushValue(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertType(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template<> -struct ArrayItemHelper { - struct Traits { - static void pushRefPtr(InspectorArray* array, PassRefPtr value) - { - array->pushArray(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - RuntimeCastHelper::assertType(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -template -struct ArrayItemHelper> { - struct Traits { - static void pushRefPtr(InspectorArray* array, PassRefPtr> value) - { - array->pushValue(value); - } - -#if !ASSERT_DISABLED - template - static void assertCorrectValue(InspectorValue* value) - { - S::assertCorrectValue(value); - } -#endif // !ASSERT_DISABLED - }; -}; - -} // namespace TypeBuilder - -} // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(InspectorTypeBuilder_h) diff --git a/Source/JavaScriptCore/inspector/InspectorValues.cpp b/Source/JavaScriptCore/inspector/InspectorValues.cpp index 4cdf71e92..14fb7e70d 100644 --- a/Source/JavaScriptCore/inspector/InspectorValues.cpp +++ b/Source/JavaScriptCore/inspector/InspectorValues.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -63,8 +64,10 @@ const char* const falseString = "false"; bool parseConstToken(const UChar* start, const UChar* end, const UChar** tokenEnd, const char* token) { while (start < end && *token != '\0' && *start++ == *token++) { } + if (*token != '\0') return false; + *tokenEnd = start; return true; } @@ -73,16 +76,20 @@ bool readInt(const UChar* start, const UChar* end, const UChar** tokenEnd, bool { if (start == end) return false; + bool haveLeadingZero = '0' == *start; int length = 0; while (start < end && '0' <= *start && *start <= '9') { ++start; ++length; } + if (!length) return false; + if (!canHaveLeadingZeros && length > 1 && haveLeadingZero) return false; + *tokenEnd = start; return true; } @@ -93,12 +100,14 @@ bool parseNumberToken(const UChar* start, const UChar* end, const UChar** tokenE // According to RFC4627, a valid number is: [minus] int [frac] [exp] if (start == end) return false; + UChar c = *start; if ('-' == c) ++start; if (!readInt(start, end, &start, false)) return false; + if (start == end) { *tokenEnd = start; return true; @@ -140,11 +149,12 @@ bool readHexDigits(const UChar* start, const UChar* end, const UChar** tokenEnd, { if (end - start < digits) return false; + for (int i = 0; i < digits; ++i) { - UChar c = *start++; - if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'))) + if (!isASCIIHexDigit(*start++)) return false; } + *tokenEnd = start; return true; } @@ -183,6 +193,7 @@ bool parseStringToken(const UChar* start, const UChar* end, const UChar** tokenE return true; } } + return false; } @@ -246,27 +257,16 @@ Token parseToken(const UChar* start, const UChar* end, const UChar** tokenStart, return STRING; break; } - return INVALID_TOKEN; -} -inline int hexToInt(UChar c) -{ - if ('0' <= c && c <= '9') - return c - '0'; - if ('A' <= c && c <= 'F') - return c - 'A' + 10; - if ('a' <= c && c <= 'f') - return c - 'a' + 10; - ASSERT_NOT_REACHED(); - return 0; + return INVALID_TOKEN; } -bool decodeString(const UChar* start, const UChar* end, StringBuilder* output) +bool decodeString(const UChar* start, const UChar* end, StringBuilder& output) { while (start < end) { UChar c = *start++; if ('\\' != c) { - output->append(c); + output.append(c); continue; } c = *start++; @@ -294,45 +294,45 @@ bool decodeString(const UChar* start, const UChar* end, StringBuilder* output) c = '\v'; break; case 'x': - c = (hexToInt(*start) << 4) + - hexToInt(*(start + 1)); + c = toASCIIHexValue(start[0], start[1]); start += 2; break; case 'u': - c = (hexToInt(*start) << 12) + - (hexToInt(*(start + 1)) << 8) + - (hexToInt(*(start + 2)) << 4) + - hexToInt(*(start + 3)); + c = toASCIIHexValue(start[0], start[1]) << 8 | toASCIIHexValue(start[2], start[3]); start += 4; break; default: return false; } - output->append(c); + output.append(c); } + return true; } -bool decodeString(const UChar* start, const UChar* end, String* output) +bool decodeString(const UChar* start, const UChar* end, String& output) { if (start == end) { - *output = ""; + output = emptyString(); return true; } + if (start > end) return false; + StringBuilder buffer; buffer.reserveCapacity(end - start); - if (!decodeString(start, end, &buffer)) + if (!decodeString(start, end, buffer)) return false; - *output = buffer.toString(); + + output = buffer.toString(); return true; } -PassRefPtr buildValue(const UChar* start, const UChar* end, const UChar** valueTokenEnd, int depth) +RefPtr buildValue(const UChar* start, const UChar* end, const UChar** valueTokenEnd, int depth) { if (depth > stackLimit) - return 0; + return nullptr; RefPtr result; const UChar* tokenStart; @@ -340,41 +340,41 @@ PassRefPtr buildValue(const UChar* start, const UChar* end, cons Token token = parseToken(start, end, &tokenStart, &tokenEnd); switch (token) { case INVALID_TOKEN: - return 0; + return nullptr; case NULL_TOKEN: result = InspectorValue::null(); break; case BOOL_TRUE: - result = InspectorBasicValue::create(true); + result = InspectorValue::create(true); break; case BOOL_FALSE: - result = InspectorBasicValue::create(false); + result = InspectorValue::create(false); break; case NUMBER: { bool ok; double value = charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok); if (!ok) - return 0; - result = InspectorBasicValue::create(value); + return nullptr; + result = InspectorValue::create(value); break; } case STRING: { String value; - bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value); + bool ok = decodeString(tokenStart + 1, tokenEnd - 1, value); if (!ok) - return 0; - result = InspectorString::create(value); + return nullptr; + result = InspectorValue::create(value); break; } case ARRAY_BEGIN: { - RefPtr array = InspectorArray::create(); + Ref array = InspectorArray::create(); start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); while (token != ARRAY_END) { RefPtr arrayNode = buildValue(start, end, &tokenEnd, depth + 1); if (!arrayNode) - return 0; - array->pushValue(arrayNode); + return nullptr; + array->pushValue(WTFMove(arrayNode)); // After a list value, we expect a comma or the end of the list. start = tokenEnd; @@ -383,38 +383,38 @@ PassRefPtr buildValue(const UChar* start, const UChar* end, cons start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); if (token == ARRAY_END) - return 0; + return nullptr; } else if (token != ARRAY_END) { // Unexpected value after list value. Bail out. - return 0; + return nullptr; } } if (token != ARRAY_END) - return 0; - result = array.release(); + return nullptr; + result = WTFMove(array); break; } case OBJECT_BEGIN: { - RefPtr object = InspectorObject::create(); + Ref object = InspectorObject::create(); start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); while (token != OBJECT_END) { if (token != STRING) - return 0; + return nullptr; String key; - if (!decodeString(tokenStart + 1, tokenEnd - 1, &key)) - return 0; + if (!decodeString(tokenStart + 1, tokenEnd - 1, key)) + return nullptr; start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); if (token != OBJECT_PAIR_SEPARATOR) - return 0; + return nullptr; start = tokenEnd; RefPtr value = buildValue(start, end, &tokenEnd, depth + 1); if (!value) - return 0; - object->setValue(key, value); + return nullptr; + object->setValue(key, WTFMove(value)); start = tokenEnd; // After a key/value pair, we expect a comma or the end of the @@ -424,45 +424,45 @@ PassRefPtr buildValue(const UChar* start, const UChar* end, cons start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); if (token == OBJECT_END) - return 0; + return nullptr; } else if (token != OBJECT_END) { // Unexpected value after last object value. Bail out. - return 0; + return nullptr; } } if (token != OBJECT_END) - return 0; - result = object.release(); + return nullptr; + result = WTFMove(object); break; } default: // We got a token that's not a value. - return 0; + return nullptr; } *valueTokenEnd = tokenEnd; - return result.release(); + return result; } -inline bool escapeChar(UChar c, StringBuilder* dst) +inline bool escapeChar(UChar c, StringBuilder& dst) { switch (c) { - case '\b': dst->append("\\b", 2); break; - case '\f': dst->append("\\f", 2); break; - case '\n': dst->append("\\n", 2); break; - case '\r': dst->append("\\r", 2); break; - case '\t': dst->append("\\t", 2); break; - case '\\': dst->append("\\\\", 2); break; - case '"': dst->append("\\\"", 2); break; + case '\b': dst.appendLiteral("\\b"); break; + case '\f': dst.appendLiteral("\\f"); break; + case '\n': dst.appendLiteral("\\n"); break; + case '\r': dst.appendLiteral("\\r"); break; + case '\t': dst.appendLiteral("\\t"); break; + case '\\': dst.appendLiteral("\\\\"); break; + case '"': dst.appendLiteral("\\\""); break; default: return false; } return true; } -inline void doubleQuoteString(const String& str, StringBuilder* dst) +inline void doubleQuoteString(const String& str, StringBuilder& dst) { - dst->append('"'); + dst.append('"'); for (unsigned i = 0; i < str.length(); ++i) { UChar c = str[i]; if (!escapeChar(c, dst)) { @@ -470,285 +470,306 @@ inline void doubleQuoteString(const String& str, StringBuilder* dst) // 1. Escaping <, > to prevent script execution. // 2. Technically, we could also pass through c > 126 as UTF8, but this // is also optional. It would also be a pain to implement here. - unsigned int symbol = static_cast(c); - String symbolCode = String::format("\\u%04X", symbol); - dst->append(symbolCode.deprecatedCharacters(), symbolCode.length()); + dst.append(String::format("\\u%04X", c)); } else - dst->append(c); + dst.append(c); } } - dst->append('"'); + dst.append('"'); } } // anonymous namespace -bool InspectorValue::asBoolean(bool*) const +Ref InspectorValue::null() { - return false; + return adoptRef(*new InspectorValue); } -bool InspectorValue::asNumber(double*) const +Ref InspectorValue::create(bool value) { - return false; + return adoptRef(*new InspectorValue(value)); } -bool InspectorValue::asNumber(long*) const +Ref InspectorValue::create(int value) { - return false; + return adoptRef(*new InspectorValue(value)); } -bool InspectorValue::asNumber(int*) const +Ref InspectorValue::create(double value) { - return false; + return adoptRef(*new InspectorValue(value)); } -bool InspectorValue::asNumber(unsigned long*) const +Ref InspectorValue::create(const String& value) { - return false; + return adoptRef(*new InspectorValue(value)); } -bool InspectorValue::asNumber(unsigned int*) const +Ref InspectorValue::create(const char* value) { - return false; + return adoptRef(*new InspectorValue(value)); } -bool InspectorValue::asString(String*) const +bool InspectorValue::asValue(RefPtr & value) { - return false; + value = this; + return true; } -bool InspectorValue::asValue(RefPtr* output) +bool InspectorValue::asObject(RefPtr&) { - *output = this; - return true; + return false; } -bool InspectorValue::asObject(RefPtr*) +bool InspectorValue::asArray(RefPtr&) { return false; } -bool InspectorValue::asArray(RefPtr*) +bool InspectorValue::parseJSON(const String& jsonInput, RefPtr& output) { - return false; + // FIXME: This whole file should just use StringView instead of UChar/length and avoid upconverting. + auto characters = StringView(jsonInput).upconvertedCharacters(); + const UChar* start = characters; + const UChar* end = start + jsonInput.length(); + const UChar* tokenEnd; + auto result = buildValue(start, end, &tokenEnd, 0); + if (!result || tokenEnd != end) + return false; + + output = WTFMove(result); + return true; } -PassRefPtr InspectorValue::asObject() +String InspectorValue::toJSONString() const { - return 0; + StringBuilder result; + result.reserveCapacity(512); + writeJSON(result); + return result.toString(); } -PassRefPtr InspectorValue::asArray() +bool InspectorValue::asBoolean(bool& output) const { - return 0; + if (type() != Type::Boolean) + return false; + + output = m_value.boolean; + return true; } -PassRefPtr InspectorValue::parseJSON(const String& json) +bool InspectorValue::asDouble(double& output) const { - const UChar* start = json.deprecatedCharacters(); - const UChar* end = json.deprecatedCharacters() + json.length(); - const UChar *tokenEnd; - RefPtr value = buildValue(start, end, &tokenEnd, 0); - if (!value || tokenEnd != end) - return 0; - return value.release(); + if (type() != Type::Double) + return false; + + output = m_value.number; + return true; } -String InspectorValue::toJSONString() const +bool InspectorValue::asDouble(float& output) const { - StringBuilder result; - result.reserveCapacity(512); - writeJSON(&result); - return result.toString(); + if (type() != Type::Double) + return false; + + output = static_cast(m_value.number); + return true; } -void InspectorValue::writeJSON(StringBuilder* output) const +bool InspectorValue::asInteger(int& output) const { - ASSERT(m_type == TypeNull); - output->append(nullString, 4); + if (type() != Type::Integer && type() != Type::Double) + return false; + + output = static_cast(m_value.number); + return true; } -bool InspectorBasicValue::asBoolean(bool* output) const +bool InspectorValue::asInteger(unsigned& output) const { - if (type() != TypeBoolean) + if (type() != Type::Integer && type() != Type::Double) return false; - *output = m_boolValue; + + output = static_cast(m_value.number); return true; } -bool InspectorBasicValue::asNumber(double* output) const +bool InspectorValue::asInteger(long& output) const { - if (type() != TypeNumber) + if (type() != Type::Integer && type() != Type::Double) return false; - *output = m_doubleValue; + + output = static_cast(m_value.number); return true; } -bool InspectorBasicValue::asNumber(long* output) const +bool InspectorValue::asInteger(long long& output) const { - if (type() != TypeNumber) + if (type() != Type::Integer && type() != Type::Double) return false; - *output = static_cast(m_doubleValue); + + output = static_cast(m_value.number); return true; } -bool InspectorBasicValue::asNumber(int* output) const +bool InspectorValue::asInteger(unsigned long& output) const { - if (type() != TypeNumber) + if (type() != Type::Integer && type() != Type::Double) return false; - *output = static_cast(m_doubleValue); + + output = static_cast(m_value.number); return true; } -bool InspectorBasicValue::asNumber(unsigned long* output) const +bool InspectorValue::asInteger(unsigned long long& output) const { - if (type() != TypeNumber) + if (type() != Type::Integer && type() != Type::Double) return false; - *output = static_cast(m_doubleValue); + + output = static_cast(m_value.number); return true; } -bool InspectorBasicValue::asNumber(unsigned int* output) const +bool InspectorValue::asString(String& output) const { - if (type() != TypeNumber) + if (type() != Type::String) return false; - *output = static_cast(m_doubleValue); + + output = m_value.string; return true; } -void InspectorBasicValue::writeJSON(StringBuilder* output) const +void InspectorValue::writeJSON(StringBuilder& output) const { - ASSERT(type() == TypeBoolean || type() == TypeNumber); - if (type() == TypeBoolean) { - if (m_boolValue) - output->append(trueString, 4); + switch (m_type) { + case Type::Null: + output.appendLiteral("null"); + break; + case Type::Boolean: + if (m_value.boolean) + output.appendLiteral("true"); else - output->append(falseString, 5); - } else if (type() == TypeNumber) { + output.appendLiteral("false"); + break; + case Type::String: + doubleQuoteString(m_value.string, output); + break; + case Type::Double: + case Type::Integer: { NumberToLStringBuffer buffer; - if (!std::isfinite(m_doubleValue)) { - output->append(nullString, 4); + if (!std::isfinite(m_value.number)) { + output.appendLiteral("null"); return; } - DecimalNumber decimal = m_doubleValue; + DecimalNumber decimal = m_value.number; unsigned length = 0; if (decimal.bufferLengthForStringDecimal() > WTF::NumberToStringBufferLength) { // Not enough room for decimal. Use exponential format. if (decimal.bufferLengthForStringExponential() > WTF::NumberToStringBufferLength) { // Fallback for an abnormal case if it's too little even for exponential. - output->append("NaN", 3); + output.appendLiteral("NaN"); return; } length = decimal.toStringExponential(buffer, WTF::NumberToStringBufferLength); } else length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength); - output->append(buffer, length); + output.append(buffer, length); + break; + } + default: + ASSERT_NOT_REACHED(); } -} - -bool InspectorString::asString(String* output) const -{ - *output = m_stringValue; - return true; -} - -void InspectorString::writeJSON(StringBuilder* output) const -{ - ASSERT(type() == TypeString); - doubleQuoteString(m_stringValue, output); } InspectorObjectBase::~InspectorObjectBase() { } -bool InspectorObjectBase::asObject(RefPtr* output) +bool InspectorObjectBase::asObject(RefPtr& output) { COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast); - *output = static_cast(this); - return true; -} -PassRefPtr InspectorObjectBase::asObject() -{ - return openAccessors(); + output = static_cast(this); + return true; } InspectorObject* InspectorObjectBase::openAccessors() { COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast); + return static_cast(this); } -bool InspectorObjectBase::getBoolean(const String& name, bool* output) const +bool InspectorObjectBase::getBoolean(const String& name, bool& output) const { - RefPtr value = get(name); - if (!value) + RefPtr value; + if (!getValue(name, value)) return false; + return value->asBoolean(output); } -bool InspectorObjectBase::getString(const String& name, String* output) const +bool InspectorObjectBase::getString(const String& name, String& output) const { - RefPtr value = get(name); - if (!value) + RefPtr value; + if (!getValue(name, value)) return false; + return value->asString(output); } -PassRefPtr InspectorObjectBase::getObject(const String& name) const +bool InspectorObjectBase::getObject(const String& name, RefPtr& output) const { - PassRefPtr value = get(name); - if (!value) - return 0; - return value->asObject(); + RefPtr value; + if (!getValue(name, value)) + return false; + + return value->asObject(output); } -PassRefPtr InspectorObjectBase::getArray(const String& name) const +bool InspectorObjectBase::getArray(const String& name, RefPtr& output) const { - PassRefPtr value = get(name); - if (!value) - return 0; - return value->asArray(); + RefPtr value; + if (!getValue(name, value)) + return false; + + return value->asArray(output); } -PassRefPtr InspectorObjectBase::get(const String& name) const +bool InspectorObjectBase::getValue(const String& name, RefPtr& output) const { - Dictionary::const_iterator it = m_data.find(name); - if (it == m_data.end()) - return 0; - return it->value; + Dictionary::const_iterator findResult = m_map.find(name); + if (findResult == m_map.end()) + return false; + + output = findResult->value; + return true; } void InspectorObjectBase::remove(const String& name) { - m_data.remove(name); - for (size_t i = 0; i < m_order.size(); ++i) { - if (m_order[i] == name) { - m_order.remove(i); - break; - } - } + m_map.remove(name); + m_order.removeFirst(name); } -void InspectorObjectBase::writeJSON(StringBuilder* output) const +void InspectorObjectBase::writeJSON(StringBuilder& output) const { - output->append('{'); + output.append('{'); for (size_t i = 0; i < m_order.size(); ++i) { - Dictionary::const_iterator it = m_data.find(m_order[i]); - ASSERT(it != m_data.end()); + auto findResult = m_map.find(m_order[i]); + ASSERT(findResult != m_map.end()); if (i) - output->append(','); - doubleQuoteString(it->key, output); - output->append(':'); - it->value->writeJSON(output); + output.append(','); + doubleQuoteString(findResult->key, output); + output.append(':'); + findResult->value->writeJSON(output); } - output->append('}'); + output.append('}'); } InspectorObjectBase::InspectorObjectBase() - : InspectorValue(TypeObject) - , m_data() + : Inspector::InspectorValue(Type::Object) + , m_map() , m_order() { } @@ -757,80 +778,44 @@ InspectorArrayBase::~InspectorArrayBase() { } -bool InspectorArrayBase::asArray(RefPtr* output) +bool InspectorArrayBase::asArray(RefPtr& output) { COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast); - *output = static_cast(this); + output = static_cast(this); return true; } -PassRefPtr InspectorArrayBase::asArray() -{ - COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast); - return static_cast(this); -} - -void InspectorArrayBase::writeJSON(StringBuilder* output) const +void InspectorArrayBase::writeJSON(StringBuilder& output) const { - output->append('['); - for (Vector>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) { - if (it != m_data.begin()) - output->append(','); + output.append('['); + for (Vector>::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it != m_map.begin()) + output.append(','); (*it)->writeJSON(output); } - output->append(']'); + output.append(']'); } InspectorArrayBase::InspectorArrayBase() - : InspectorValue(TypeArray) - , m_data() -{ -} - -PassRefPtr InspectorArrayBase::get(size_t index) -{ - ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); - return m_data[index]; -} - -PassRefPtr InspectorObject::create() -{ - return adoptRef(new InspectorObject); -} - -PassRefPtr InspectorArray::create() -{ - return adoptRef(new InspectorArray); -} - -PassRefPtr InspectorValue::null() -{ - return adoptRef(new InspectorValue); -} - -PassRefPtr InspectorString::create(const String& value) -{ - return adoptRef(new InspectorString(value)); -} - -PassRefPtr InspectorString::create(const char* value) + : InspectorValue(Type::Array) + , m_map() { - return adoptRef(new InspectorString(value)); } -PassRefPtr InspectorBasicValue::create(bool value) +RefPtr InspectorArrayBase::get(size_t index) const { - return adoptRef(new InspectorBasicValue(value)); + ASSERT_WITH_SECURITY_IMPLICATION(index < m_map.size()); + return m_map[index]; } -PassRefPtr InspectorBasicValue::create(int value) +Ref InspectorObject::create() { - return adoptRef(new InspectorBasicValue(value)); + return adoptRef(*new InspectorObject); } -PassRefPtr InspectorBasicValue::create(double value) +Ref InspectorArray::create() { - return adoptRef(new InspectorBasicValue(value)); + return adoptRef(*new InspectorArray); } } // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/InspectorValues.h b/Source/JavaScriptCore/inspector/InspectorValues.h index 06c5dfe97..6687bbaf6 100644 --- a/Source/JavaScriptCore/inspector/InspectorValues.h +++ b/Source/JavaScriptCore/inspector/InspectorValues.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -28,10 +29,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorValues_h -#define InspectorValues_h +#pragma once -#include +#include "JSExportMacros.h" +#include #include #include #include @@ -41,96 +42,121 @@ namespace Inspector { class InspectorArray; +class InspectorArrayBase; class InspectorObject; +class InspectorObjectBase; class JS_EXPORT_PRIVATE InspectorValue : public RefCounted { public: static const int maxDepth = 1000; - InspectorValue() : m_type(TypeNull) { } - virtual ~InspectorValue() { } - - static PassRefPtr null(); + virtual ~InspectorValue() + { + switch (m_type) { + case Type::Null: + case Type::Boolean: + case Type::Double: + case Type::Integer: + break; + case Type::String: + if (m_value.string) + m_value.string->deref(); + break; + case Type::Object: + case Type::Array: + break; + } + } - typedef enum { - TypeNull = 0, - TypeBoolean, - TypeNumber, - TypeString, - TypeObject, - TypeArray - } Type; + static Ref null(); + static Ref create(bool); + static Ref create(int); + static Ref create(double); + static Ref create(const String&); + static Ref create(const char*); + + enum class Type { + Null = 0, + Boolean, + Double, + Integer, + String, + Object, + Array, + }; Type type() const { return m_type; } + bool isNull() const { return m_type == Type::Null; } - bool isNull() const { return m_type == TypeNull; } + bool asBoolean(bool&) const; + bool asInteger(int&) const; + bool asInteger(unsigned&) const; + bool asInteger(long&) const; + bool asInteger(long long&) const; + bool asInteger(unsigned long&) const; + bool asInteger(unsigned long long&) const; + bool asDouble(double&) const; + bool asDouble(float&) const; + bool asString(String&) const; + bool asValue(RefPtr&); - virtual bool asBoolean(bool* output) const; - virtual bool asNumber(double* output) const; - virtual bool asNumber(long* output) const; - virtual bool asNumber(int* output) const; - virtual bool asNumber(unsigned long* output) const; - virtual bool asNumber(unsigned int* output) const; - virtual bool asString(String* output) const; - virtual bool asValue(RefPtr* output); - virtual bool asObject(RefPtr* output); - virtual bool asArray(RefPtr* output); - virtual PassRefPtr asObject(); - virtual PassRefPtr asArray(); + virtual bool asObject(RefPtr&); + virtual bool asArray(RefPtr&); - static PassRefPtr parseJSON(const String& json); + static bool parseJSON(const String& jsonInput, RefPtr& output); String toJSONString() const; - virtual void writeJSON(StringBuilder* output) const; + virtual void writeJSON(StringBuilder& output) const; protected: - explicit InspectorValue(Type type) : m_type(type) { } - -private: - Type m_type; -}; - -class JS_EXPORT_PRIVATE InspectorBasicValue : public InspectorValue { -public: - - static PassRefPtr create(bool); - static PassRefPtr create(int); - static PassRefPtr create(double); + InspectorValue() + : m_type(Type::Null) { } - virtual bool asBoolean(bool* output) const override; - virtual bool asNumber(double* output) const override; - virtual bool asNumber(long* output) const override; - virtual bool asNumber(int* output) const override; - virtual bool asNumber(unsigned long* output) const override; - virtual bool asNumber(unsigned* output) const override; + explicit InspectorValue(Type type) + : m_type(type) { } - virtual void writeJSON(StringBuilder* output) const override; - -private: - explicit InspectorBasicValue(bool value) : InspectorValue(TypeBoolean), m_boolValue(value) { } - explicit InspectorBasicValue(int value) : InspectorValue(TypeNumber), m_doubleValue((double)value) { } - explicit InspectorBasicValue(double value) : InspectorValue(TypeNumber), m_doubleValue(value) { } + explicit InspectorValue(bool value) + : m_type(Type::Boolean) + { + m_value.boolean = value; + } - union { - bool m_boolValue; - double m_doubleValue; - }; -}; + explicit InspectorValue(int value) + : m_type(Type::Integer) + { + m_value.number = static_cast(value); + } -class JS_EXPORT_PRIVATE InspectorString : public InspectorValue { -public: - static PassRefPtr create(const String&); - static PassRefPtr create(const char*); + explicit InspectorValue(double value) + : m_type(Type::Double) + { + m_value.number = value; + } - virtual bool asString(String* output) const override; + explicit InspectorValue(const String& value) + : m_type(Type::String) + { + m_value.string = value.impl(); + if (m_value.string) + m_value.string->ref(); + } - virtual void writeJSON(StringBuilder* output) const override; + explicit InspectorValue(const char* value) + : m_type(Type::String) + { + String wrapper(value); + m_value.string = wrapper.impl(); + if (m_value.string) + m_value.string->ref(); + } private: - explicit InspectorString(const String& value) : InspectorValue(TypeString), m_stringValue(value) { } - explicit InspectorString(const char* value) : InspectorValue(TypeString), m_stringValue(value) { } - - String m_stringValue; + Type m_type { Type::Null }; + union { + bool boolean; + double number; + StringImpl* string; + } m_value; }; class JS_EXPORT_PRIVATE InspectorObjectBase : public InspectorValue { @@ -141,63 +167,77 @@ public: typedef Dictionary::iterator iterator; typedef Dictionary::const_iterator const_iterator; - virtual PassRefPtr asObject() override; InspectorObject* openAccessors(); protected: virtual ~InspectorObjectBase(); - virtual bool asObject(RefPtr* output) override; + bool asObject(RefPtr& output) override; + // FIXME: use templates to reduce the amount of duplicated set*() methods. void setBoolean(const String& name, bool); - void setNumber(const String& name, double); + void setInteger(const String& name, int); + void setDouble(const String& name, double); void setString(const String& name, const String&); - void setValue(const String& name, PassRefPtr); - void setObject(const String& name, PassRefPtr); - void setArray(const String& name, PassRefPtr); + void setValue(const String& name, RefPtr&&); + void setObject(const String& name, RefPtr&&); + void setArray(const String& name, RefPtr&&); iterator find(const String& name); const_iterator find(const String& name) const; - bool getBoolean(const String& name, bool* output) const; - template bool getNumber(const String& name, T* output) const + + // FIXME: use templates to reduce the amount of duplicated get*() methods. + bool getBoolean(const String& name, bool& output) const; + template bool getDouble(const String& name, T& output) const + { + RefPtr value; + if (!getValue(name, value)) + return false; + + return value->asDouble(output); + } + template bool getInteger(const String& name, T& output) const { - RefPtr value = get(name); - if (!value) + RefPtr value; + if (!getValue(name, value)) return false; - return value->asNumber(output); + + return value->asInteger(output); } - bool getString(const String& name, String* output) const; - PassRefPtr getObject(const String& name) const; - PassRefPtr getArray(const String& name) const; - PassRefPtr get(const String& name) const; + + bool getString(const String& name, String& output) const; + bool getObject(const String& name, RefPtr&) const; + bool getArray(const String& name, RefPtr&) const; + bool getValue(const String& name, RefPtr&) const; void remove(const String& name); - virtual void writeJSON(StringBuilder* output) const override; + void writeJSON(StringBuilder& output) const override; - iterator begin() { return m_data.begin(); } - iterator end() { return m_data.end(); } - const_iterator begin() const { return m_data.begin(); } - const_iterator end() const { return m_data.end(); } + iterator begin() { return m_map.begin(); } + iterator end() { return m_map.end(); } + const_iterator begin() const { return m_map.begin(); } + const_iterator end() const { return m_map.end(); } - int size() const { return m_data.size(); } + int size() const { return m_map.size(); } protected: InspectorObjectBase(); private: - Dictionary m_data; + Dictionary m_map; Vector m_order; }; class InspectorObject : public InspectorObjectBase { public: - static JS_EXPORT_PRIVATE PassRefPtr create(); + static JS_EXPORT_PRIVATE Ref create(); using InspectorObjectBase::asObject; using InspectorObjectBase::setBoolean; - using InspectorObjectBase::setNumber; + using InspectorObjectBase::setInteger; + using InspectorObjectBase::setDouble; using InspectorObjectBase::setString; using InspectorObjectBase::setValue; using InspectorObjectBase::setObject; @@ -205,11 +245,12 @@ public: using InspectorObjectBase::find; using InspectorObjectBase::getBoolean; - using InspectorObjectBase::getNumber; + using InspectorObjectBase::getInteger; + using InspectorObjectBase::getDouble; using InspectorObjectBase::getString; using InspectorObjectBase::getObject; using InspectorObjectBase::getArray; - using InspectorObjectBase::get; + using InspectorObjectBase::getValue; using InspectorObjectBase::remove; @@ -225,48 +266,46 @@ public: typedef Vector>::iterator iterator; typedef Vector>::const_iterator const_iterator; - virtual PassRefPtr asArray() override; - - unsigned length() const { return m_data.size(); } + unsigned length() const { return static_cast(m_map.size()); } protected: virtual ~InspectorArrayBase(); - virtual bool asArray(RefPtr* output) override; + bool asArray(RefPtr&) override; void pushBoolean(bool); - void pushInt(int); - void pushNumber(double); + void pushInteger(int); + void pushDouble(double); void pushString(const String&); - void pushValue(PassRefPtr); - void pushObject(PassRefPtr); - void pushArray(PassRefPtr); + void pushValue(RefPtr&&); + void pushObject(RefPtr&&); + void pushArray(RefPtr&&); - PassRefPtr get(size_t index); + RefPtr get(size_t index) const; - virtual void writeJSON(StringBuilder* output) const override; + void writeJSON(StringBuilder& output) const override; - iterator begin() { return m_data.begin(); } - iterator end() { return m_data.end(); } - const_iterator begin() const { return m_data.begin(); } - const_iterator end() const { return m_data.end(); } + iterator begin() { return m_map.begin(); } + iterator end() { return m_map.end(); } + const_iterator begin() const { return m_map.begin(); } + const_iterator end() const { return m_map.end(); } protected: InspectorArrayBase(); private: - Vector> m_data; + Vector> m_map; }; class InspectorArray : public InspectorArrayBase { public: - static JS_EXPORT_PRIVATE PassRefPtr create(); + static JS_EXPORT_PRIVATE Ref create(); using InspectorArrayBase::asArray; using InspectorArrayBase::pushBoolean; - using InspectorArrayBase::pushInt; - using InspectorArrayBase::pushNumber; + using InspectorArrayBase::pushInteger; + using InspectorArrayBase::pushDouble; using InspectorArrayBase::pushString; using InspectorArrayBase::pushValue; using InspectorArrayBase::pushObject; @@ -281,88 +320,91 @@ public: inline InspectorObjectBase::iterator InspectorObjectBase::find(const String& name) { - return m_data.find(name); + return m_map.find(name); } inline InspectorObjectBase::const_iterator InspectorObjectBase::find(const String& name) const { - return m_data.find(name); + return m_map.find(name); } inline void InspectorObjectBase::setBoolean(const String& name, bool value) { - setValue(name, InspectorBasicValue::create(value)); + setValue(name, InspectorValue::create(value)); } -inline void InspectorObjectBase::setNumber(const String& name, double value) +inline void InspectorObjectBase::setInteger(const String& name, int value) { - setValue(name, InspectorBasicValue::create(value)); + setValue(name, InspectorValue::create(value)); +} + +inline void InspectorObjectBase::setDouble(const String& name, double value) +{ + setValue(name, InspectorValue::create(value)); } inline void InspectorObjectBase::setString(const String& name, const String& value) { - setValue(name, InspectorString::create(value)); + setValue(name, InspectorValue::create(value)); } -inline void InspectorObjectBase::setValue(const String& name, PassRefPtr value) +inline void InspectorObjectBase::setValue(const String& name, RefPtr&& value) { ASSERT(value); - if (m_data.set(name, value).isNewEntry) + if (m_map.set(name, WTFMove(value)).isNewEntry) m_order.append(name); } -inline void InspectorObjectBase::setObject(const String& name, PassRefPtr value) +inline void InspectorObjectBase::setObject(const String& name, RefPtr&& value) { ASSERT(value); - if (m_data.set(name, value).isNewEntry) + if (m_map.set(name, WTFMove(value)).isNewEntry) m_order.append(name); } -inline void InspectorObjectBase::setArray(const String& name, PassRefPtr value) +inline void InspectorObjectBase::setArray(const String& name, RefPtr&& value) { ASSERT(value); - if (m_data.set(name, value).isNewEntry) + if (m_map.set(name, WTFMove(value)).isNewEntry) m_order.append(name); } inline void InspectorArrayBase::pushBoolean(bool value) { - m_data.append(InspectorBasicValue::create(value)); + m_map.append(InspectorValue::create(value)); } -inline void InspectorArrayBase::pushInt(int value) +inline void InspectorArrayBase::pushInteger(int value) { - m_data.append(InspectorBasicValue::create(value)); + m_map.append(InspectorValue::create(value)); } -inline void InspectorArrayBase::pushNumber(double value) +inline void InspectorArrayBase::pushDouble(double value) { - m_data.append(InspectorBasicValue::create(value)); + m_map.append(InspectorValue::create(value)); } inline void InspectorArrayBase::pushString(const String& value) { - m_data.append(InspectorString::create(value)); + m_map.append(InspectorValue::create(value)); } -inline void InspectorArrayBase::pushValue(PassRefPtr value) +inline void InspectorArrayBase::pushValue(RefPtr&& value) { ASSERT(value); - m_data.append(value); + m_map.append(WTFMove(value)); } -inline void InspectorArrayBase::pushObject(PassRefPtr value) +inline void InspectorArrayBase::pushObject(RefPtr&& value) { ASSERT(value); - m_data.append(value); + m_map.append(WTFMove(value)); } -inline void InspectorArrayBase::pushArray(PassRefPtr value) +inline void InspectorArrayBase::pushArray(RefPtr&& value) { ASSERT(value); - m_data.append(value); + m_map.append(WTFMove(value)); } } // namespace Inspector - -#endif // !defined(InspectorValues_h) diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp new file mode 100644 index 000000000..1f903bae7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectConsoleClient.h" + +#include "ConsoleMessage.h" +#include "InspectorConsoleAgent.h" +#include "InspectorDebuggerAgent.h" +#include "InspectorScriptProfilerAgent.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" + +using namespace JSC; + +namespace Inspector { + +#if !LOG_DISABLED +static bool sLogToSystemConsole = true; +#else +static bool sLogToSystemConsole = false; +#endif + +bool JSGlobalObjectConsoleClient::logToSystemConsole() +{ + return sLogToSystemConsole; +} + +void JSGlobalObjectConsoleClient::setLogToSystemConsole(bool shouldLog) +{ + sLogToSystemConsole = shouldLog; +} + +JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient(InspectorConsoleAgent* consoleAgent, InspectorDebuggerAgent* debuggerAgent, InspectorScriptProfilerAgent* scriptProfilerAgent) + : ConsoleClient() + , m_consoleAgent(consoleAgent) + , m_debuggerAgent(debuggerAgent) + , m_scriptProfilerAgent(scriptProfilerAgent) +{ +} + +void JSGlobalObjectConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref&& arguments) +{ + if (JSGlobalObjectConsoleClient::logToSystemConsole()) + ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, exec, arguments.copyRef()); + + String message; + arguments->getFirstArgumentAsString(message); + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, type, level, message, WTFMove(arguments), exec)); +} + +void JSGlobalObjectConsoleClient::count(ExecState* exec, Ref&& arguments) +{ + m_consoleAgent->count(exec, WTFMove(arguments)); +} + +void JSGlobalObjectConsoleClient::profile(JSC::ExecState*, const String& title) +{ + if (!m_consoleAgent->enabled()) + return; + + // Allow duplicate unnamed profiles. Disallow duplicate named profiles. + if (!title.isEmpty()) { + for (auto& existingTitle : m_profiles) { + if (existingTitle == title) { + // FIXME: Send an enum to the frontend for localization? + String warning = title.isEmpty() ? ASCIILiteral("Unnamed Profile already exists") : makeString("Profile \"", title, "\" already exists"); + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Profile, MessageLevel::Warning, warning)); + return; + } + } + } + + m_profiles.append(title); + startConsoleProfile(); +} + +void JSGlobalObjectConsoleClient::profileEnd(JSC::ExecState*, const String& title) +{ + if (!m_consoleAgent->enabled()) + return; + + // Stop profiles in reverse order. If the title is empty, then stop the last profile. + // Otherwise, match the title of the profile to stop. + for (ptrdiff_t i = m_profiles.size() - 1; i >= 0; --i) { + if (title.isEmpty() || m_profiles[i] == title) { + m_profiles.remove(i); + if (m_profiles.isEmpty()) + stopConsoleProfile(); + return; + } + } + + // FIXME: Send an enum to the frontend for localization? + String warning = title.isEmpty() ? ASCIILiteral("No profiles exist") : makeString("Profile \"", title, "\" does not exist"); + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::ProfileEnd, MessageLevel::Warning, warning)); +} + +void JSGlobalObjectConsoleClient::startConsoleProfile() +{ + // FIXME: Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection + m_scriptProfilerAgent->programmaticCaptureStarted(); + + m_profileRestoreBreakpointActiveValue = m_debuggerAgent->breakpointsActive(); + + ErrorString unused; + m_debuggerAgent->setBreakpointsActive(unused, false); + + const bool includeSamples = true; + m_scriptProfilerAgent->startTracking(unused, &includeSamples); +} + +void JSGlobalObjectConsoleClient::stopConsoleProfile() +{ + ErrorString unused; + m_scriptProfilerAgent->stopTracking(unused); + + m_debuggerAgent->setBreakpointsActive(unused, m_profileRestoreBreakpointActiveValue); + + // FIXME: Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection + m_scriptProfilerAgent->programmaticCaptureStopped(); +} + +void JSGlobalObjectConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String& title) +{ + m_consoleAgent->takeHeapSnapshot(title); +} + +void JSGlobalObjectConsoleClient::time(ExecState*, const String& title) +{ + m_consoleAgent->startTiming(title); +} + +void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title) +{ + m_consoleAgent->stopTiming(title, createScriptCallStackForConsole(exec, 1)); +} + +void JSGlobalObjectConsoleClient::timeStamp(ExecState*, Ref&&) +{ + // FIXME: JSContext inspection needs a timeline. + warnUnimplemented(ASCIILiteral("console.timeStamp")); +} + +void JSGlobalObjectConsoleClient::warnUnimplemented(const String& method) +{ + String message = method + " is currently ignored in JavaScript context inspection."; + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, message)); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h b/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h new file mode 100644 index 000000000..d9b259cb6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "ConsoleClient.h" +#include +#include + +namespace Inspector { + +class InspectorConsoleAgent; +class InspectorDebuggerAgent; +class InspectorScriptProfilerAgent; + +class JSGlobalObjectConsoleClient final : public JSC::ConsoleClient { + WTF_MAKE_FAST_ALLOCATED; +public: + explicit JSGlobalObjectConsoleClient(InspectorConsoleAgent*, InspectorDebuggerAgent*, InspectorScriptProfilerAgent*); + virtual ~JSGlobalObjectConsoleClient() { } + + static bool logToSystemConsole(); + static void setLogToSystemConsole(bool); + +protected: + void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref&&) override; + void count(JSC::ExecState*, Ref&&) override; + void profile(JSC::ExecState*, const String& title) override; + void profileEnd(JSC::ExecState*, const String& title) override; + void takeHeapSnapshot(JSC::ExecState*, const String& title) override; + void time(JSC::ExecState*, const String& title) override; + void timeEnd(JSC::ExecState*, const String& title) override; + void timeStamp(JSC::ExecState*, Ref&&) override; + +private: + void warnUnimplemented(const String& method); + void internalAddMessage(MessageType, MessageLevel, JSC::ExecState*, Ref&&); + + void startConsoleProfile(); + void stopConsoleProfile(); + + InspectorConsoleAgent* m_consoleAgent; + InspectorDebuggerAgent* m_debuggerAgent; + InspectorScriptProfilerAgent* m_scriptProfilerAgent; + Vector m_profiles; + bool m_profileRestoreBreakpointActiveValue { false }; +}; + +} diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp new file mode 100644 index 000000000..313730a57 --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp @@ -0,0 +1,315 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectInspectorController.h" + +#include "Completion.h" +#include "ConsoleMessage.h" +#include "ErrorHandlingScope.h" +#include "Exception.h" +#include "InjectedScriptHost.h" +#include "InjectedScriptManager.h" +#include "InspectorAgent.h" +#include "InspectorBackendDispatcher.h" +#include "InspectorFrontendChannel.h" +#include "InspectorFrontendRouter.h" +#include "InspectorHeapAgent.h" +#include "InspectorScriptProfilerAgent.h" +#include "JSCInlines.h" +#include "JSGlobalObject.h" +#include "JSGlobalObjectConsoleAgent.h" +#include "JSGlobalObjectConsoleClient.h" +#include "JSGlobalObjectDebuggerAgent.h" +#include "JSGlobalObjectRuntimeAgent.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" +#include + +#if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK)) +#include +#include +#include +#endif + +#if ENABLE(REMOTE_INSPECTOR) +#include "JSGlobalObjectDebuggable.h" +#include "RemoteInspector.h" +#endif + +using namespace JSC; + +namespace Inspector { + +JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObject& globalObject) + : m_globalObject(globalObject) + , m_injectedScriptManager(std::make_unique(*this, InjectedScriptHost::create())) + , m_executionStopwatch(Stopwatch::create()) + , m_scriptDebugServer(globalObject) + , m_frontendRouter(FrontendRouter::create()) + , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef())) +{ + AgentContext baseContext = { + *this, + *m_injectedScriptManager, + m_frontendRouter.get(), + m_backendDispatcher.get() + }; + + JSAgentContext context = { + baseContext, + globalObject + }; + + auto inspectorAgent = std::make_unique(context); + auto runtimeAgent = std::make_unique(context); + auto heapAgent = std::make_unique(context); + auto consoleAgent = std::make_unique(context, heapAgent.get()); + auto debuggerAgent = std::make_unique(context, consoleAgent.get()); + auto scriptProfilerAgent = std::make_unique(context); + + m_inspectorAgent = inspectorAgent.get(); + m_debuggerAgent = debuggerAgent.get(); + m_consoleAgent = consoleAgent.get(); + m_consoleClient = std::make_unique(m_consoleAgent, m_debuggerAgent, scriptProfilerAgent.get()); + + m_agents.append(WTFMove(inspectorAgent)); + m_agents.append(WTFMove(runtimeAgent)); + m_agents.append(WTFMove(consoleAgent)); + m_agents.append(WTFMove(debuggerAgent)); + m_agents.append(WTFMove(heapAgent)); + m_agents.append(WTFMove(scriptProfilerAgent)); + + m_executionStopwatch->start(); +} + +JSGlobalObjectInspectorController::~JSGlobalObjectInspectorController() +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_augmentingClient) + m_augmentingClient->inspectorControllerDestroyed(); +#endif +} + +void JSGlobalObjectInspectorController::globalObjectDestroyed() +{ + ASSERT(!m_frontendRouter->hasFrontends()); + + m_injectedScriptManager->disconnect(); + + m_agents.discardValues(); +} + +void JSGlobalObjectInspectorController::connectFrontend(FrontendChannel* frontendChannel, bool isAutomaticInspection) +{ + ASSERT_ARG(frontendChannel, frontendChannel); + + m_isAutomaticInspection = isAutomaticInspection; + + bool connectedFirstFrontend = !m_frontendRouter->hasFrontends(); + m_frontendRouter->connectFrontend(frontendChannel); + + if (!connectedFirstFrontend) + return; + + // Keep the JSGlobalObject and VM alive while we are debugging it. + m_strongVM = &m_globalObject.vm(); + m_strongGlobalObject.set(m_globalObject.vm(), &m_globalObject); + + // FIXME: change this to notify agents which frontend has connected (by id). + m_agents.didCreateFrontendAndBackend(nullptr, nullptr); + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + m_inspectorAgent->activateExtraDomains(m_agents.extraDomains()); + + if (m_augmentingClient) + m_augmentingClient->inspectorConnected(); +#endif +} + +void JSGlobalObjectInspectorController::disconnectFrontend(FrontendChannel* frontendChannel) +{ + ASSERT_ARG(frontendChannel, frontendChannel); + + // FIXME: change this to notify agents which frontend has disconnected (by id). + m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectorDestroyed); + + m_frontendRouter->disconnectFrontend(frontendChannel); + + m_isAutomaticInspection = false; + + bool disconnectedLastFrontend = !m_frontendRouter->hasFrontends(); + if (!disconnectedLastFrontend) + return; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_augmentingClient) + m_augmentingClient->inspectorDisconnected(); +#endif + + // Remove our JSGlobalObject and VM references, we are done debugging it. + m_strongGlobalObject.clear(); + m_strongVM = nullptr; +} + +void JSGlobalObjectInspectorController::dispatchMessageFromFrontend(const String& message) +{ + m_backendDispatcher->dispatch(message); +} + +void JSGlobalObjectInspectorController::pause() +{ + ErrorString dummyError; + m_debuggerAgent->enable(dummyError); + m_debuggerAgent->pause(dummyError); +} + +void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack& callStack) +{ +#if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK)) + static const int framesToShow = 31; + static const int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException. + + void* samples[framesToShow + framesToSkip]; + int frames = framesToShow + framesToSkip; + WTFGetBacktrace(samples, &frames); + + void** stack = samples + framesToSkip; + int size = frames - framesToSkip; + for (int i = 0; i < size; ++i) { + const char* mangledName = nullptr; + char* cxaDemangled = nullptr; + Dl_info info; + if (dladdr(stack[i], &info) && info.dli_sname) + mangledName = info.dli_sname; + if (mangledName) + cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, nullptr); + if (mangledName || cxaDemangled) + callStack.append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), noSourceID, 0, 0)); + else + callStack.append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), noSourceID, 0, 0)); + free(cxaDemangled); + } +#else + UNUSED_PARAM(callStack); +#endif +} + +void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, Exception* exception) +{ + VM& vm = exec->vm(); + if (isTerminatedExecutionException(vm, exception)) + return; + + auto scope = DECLARE_CATCH_SCOPE(vm); + ErrorHandlingScope errorScope(vm); + + Ref callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture); + if (includesNativeCallStackWhenReportingExceptions()) + appendAPIBacktrace(callStack.get()); + + // FIXME: Web Inspector: Should not evaluate JavaScript handling exceptions + // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception. + String errorMessage = exception->value().toWTFString(exec); + scope.clearException(); + + if (JSGlobalObjectConsoleClient::logToSystemConsole()) { + if (callStack->size()) { + const ScriptCallFrame& callFrame = callStack->at(0); + ConsoleClient::printConsoleMessage(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, callFrame.sourceURL(), callFrame.lineNumber(), callFrame.columnNumber()); + } else + ConsoleClient::printConsoleMessage(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, String(), 0, 0); + } + + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, WTFMove(callStack))); +} + +ConsoleClient* JSGlobalObjectInspectorController::consoleClient() const +{ + return m_consoleClient.get(); +} + +bool JSGlobalObjectInspectorController::developerExtrasEnabled() const +{ +#if ENABLE(REMOTE_INSPECTOR) + if (!RemoteInspector::singleton().enabled()) + return false; + + if (!m_globalObject.inspectorDebuggable().remoteDebuggingAllowed()) + return false; +#endif + + return true; +} + +InspectorFunctionCallHandler JSGlobalObjectInspectorController::functionCallHandler() const +{ + return JSC::call; +} + +InspectorEvaluateHandler JSGlobalObjectInspectorController::evaluateHandler() const +{ + return JSC::evaluate; +} + +void JSGlobalObjectInspectorController::frontendInitialized() +{ +#if ENABLE(REMOTE_INSPECTOR) + if (m_isAutomaticInspection) + m_globalObject.inspectorDebuggable().unpauseForInitializedInspector(); +#endif +} + +Ref JSGlobalObjectInspectorController::executionStopwatch() +{ + return m_executionStopwatch.copyRef(); +} + +JSGlobalObjectScriptDebugServer& JSGlobalObjectInspectorController::scriptDebugServer() +{ + return m_scriptDebugServer; +} + +VM& JSGlobalObjectInspectorController::vm() +{ + return m_globalObject.vm(); +} + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +void JSGlobalObjectInspectorController::appendExtraAgent(std::unique_ptr agent) +{ + String domainName = agent->domainName(); + + // FIXME: change this to notify agents which frontend has connected (by id). + agent->didCreateFrontendAndBackend(nullptr, nullptr); + + m_agents.appendExtraAgent(WTFMove(agent)); + + m_inspectorAgent->activateExtraDomain(domainName); +} +#endif + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h new file mode 100644 index 000000000..26a568f60 --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorAgentRegistry.h" +#include "InspectorEnvironment.h" +#include "InspectorFrontendRouter.h" +#include "JSGlobalObjectScriptDebugServer.h" +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "AugmentableInspectorController.h" +#endif + +namespace JSC { +class ConsoleClient; +class Exception; +class ExecState; +class JSGlobalObject; +} + +namespace Inspector { + +class BackendDispatcher; +class FrontendChannel; +class InjectedScriptManager; +class InspectorAgent; +class InspectorConsoleAgent; +class InspectorDebuggerAgent; +class InspectorScriptProfilerAgent; +class JSGlobalObjectConsoleClient; +class ScriptCallStack; + +class JSGlobalObjectInspectorController final + : public InspectorEnvironment +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + , public AugmentableInspectorController +#endif +{ + WTF_MAKE_NONCOPYABLE(JSGlobalObjectInspectorController); + WTF_MAKE_FAST_ALLOCATED; +public: + JSGlobalObjectInspectorController(JSC::JSGlobalObject&); + ~JSGlobalObjectInspectorController(); + + void connectFrontend(FrontendChannel*, bool isAutomaticInspection); + void disconnectFrontend(FrontendChannel*); + + void dispatchMessageFromFrontend(const String&); + + void globalObjectDestroyed(); + + bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions; } + void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack) { m_includeNativeCallStackWithExceptions = includesNativeCallStack; } + + void pause(); + void reportAPIException(JSC::ExecState*, JSC::Exception*); + + JSC::ConsoleClient* consoleClient() const; + + bool developerExtrasEnabled() const override; + bool canAccessInspectedScriptState(JSC::ExecState*) const override { return true; } + InspectorFunctionCallHandler functionCallHandler() const override; + InspectorEvaluateHandler evaluateHandler() const override; + void frontendInitialized() override; + Ref executionStopwatch() override; + JSGlobalObjectScriptDebugServer& scriptDebugServer() override; + JSC::VM& vm() override; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + AugmentableInspectorControllerClient* augmentableInspectorControllerClient() const override { return m_augmentingClient; } + void setAugmentableInspectorControllerClient(AugmentableInspectorControllerClient* client) override { m_augmentingClient = client; } + + const FrontendRouter& frontendRouter() const override { return m_frontendRouter.get(); } + BackendDispatcher& backendDispatcher() override { return m_backendDispatcher.get(); } + void appendExtraAgent(std::unique_ptr) override; +#endif + +private: + void appendAPIBacktrace(ScriptCallStack&); + + JSC::JSGlobalObject& m_globalObject; + std::unique_ptr m_injectedScriptManager; + std::unique_ptr m_consoleClient; + Ref m_executionStopwatch; + JSGlobalObjectScriptDebugServer m_scriptDebugServer; + + AgentRegistry m_agents; + InspectorAgent* m_inspectorAgent { nullptr }; + InspectorConsoleAgent* m_consoleAgent { nullptr }; + InspectorDebuggerAgent* m_debuggerAgent { nullptr }; + + Ref m_frontendRouter; + Ref m_backendDispatcher; + + // Used to keep the JSGlobalObject and VM alive while we are debugging it. + JSC::Strong m_strongGlobalObject; + RefPtr m_strongVM; + + bool m_includeNativeCallStackWithExceptions { true }; + bool m_isAutomaticInspection { false }; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + AugmentableInspectorControllerClient* m_augmentingClient { nullptr }; +#endif +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp new file mode 100644 index 000000000..667438b5b --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectScriptDebugServer.h" + +#include "EventLoop.h" +#include "JSCInlines.h" +#include "JSLock.h" + +using namespace JSC; + +namespace Inspector { + +JSGlobalObjectScriptDebugServer::JSGlobalObjectScriptDebugServer(JSGlobalObject& globalObject) + : ScriptDebugServer(globalObject.vm()) + , m_globalObject(globalObject) +{ +} + +void JSGlobalObjectScriptDebugServer::attachDebugger() +{ + attach(&m_globalObject); +} + +void JSGlobalObjectScriptDebugServer::detachDebugger(bool isBeingDestroyed) +{ + detach(&m_globalObject, isBeingDestroyed ? Debugger::GlobalObjectIsDestructing : Debugger::TerminatingDebuggingSession); + if (!isBeingDestroyed) + recompileAllJSFunctions(); +} + +void JSGlobalObjectScriptDebugServer::runEventLoopWhilePaused() +{ + // Drop all locks so another thread can work in the VM while we are nested. + JSC::JSLock::DropAllLocks dropAllLocks(&m_globalObject.vm()); + + EventLoop loop; + while (!m_doneProcessingDebuggerEvents && !loop.ended()) + loop.cycle(); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h new file mode 100644 index 000000000..6c63be080 --- /dev/null +++ b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "ScriptDebugServer.h" + +namespace Inspector { + +class JSGlobalObjectScriptDebugServer final : public ScriptDebugServer { + WTF_MAKE_NONCOPYABLE(JSGlobalObjectScriptDebugServer); +public: + JSGlobalObjectScriptDebugServer(JSC::JSGlobalObject&); + virtual ~JSGlobalObjectScriptDebugServer() { } + + JSC::JSGlobalObject& globalObject() const { return m_globalObject; } + +private: + void attachDebugger() override; + void detachDebugger(bool isBeingDestroyed) override; + + void didPause(JSC::JSGlobalObject*) override { } + void didContinue(JSC::JSGlobalObject*) override { } + void runEventLoopWhilePaused() override; + bool isContentScript(JSC::ExecState*) const override { return false; } + + // NOTE: Currently all exceptions are reported at the API boundary through reportAPIException. + // Until a time comes where an exception can be caused outside of the API (e.g. setTimeout + // or some other async operation in a pure JSContext) we can ignore exceptions reported here. + void reportException(JSC::ExecState*, JSC::Exception*) const override { } + + JSC::JSGlobalObject& m_globalObject; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp index 3f2f1ed4a..828d0c04f 100644 --- a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp +++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,37 +26,54 @@ #include "config.h" #include "JSInjectedScriptHost.h" -#if ENABLE(INSPECTOR) - +#include "BuiltinNames.h" +#include "Completion.h" #include "DateInstance.h" +#include "DirectArguments.h" #include "Error.h" #include "InjectedScriptHost.h" +#include "IteratorOperations.h" #include "JSArray.h" +#include "JSBoundFunction.h" +#include "JSCInlines.h" #include "JSFunction.h" +#include "JSGlobalObjectFunctions.h" #include "JSInjectedScriptHostPrototype.h" +#include "JSMap.h" +#include "JSMapIterator.h" +#include "JSPromise.h" +#include "JSPropertyNameIterator.h" +#include "JSSet.h" +#include "JSSetIterator.h" +#include "JSStringIterator.h" #include "JSTypedArrays.h" +#include "JSWeakMap.h" +#include "JSWeakSet.h" +#include "JSWithScope.h" #include "ObjectConstructor.h" -#include "Operations.h" +#include "ProxyObject.h" #include "RegExpObject.h" +#include "ScopedArguments.h" #include "SourceCode.h" #include "TypedArrayInlines.h" +#include "WeakMapData.h" using namespace JSC; namespace Inspector { -const ClassInfo JSInjectedScriptHost::s_info = { "InjectedScriptHost", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSInjectedScriptHost) }; +const ClassInfo JSInjectedScriptHost::s_info = { "InjectedScriptHost", &Base::s_info, 0, CREATE_METHOD_TABLE(JSInjectedScriptHost) }; -JSInjectedScriptHost::JSInjectedScriptHost(VM& vm, Structure* structure, PassRefPtr impl) +JSInjectedScriptHost::JSInjectedScriptHost(VM& vm, Structure* structure, Ref&& impl) : JSDestructibleObject(vm, structure) - , m_impl(impl.leakRef()) + , m_wrapped(WTFMove(impl)) { } void JSInjectedScriptHost::finishCreation(VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(info())); + ASSERT(inherits(vm, info())); } JSObject* JSInjectedScriptHost::createPrototype(VM& vm, JSGlobalObject* globalObject) @@ -70,23 +87,31 @@ void JSInjectedScriptHost::destroy(JSC::JSCell* cell) thisObject->JSInjectedScriptHost::~JSInjectedScriptHost(); } -void JSInjectedScriptHost::releaseImpl() +JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const { - if (m_impl) { - m_impl->deref(); - m_impl = nullptr; - } + JSGlobalObject* globalObject = exec->lexicalGlobalObject(); + return globalObject->evalFunction(); } -JSInjectedScriptHost::~JSInjectedScriptHost() +JSValue JSInjectedScriptHost::evaluateWithScopeExtension(ExecState* exec) { - releaseImpl(); -} + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); -JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const -{ - JSGlobalObject* globalObject = exec->lexicalGlobalObject(); - return globalObject->evalFunction(); + JSValue scriptValue = exec->argument(0); + if (!scriptValue.isString()) + return throwTypeError(exec, scope, ASCIILiteral("InjectedScriptHost.evaluateWithScopeExtension first argument must be a string.")); + + String program = asString(scriptValue)->value(exec); + RETURN_IF_EXCEPTION(scope, JSValue()); + + NakedPtr exception; + JSObject* scopeExtension = exec->argument(1).getObject(); + JSValue result = JSC::evaluateWithScopeExtension(exec, makeSource(program, exec->callerSourceOrigin()), scopeExtension, exception); + if (exception) + throwException(exec, scope, exception); + + return result; } JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec) @@ -94,9 +119,8 @@ JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec) if (exec->argumentCount() < 1) return jsUndefined(); - JSObject* thisObject = jsCast(exec->uncheckedArgument(0).toThis(exec, NotStrictMode)); - String result = thisObject->methodTable()->className(thisObject); - return jsString(exec, result); + JSObject* object = jsCast(exec->uncheckedArgument(0).toThis(exec, NotStrictMode)); + return jsString(exec, JSObject::calculatedClassName(object)); } JSValue JSInjectedScriptHost::isHTMLAllCollection(ExecState* exec) @@ -104,12 +128,14 @@ JSValue JSInjectedScriptHost::isHTMLAllCollection(ExecState* exec) if (exec->argumentCount() < 1) return jsUndefined(); + VM& vm = exec->vm(); JSValue value = exec->uncheckedArgument(0); - return jsBoolean(impl().isHTMLAllCollection(value)); + return jsBoolean(impl().isHTMLAllCollection(vm, value)); } -JSValue JSInjectedScriptHost::type(ExecState* exec) +JSValue JSInjectedScriptHost::subtype(ExecState* exec) { + VM& vm = exec->vm(); if (exec->argumentCount() < 1) return jsUndefined(); @@ -120,21 +146,58 @@ JSValue JSInjectedScriptHost::type(ExecState* exec) return exec->vm().smallStrings.booleanString(); if (value.isNumber()) return exec->vm().smallStrings.numberString(); + if (value.isSymbol()) + return exec->vm().smallStrings.symbolString(); + + JSObject* object = asObject(value); + if (object) { + if (object->isErrorInstance()) + return jsNontrivialString(exec, ASCIILiteral("error")); + + // Consider class constructor functions class objects. + JSFunction* function = jsDynamicCast(vm, value); + if (function && function->isClassConstructorFunction()) + return jsNontrivialString(exec, ASCIILiteral("class")); + } - if (value.inherits(JSArray::info())) + if (value.inherits(vm, JSArray::info())) return jsNontrivialString(exec, ASCIILiteral("array")); - if (value.inherits(DateInstance::info())) + if (value.inherits(vm, DirectArguments::info()) || value.inherits(vm, ScopedArguments::info())) + return jsNontrivialString(exec, ASCIILiteral("array")); + + if (value.inherits(vm, DateInstance::info())) return jsNontrivialString(exec, ASCIILiteral("date")); - if (value.inherits(RegExpObject::info())) + if (value.inherits(vm, RegExpObject::info())) return jsNontrivialString(exec, ASCIILiteral("regexp")); - if (value.inherits(JSInt8Array::info()) || value.inherits(JSInt16Array::info()) || value.inherits(JSInt32Array::info())) + if (value.inherits(vm, ProxyObject::info())) + return jsNontrivialString(exec, ASCIILiteral("proxy")); + + if (value.inherits(vm, JSMap::info())) + return jsNontrivialString(exec, ASCIILiteral("map")); + if (value.inherits(vm, JSSet::info())) + return jsNontrivialString(exec, ASCIILiteral("set")); + if (value.inherits(vm, JSWeakMap::info())) + return jsNontrivialString(exec, ASCIILiteral("weakmap")); + if (value.inherits(vm, JSWeakSet::info())) + return jsNontrivialString(exec, ASCIILiteral("weakset")); + + if (value.inherits(vm, JSMapIterator::info()) + || value.inherits(vm, JSSetIterator::info()) + || value.inherits(vm, JSStringIterator::info()) + || value.inherits(vm, JSPropertyNameIterator::info())) + return jsNontrivialString(exec, ASCIILiteral("iterator")); + + if (object && object->getDirect(exec->vm(), exec->vm().propertyNames->builtinNames().arrayIteratorNextIndexPrivateName())) + return jsNontrivialString(exec, ASCIILiteral("iterator")); + + if (value.inherits(vm, JSInt8Array::info()) || value.inherits(vm, JSInt16Array::info()) || value.inherits(vm, JSInt32Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); - if (value.inherits(JSUint8Array::info()) || value.inherits(JSUint16Array::info()) || value.inherits(JSUint32Array::info())) + if (value.inherits(vm, JSUint8Array::info()) || value.inherits(vm, JSUint16Array::info()) || value.inherits(vm, JSUint32Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); - if (value.inherits(JSFloat32Array::info()) || value.inherits(JSFloat64Array::info())) + if (value.inherits(vm, JSFloat32Array::info()) || value.inherits(vm, JSFloat64Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); - return impl().type(exec, value); + return impl().subtype(exec, value); } JSValue JSInjectedScriptHost::functionDetails(ExecState* exec) @@ -142,34 +205,42 @@ JSValue JSInjectedScriptHost::functionDetails(ExecState* exec) if (exec->argumentCount() < 1) return jsUndefined(); + VM& vm = exec->vm(); JSValue value = exec->uncheckedArgument(0); - if (!value.asCell()->inherits(JSFunction::info())) + if (!value.asCell()->inherits(vm, JSFunction::info())) return jsUndefined(); + // FIXME: This should provide better details for JSBoundFunctions. + JSFunction* function = jsCast(value); const SourceCode* sourceCode = function->sourceCode(); if (!sourceCode) return jsUndefined(); - int lineNumber = sourceCode->firstLine(); + // In the inspector protocol all positions are 0-based while in SourceCode they are 1-based + int lineNumber = sourceCode->firstLine().oneBasedInt(); if (lineNumber) - lineNumber -= 1; // In the inspector protocol all positions are 0-based while in SourceCode they are 1-based + lineNumber -= 1; + int columnNumber = sourceCode->startColumn().oneBasedInt(); + if (columnNumber) + columnNumber -= 1; String scriptID = String::number(sourceCode->provider()->asID()); JSObject* location = constructEmptyObject(exec); - location->putDirect(exec->vm(), Identifier(exec, "lineNumber"), jsNumber(lineNumber)); - location->putDirect(exec->vm(), Identifier(exec, "scriptId"), jsString(exec, scriptID)); + location->putDirect(vm, Identifier::fromString(exec, "scriptId"), jsString(exec, scriptID)); + location->putDirect(vm, Identifier::fromString(exec, "lineNumber"), jsNumber(lineNumber)); + location->putDirect(vm, Identifier::fromString(exec, "columnNumber"), jsNumber(columnNumber)); JSObject* result = constructEmptyObject(exec); - result->putDirect(exec->vm(), Identifier(exec, "location"), location); + result->putDirect(vm, Identifier::fromString(exec, "location"), location); - String name = function->name(exec); + String name = function->name(vm); if (!name.isEmpty()) - result->putDirect(exec->vm(), Identifier(exec, "name"), jsString(exec, name)); + result->putDirect(vm, Identifier::fromString(exec, "name"), jsString(exec, name)); - String displayName = function->displayName(exec); + String displayName = function->displayName(vm); if (!displayName.isEmpty()) - result->putDirect(exec->vm(), Identifier(exec, "displayName"), jsString(exec, displayName)); + result->putDirect(vm, Identifier::fromString(exec, "displayName"), jsString(exec, displayName)); // FIXME: provide function scope data in "scopesRaw" property when JSC supports it. // [JSC] expose function (closure) inner context to debugger @@ -177,29 +248,344 @@ JSValue JSInjectedScriptHost::functionDetails(ExecState* exec) return result; } -JSValue JSInjectedScriptHost::getInternalProperties(ExecState*) +static JSObject* constructInternalProperty(ExecState* exec, const String& name, JSValue value) { - // FIXME: [JSC] expose object inner properties to debugger + JSObject* result = constructEmptyObject(exec); + result->putDirect(exec->vm(), Identifier::fromString(exec, "name"), jsString(exec, name)); + result->putDirect(exec->vm(), Identifier::fromString(exec, "value"), value); + return result; +} + +JSValue JSInjectedScriptHost::getInternalProperties(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue value = exec->uncheckedArgument(0); + + if (JSPromise* promise = jsDynamicCast(vm, value)) { + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr); + RETURN_IF_EXCEPTION(scope, JSValue()); + switch (promise->status(exec->vm())) { + case JSPromise::Status::Pending: + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("pending")))); + return array; + case JSPromise::Status::Fulfilled: + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("resolved")))); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("result"), promise->result(exec->vm()))); + return array; + case JSPromise::Status::Rejected: + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("rejected")))); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("result"), promise->result(exec->vm()))); + return array; + } + // FIXME: Web Inspector: ES6: Improved Support for Promises - Promise Reactions + RELEASE_ASSERT_NOT_REACHED(); + } + + if (JSBoundFunction* boundFunction = jsDynamicCast(vm, value)) { + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "targetFunction", boundFunction->targetFunction())); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "boundThis", boundFunction->boundThis())); + RETURN_IF_EXCEPTION(scope, JSValue()); + if (boundFunction->boundArgs()) { + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "boundArgs", boundFunction->boundArgs())); + return array; + } + return array; + } + + if (ProxyObject* proxy = jsDynamicCast(vm, value)) { + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 2); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("target"), proxy->target())); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("handler"), proxy->handler())); + return array; + } + + if (JSObject* iteratorObject = jsDynamicCast(vm, value)) { + if (iteratorObject->getDirect(exec->vm(), exec->vm().propertyNames->builtinNames().arrayIteratorNextIndexPrivateName())) { + JSValue iteratedValue = iteratorObject->getDirect(exec->vm(), exec->vm().propertyNames->builtinNames().iteratedObjectPrivateName()); + JSValue kind = iteratorObject->getDirect(exec->vm(), exec->vm().propertyNames->builtinNames().arrayIteratorKindPrivateName()); + + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 2); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "array", iteratedValue)); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", kind)); + return array; + } + } + + if (JSMapIterator* mapIterator = jsDynamicCast(vm, value)) { + String kind; + switch (mapIterator->kind()) { + case IterateKey: + kind = ASCIILiteral("key"); + break; + case IterateValue: + kind = ASCIILiteral("value"); + break; + case IterateKeyValue: + kind = ASCIILiteral("key+value"); + break; + } + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 2); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "map", mapIterator->iteratedValue())); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", jsNontrivialString(exec, kind))); + return array; + } + + if (JSSetIterator* setIterator = jsDynamicCast(vm, value)) { + String kind; + switch (setIterator->kind()) { + case IterateKey: + kind = ASCIILiteral("key"); + break; + case IterateValue: + kind = ASCIILiteral("value"); + break; + case IterateKeyValue: + kind = ASCIILiteral("key+value"); + break; + } + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 2); + RETURN_IF_EXCEPTION(scope, JSValue()); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "set", setIterator->iteratedValue())); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", jsNontrivialString(exec, kind))); + return array; + } + + if (JSStringIterator* stringIterator = jsDynamicCast(vm, value)) { + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 1); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "string", stringIterator->iteratedValue(exec))); + return array; + } + + if (JSPropertyNameIterator* propertyNameIterator = jsDynamicCast(vm, value)) { + unsigned index = 0; + JSArray* array = constructEmptyArray(exec, nullptr, 1); + RETURN_IF_EXCEPTION(scope, JSValue()); + scope.release(); + array->putDirectIndex(exec, index++, constructInternalProperty(exec, "object", propertyNameIterator->iteratedValue())); + return array; + } + return jsUndefined(); } -JSValue toJS(ExecState* exec, JSGlobalObject* globalObject, InjectedScriptHost* impl) +JSValue JSInjectedScriptHost::proxyTargetValue(ExecState *exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + VM& vm = exec->vm(); + JSValue value = exec->uncheckedArgument(0); + ProxyObject* proxy = jsDynamicCast(vm, value); + if (!proxy) + return jsUndefined(); + + JSObject* target = proxy->target(); + while (ProxyObject* proxy = jsDynamicCast(vm, target)) + target = proxy->target(); + + return target; +} + +JSValue JSInjectedScriptHost::weakMapSize(ExecState* exec) { - if (!impl) - return jsNull(); + if (exec->argumentCount() < 1) + return jsUndefined(); - JSObject* prototype = JSInjectedScriptHost::createPrototype(exec->vm(), globalObject); - Structure* structure = JSInjectedScriptHost::createStructure(exec->vm(), globalObject, prototype); - JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, impl); + VM& vm = exec->vm(); + JSValue value = exec->uncheckedArgument(0); + JSWeakMap* weakMap = jsDynamicCast(vm, value); + if (!weakMap) + return jsUndefined(); - return injectedScriptHost; + return jsNumber(weakMap->weakMapData()->size()); } -JSInjectedScriptHost* toJSInjectedScriptHost(JSValue value) +JSValue JSInjectedScriptHost::weakMapEntries(ExecState* exec) { - return value.inherits(JSInjectedScriptHost::info()) ? jsCast(value) : nullptr; + if (exec->argumentCount() < 1) + return jsUndefined(); + + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue value = exec->uncheckedArgument(0); + JSWeakMap* weakMap = jsDynamicCast(vm, value); + if (!weakMap) + return jsUndefined(); + + unsigned fetched = 0; + unsigned numberToFetch = 100; + + JSValue numberToFetchArg = exec->argument(1); + double fetchDouble = numberToFetchArg.toInteger(exec); + if (fetchDouble >= 0) + numberToFetch = static_cast(fetchDouble); + + JSArray* array = constructEmptyArray(exec, nullptr); + RETURN_IF_EXCEPTION(scope, JSValue()); + for (auto it = weakMap->weakMapData()->begin(); it != weakMap->weakMapData()->end(); ++it) { + JSObject* entry = constructEmptyObject(exec); + entry->putDirect(exec->vm(), Identifier::fromString(exec, "key"), it->key); + entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->value.get()); + array->putDirectIndex(exec, fetched++, entry); + RETURN_IF_EXCEPTION(scope, JSValue()); + if (numberToFetch && fetched >= numberToFetch) + break; + } + + return array; } -} // namespace Inspector +JSValue JSInjectedScriptHost::weakSetSize(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); -#endif // ENABLE(INSPECTOR) + VM& vm = exec->vm(); + JSValue value = exec->uncheckedArgument(0); + JSWeakSet* weakSet = jsDynamicCast(vm, value); + if (!weakSet) + return jsUndefined(); + + return jsNumber(weakSet->weakMapData()->size()); +} + +JSValue JSInjectedScriptHost::weakSetEntries(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue value = exec->uncheckedArgument(0); + JSWeakSet* weakSet = jsDynamicCast(vm, value); + if (!weakSet) + return jsUndefined(); + + unsigned fetched = 0; + unsigned numberToFetch = 100; + + JSValue numberToFetchArg = exec->argument(1); + double fetchDouble = numberToFetchArg.toInteger(exec); + if (fetchDouble >= 0) + numberToFetch = static_cast(fetchDouble); + + JSArray* array = constructEmptyArray(exec, nullptr); + RETURN_IF_EXCEPTION(scope, JSValue()); + for (auto it = weakSet->weakMapData()->begin(); it != weakSet->weakMapData()->end(); ++it) { + JSObject* entry = constructEmptyObject(exec); + entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->key); + array->putDirectIndex(exec, fetched++, entry); + RETURN_IF_EXCEPTION(scope, JSValue()); + if (numberToFetch && fetched >= numberToFetch) + break; + } + + return array; +} + +static JSObject* cloneArrayIteratorObject(ExecState* exec, VM& vm, JSObject* iteratorObject, JSValue nextIndex) +{ + ASSERT(iteratorObject->type() == FinalObjectType); + JSObject* clone = constructEmptyObject(exec, iteratorObject->structure()); + clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextIndexPrivateName(), nextIndex); + clone->putDirect(vm, vm.propertyNames->builtinNames().iteratedObjectPrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().iteratedObjectPrivateName())); + clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorIsDonePrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorIsDonePrivateName())); + clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextPrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextPrivateName())); + return clone; +} + +JSValue JSInjectedScriptHost::iteratorEntries(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue iterator; + JSValue value = exec->uncheckedArgument(0); + if (JSMapIterator* mapIterator = jsDynamicCast(vm, value)) + iterator = mapIterator->clone(exec); + else if (JSSetIterator* setIterator = jsDynamicCast(vm, value)) + iterator = setIterator->clone(exec); + else if (JSStringIterator* stringIterator = jsDynamicCast(vm, value)) + iterator = stringIterator->clone(exec); + else if (JSPropertyNameIterator* propertyNameIterator = jsDynamicCast(vm, value)) { + iterator = propertyNameIterator->clone(exec); + RETURN_IF_EXCEPTION(scope, JSValue()); + } else { + if (JSObject* iteratorObject = jsDynamicCast(vm, value)) { + // Array Iterators are created in JS for performance reasons. Thus the only way to know we have one is to + // look for a property that is unique to them. + if (JSValue nextIndex = iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextIndexPrivateName())) + iterator = cloneArrayIteratorObject(exec, vm, iteratorObject, nextIndex); + } + } + if (!iterator) + return jsUndefined(); + + unsigned numberToFetch = 5; + JSValue numberToFetchArg = exec->argument(1); + double fetchDouble = numberToFetchArg.toInteger(exec); + if (fetchDouble >= 0) + numberToFetch = static_cast(fetchDouble); + + JSArray* array = constructEmptyArray(exec, nullptr); + RETURN_IF_EXCEPTION(scope, JSValue()); + + for (unsigned i = 0; i < numberToFetch; ++i) { + JSValue next = iteratorStep(exec, iterator); + if (UNLIKELY(scope.exception())) + break; + if (next.isFalse()) + break; + + JSValue nextValue = iteratorValue(exec, next); + if (UNLIKELY(scope.exception())) + break; + + JSObject* entry = constructEmptyObject(exec); + entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), nextValue); + array->putDirectIndex(exec, i, entry); + if (UNLIKELY(scope.exception())) + break; + } + + iteratorClose(exec, iterator); + + return array; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h index dc2356802..ede75437a 100644 --- a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h +++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSInjectedScriptHost_h -#define JSInjectedScriptHost_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSDestructibleObject.h" @@ -37,6 +34,7 @@ class InjectedScriptHost; class JSInjectedScriptHost : public JSC::JSDestructibleObject { public: typedef JSC::JSDestructibleObject Base; + static const unsigned StructureFlags = Base::StructureFlags; DECLARE_INFO; @@ -45,9 +43,9 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } - static JSInjectedScriptHost* create(JSC::VM& vm, JSC::Structure* structure, PassRefPtr impl) + static JSInjectedScriptHost* create(JSC::VM& vm, JSC::Structure* structure, Ref&& impl) { - JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell(vm.heap)) JSInjectedScriptHost(vm, structure, impl); + JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell(vm.heap)) JSInjectedScriptHost(vm, structure, WTFMove(impl)); instance->finishCreation(vm); return instance; } @@ -55,36 +53,32 @@ public: static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*); static void destroy(JSC::JSCell*); - InjectedScriptHost& impl() const { return *m_impl; } - void releaseImpl(); + InjectedScriptHost& impl() const { return m_wrapped; } // Attributes. JSC::JSValue evaluate(JSC::ExecState*) const; // Functions. + JSC::JSValue evaluateWithScopeExtension(JSC::ExecState*); JSC::JSValue internalConstructorName(JSC::ExecState*); JSC::JSValue isHTMLAllCollection(JSC::ExecState*); - JSC::JSValue type(JSC::ExecState*); + JSC::JSValue subtype(JSC::ExecState*); JSC::JSValue functionDetails(JSC::ExecState*); JSC::JSValue getInternalProperties(JSC::ExecState*); + JSC::JSValue proxyTargetValue(JSC::ExecState*); + JSC::JSValue weakMapSize(JSC::ExecState*); + JSC::JSValue weakMapEntries(JSC::ExecState*); + JSC::JSValue weakSetSize(JSC::ExecState*); + JSC::JSValue weakSetEntries(JSC::ExecState*); + JSC::JSValue iteratorEntries(JSC::ExecState*); protected: - static const unsigned StructureFlags = Base::StructureFlags; - void finishCreation(JSC::VM&); private: - JSInjectedScriptHost(JSC::VM&, JSC::Structure*, PassRefPtr); - ~JSInjectedScriptHost(); + JSInjectedScriptHost(JSC::VM&, JSC::Structure*, Ref&&); - InjectedScriptHost* m_impl; + Ref m_wrapped; }; -JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, InjectedScriptHost*); -JSInjectedScriptHost* toJSInjectedScriptHost(JSC::JSValue); - } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(JSInjectedScriptHost_h) diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp index 12c7a5021..a6f716879 100644 --- a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp +++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,13 +26,11 @@ #include "config.h" #include "JSInjectedScriptHostPrototype.h" -#if ENABLE(INSPECTOR) - #include "Error.h" #include "GetterSetter.h" #include "Identifier.h" #include "InjectedScriptHost.h" -#include "JSCJSValueInlines.h" +#include "JSCInlines.h" #include "JSFunction.h" #include "JSInjectedScriptHost.h" @@ -40,101 +38,213 @@ using namespace JSC; namespace Inspector { -static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionType(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionSubtype(ExecState*); static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionFunctionDetails(ExecState*); static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState*); static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState*); static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetEntries(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIteratorEntries(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension(ExecState*); static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*); -const ClassInfo JSInjectedScriptHostPrototype::s_info = { "InjectedScriptHost", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSInjectedScriptHostPrototype) }; +const ClassInfo JSInjectedScriptHostPrototype::s_info = { "InjectedScriptHost", &Base::s_info, 0, CREATE_METHOD_TABLE(JSInjectedScriptHostPrototype) }; void JSInjectedScriptHostPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) { Base::finishCreation(vm); - ASSERT(inherits(info())); + ASSERT(inherits(vm, info())); vm.prototypeMap.addPrototype(this); - JSC_NATIVE_FUNCTION("type", jsInjectedScriptHostPrototypeFunctionType, DontEnum, 1); - JSC_NATIVE_FUNCTION("functionDetails", jsInjectedScriptHostPrototypeFunctionFunctionDetails, DontEnum, 1); - JSC_NATIVE_FUNCTION("getInternalProperties", jsInjectedScriptHostPrototypeFunctionGetInternalProperties, DontEnum, 1); - JSC_NATIVE_FUNCTION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, DontEnum, 1); - JSC_NATIVE_FUNCTION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1); - - Identifier evaluateIdentifier(&vm, "evaluate"); - GetterSetter* accessor = GetterSetter::create(vm); - JSFunction* function = JSFunction::create(vm, globalObject, 0, evaluateIdentifier.string(), jsInjectedScriptHostPrototypeAttributeEvaluate); - accessor->setGetter(vm, function); - putDirectNonIndexAccessor(vm, evaluateIdentifier, accessor, DontEnum | Accessor); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("subtype", jsInjectedScriptHostPrototypeFunctionSubtype, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("functionDetails", jsInjectedScriptHostPrototypeFunctionFunctionDetails, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("getInternalProperties", jsInjectedScriptHostPrototypeFunctionGetInternalProperties, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("proxyTargetValue", jsInjectedScriptHostPrototypeFunctionProxyTargetValue, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakSetSize", jsInjectedScriptHostPrototypeFunctionWeakSetSize, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakSetEntries", jsInjectedScriptHostPrototypeFunctionWeakSetEntries, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("iteratorEntries", jsInjectedScriptHostPrototypeFunctionIteratorEntries, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("evaluateWithScopeExtension", jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension, DontEnum, 1); + + JSC_NATIVE_GETTER("evaluate", jsInjectedScriptHostPrototypeAttributeEvaluate, DontEnum | Accessor); } EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); return JSValue::encode(castedThis->evaluate(exec)); } EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); return JSValue::encode(castedThis->internalConstructorName(exec)); } EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); return JSValue::encode(castedThis->isHTMLAllCollection(exec)); } -EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionType(ExecState* exec) +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); - return JSValue::encode(castedThis->type(exec)); + return JSValue::encode(castedThis->proxyTargetValue(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->weakMapSize(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->weakMapEntries(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->weakSetSize(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetEntries(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->weakSetEntries(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIteratorEntries(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->iteratorEntries(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->evaluateWithScopeExtension(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionSubtype(ExecState* exec) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); + + return JSValue::encode(castedThis->subtype(exec)); } EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionFunctionDetails(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); return JSValue::encode(castedThis->functionDetails(exec)); } EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSInjectedScriptHost* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSInjectedScriptHost* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info()); return JSValue::encode(castedThis->getInternalProperties(exec)); } } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h index 9d0b7b666..58e9e5504 100644 --- a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h +++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSInjectedScriptHostPrototype_h -#define JSInjectedScriptHostPrototype_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSObject.h" @@ -35,6 +32,7 @@ namespace Inspector { class JSInjectedScriptHostPrototype : public JSC::JSNonFinalObject { public: typedef JSC::JSNonFinalObject Base; + static const unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot; DECLARE_INFO; @@ -50,9 +48,6 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } -protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - private: JSInjectedScriptHostPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(vm, structure) @@ -62,7 +57,3 @@ private: }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(JSInjectedScriptHostPrototype_h) diff --git a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp index 08fd618a8..1916c5dc8 100644 --- a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp +++ b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (C) 2014, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,30 +26,29 @@ #include "config.h" #include "JSJavaScriptCallFrame.h" -#if ENABLE(INSPECTOR) - +#include "DebuggerScope.h" #include "Error.h" -#include "JSCJSValue.h" -#include "JSCellInlines.h" +#include "IdentifierInlines.h" +#include "JSCInlines.h" #include "JSJavaScriptCallFramePrototype.h" -#include "StructureInlines.h" +#include "ObjectConstructor.h" using namespace JSC; namespace Inspector { -const ClassInfo JSJavaScriptCallFrame::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFrame) }; +const ClassInfo JSJavaScriptCallFrame::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFrame) }; -JSJavaScriptCallFrame::JSJavaScriptCallFrame(VM& vm, Structure* structure, PassRefPtr impl) +JSJavaScriptCallFrame::JSJavaScriptCallFrame(VM& vm, Structure* structure, Ref&& impl) : JSDestructibleObject(vm, structure) - , m_impl(impl.leakRef()) + , m_impl(&impl.leakRef()) { } void JSJavaScriptCallFrame::finishCreation(VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(info())); + ASSERT(inherits(vm, info())); } JSObject* JSJavaScriptCallFrame::createPrototype(VM& vm, JSGlobalObject* globalObject) @@ -65,10 +64,8 @@ void JSJavaScriptCallFrame::destroy(JSC::JSCell* cell) void JSJavaScriptCallFrame::releaseImpl() { - if (m_impl) { - m_impl->deref(); - m_impl = nullptr; - } + if (auto impl = std::exchange(m_impl, nullptr)) + impl->deref(); } JSJavaScriptCallFrame::~JSJavaScriptCallFrame() @@ -76,55 +73,83 @@ JSJavaScriptCallFrame::~JSJavaScriptCallFrame() releaseImpl(); } -JSValue JSJavaScriptCallFrame::evaluate(ExecState* exec) +JSValue JSJavaScriptCallFrame::evaluateWithScopeExtension(ExecState* exec) { - JSValue exception; - JSValue result = impl().evaluate(exec->argument(0).toString(exec)->value(exec), exception); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue scriptValue = exec->argument(0); + if (!scriptValue.isString()) + return throwTypeError(exec, scope, ASCIILiteral("JSJavaScriptCallFrame.evaluateWithScopeExtension first argument must be a string.")); + + String script = asString(scriptValue)->value(exec); + RETURN_IF_EXCEPTION(scope, JSValue()); + + NakedPtr exception; + JSObject* scopeExtension = exec->argument(1).getObject(); + JSValue result = impl().evaluateWithScopeExtension(script, scopeExtension, exception); if (exception) - exec->vm().throwException(exec, exception); + throwException(exec, scope, exception); return result; } -JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec) +static JSValue valueForScopeType(DebuggerScope* scope) { - if (!impl().scopeChain()) - return jsUndefined(); + if (scope->isCatchScope()) + return jsNumber(JSJavaScriptCallFrame::CATCH_SCOPE); + if (scope->isFunctionNameScope()) + return jsNumber(JSJavaScriptCallFrame::FUNCTION_NAME_SCOPE); + if (scope->isWithScope()) + return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE); + if (scope->isNestedLexicalScope()) + return jsNumber(JSJavaScriptCallFrame::NESTED_LEXICAL_SCOPE); + if (scope->isGlobalLexicalEnvironment()) + return jsNumber(JSJavaScriptCallFrame::GLOBAL_LEXICAL_ENVIRONMENT_SCOPE); + if (scope->isGlobalScope()) + return jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE); - if (!exec->argument(0).isInt32()) + ASSERT(scope->isClosureScope()); + return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE); +} + +static JSValue valueForScopeLocation(ExecState* exec, const DebuggerLocation& location) +{ + if (location.sourceID == noSourceID) + return jsNull(); + + // Debugger.Location protocol object. + JSObject* result = constructEmptyObject(exec); + result->putDirect(exec->vm(), Identifier::fromString(exec, "scriptId"), jsString(exec, String::number(location.sourceID))); + result->putDirect(exec->vm(), Identifier::fromString(exec, "lineNumber"), jsNumber(location.line)); + result->putDirect(exec->vm(), Identifier::fromString(exec, "columnNumber"), jsNumber(location.column)); + return result; +} + +JSValue JSJavaScriptCallFrame::scopeDescriptions(ExecState* exec) +{ + VM& vm = exec->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + + DebuggerScope* scopeChain = impl().scopeChain(); + if (!scopeChain) return jsUndefined(); - int index = exec->argument(0).asInt32(); - - JSScope* scopeChain = impl().scopeChain(); - ScopeChainIterator end = scopeChain->end(); - - // FIXME: We should be identifying and returning CATCH_SCOPE appropriately. - - bool foundLocalScope = false; - for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) { - JSObject* scope = iter.get(); - if (scope->isActivationObject()) { - if (!foundLocalScope) { - // First activation object is local scope, each successive activation object is closure. - if (!index) - return jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE); - foundLocalScope = true; - } else if (!index) - return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE); - } - - if (!index) { - // Last in the chain is global scope. - if (++iter == end) - return jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE); - return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE); - } - - --index; + + int index = 0; + JSArray* array = constructEmptyArray(exec, nullptr); + + DebuggerScope::iterator end = scopeChain->end(); + for (DebuggerScope::iterator iter = scopeChain->begin(); iter != end; ++iter) { + DebuggerScope* scope = iter.get(); + JSObject* description = constructEmptyObject(exec); + description->putDirect(exec->vm(), Identifier::fromString(exec, "type"), valueForScopeType(scope)); + description->putDirect(exec->vm(), Identifier::fromString(exec, "name"), jsString(exec, scope->name())); + description->putDirect(exec->vm(), Identifier::fromString(exec, "location"), valueForScopeLocation(exec, scope->location())); + array->putDirectIndex(exec, index++, description); + RETURN_IF_EXCEPTION(throwScope, JSValue()); } - ASSERT_NOT_REACHED(); - return jsUndefined(); + return array; } JSValue JSJavaScriptCallFrame::caller(ExecState* exec) const @@ -157,9 +182,9 @@ JSValue JSJavaScriptCallFrame::scopeChain(ExecState* exec) const if (!impl().scopeChain()) return jsNull(); - JSScope* scopeChain = impl().scopeChain(); - ScopeChainIterator iter = scopeChain->begin(); - ScopeChainIterator end = scopeChain->end(); + DebuggerScope* scopeChain = impl().scopeChain(); + DebuggerScope::iterator iter = scopeChain->begin(); + DebuggerScope::iterator end = scopeChain->end(); // We must always have something in the scope chain. ASSERT(iter != end); @@ -178,6 +203,11 @@ JSValue JSJavaScriptCallFrame::thisObject(ExecState*) const return impl().thisValue(); } +JSValue JSJavaScriptCallFrame::isTailDeleted(JSC::ExecState*) const +{ + return jsBoolean(impl().isTailDeleted()); +} + JSValue JSJavaScriptCallFrame::type(ExecState* exec) const { switch (impl().type()) { @@ -198,16 +228,10 @@ JSValue toJS(ExecState* exec, JSGlobalObject* globalObject, JavaScriptCallFrame* JSObject* prototype = JSJavaScriptCallFrame::createPrototype(exec->vm(), globalObject); Structure* structure = JSJavaScriptCallFrame::createStructure(exec->vm(), globalObject, prototype); - JSJavaScriptCallFrame* javaScriptCallFrame = JSJavaScriptCallFrame::create(exec->vm(), structure, impl); + JSJavaScriptCallFrame* javaScriptCallFrame = JSJavaScriptCallFrame::create(exec->vm(), structure, *impl); return javaScriptCallFrame; } -JSJavaScriptCallFrame* toJSJavaScriptCallFrame(JSValue value) -{ - return value.inherits(JSJavaScriptCallFrame::info()) ? jsCast(value) : nullptr; -} - } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h index dbbb93fa2..2ac247cae 100644 --- a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h +++ b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSJavaScriptCallFrame_h -#define JSJavaScriptCallFrame_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSDestructibleObject.h" #include "JavaScriptCallFrame.h" @@ -36,6 +33,7 @@ namespace Inspector { class JSJavaScriptCallFrame : public JSC::JSDestructibleObject { public: typedef JSC::JSDestructibleObject Base; + static const unsigned StructureFlags = Base::StructureFlags; DECLARE_INFO; @@ -44,9 +42,9 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } - static JSJavaScriptCallFrame* create(JSC::VM& vm, JSC::Structure* structure, PassRefPtr impl) + static JSJavaScriptCallFrame* create(JSC::VM& vm, JSC::Structure* structure, Ref&& impl) { - JSJavaScriptCallFrame* instance = new (NotNull, JSC::allocateCell(vm.heap)) JSJavaScriptCallFrame(vm, structure, impl); + JSJavaScriptCallFrame* instance = new (NotNull, JSC::allocateCell(vm.heap)) JSJavaScriptCallFrame(vm, structure, WTFMove(impl)); instance->finishCreation(vm); return instance; } @@ -58,8 +56,8 @@ public: void releaseImpl(); // Functions. - JSC::JSValue evaluate(JSC::ExecState*); - JSC::JSValue scopeType(JSC::ExecState*); + JSC::JSValue evaluateWithScopeExtension(JSC::ExecState*); + JSC::JSValue scopeDescriptions(JSC::ExecState*); // Attributes. JSC::JSValue caller(JSC::ExecState*) const; @@ -70,31 +68,27 @@ public: JSC::JSValue scopeChain(JSC::ExecState*) const; JSC::JSValue thisObject(JSC::ExecState*) const; JSC::JSValue type(JSC::ExecState*) const; + JSC::JSValue isTailDeleted(JSC::ExecState*) const; // Constants. static const unsigned short GLOBAL_SCOPE = 0; - static const unsigned short LOCAL_SCOPE = 1; - static const unsigned short WITH_SCOPE = 2; - static const unsigned short CLOSURE_SCOPE = 3; - static const unsigned short CATCH_SCOPE = 4; + static const unsigned short WITH_SCOPE = 1; + static const unsigned short CLOSURE_SCOPE = 2; + static const unsigned short CATCH_SCOPE = 3; + static const unsigned short FUNCTION_NAME_SCOPE = 4; + static const unsigned short GLOBAL_LEXICAL_ENVIRONMENT_SCOPE = 5; + static const unsigned short NESTED_LEXICAL_SCOPE = 6; protected: - static const unsigned StructureFlags = Base::StructureFlags; - void finishCreation(JSC::VM&); private: - JSJavaScriptCallFrame(JSC::VM&, JSC::Structure*, PassRefPtr); + JSJavaScriptCallFrame(JSC::VM&, JSC::Structure*, Ref&&); ~JSJavaScriptCallFrame(); JavaScriptCallFrame* m_impl; }; JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, JavaScriptCallFrame*); -JSJavaScriptCallFrame* toJSJavaScriptCallFrame(JSC::JSValue); } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(JSJavaScriptCallFrame_h) diff --git a/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.cpp b/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.cpp index d74126cb2..3a0a8a980 100644 --- a/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.cpp +++ b/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (C) 2014, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,12 +26,9 @@ #include "config.h" #include "JSJavaScriptCallFramePrototype.h" -#if ENABLE(INSPECTOR) - #include "Error.h" -#include "GetterSetter.h" #include "Identifier.h" -#include "JSCJSValueInlines.h" +#include "JSCInlines.h" #include "JSFunction.h" #include "JSJavaScriptCallFrame.h" @@ -40,8 +37,8 @@ using namespace JSC; namespace Inspector { // Functions. -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionEvaluate(ExecState*); -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionScopeType(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionEvaluateWithScopeExtension(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionScopeDescriptions(ExecState*); // Attributes. static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeCaller(ExecState*); @@ -52,185 +49,171 @@ static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeFunctionName(E static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeScopeChain(ExecState*); static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeThisObject(ExecState*); static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeType(ExecState*); +static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameIsTailDeleted(ExecState*); -// Constants. -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantGLOBAL_SCOPE(ExecState*); -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantLOCAL_SCOPE(ExecState*); -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantWITH_SCOPE(ExecState*); -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantCLOSURE_SCOPE(ExecState*); -static EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantCATCH_SCOPE(ExecState*); - -const ClassInfo JSJavaScriptCallFramePrototype::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFramePrototype) }; - -#define JSC_NATIVE_NON_INDEX_ACCESSOR(jsName, cppName, attributes) \ - { \ - Identifier identifier(&vm, jsName); \ - GetterSetter* accessor = GetterSetter::create(vm); \ - JSFunction* function = JSFunction::create(vm, globalObject, 0, identifier.string(), cppName); \ - accessor->setGetter(vm, function); \ - putDirectNonIndexAccessor(vm, identifier, accessor, (attributes)); \ - } +const ClassInfo JSJavaScriptCallFramePrototype::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFramePrototype) }; void JSJavaScriptCallFramePrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) { Base::finishCreation(vm); - ASSERT(inherits(info())); + ASSERT(inherits(vm, info())); vm.prototypeMap.addPrototype(this); - JSC_NATIVE_FUNCTION("evaluate", jsJavaScriptCallFramePrototypeFunctionEvaluate, DontEnum, 1); - JSC_NATIVE_FUNCTION("scopeType", jsJavaScriptCallFramePrototypeFunctionScopeType, DontEnum, 1); - - JSC_NATIVE_NON_INDEX_ACCESSOR("caller", jsJavaScriptCallFrameAttributeCaller, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("sourceID", jsJavaScriptCallFrameAttributeSourceID, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("line", jsJavaScriptCallFrameAttributeLine, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("column", jsJavaScriptCallFrameAttributeColumn, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("functionName", jsJavaScriptCallFrameAttributeFunctionName, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("scopeChain", jsJavaScriptCallFrameAttributeScopeChain, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("thisObject", jsJavaScriptCallFrameAttributeThisObject, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("type", jsJavaScriptCallFrameAttributeType, DontEnum | Accessor); - - JSC_NATIVE_NON_INDEX_ACCESSOR("GLOBAL_SCOPE", jsJavaScriptCallFrameConstantGLOBAL_SCOPE, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("LOCAL_SCOPE", jsJavaScriptCallFrameConstantLOCAL_SCOPE, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("WITH_SCOPE", jsJavaScriptCallFrameConstantWITH_SCOPE, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("CLOSURE_SCOPE", jsJavaScriptCallFrameConstantCLOSURE_SCOPE, DontEnum | Accessor); - JSC_NATIVE_NON_INDEX_ACCESSOR("CATCH_SCOPE", jsJavaScriptCallFrameConstantCATCH_SCOPE, DontEnum | Accessor); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("evaluateWithScopeExtension", jsJavaScriptCallFramePrototypeFunctionEvaluateWithScopeExtension, DontEnum, 1); + JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("scopeDescriptions", jsJavaScriptCallFramePrototypeFunctionScopeDescriptions, DontEnum, 0); + + JSC_NATIVE_GETTER("caller", jsJavaScriptCallFrameAttributeCaller, DontEnum | Accessor); + JSC_NATIVE_GETTER("sourceID", jsJavaScriptCallFrameAttributeSourceID, DontEnum | Accessor); + JSC_NATIVE_GETTER("line", jsJavaScriptCallFrameAttributeLine, DontEnum | Accessor); + JSC_NATIVE_GETTER("column", jsJavaScriptCallFrameAttributeColumn, DontEnum | Accessor); + JSC_NATIVE_GETTER("functionName", jsJavaScriptCallFrameAttributeFunctionName, DontEnum | Accessor); + JSC_NATIVE_GETTER("scopeChain", jsJavaScriptCallFrameAttributeScopeChain, DontEnum | Accessor); + JSC_NATIVE_GETTER("thisObject", jsJavaScriptCallFrameAttributeThisObject, DontEnum | Accessor); + JSC_NATIVE_GETTER("type", jsJavaScriptCallFrameAttributeType, DontEnum | Accessor); + JSC_NATIVE_GETTER("isTailDeleted", jsJavaScriptCallFrameIsTailDeleted, DontEnum | Accessor); } -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionEvaluate(ExecState* exec) +EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionEvaluateWithScopeExtension(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); - return JSValue::encode(castedThis->evaluate(exec)); + return JSValue::encode(castedThis->evaluateWithScopeExtension(exec)); } -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionScopeType(ExecState* exec) +EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionScopeDescriptions(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); - return JSValue::encode(castedThis->scopeType(exec)); + return JSValue::encode(castedThis->scopeDescriptions(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeCaller(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->caller(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeSourceID(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->sourceID(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeLine(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->line(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeColumn(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->column(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeFunctionName(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->functionName(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeScopeChain(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->scopeChain(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeThisObject(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->thisObject(exec)); } EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameAttributeType(ExecState* exec) { - JSValue thisValue = exec->hostThisValue(); - JSJavaScriptCallFrame* castedThis = jsDynamicCast(thisValue); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); if (!castedThis) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); - ASSERT_GC_OBJECT_INHERITS(castedThis, JSJavaScriptCallFrame::info()); return JSValue::encode(castedThis->type(exec)); } -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantGLOBAL_SCOPE(ExecState*) +EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameIsTailDeleted(ExecState* exec) { - return JSValue::encode(jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE)); -} + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantLOCAL_SCOPE(ExecState*) -{ - return JSValue::encode(jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE)); -} - -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantWITH_SCOPE(ExecState*) -{ - return JSValue::encode(jsNumber(JSJavaScriptCallFrame::WITH_SCOPE)); -} - -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantCLOSURE_SCOPE(ExecState*) -{ - return JSValue::encode(jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE)); -} + JSValue thisValue = exec->thisValue(); + JSJavaScriptCallFrame* castedThis = jsDynamicCast(vm, thisValue); + if (!castedThis) + return throwVMTypeError(exec, scope); -EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFrameConstantCATCH_SCOPE(ExecState*) -{ - return JSValue::encode(jsNumber(JSJavaScriptCallFrame::CATCH_SCOPE)); + return JSValue::encode(castedThis->isTailDeleted(exec)); } } // namespace Inspector - -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.h b/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.h index b868c53e2..c69e94a4e 100644 --- a/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.h +++ b/Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.h @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSJavaScriptCallFramePrototype_h -#define JSJavaScriptCallFramePrototype_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSObject.h" @@ -35,6 +32,7 @@ namespace Inspector { class JSJavaScriptCallFramePrototype : public JSC::JSNonFinalObject { public: typedef JSC::JSNonFinalObject Base; + static const unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot; DECLARE_INFO; @@ -50,9 +48,6 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } -protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - private: JSJavaScriptCallFramePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(vm, structure) @@ -62,7 +57,3 @@ private: }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(JSJavaScriptCallFramePrototype_h) diff --git a/Source/JavaScriptCore/inspector/JavaScriptCallFrame.cpp b/Source/JavaScriptCore/inspector/JavaScriptCallFrame.cpp index f735a8aa6..3c28484ae 100644 --- a/Source/JavaScriptCore/inspector/JavaScriptCallFrame.cpp +++ b/Source/JavaScriptCore/inspector/JavaScriptCallFrame.cpp @@ -26,14 +26,12 @@ #include "config.h" #include "JavaScriptCallFrame.h" -#if ENABLE(INSPECTOR) - using namespace JSC; namespace Inspector { -JavaScriptCallFrame::JavaScriptCallFrame(PassRefPtr debuggerCallFrame) - : m_debuggerCallFrame(debuggerCallFrame) +JavaScriptCallFrame::JavaScriptCallFrame(Ref&& debuggerCallFrame) + : m_debuggerCallFrame(WTFMove(debuggerCallFrame)) { } @@ -46,10 +44,9 @@ JavaScriptCallFrame* JavaScriptCallFrame::caller() if (!debuggerCallerFrame) return nullptr; - m_caller = create(debuggerCallerFrame); + m_caller = create(debuggerCallerFrame.releaseNonNull()); return m_caller.get(); } } // namespace Inspector -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h b/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h index b584067a2..ee1f8aea3 100644 --- a/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h +++ b/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2008, 2013-2014 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,16 +23,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JavaScriptCallFrame_h -#define JavaScriptCallFrame_h - -#if ENABLE(INSPECTOR) +#pragma once #include "JSCJSValueInlines.h" #include "debugger/DebuggerCallFrame.h" #include "interpreter/CallFrame.h" #include -#include #include #include @@ -40,9 +36,9 @@ namespace Inspector { class JavaScriptCallFrame : public RefCounted { public: - static PassRefPtr create(PassRefPtr debuggerCallFrame) + static Ref create(Ref&& debuggerCallFrame) { - return adoptRef(new JavaScriptCallFrame(debuggerCallFrame)); + return adoptRef(*new JavaScriptCallFrame(WTFMove(debuggerCallFrame))); } JavaScriptCallFrame* caller(); @@ -53,21 +49,18 @@ public: String functionName() const { return m_debuggerCallFrame->functionName(); } JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); } - JSC::JSScope* scopeChain() const { return m_debuggerCallFrame->scope(); } + JSC::DebuggerScope* scopeChain() const { return m_debuggerCallFrame->scope(); } JSC::JSGlobalObject* vmEntryGlobalObject() const { return m_debuggerCallFrame->vmEntryGlobalObject(); } + bool isTailDeleted() const { return m_debuggerCallFrame->isTailDeleted(); } JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); } - JSC::JSValue evaluate(const String& script, JSC::JSValue& exception) const { return m_debuggerCallFrame->evaluate(script, exception); } + JSC::JSValue evaluateWithScopeExtension(const String& script, JSC::JSObject* scopeExtension, NakedPtr& exception) const { return m_debuggerCallFrame->evaluateWithScopeExtension(script, scopeExtension, exception); } private: - JavaScriptCallFrame(PassRefPtr); + JavaScriptCallFrame(Ref&&); - RefPtr m_debuggerCallFrame; + Ref m_debuggerCallFrame; RefPtr m_caller; }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // JavaScriptCallFrame_h diff --git a/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp b/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp new file mode 100644 index 000000000..c9b7abd8f --- /dev/null +++ b/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PerGlobalObjectWrapperWorld.h" + +using namespace JSC; + +namespace Inspector { + +JSValue PerGlobalObjectWrapperWorld::getWrapper(JSGlobalObject* globalObject) +{ + auto it = m_wrappers.find(globalObject); + if (it != m_wrappers.end()) + return it->value.get(); + return JSValue(); +} + +void PerGlobalObjectWrapperWorld::addWrapper(JSGlobalObject* globalObject, JSObject* object) +{ + Strong wrapper(globalObject->vm(), object); + m_wrappers.add(globalObject, wrapper); +} + +void PerGlobalObjectWrapperWorld::clearAllWrappers() +{ + m_wrappers.clear(); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h b/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h new file mode 100644 index 000000000..51adaed06 --- /dev/null +++ b/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "JSCJSValueInlines.h" +#include "Strong.h" +#include "StrongInlines.h" +#include + +namespace Inspector { + +class JS_EXPORT_PRIVATE PerGlobalObjectWrapperWorld { +public: + JSC::JSValue getWrapper(JSC::JSGlobalObject*); + void addWrapper(JSC::JSGlobalObject*, JSC::JSObject*); + void clearAllWrappers(); + +private: + HashMap> m_wrappers; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptArguments.cpp b/Source/JavaScriptCore/inspector/ScriptArguments.cpp new file mode 100644 index 000000000..ff131b581 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptArguments.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptArguments.h" + +#include "JSCInlines.h" +#include "ProxyObject.h" +#include "ScriptValue.h" + +namespace Inspector { + +Ref ScriptArguments::create(JSC::ExecState* scriptState, Vector& arguments) +{ + return adoptRef(*new ScriptArguments(scriptState, arguments)); +} + +Ref ScriptArguments::createEmpty(JSC::ExecState* scriptState) +{ + return adoptRef(*new ScriptArguments(scriptState)); +} + +ScriptArguments::ScriptArguments(JSC::ExecState* execState) + : m_globalObject(execState->vm(), execState->lexicalGlobalObject()) +{ +} + +ScriptArguments::ScriptArguments(JSC::ExecState* execState, Vector& arguments) + : m_globalObject(execState->vm(), execState->lexicalGlobalObject()) +{ + m_arguments.swap(arguments); +} + +ScriptArguments::~ScriptArguments() +{ +} + +const Deprecated::ScriptValue& ScriptArguments::argumentAt(size_t index) const +{ + ASSERT(m_arguments.size() > index); + return m_arguments[index]; +} + +JSC::ExecState* ScriptArguments::globalState() const +{ + if (m_globalObject) + return const_cast(m_globalObject.get())->globalExec(); + + return nullptr; +} + +bool ScriptArguments::getFirstArgumentAsString(String& result) +{ + if (!argumentCount()) + return false; + + if (!globalState()) { + ASSERT_NOT_REACHED(); + return false; + } + + JSC::JSValue value = argumentAt(0).jsValue(); + if (JSC::jsDynamicCast(globalState()->vm(), value)) { + result = ASCIILiteral("[object Proxy]"); + return true; + } + + result = argumentAt(0).toString(globalState()); + return true; +} + +bool ScriptArguments::isEqual(ScriptArguments* other) const +{ + if (!other) + return false; + + if (m_arguments.size() != other->m_arguments.size()) + return false; + if (!globalState() && m_arguments.size()) + return false; + + for (size_t i = 0; i < m_arguments.size(); ++i) { + if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i])) + return false; + } + + return true; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptArguments.h b/Source/JavaScriptCore/inspector/ScriptArguments.h new file mode 100644 index 000000000..50abd1bdf --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptArguments.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace Deprecated { +class ScriptValue; +} + +namespace JSC { +class ExecState; +class JSGlobalObject; +} + +namespace Inspector { + +class JS_EXPORT_PRIVATE ScriptArguments : public RefCounted { +public: + static Ref create(JSC::ExecState*, Vector& arguments); + static Ref createEmpty(JSC::ExecState*); + ~ScriptArguments(); + + const Deprecated::ScriptValue& argumentAt(size_t) const; + size_t argumentCount() const { return m_arguments.size(); } + + JSC::ExecState* globalState() const; + + bool getFirstArgumentAsString(String& result); + bool isEqual(ScriptArguments*) const; + +private: + ScriptArguments(JSC::ExecState*); + ScriptArguments(JSC::ExecState*, Vector& arguments); + + JSC::Strong m_globalObject; + Vector m_arguments; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptBreakpoint.h b/Source/JavaScriptCore/inspector/ScriptBreakpoint.h index e3d52424d..586041796 100644 --- a/Source/JavaScriptCore/inspector/ScriptBreakpoint.h +++ b/Source/JavaScriptCore/inspector/ScriptBreakpoint.h @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,8 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScriptBreakpoint_h -#define ScriptBreakpoint_h +#pragma once #include #include @@ -55,35 +54,38 @@ struct ScriptBreakpointAction { String data; }; +typedef Vector BreakpointActions; + struct ScriptBreakpoint { ScriptBreakpoint() { } - ScriptBreakpoint(int lineNumber, int columnNumber, const String& condition, bool autoContinue) + ScriptBreakpoint(int lineNumber, int columnNumber, const String& condition, bool autoContinue, unsigned ignoreCount) : lineNumber(lineNumber) , columnNumber(columnNumber) , condition(condition) , autoContinue(autoContinue) + , ignoreCount(ignoreCount) { } - ScriptBreakpoint(int lineNumber, int columnNumber, const String& condition, Vector& actions, bool autoContinue) + ScriptBreakpoint(int lineNumber, int columnNumber, const String& condition, BreakpointActions& actions, bool autoContinue, unsigned ignoreCount) : lineNumber(lineNumber) , columnNumber(columnNumber) , condition(condition) , actions(actions) , autoContinue(autoContinue) + , ignoreCount(ignoreCount) { } - int lineNumber; - int columnNumber; + int lineNumber { 0 }; + int columnNumber { 0 }; String condition; - Vector actions; - bool autoContinue; + BreakpointActions actions; + bool autoContinue { false }; + unsigned ignoreCount { 0 }; }; } // namespace Inspector - -#endif // !defined(ScriptBreakpoint_h) diff --git a/Source/JavaScriptCore/inspector/ScriptCallFrame.cpp b/Source/JavaScriptCore/inspector/ScriptCallFrame.cpp new file mode 100644 index 000000000..44627ab74 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallFrame.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptCallFrame.h" + +#include "InspectorValues.h" + +namespace Inspector { + +ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& scriptName, JSC::SourceID sourceID, unsigned lineNumber, unsigned column) + : m_functionName(functionName) + , m_scriptName(scriptName) + , m_sourceID(sourceID) + , m_lineNumber(lineNumber) + , m_column(column) +{ +} + +ScriptCallFrame::~ScriptCallFrame() +{ +} + +bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const +{ + // Ignore sourceID in isEqual in case of identical scripts executed multiple times + // that would get different script identifiers, but are otherwise the same. + return m_functionName == o.m_functionName + && m_scriptName == o.m_scriptName + && m_lineNumber == o.m_lineNumber + && m_column == o.m_column; +} + +bool ScriptCallFrame::isNative() const +{ + return m_scriptName == "[native code]"; +} + +Ref ScriptCallFrame::buildInspectorObject() const +{ + return Inspector::Protocol::Console::CallFrame::create() + .setFunctionName(m_functionName) + .setUrl(m_scriptName) + .setScriptId(String::number(m_sourceID)) + .setLineNumber(m_lineNumber) + .setColumnNumber(m_column) + .release(); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptCallFrame.h b/Source/JavaScriptCore/inspector/ScriptCallFrame.h new file mode 100644 index 000000000..f80b42638 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallFrame.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "DebuggerPrimitives.h" +#include "InspectorProtocolObjects.h" +#include +#include + +namespace Inspector { + +class JS_EXPORT_PRIVATE ScriptCallFrame { +public: + ScriptCallFrame(const String& functionName, const String& scriptName, JSC::SourceID sourceID, unsigned lineNumber, unsigned column); + ~ScriptCallFrame(); + + const String& functionName() const { return m_functionName; } + const String& sourceURL() const { return m_scriptName; } + unsigned lineNumber() const { return m_lineNumber; } + unsigned columnNumber() const { return m_column; } + JSC::SourceID sourceID() const { return m_sourceID; } + + bool isEqual(const ScriptCallFrame&) const; + bool isNative() const; + + Ref buildInspectorObject() const; + +private: + String m_functionName; + String m_scriptName; + JSC::SourceID m_sourceID; + unsigned m_lineNumber; + unsigned m_column; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptCallStack.cpp b/Source/JavaScriptCore/inspector/ScriptCallStack.cpp new file mode 100644 index 000000000..612c448c4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallStack.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2008, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptCallStack.h" + +#include "InspectorValues.h" + +namespace Inspector { + +Ref ScriptCallStack::create() +{ + return adoptRef(*new ScriptCallStack); +} + +Ref ScriptCallStack::create(Vector& frames) +{ + return adoptRef(*new ScriptCallStack(frames)); +} + +ScriptCallStack::ScriptCallStack() +{ +} + +ScriptCallStack::ScriptCallStack(Vector& frames) +{ + m_frames.swap(frames); +} + +ScriptCallStack::~ScriptCallStack() +{ +} + +const ScriptCallFrame& ScriptCallStack::at(size_t index) const +{ + ASSERT(m_frames.size() > index); + return m_frames[index]; +} + +size_t ScriptCallStack::size() const +{ + return m_frames.size(); +} + +const ScriptCallFrame* ScriptCallStack::firstNonNativeCallFrame() const +{ + if (!m_frames.size()) + return nullptr; + + for (const auto& frame : m_frames) { + if (!frame.isNative()) + return &frame; + } + + return nullptr; +} + +void ScriptCallStack::append(const ScriptCallFrame& frame) +{ + m_frames.append(frame); +} + +bool ScriptCallStack::isEqual(ScriptCallStack* o) const +{ + if (!o) + return false; + + size_t frameCount = o->m_frames.size(); + if (frameCount != m_frames.size()) + return false; + + for (size_t i = 0; i < frameCount; ++i) { + if (!m_frames[i].isEqual(o->m_frames[i])) + return false; + } + + return true; +} + +Ref> ScriptCallStack::buildInspectorArray() const +{ + auto frames = Inspector::Protocol::Array::create(); + for (size_t i = 0; i < m_frames.size(); i++) + frames->addItem(m_frames.at(i).buildInspectorObject()); + return frames; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptCallStack.h b/Source/JavaScriptCore/inspector/ScriptCallStack.h new file mode 100644 index 000000000..0f5e33249 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallStack.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2008, 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorProtocolObjects.h" +#include "ScriptCallFrame.h" +#include +#include +#include + +namespace Inspector { + +class JS_EXPORT_PRIVATE ScriptCallStack : public RefCounted { +public: + static const size_t maxCallStackSizeToCapture = 200; + + static Ref create(); + static Ref create(Vector&); + + ~ScriptCallStack(); + + const ScriptCallFrame& at(size_t) const; + size_t size() const; + + const ScriptCallFrame* firstNonNativeCallFrame() const; + + void append(const ScriptCallFrame&); + + bool isEqual(ScriptCallStack*) const; + + Ref> buildInspectorArray() const; + +private: + ScriptCallStack(); + ScriptCallStack(Vector&); + + Vector m_frames; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp new file mode 100644 index 000000000..c47758fb4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2014, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptCallStackFactory.h" + +#include "CallFrame.h" +#include "CodeBlock.h" +#include "Exception.h" +#include "JSCJSValue.h" +#include "JSCInlines.h" +#include "ScriptArguments.h" +#include "ScriptCallFrame.h" +#include "ScriptCallStack.h" +#include "ScriptValue.h" +#include "StackVisitor.h" +#include + +using namespace JSC; + +namespace Inspector { + +class CreateScriptCallStackFunctor { +public: + CreateScriptCallStackFunctor(bool needToSkipAFrame, Vector& frames, size_t remainingCapacity) + : m_needToSkipAFrame(needToSkipAFrame) + , m_frames(frames) + , m_remainingCapacityForFrameCapture(remainingCapacity) + { + } + + StackVisitor::Status operator()(StackVisitor& visitor) const + { + if (m_needToSkipAFrame) { + m_needToSkipAFrame = false; + return StackVisitor::Continue; + } + + if (m_remainingCapacityForFrameCapture) { + unsigned line; + unsigned column; + visitor->computeLineAndColumn(line, column); + m_frames.append(ScriptCallFrame(visitor->functionName(), visitor->sourceURL(), static_cast(visitor->sourceID()), line, column)); + + m_remainingCapacityForFrameCapture--; + return StackVisitor::Continue; + } + + return StackVisitor::Done; + } + +private: + mutable bool m_needToSkipAFrame; + Vector& m_frames; + mutable size_t m_remainingCapacityForFrameCapture; +}; + +Ref createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) +{ + if (!exec) + return ScriptCallStack::create(); + + Vector frames; + + CallFrame* frame = exec->vm().topCallFrame; + CreateScriptCallStackFunctor functor(false, frames, maxStackSize); + frame->iterate(functor); + + return ScriptCallStack::create(frames); +} + +Ref createScriptCallStackForConsole(JSC::ExecState* exec, size_t maxStackSize) +{ + if (!exec) + return ScriptCallStack::create(); + + Vector frames; + + CallFrame* frame = exec->vm().topCallFrame; + CreateScriptCallStackFunctor functor(true, frames, maxStackSize); + frame->iterate(functor); + + if (frames.isEmpty()) { + CreateScriptCallStackFunctor functor(false, frames, maxStackSize); + frame->iterate(functor); + } + + return ScriptCallStack::create(frames); +} + +static void extractSourceInformationFromException(JSC::ExecState* exec, JSObject* exceptionObject, int* lineNumber, int* columnNumber, String* sourceURL) +{ + VM& vm = exec->vm(); + auto scope = DECLARE_CATCH_SCOPE(vm); + + // FIXME: Web Inspector: Should not need to evaluate JavaScript handling exceptions + JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "line")); + *lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; + JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "column")); + *columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0; + JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "sourceURL")); + *sourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toWTFString(exec) : ASCIILiteral("undefined"); + scope.clearException(); +} + +Ref createScriptCallStackFromException(JSC::ExecState* exec, JSC::Exception* exception, size_t maxStackSize) +{ + Vector frames; + auto& stackTrace = exception->stack(); + VM& vm = exec->vm(); + for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) { + unsigned line; + unsigned column; + stackTrace[i].computeLineAndColumn(line, column); + String functionName = stackTrace[i].functionName(vm); + frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL(), static_cast(stackTrace[i].sourceID()), line, column)); + } + + // Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't. + if (exception->value().isObject()) { + JSObject* exceptionObject = exception->value().toObject(exec); + ASSERT(exceptionObject); + int lineNumber; + int columnNumber; + String exceptionSourceURL; + if (!frames.size()) { + extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL); + frames.append(ScriptCallFrame(String(), exceptionSourceURL, noSourceID, lineNumber, columnNumber)); + } else { + if (!stackTrace[0].hasLineAndColumnInfo() || stackTrace[0].sourceURL().isEmpty()) { + const ScriptCallFrame& firstCallFrame = frames.first(); + extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL); + frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, stackTrace[0].sourceID(), lineNumber, columnNumber); + } + } + } + + return ScriptCallStack::create(frames); +} + +Ref createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount) +{ + Vector arguments; + size_t argumentCount = exec->argumentCount(); + for (size_t i = skipArgumentCount; i < argumentCount; ++i) + arguments.append(Deprecated::ScriptValue(exec->vm(), exec->uncheckedArgument(i))); + return ScriptArguments::create(exec, arguments); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h new file mode 100644 index 000000000..d87edbe31 --- /dev/null +++ b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +namespace JSC { +class Exception; +class ExecState; +class JSValue; +} + +namespace Inspector { + +class ScriptArguments; +class ScriptCallStack; + +// FIXME: The subtle differences between these should be eliminated. +JS_EXPORT_PRIVATE Ref createScriptCallStack(JSC::ExecState*, size_t maxStackSize); +JS_EXPORT_PRIVATE Ref createScriptCallStackForConsole(JSC::ExecState*, size_t maxStackSize); +JS_EXPORT_PRIVATE Ref createScriptCallStackFromException(JSC::ExecState*, JSC::Exception*, size_t maxStackSize); +JS_EXPORT_PRIVATE Ref createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptDebugListener.h b/Source/JavaScriptCore/inspector/ScriptDebugListener.h index bee3bc047..5b0bb9f41 100644 --- a/Source/JavaScriptCore/inspector/ScriptDebugListener.h +++ b/Source/JavaScriptCore/inspector/ScriptDebugListener.h @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,55 +27,41 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScriptDebugListener_h -#define ScriptDebugListener_h +#pragma once #include "debugger/Debugger.h" -#include +#include "parser/SourceProvider.h" #include -namespace Deprecated { -class ScriptValue; -} - namespace Inspector { +struct ScriptBreakpointAction; + class ScriptDebugListener { public: - class Script { - public: - Script() - : startLine(0) - , startColumn(0) - , endLine(0) - , endColumn(0) - , isContentScript(false) - { - } - + struct Script { String url; String source; String sourceURL; String sourceMappingURL; - int startLine; - int startColumn; - int endLine; - int endColumn; - bool isContentScript; + RefPtr sourceProvider; + int startLine {0}; + int startColumn {0}; + int endLine {0}; + int endColumn {0}; + bool isContentScript {false}; }; virtual ~ScriptDebugListener() { } virtual void didParseSource(JSC::SourceID, const Script&) = 0; virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0; - virtual void didPause(JSC::ExecState*, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception) = 0; - virtual void didSampleProbe(JSC::ExecState*, int probeIdentifier, int hitCount, const Deprecated::ScriptValue& result) = 0; + virtual void didPause(JSC::ExecState&, JSC::JSValue callFrames, JSC::JSValue exception) = 0; virtual void didContinue() = 0; - virtual void breakpointActionLog(JSC::ExecState*, const String&) = 0; - virtual void breakpointActionSound() = 0; + virtual void breakpointActionLog(JSC::ExecState&, const String&) = 0; + virtual void breakpointActionSound(int breakpointActionIdentifier) = 0; + virtual void breakpointActionProbe(JSC::ExecState&, const ScriptBreakpointAction&, unsigned batchId, unsigned sampleId, JSC::JSValue result) = 0; }; } // namespace Inspector - -#endif // ScriptDebugListener_h diff --git a/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp b/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp index b1151cf7f..84cefdf70 100644 --- a/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp +++ b/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -32,25 +32,22 @@ #include "ScriptDebugServer.h" #include "DebuggerCallFrame.h" +#include "DebuggerScope.h" +#include "Exception.h" +#include "JSCInlines.h" #include "JSJavaScriptCallFrame.h" -#include "JSLock.h" #include "JavaScriptCallFrame.h" #include "ScriptValue.h" #include "SourceProvider.h" -#include #include -#include -#include +#include using namespace JSC; -using namespace Inspector; namespace Inspector { -ScriptDebugServer::ScriptDebugServer(bool isInWorkerThread) - : Debugger(isInWorkerThread) - , m_doneProcessingDebuggerEvents(true) - , m_callingListeners(false) +ScriptDebugServer::ScriptDebugServer(VM& vm) + : Debugger(vm) { } @@ -58,62 +55,67 @@ ScriptDebugServer::~ScriptDebugServer() { } -JSC::BreakpointID ScriptDebugServer::setBreakpoint(JSC::SourceID sourceID, const ScriptBreakpoint& scriptBreakpoint, unsigned* actualLineNumber, unsigned* actualColumnNumber) +void ScriptDebugServer::setBreakpointActions(BreakpointID id, const ScriptBreakpoint& scriptBreakpoint) { - if (!sourceID) - return JSC::noBreakpointID; - - JSC::Breakpoint breakpoint(sourceID, scriptBreakpoint.lineNumber, scriptBreakpoint.columnNumber, scriptBreakpoint.condition, scriptBreakpoint.autoContinue); - JSC::BreakpointID id = Debugger::setBreakpoint(breakpoint, *actualLineNumber, *actualColumnNumber); - if (id != JSC::noBreakpointID && !scriptBreakpoint.actions.isEmpty()) { -#ifndef NDEBUG - BreakpointIDToActionsMap::iterator it = m_breakpointIDToActions.find(id); - ASSERT(it == m_breakpointIDToActions.end()); -#endif - const Vector &actions = scriptBreakpoint.actions; - m_breakpointIDToActions.set(id, actions); - } - return id; + ASSERT(id != noBreakpointID); + ASSERT(!m_breakpointIDToActions.contains(id)); + + m_breakpointIDToActions.set(id, scriptBreakpoint.actions); } -void ScriptDebugServer::removeBreakpoint(JSC::BreakpointID id) +void ScriptDebugServer::removeBreakpointActions(BreakpointID id) { - ASSERT(id != JSC::noBreakpointID); - BreakpointIDToActionsMap::iterator it = m_breakpointIDToActions.find(id); - if (it != m_breakpointIDToActions.end()) - m_breakpointIDToActions.remove(it); + ASSERT(id != noBreakpointID); - Debugger::removeBreakpoint(id); + m_breakpointIDToActions.remove(id); +} + +const BreakpointActions& ScriptDebugServer::getActionsForBreakpoint(BreakpointID id) +{ + ASSERT(id != noBreakpointID); + + auto entry = m_breakpointIDToActions.find(id); + if (entry != m_breakpointIDToActions.end()) + return entry->value; + + static NeverDestroyed emptyActionVector = BreakpointActions(); + return emptyActionVector; +} + +void ScriptDebugServer::clearBreakpointActions() +{ + m_breakpointIDToActions.clear(); } bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& breakpointAction) { - DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); + DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame(); switch (breakpointAction.type) { case ScriptBreakpointActionTypeLog: { - dispatchBreakpointActionLog(debuggerCallFrame->exec(), breakpointAction.data); + dispatchBreakpointActionLog(debuggerCallFrame.globalExec(), breakpointAction.data); break; } case ScriptBreakpointActionTypeEvaluate: { - JSValue exception; - debuggerCallFrame->evaluate(breakpointAction.data, exception); + NakedPtr exception; + JSObject* scopeExtensionObject = nullptr; + debuggerCallFrame.evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception); if (exception) - reportException(debuggerCallFrame->exec(), exception); + reportException(debuggerCallFrame.globalExec(), exception); break; } case ScriptBreakpointActionTypeSound: - dispatchBreakpointActionSound(debuggerCallFrame->exec()); + dispatchBreakpointActionSound(debuggerCallFrame.globalExec(), breakpointAction.identifier); break; case ScriptBreakpointActionTypeProbe: { - JSValue exception; - JSValue result = debuggerCallFrame->evaluate(breakpointAction.data, exception); + NakedPtr exception; + JSObject* scopeExtensionObject = nullptr; + JSValue result = debuggerCallFrame.evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception); + JSC::ExecState* exec = debuggerCallFrame.globalExec(); if (exception) - reportException(debuggerCallFrame->exec(), exception); - - JSC::ExecState* state = debuggerCallFrame->scope()->globalObject()->globalExec(); - Deprecated::ScriptValue wrappedResult = Deprecated::ScriptValue(state->vm(), exception ? exception : result); - dispatchDidSampleProbe(state, breakpointAction.identifier, wrappedResult); + reportException(exec, exception); + + dispatchBreakpointActionProbe(exec, breakpointAction, exception ? exception->value() : result); break; } default: @@ -123,21 +125,14 @@ bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& b return true; } -void ScriptDebugServer::clearBreakpoints() -{ - Debugger::clearBreakpoints(); - m_breakpointIDToActions.clear(); -} - void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener) { ASSERT(isPaused()); - DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); - JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject(); - JSC::ExecState* state = globalObject->globalExec(); - RefPtr javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame); - JSValue jsCallFrame = toJS(state, globalObject, javaScriptCallFrame.get()); - listener->didPause(state, Deprecated::ScriptValue(state->vm(), jsCallFrame), Deprecated::ScriptValue()); + DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame(); + JSGlobalObject* globalObject = debuggerCallFrame.scope()->globalObject(); + JSC::ExecState& state = *globalObject->globalExec(); + JSValue jsCallFrame = toJS(&state, globalObject, JavaScriptCallFrame::create(debuggerCallFrame).ptr()); + listener->didPause(state, jsCallFrame, exceptionOrCaughtValue(&state)); } void ScriptDebugServer::dispatchBreakpointActionLog(ExecState* exec, const String& message) @@ -145,53 +140,49 @@ void ScriptDebugServer::dispatchBreakpointActionLog(ExecState* exec, const Strin if (m_callingListeners) return; - ListenerSet* listeners = getListenersForGlobalObject(exec->lexicalGlobalObject()); - if (!listeners) + if (m_listeners.isEmpty()) return; - ASSERT(!listeners->isEmpty()); - TemporaryChange change(m_callingListeners, true); + SetForScope change(m_callingListeners, true); Vector listenersCopy; - copyToVector(*listeners, listenersCopy); - for (auto listener : listenersCopy) - listener->breakpointActionLog(exec, message); + copyToVector(m_listeners, listenersCopy); + for (auto* listener : listenersCopy) + listener->breakpointActionLog(*exec, message); } -void ScriptDebugServer::dispatchBreakpointActionSound(ExecState* exec) +void ScriptDebugServer::dispatchBreakpointActionSound(ExecState*, int breakpointActionIdentifier) { if (m_callingListeners) return; - ListenerSet* listeners = getListenersForGlobalObject(exec->lexicalGlobalObject()); - if (!listeners) + if (m_listeners.isEmpty()) return; - ASSERT(!listeners->isEmpty()); - TemporaryChange change(m_callingListeners, true); + SetForScope change(m_callingListeners, true); Vector listenersCopy; - copyToVector(*listeners, listenersCopy); - for (auto listener : listenersCopy) - listener->breakpointActionSound(); + copyToVector(m_listeners, listenersCopy); + for (auto* listener : listenersCopy) + listener->breakpointActionSound(breakpointActionIdentifier); } -void ScriptDebugServer::dispatchDidSampleProbe(ExecState* exec, int identifier, const Deprecated::ScriptValue& sample) +void ScriptDebugServer::dispatchBreakpointActionProbe(ExecState* exec, const ScriptBreakpointAction& action, JSC::JSValue sampleValue) { if (m_callingListeners) return; - ListenerSet* listeners = getListenersForGlobalObject(exec->lexicalGlobalObject()); - if (!listeners) + if (m_listeners.isEmpty()) return; - ASSERT(!listeners->isEmpty()); - TemporaryChange change(m_callingListeners, true); + SetForScope change(m_callingListeners, true); + + unsigned sampleId = m_nextProbeSampleId++; Vector listenersCopy; - copyToVector(*listeners, listenersCopy); - for (auto listener : listenersCopy) - listener->didSampleProbe(exec, identifier, m_hitCount, sample); + copyToVector(m_listeners, listenersCopy); + for (auto* listener : listenersCopy) + listener->breakpointActionProbe(*exec, action, m_currentProbeBatchId, sampleId, sampleValue); } void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener) @@ -203,12 +194,16 @@ void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, Sou { JSC::SourceID sourceID = sourceProvider->asID(); + // FIXME: Web Inspector: Simplify ScriptDebugListener::Script to use SourceProvider ScriptDebugListener::Script script; + script.sourceProvider = sourceProvider; script.url = sourceProvider->url(); - script.source = sourceProvider->source(); + script.source = sourceProvider->source().toString(); script.startLine = sourceProvider->startPosition().m_line.zeroBasedInt(); script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt(); script.isContentScript = isContentScript; + script.sourceURL = sourceProvider->sourceURL(); + script.sourceMappingURL = sourceProvider->sourceMappingURL(); int sourceLength = script.source.length(); int lineCount = 1; @@ -235,7 +230,7 @@ void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, Sou void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, int errorLine, const String& errorMessage) { String url = sourceProvider->url(); - const String& data = sourceProvider->source(); + String data = sourceProvider->source().toString(); int firstLine = sourceProvider->startPosition().m_line.oneBasedInt(); Vector copy; @@ -249,18 +244,29 @@ void ScriptDebugServer::sourceParsed(ExecState* exec, SourceProvider* sourceProv if (m_callingListeners) return; - ListenerSet* listeners = getListenersForGlobalObject(exec->lexicalGlobalObject()); - if (!listeners) + if (m_listeners.isEmpty()) return; - ASSERT(!listeners->isEmpty()); - TemporaryChange change(m_callingListeners, true); + SetForScope change(m_callingListeners, true); bool isError = errorLine != -1; if (isError) - dispatchFailedToParseSource(*listeners, sourceProvider, errorLine, errorMessage); + dispatchFailedToParseSource(m_listeners, sourceProvider, errorLine, errorMessage); else - dispatchDidParseSource(*listeners, sourceProvider, isContentScript(exec)); + dispatchDidParseSource(m_listeners, sourceProvider, isContentScript(exec)); +} + +void ScriptDebugServer::dispatchFunctionToListeners(JavaScriptExecutionCallback callback) +{ + if (m_callingListeners) + return; + + if (m_listeners.isEmpty()) + return; + + SetForScope change(m_callingListeners, true); + + dispatchFunctionToListeners(m_listeners, callback); } void ScriptDebugServer::dispatchFunctionToListeners(const ListenerSet& listeners, JavaScriptExecutionCallback callback) @@ -271,68 +277,81 @@ void ScriptDebugServer::dispatchFunctionToListeners(const ListenerSet& listeners (this->*callback)(copy[i]); } -void ScriptDebugServer::dispatchFunctionToListeners(JavaScriptExecutionCallback callback, JSGlobalObject* globalObject) -{ - if (m_callingListeners) - return; - - TemporaryChange change(m_callingListeners, true); - - if (ListenerSet* listeners = getListenersForGlobalObject(globalObject)) { - ASSERT(!listeners->isEmpty()); - dispatchFunctionToListeners(*listeners, callback); - } -} - void ScriptDebugServer::notifyDoneProcessingDebuggerEvents() { m_doneProcessingDebuggerEvents = true; } -bool ScriptDebugServer::needPauseHandling(JSGlobalObject* globalObject) +void ScriptDebugServer::handleBreakpointHit(JSC::JSGlobalObject* globalObject, const JSC::Breakpoint& breakpoint) { - return !!getListenersForGlobalObject(globalObject); -} + ASSERT(isAttached(globalObject)); -void ScriptDebugServer::handleBreakpointHit(const JSC::Breakpoint& breakpoint) -{ - m_hitCount++; - BreakpointIDToActionsMap::iterator it = m_breakpointIDToActions.find(breakpoint.id); - if (it != m_breakpointIDToActions.end()) { - BreakpointActions& actions = it->value; + m_currentProbeBatchId++; + + auto entry = m_breakpointIDToActions.find(breakpoint.id); + if (entry != m_breakpointIDToActions.end()) { + BreakpointActions actions = entry->value; for (size_t i = 0; i < actions.size(); ++i) { if (!evaluateBreakpointAction(actions[i])) return; + if (!isAttached(globalObject)) + return; } } } -void ScriptDebugServer::handleExceptionInBreakpointCondition(JSC::ExecState* exec, JSC::JSValue exception) const +void ScriptDebugServer::handleExceptionInBreakpointCondition(JSC::ExecState* exec, JSC::Exception* exception) const { reportException(exec, exception); } -void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* vmEntryGlobalObject) +void ScriptDebugServer::handlePause(JSGlobalObject* vmEntryGlobalObject, Debugger::ReasonForPause) { - dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, vmEntryGlobalObject); + dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause); didPause(vmEntryGlobalObject); m_doneProcessingDebuggerEvents = false; runEventLoopWhilePaused(); didContinue(vmEntryGlobalObject); - dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, vmEntryGlobalObject); + dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue); } -const Vector& ScriptDebugServer::getActionsForBreakpoint(JSC::BreakpointID breakpointID) +void ScriptDebugServer::addListener(ScriptDebugListener* listener) { - ASSERT(breakpointID != JSC::noBreakpointID); + ASSERT(listener); - if (m_breakpointIDToActions.contains(breakpointID)) - return m_breakpointIDToActions.find(breakpointID)->value; - - static NeverDestroyed> emptyActionVector = Vector(); - return emptyActionVector; + bool wasEmpty = m_listeners.isEmpty(); + m_listeners.add(listener); + + // First listener. Attach the debugger. + if (wasEmpty) + attachDebugger(); +} + +void ScriptDebugServer::removeListener(ScriptDebugListener* listener, bool isBeingDestroyed) +{ + ASSERT(listener); + + m_listeners.remove(listener); + + // Last listener. Detach the debugger. + if (m_listeners.isEmpty()) + detachDebugger(isBeingDestroyed); +} + +JSC::JSValue ScriptDebugServer::exceptionOrCaughtValue(JSC::ExecState* state) +{ + if (reasonForPause() == PausedForException) + return currentException(); + + for (RefPtr frame = ¤tDebuggerCallFrame(); frame; frame = frame->callerFrame()) { + DebuggerScope& scope = *frame->scope(); + if (scope.isCatchScope()) + return scope.caughtValue(state); + } + + return { }; } } // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/ScriptDebugServer.h b/Source/JavaScriptCore/inspector/ScriptDebugServer.h index 6d55de241..7e4c54335 100644 --- a/Source/JavaScriptCore/inspector/ScriptDebugServer.h +++ b/Source/JavaScriptCore/inspector/ScriptDebugServer.h @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,8 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScriptDebugServer_h -#define ScriptDebugServer_h +#pragma once #include "ScriptBreakpoint.h" #include "ScriptDebugListener.h" @@ -36,14 +35,12 @@ #include "debugger/Debugger.h" #include #include -#include -#include -#include #include namespace JSC { class ExecState; class JSGlobalObject; +class VM; } namespace Inspector { @@ -52,65 +49,63 @@ class JS_EXPORT_PRIVATE ScriptDebugServer : public JSC::Debugger { WTF_MAKE_NONCOPYABLE(ScriptDebugServer); WTF_MAKE_FAST_ALLOCATED; public: - JSC::BreakpointID setBreakpoint(JSC::SourceID, const ScriptBreakpoint&, unsigned* actualLineNumber, unsigned* actualColumnNumber); - void removeBreakpoint(JSC::BreakpointID); - void clearBreakpoints(); - virtual void recompileAllJSFunctions() = 0; + // FIXME: Move BreakpointAction handling into JSC::Debugger or InspectorDebuggerAgent. + void setBreakpointActions(JSC::BreakpointID, const ScriptBreakpoint&); + void removeBreakpointActions(JSC::BreakpointID); + void clearBreakpointActions(); - const Vector& getActionsForBreakpoint(JSC::BreakpointID); + const BreakpointActions& getActionsForBreakpoint(JSC::BreakpointID); - class Task { - WTF_MAKE_FAST_ALLOCATED; - public: - virtual ~Task() { } - virtual void run() = 0; - }; + void addListener(ScriptDebugListener*); + void removeListener(ScriptDebugListener*, bool isBeingDestroyed); protected: typedef HashSet ListenerSet; typedef void (ScriptDebugServer::*JavaScriptExecutionCallback)(ScriptDebugListener*); - ScriptDebugServer(bool isInWorkerThread = false); + ScriptDebugServer(JSC::VM&); ~ScriptDebugServer(); - virtual ListenerSet* getListenersForGlobalObject(JSC::JSGlobalObject*) = 0; + virtual void attachDebugger() = 0; + virtual void detachDebugger(bool isBeingDestroyed) = 0; + virtual void didPause(JSC::JSGlobalObject*) = 0; virtual void didContinue(JSC::JSGlobalObject*) = 0; virtual void runEventLoopWhilePaused() = 0; virtual bool isContentScript(JSC::ExecState*) const = 0; - virtual void reportException(JSC::ExecState*, JSC::JSValue) const = 0; + virtual void reportException(JSC::ExecState*, JSC::Exception*) const = 0; bool evaluateBreakpointAction(const ScriptBreakpointAction&); - void dispatchFunctionToListeners(JavaScriptExecutionCallback, JSC::JSGlobalObject*); + void dispatchFunctionToListeners(JavaScriptExecutionCallback); void dispatchFunctionToListeners(const ListenerSet& listeners, JavaScriptExecutionCallback); void dispatchDidPause(ScriptDebugListener*); void dispatchDidContinue(ScriptDebugListener*); void dispatchDidParseSource(const ListenerSet& listeners, JSC::SourceProvider*, bool isContentScript); void dispatchFailedToParseSource(const ListenerSet& listeners, JSC::SourceProvider*, int errorLine, const String& errorMessage); void dispatchBreakpointActionLog(JSC::ExecState*, const String&); - void dispatchBreakpointActionSound(JSC::ExecState*); - void dispatchDidSampleProbe(JSC::ExecState*, int probeIdentifier, const Deprecated::ScriptValue& sample); + void dispatchBreakpointActionSound(JSC::ExecState*, int breakpointActionIdentifier); + void dispatchBreakpointActionProbe(JSC::ExecState*, const ScriptBreakpointAction&, JSC::JSValue sample); - bool m_doneProcessingDebuggerEvents; + bool m_doneProcessingDebuggerEvents { true }; private: - typedef Vector BreakpointActions; typedef HashMap BreakpointIDToActionsMap; - virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const String& errorMsg) override final; - virtual bool needPauseHandling(JSC::JSGlobalObject*) override final; - virtual void handleBreakpointHit(const JSC::Breakpoint&) override final; - virtual void handleExceptionInBreakpointCondition(JSC::ExecState*, JSC::JSValue exception) const override final; - virtual void handlePause(JSC::Debugger::ReasonForPause, JSC::JSGlobalObject*) override final; - virtual void notifyDoneProcessingDebuggerEvents() override final; + void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const String& errorMsg) final; + void handleBreakpointHit(JSC::JSGlobalObject*, const JSC::Breakpoint&) final; + void handleExceptionInBreakpointCondition(JSC::ExecState*, JSC::Exception*) const final; + void handlePause(JSC::JSGlobalObject*, JSC::Debugger::ReasonForPause) final; + void notifyDoneProcessingDebuggerEvents() final; + + JSC::JSValue exceptionOrCaughtValue(JSC::ExecState*); - unsigned m_hitCount; - bool m_callingListeners; BreakpointIDToActionsMap m_breakpointIDToActions; + ListenerSet m_listeners; + bool m_callingListeners { false }; + unsigned m_nextProbeSampleId { 1 }; + unsigned m_currentProbeBatchId { 0 }; }; } // namespace Inspector - -#endif // ScriptDebugServer_h diff --git a/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp index fcee46e9d..f64baf3d3 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp +++ b/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2007-2010, 2015 Apple Inc. All rights reserved. * Copyright (C) 2008 Matt Lilek * Copyright (C) 2011 Google Inc. All rights reserved. * @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,18 +31,18 @@ #include "config.h" #include "InspectorAgent.h" -#if ENABLE(INSPECTOR) - +#include "InspectorEnvironment.h" +#include "InspectorFrontendRouter.h" #include "InspectorValues.h" #include "ScriptValue.h" -#include -#include namespace Inspector { -InspectorAgent::InspectorAgent() +InspectorAgent::InspectorAgent(AgentContext& context) : InspectorAgentBase(ASCIILiteral("Inspector")) - , m_enabled(false) + , m_environment(context.environment) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(InspectorBackendDispatcher::create(context.backendDispatcher, this)) { } @@ -50,43 +50,49 @@ InspectorAgent::~InspectorAgent() { } -void InspectorAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher) +void InspectorAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) { - m_frontendDispatcher = std::make_unique(frontendChannel); - m_backendDispatcher = InspectorInspectorBackendDispatcher::create(backendDispatcher, this); } -void InspectorAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason) +void InspectorAgent::willDestroyFrontendAndBackend(DisconnectReason) { - m_frontendDispatcher = nullptr; - m_backendDispatcher.clear(); - m_pendingEvaluateTestCommands.clear(); - ErrorString error; - disable(&error); + ErrorString unused; + disable(unused); } -void InspectorAgent::enable(ErrorString*) +void InspectorAgent::enable(ErrorString&) { m_enabled = true; if (m_pendingInspectData.first) - inspect(m_pendingInspectData.first, m_pendingInspectData.second); + inspect(m_pendingInspectData.first.copyRef(), m_pendingInspectData.second.copyRef()); + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_pendingExtraDomainsData) + m_frontendDispatcher->activateExtraDomains(m_pendingExtraDomainsData); +#endif + + for (auto& testCommand : m_pendingEvaluateTestCommands) + m_frontendDispatcher->evaluateForTestInFrontend(testCommand); - for (Vector>::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontendDispatcher && it != m_pendingEvaluateTestCommands.end(); ++it) - m_frontendDispatcher->evaluateForTestInFrontend(static_cast((*it).first), (*it).second); m_pendingEvaluateTestCommands.clear(); } -void InspectorAgent::disable(ErrorString*) +void InspectorAgent::disable(ErrorString&) { m_enabled = false; } -void InspectorAgent::inspect(PassRefPtr objectToInspect, PassRefPtr hints) +void InspectorAgent::initialized(ErrorString&) { - if (m_enabled && m_frontendDispatcher) { + m_environment.frontendInitialized(); +} + +void InspectorAgent::inspect(RefPtr&& objectToInspect, RefPtr&& hints) +{ + if (m_enabled) { m_frontendDispatcher->inspect(objectToInspect, hints); m_pendingInspectData.first = nullptr; m_pendingInspectData.second = nullptr; @@ -97,14 +103,43 @@ void InspectorAgent::inspect(PassRefPtr obje m_pendingInspectData.second = hints; } -void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script) +void InspectorAgent::evaluateForTestInFrontend(const String& script) { - if (m_enabled && m_frontendDispatcher) - m_frontendDispatcher->evaluateForTestInFrontend(static_cast(callId), script); + if (m_enabled) + m_frontendDispatcher->evaluateForTestInFrontend(script); else - m_pendingEvaluateTestCommands.append(std::pair(callId, script)); + m_pendingEvaluateTestCommands.append(script); } -} // namespace Inspector +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +void InspectorAgent::activateExtraDomain(const String& domainName) +{ + if (!m_enabled) { + if (!m_pendingExtraDomainsData) + m_pendingExtraDomainsData = Inspector::Protocol::Array::create(); + m_pendingExtraDomainsData->addItem(domainName); + return; + } -#endif // ENABLE(INSPECTOR) + auto domainNames = Inspector::Protocol::Array::create(); + domainNames->addItem(domainName); + m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames)); +} + +void InspectorAgent::activateExtraDomains(const Vector& extraDomains) +{ + if (extraDomains.isEmpty()) + return; + + auto domainNames = Inspector::Protocol::Array::create(); + for (auto domainName : extraDomains) + domainNames->addItem(domainName); + + if (!m_enabled) + m_pendingExtraDomainsData = WTFMove(domainNames); + else + m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames)); +} +#endif + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorAgent.h index c7dc9ba5a..a9b039207 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorAgent.h +++ b/Source/JavaScriptCore/inspector/agents/InspectorAgent.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2007-2010, 2015 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,46 +27,55 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorAgent_h -#define InspectorAgent_h +#pragma once -#include "InspectorJSBackendDispatchers.h" -#include "InspectorJSFrontendDispatchers.h" +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" #include "inspector/InspectorAgentBase.h" #include -#include #include namespace Inspector { +class BackendDispatcher; +class InspectorEnvironment; class InspectorObject; -class InstrumentingAgents; typedef String ErrorString; -class JS_EXPORT_PRIVATE InspectorAgent final : public InspectorAgentBase, public InspectorInspectorBackendDispatcherHandler { +class JS_EXPORT_PRIVATE InspectorAgent final : public InspectorAgentBase, public InspectorBackendDispatcherHandler { WTF_MAKE_NONCOPYABLE(InspectorAgent); + WTF_MAKE_FAST_ALLOCATED; public: - InspectorAgent(); + InspectorAgent(AgentContext&); virtual ~InspectorAgent(); - virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) override; - virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason reason) override; + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; + void willDestroyFrontendAndBackend(DisconnectReason) override; - virtual void enable(ErrorString*) override; - virtual void disable(ErrorString*) override; + void enable(ErrorString&) override; + void disable(ErrorString&) override; + void initialized(ErrorString&) override; - void inspect(PassRefPtr objectToInspect, PassRefPtr hints); - void evaluateForTestInFrontend(long testCallId, const String& script); + void inspect(RefPtr&& objectToInspect, RefPtr&& hints); + void evaluateForTestInFrontend(const String& script); + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + void activateExtraDomain(const String&); + void activateExtraDomains(const Vector&); +#endif private: - std::unique_ptr m_frontendDispatcher; - RefPtr m_backendDispatcher; - Vector> m_pendingEvaluateTestCommands; - std::pair, RefPtr> m_pendingInspectData; - bool m_enabled; + InspectorEnvironment& m_environment; + std::unique_ptr m_frontendDispatcher; + Ref m_backendDispatcher; + + Vector m_pendingEvaluateTestCommands; + std::pair, RefPtr> m_pendingInspectData; +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + RefPtr> m_pendingExtraDomainsData; +#endif + bool m_enabled { false }; }; } // namespace Inspector - -#endif // !defined(InspectorAgent_h) diff --git a/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp new file mode 100644 index 000000000..d453dbbd8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorConsoleAgent.h" + +#include "ConsoleMessage.h" +#include "InjectedScriptManager.h" +#include "InspectorFrontendRouter.h" +#include "InspectorHeapAgent.h" +#include "ScriptArguments.h" +#include "ScriptCallFrame.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" +#include "ScriptObject.h" +#include +#include + +namespace Inspector { + +static const unsigned maximumConsoleMessages = 100; +static const int expireConsoleMessagesStep = 10; + +InspectorConsoleAgent::InspectorConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent) + : InspectorAgentBase(ASCIILiteral("Console")) + , m_injectedScriptManager(context.injectedScriptManager) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(ConsoleBackendDispatcher::create(context.backendDispatcher, this)) + , m_heapAgent(heapAgent) +{ +} + +InspectorConsoleAgent::~InspectorConsoleAgent() +{ +} + +void InspectorConsoleAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) +{ +} + +void InspectorConsoleAgent::willDestroyFrontendAndBackend(DisconnectReason) +{ + String errorString; + disable(errorString); +} + +void InspectorConsoleAgent::discardValues() +{ + m_consoleMessages.clear(); +} + +void InspectorConsoleAgent::enable(ErrorString&) +{ + if (m_enabled) + return; + + m_enabled = true; + + if (m_expiredConsoleMessageCount) { + ConsoleMessage expiredMessage(MessageSource::Other, MessageType::Log, MessageLevel::Warning, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount)); + expiredMessage.addToFrontend(*m_frontendDispatcher, m_injectedScriptManager, false); + } + + size_t messageCount = m_consoleMessages.size(); + for (size_t i = 0; i < messageCount; ++i) + m_consoleMessages[i]->addToFrontend(*m_frontendDispatcher, m_injectedScriptManager, false); +} + +void InspectorConsoleAgent::disable(ErrorString&) +{ + if (!m_enabled) + return; + + m_enabled = false; +} + +void InspectorConsoleAgent::clearMessages(ErrorString&) +{ + m_consoleMessages.clear(); + m_expiredConsoleMessageCount = 0; + m_previousMessage = nullptr; + + m_injectedScriptManager.releaseObjectGroup(ASCIILiteral("console")); + + if (m_enabled) + m_frontendDispatcher->messagesCleared(); +} + +void InspectorConsoleAgent::reset() +{ + ErrorString unused; + clearMessages(unused); + + m_times.clear(); + m_counts.clear(); +} + +void InspectorConsoleAgent::addMessageToConsole(std::unique_ptr message) +{ + if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) + return; + + if (message->type() == MessageType::Clear) { + ErrorString unused; + clearMessages(unused); + } + + addConsoleMessage(WTFMove(message)); +} + +void InspectorConsoleAgent::startTiming(const String& title) +{ + ASSERT(!title.isNull()); + if (title.isNull()) + return; + + auto result = m_times.add(title, monotonicallyIncreasingTime()); + + if (!result.isNewEntry) { + // FIXME: Send an enum to the frontend for localization? + String warning = makeString("Timer \"", title, "\" already exists"); + addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning)); + } +} + +void InspectorConsoleAgent::stopTiming(const String& title, Ref&& callStack) +{ + ASSERT(!title.isNull()); + if (title.isNull()) + return; + + auto it = m_times.find(title); + if (it == m_times.end()) { + // FIXME: Send an enum to the frontend for localization? + String warning = makeString("Timer \"", title, "\" does not exist"); + addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning)); + return; + } + + double startTime = it->value; + m_times.remove(it); + + double elapsed = monotonicallyIncreasingTime() - startTime; + String message = title + String::format(": %.3fms", elapsed * 1000); + addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack))); +} + +void InspectorConsoleAgent::takeHeapSnapshot(const String& title) +{ + if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) + return; + + ErrorString ignored; + double timestamp; + String snapshotData; + m_heapAgent->snapshot(ignored, ×tamp, &snapshotData); + + m_frontendDispatcher->heapSnapshot(timestamp, snapshotData, title.isEmpty() ? nullptr : &title); +} + +void InspectorConsoleAgent::count(JSC::ExecState* state, Ref&& arguments) +{ + Ref callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture); + + String title; + String identifier; + if (!arguments->argumentCount()) { + // '@' prefix for engine generated labels. + title = ASCIILiteral("Global"); + identifier = makeString('@', title); + } else { + // '#' prefix for user labels. + arguments->getFirstArgumentAsString(title); + identifier = makeString('#', title); + } + + auto result = m_counts.add(identifier, 1); + if (!result.isNewEntry) + result.iterator->value += 1; + + // FIXME: Web Inspector should have a better UI for counters, but for now we just log an updated counter value. + + String message = makeString(title, ": ", String::number(result.iterator->value)); + addMessageToConsole(std::make_unique(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, WTFMove(callStack))); +} + +static bool isGroupMessage(MessageType type) +{ + return type == MessageType::StartGroup + || type == MessageType::StartGroupCollapsed + || type == MessageType::EndGroup; +} + +void InspectorConsoleAgent::addConsoleMessage(std::unique_ptr consoleMessage) +{ + ASSERT(m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()); + ASSERT_ARG(consoleMessage, consoleMessage); + + if (m_previousMessage && !isGroupMessage(m_previousMessage->type()) && m_previousMessage->isEqual(consoleMessage.get())) { + m_previousMessage->incrementCount(); + if (m_enabled) + m_previousMessage->updateRepeatCountInConsole(*m_frontendDispatcher); + } else { + m_previousMessage = consoleMessage.get(); + m_consoleMessages.append(WTFMove(consoleMessage)); + if (m_enabled) + m_previousMessage->addToFrontend(*m_frontendDispatcher, m_injectedScriptManager, true); + } + + if (m_consoleMessages.size() >= maximumConsoleMessages) { + m_expiredConsoleMessageCount += expireConsoleMessagesStep; + m_consoleMessages.remove(0, expireConsoleMessagesStep); + } +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h new file mode 100644 index 000000000..175cec9da --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h @@ -0,0 +1,94 @@ +/* +* Copyright (C) 2014, 2015 Apple Inc. All rights reserved. +* Copyright (C) 2011 Google Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#pragma once + +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" +#include "inspector/InspectorAgentBase.h" +#include "runtime/ConsoleTypes.h" +#include +#include +#include +#include +#include + +namespace JSC { +class ExecState; +} + +namespace Inspector { + +class ConsoleMessage; +class InjectedScriptManager; +class InspectorHeapAgent; +class ScriptArguments; +class ScriptCallStack; +typedef String ErrorString; + +class JS_EXPORT_PRIVATE InspectorConsoleAgent : public InspectorAgentBase, public ConsoleBackendDispatcherHandler { + WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent); + WTF_MAKE_FAST_ALLOCATED; +public: + InspectorConsoleAgent(AgentContext&, InspectorHeapAgent*); + virtual ~InspectorConsoleAgent(); + + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; + void willDestroyFrontendAndBackend(DisconnectReason) override; + void discardValues() override; + + void enable(ErrorString&) override; + void disable(ErrorString&) override; + void clearMessages(ErrorString&) override; + void setMonitoringXHREnabled(ErrorString&, bool enabled) override = 0; + void addInspectedNode(ErrorString&, int nodeId) override = 0; + + bool enabled() const { return m_enabled; } + void reset(); + + void addMessageToConsole(std::unique_ptr); + + void startTiming(const String& title); + void stopTiming(const String& title, Ref&&); + void takeHeapSnapshot(const String& title); + void count(JSC::ExecState*, Ref&&); + +protected: + void addConsoleMessage(std::unique_ptr); + + InjectedScriptManager& m_injectedScriptManager; + std::unique_ptr m_frontendDispatcher; + RefPtr m_backendDispatcher; + InspectorHeapAgent* m_heapAgent; + + ConsoleMessage* m_previousMessage { nullptr }; + Vector> m_consoleMessages; + int m_expiredConsoleMessageCount { 0 }; + HashMap m_counts; + HashMap m_times; + bool m_enabled { false }; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp index 06b759568..617efb9ac 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp +++ b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. - * Copyright (C) 2010-2011 Google Inc. All rights reserved. + * Copyright (C) 2010, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -30,38 +30,43 @@ #include "config.h" #include "InspectorDebuggerAgent.h" -#if ENABLE(INSPECTOR) - +#include "AsyncStackTrace.h" #include "ContentSearchUtilities.h" #include "InjectedScript.h" #include "InjectedScriptManager.h" +#include "InspectorFrontendRouter.h" #include "InspectorValues.h" +#include "JSCInlines.h" #include "RegularExpression.h" +#include "ScriptCallStackFactory.h" #include "ScriptDebugServer.h" #include "ScriptObject.h" #include "ScriptValue.h" +#include +#include #include namespace Inspector { const char* InspectorDebuggerAgent::backtraceObjectGroup = "backtrace"; -static String objectGroupForBreakpointAction(int identifier) +// Objects created and retained by evaluating breakpoint actions are put into object groups +// according to the breakpoint action identifier assigned by the frontend. A breakpoint may +// have several object groups, and objects from several backend breakpoint action instances may +// create objects in the same group. +static String objectGroupForBreakpointAction(const ScriptBreakpointAction& action) { - DEFINE_STATIC_LOCAL(const AtomicString, objectGroup, ("breakpoint-action-", AtomicString::ConstructFromLiteral)); - return makeString(objectGroup, String::number(identifier)); + static NeverDestroyed objectGroup(ASCIILiteral("breakpoint-action-")); + return makeString(objectGroup.get(), String::number(action.identifier)); } -InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedScriptManager) +InspectorDebuggerAgent::InspectorDebuggerAgent(AgentContext& context) : InspectorAgentBase(ASCIILiteral("Debugger")) - , m_injectedScriptManager(injectedScriptManager) - , m_listener(nullptr) - , m_pausedScriptState(nullptr) + , m_injectedScriptManager(context.injectedScriptManager) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(DebuggerBackendDispatcher::create(context.backendDispatcher, this)) + , m_scriptDebugServer(context.environment.scriptDebugServer()) , m_continueToLocationBreakpointID(JSC::noBreakpointID) - , m_enabled(false) - , m_javaScriptPauseScheduled(false) - , m_nextProbeSampleId(1) - , m_nextBreakpointActionIdentifier(1) { // FIXME: make breakReason optional so that there was no need to init it with "other". clearBreakDetails(); @@ -71,18 +76,13 @@ InspectorDebuggerAgent::~InspectorDebuggerAgent() { } -void InspectorDebuggerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher) +void InspectorDebuggerAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) { - m_frontendDispatcher = std::make_unique(frontendChannel); - m_backendDispatcher = InspectorDebuggerBackendDispatcher::create(backendDispatcher, this); } -void InspectorDebuggerAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason reason) +void InspectorDebuggerAgent::willDestroyFrontendAndBackend(DisconnectReason reason) { - m_frontendDispatcher = nullptr; - m_backendDispatcher.clear(); - - bool skipRecompile = reason == InspectorDisconnectReason::InspectedTargetDestroyed; + bool skipRecompile = reason == DisconnectReason::InspectedTargetDestroyed; disable(skipRecompile); } @@ -91,8 +91,7 @@ void InspectorDebuggerAgent::enable() if (m_enabled) return; - scriptDebugServer().setBreakpointsActivated(true); - startListeningScriptDebugServer(); + m_scriptDebugServer.addListener(this); if (m_listener) m_listener->debuggerWasEnabled(); @@ -105,55 +104,221 @@ void InspectorDebuggerAgent::disable(bool isBeingDestroyed) if (!m_enabled) return; - m_javaScriptBreakpoints.clear(); + m_scriptDebugServer.removeListener(this, isBeingDestroyed); + clearInspectorBreakpointState(); + + if (!isBeingDestroyed) + m_scriptDebugServer.deactivateBreakpoints(); - stopListeningScriptDebugServer(isBeingDestroyed); - clearResolvedBreakpointState(); + ASSERT(m_javaScriptBreakpoints.isEmpty()); if (m_listener) m_listener->debuggerWasDisabled(); + clearAsyncStackTraceData(); + + m_pauseOnAssertionFailures = false; + m_enabled = false; } -void InspectorDebuggerAgent::enable(ErrorString*) +void InspectorDebuggerAgent::enable(ErrorString&) { enable(); } -void InspectorDebuggerAgent::disable(ErrorString*) +void InspectorDebuggerAgent::disable(ErrorString&) { disable(false); } -void InspectorDebuggerAgent::setBreakpointsActive(ErrorString*, bool active) +bool InspectorDebuggerAgent::breakpointsActive() const +{ + return m_scriptDebugServer.breakpointsActive(); +} + +void InspectorDebuggerAgent::setAsyncStackTraceDepth(ErrorString& errorString, int depth) +{ + if (m_asyncStackTraceDepth == depth) + return; + + if (depth < 0) { + errorString = ASCIILiteral("depth must be a positive number."); + return; + } + + m_asyncStackTraceDepth = depth; + + if (!m_asyncStackTraceDepth) + clearAsyncStackTraceData(); +} + +void InspectorDebuggerAgent::setBreakpointsActive(ErrorString&, bool active) { if (active) - scriptDebugServer().activateBreakpoints(); + m_scriptDebugServer.activateBreakpoints(); else - scriptDebugServer().deactivateBreakpoints(); + m_scriptDebugServer.deactivateBreakpoints(); +} + +bool InspectorDebuggerAgent::isPaused() const +{ + return m_scriptDebugServer.isPaused(); +} + +void InspectorDebuggerAgent::setSuppressAllPauses(bool suppress) +{ + m_scriptDebugServer.setSuppressAllPauses(suppress); +} + +static RefPtr buildAssertPauseReason(const String& message) +{ + auto reason = Inspector::Protocol::Debugger::AssertPauseReason::create().release(); + if (!message.isNull()) + reason->setMessage(message); + return reason->openAccessors(); +} + +static RefPtr buildCSPViolationPauseReason(const String& directiveText) +{ + auto reason = Inspector::Protocol::Debugger::CSPViolationPauseReason::create() + .setDirective(directiveText) + .release(); + return reason->openAccessors(); +} + +RefPtr InspectorDebuggerAgent::buildBreakpointPauseReason(JSC::BreakpointID debuggerBreakpointIdentifier) +{ + ASSERT(debuggerBreakpointIdentifier != JSC::noBreakpointID); + auto it = m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.find(debuggerBreakpointIdentifier); + if (it == m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.end()) + return nullptr; + + auto reason = Inspector::Protocol::Debugger::BreakpointPauseReason::create() + .setBreakpointId(it->value) + .release(); + return reason->openAccessors(); +} + +RefPtr InspectorDebuggerAgent::buildExceptionPauseReason(JSC::JSValue exception, const InjectedScript& injectedScript) +{ + ASSERT(exception); + if (!exception) + return nullptr; + + ASSERT(!injectedScript.hasNoValue()); + if (injectedScript.hasNoValue()) + return nullptr; + + return injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors(); +} + +void InspectorDebuggerAgent::handleConsoleAssert(const String& message) +{ + if (!m_scriptDebugServer.breakpointsActive()) + return; + + if (m_pauseOnAssertionFailures) + breakProgram(DebuggerFrontendDispatcher::Reason::Assert, buildAssertPauseReason(message)); +} + +void InspectorDebuggerAgent::didScheduleAsyncCall(JSC::ExecState* exec, int asyncCallType, int callbackIdentifier, bool singleShot) +{ + if (!m_asyncStackTraceDepth) + return; + + if (!m_scriptDebugServer.breakpointsActive()) + return; + + Ref callStack = createScriptCallStack(exec, m_asyncStackTraceDepth); + ASSERT(callStack->size()); + if (!callStack->size()) + return; + + RefPtr parentStackTrace; + if (m_currentAsyncCallIdentifier) { + auto it = m_pendingAsyncCalls.find(m_currentAsyncCallIdentifier.value()); + ASSERT(it != m_pendingAsyncCalls.end()); + parentStackTrace = it->value; + } + + auto identifier = std::make_pair(asyncCallType, callbackIdentifier); + auto asyncStackTrace = AsyncStackTrace::create(WTFMove(callStack), singleShot, WTFMove(parentStackTrace)); + + m_pendingAsyncCalls.set(identifier, WTFMove(asyncStackTrace)); +} + +void InspectorDebuggerAgent::didCancelAsyncCall(int asyncCallType, int callbackIdentifier) +{ + if (!m_asyncStackTraceDepth) + return; + + auto identifier = std::make_pair(asyncCallType, callbackIdentifier); + auto it = m_pendingAsyncCalls.find(identifier); + if (it == m_pendingAsyncCalls.end()) + return; + + auto& asyncStackTrace = it->value; + asyncStackTrace->didCancelAsyncCall(); + + if (m_currentAsyncCallIdentifier && m_currentAsyncCallIdentifier.value() == identifier) + return; + + m_pendingAsyncCalls.remove(identifier); } -bool InspectorDebuggerAgent::isPaused() +void InspectorDebuggerAgent::willDispatchAsyncCall(int asyncCallType, int callbackIdentifier) { - return scriptDebugServer().isPaused(); + if (!m_asyncStackTraceDepth) + return; + + if (m_currentAsyncCallIdentifier) + return; + + // A call can be scheduled before the Inspector is opened, or while async stack + // traces are disabled. If no call data exists, do nothing. + auto identifier = std::make_pair(asyncCallType, callbackIdentifier); + auto it = m_pendingAsyncCalls.find(identifier); + if (it == m_pendingAsyncCalls.end()) + return; + + auto& asyncStackTrace = it->value; + asyncStackTrace->willDispatchAsyncCall(m_asyncStackTraceDepth); + + m_currentAsyncCallIdentifier = identifier; } -void InspectorDebuggerAgent::handleConsoleAssert() +void InspectorDebuggerAgent::didDispatchAsyncCall() { - if (scriptDebugServer().pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions) - breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Assert, nullptr); + if (!m_asyncStackTraceDepth) + return; + + if (!m_currentAsyncCallIdentifier) + return; + + auto identifier = m_currentAsyncCallIdentifier.value(); + auto it = m_pendingAsyncCalls.find(identifier); + ASSERT(it != m_pendingAsyncCalls.end()); + + auto& asyncStackTrace = it->value; + asyncStackTrace->didDispatchAsyncCall(); + + m_currentAsyncCallIdentifier = std::nullopt; + + if (!asyncStackTrace->isPending()) + m_pendingAsyncCalls.remove(identifier); } -static PassRefPtr buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, RefPtr& actions, bool isRegex, bool autoContinue) +static Ref buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, RefPtr& actions, bool isRegex, bool autoContinue, unsigned ignoreCount) { - RefPtr breakpointObject = InspectorObject::create(); + Ref breakpointObject = InspectorObject::create(); breakpointObject->setString(ASCIILiteral("url"), url); - breakpointObject->setNumber(ASCIILiteral("lineNumber"), lineNumber); - breakpointObject->setNumber(ASCIILiteral("columnNumber"), columnNumber); + breakpointObject->setInteger(ASCIILiteral("lineNumber"), lineNumber); + breakpointObject->setInteger(ASCIILiteral("columnNumber"), columnNumber); breakpointObject->setString(ASCIILiteral("condition"), condition); breakpointObject->setBoolean(ASCIILiteral("isRegex"), isRegex); breakpointObject->setBoolean(ASCIILiteral("autoContinue"), autoContinue); + breakpointObject->setInteger(ASCIILiteral("ignoreCount"), ignoreCount); if (actions) breakpointObject->setArray(ASCIILiteral("actions"), actions); @@ -172,19 +337,19 @@ static bool matches(const String& url, const String& pattern, bool isRegex) static bool breakpointActionTypeForString(const String& typeString, ScriptBreakpointActionType* output) { - if (typeString == Inspector::TypeBuilder::getJSEnumConstantValue(Inspector::TypeBuilder::Debugger::BreakpointAction::Type::Log)) { + if (typeString == Inspector::Protocol::InspectorHelpers::getEnumConstantValue(Inspector::Protocol::Debugger::BreakpointAction::Type::Log)) { *output = ScriptBreakpointActionTypeLog; return true; } - if (typeString == Inspector::TypeBuilder::getJSEnumConstantValue(Inspector::TypeBuilder::Debugger::BreakpointAction::Type::Evaluate)) { + if (typeString == Inspector::Protocol::InspectorHelpers::getEnumConstantValue(Inspector::Protocol::Debugger::BreakpointAction::Type::Evaluate)) { *output = ScriptBreakpointActionTypeEvaluate; return true; } - if (typeString == Inspector::TypeBuilder::getJSEnumConstantValue(Inspector::TypeBuilder::Debugger::BreakpointAction::Type::Sound)) { + if (typeString == Inspector::Protocol::InspectorHelpers::getEnumConstantValue(Inspector::Protocol::Debugger::BreakpointAction::Type::Sound)) { *output = ScriptBreakpointActionTypeSound; return true; } - if (typeString == Inspector::TypeBuilder::getJSEnumConstantValue(Inspector::TypeBuilder::Debugger::BreakpointAction::Type::Probe)) { + if (typeString == Inspector::Protocol::InspectorHelpers::getEnumConstantValue(Inspector::Protocol::Debugger::BreakpointAction::Type::Probe)) { *output = ScriptBreakpointActionTypeProbe; return true; } @@ -192,7 +357,7 @@ static bool breakpointActionTypeForString(const String& typeString, ScriptBreakp return false; } -bool InspectorDebuggerAgent::breakpointActionsFromProtocol(ErrorString* errorString, RefPtr& actions, Vector* result) +bool InspectorDebuggerAgent::breakpointActionsFromProtocol(ErrorString& errorString, RefPtr& actions, BreakpointActions* result) { if (!actions) return true; @@ -205,37 +370,70 @@ bool InspectorDebuggerAgent::breakpointActionsFromProtocol(ErrorString* errorStr for (unsigned i = 0; i < actionsLength; ++i) { RefPtr value = actions->get(i); RefPtr object; - if (!value->asObject(&object)) { - *errorString = ASCIILiteral("BreakpointAction of incorrect type, expected object"); + if (!value->asObject(object)) { + errorString = ASCIILiteral("BreakpointAction of incorrect type, expected object"); return false; } String typeString; - if (!object->getString(ASCIILiteral("type"), &typeString)) { - *errorString = ASCIILiteral("BreakpointAction had type missing"); + if (!object->getString(ASCIILiteral("type"), typeString)) { + errorString = ASCIILiteral("BreakpointAction had type missing"); return false; } ScriptBreakpointActionType type; if (!breakpointActionTypeForString(typeString, &type)) { - *errorString = ASCIILiteral("BreakpointAction had unknown type"); + errorString = ASCIILiteral("BreakpointAction had unknown type"); return false; } + // Specifying an identifier is optional. They are used to correlate probe samples + // in the frontend across multiple backend probe actions and segregate object groups. + int identifier = 0; + object->getInteger(ASCIILiteral("id"), identifier); + String data; - object->getString(ASCIILiteral("data"), &data); + object->getString(ASCIILiteral("data"), data); - result->append(ScriptBreakpointAction(type, m_nextBreakpointActionIdentifier++, data)); + result->append(ScriptBreakpointAction(type, identifier, data)); } return true; } -void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int lineNumber, const String* const optionalURL, const String* const optionalURLRegex, const int* const optionalColumnNumber, const RefPtr* options, Inspector::TypeBuilder::Debugger::BreakpointId* outBreakpointIdentifier, RefPtr>& locations, RefPtr>& breakpointActionIdentifiers) +static RefPtr buildDebuggerLocation(const JSC::Breakpoint& breakpoint) +{ + ASSERT(breakpoint.resolved); + + auto location = Inspector::Protocol::Debugger::Location::create() + .setScriptId(String::number(breakpoint.sourceID)) + .setLineNumber(breakpoint.line) + .release(); + location->setColumnNumber(breakpoint.column); + + return WTFMove(location); +} + +static bool parseLocation(ErrorString& errorString, const InspectorObject& location, JSC::SourceID& sourceID, unsigned& lineNumber, unsigned& columnNumber) { - locations = Inspector::TypeBuilder::Array::create(); + String scriptIDStr; + if (!location.getString(ASCIILiteral("scriptId"), scriptIDStr) || !location.getInteger(ASCIILiteral("lineNumber"), lineNumber)) { + sourceID = JSC::noSourceID; + errorString = ASCIILiteral("scriptId and lineNumber are required."); + return false; + } + + sourceID = scriptIDStr.toIntPtr(); + columnNumber = 0; + location.getInteger(ASCIILiteral("columnNumber"), columnNumber); + return true; +} + +void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString& errorString, int lineNumber, const String* const optionalURL, const String* const optionalURLRegex, const int* const optionalColumnNumber, const InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId* outBreakpointIdentifier, RefPtr>& locations) +{ + locations = Inspector::Protocol::Array::create(); if (!optionalURL == !optionalURLRegex) { - *errorString = ASCIILiteral("Either url or urlRegex must be specified."); + errorString = ASCIILiteral("Either url or urlRegex must be specified."); return; } @@ -245,258 +443,361 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li String breakpointIdentifier = (isRegex ? "/" + url + "/" : url) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber); if (m_javaScriptBreakpoints.contains(breakpointIdentifier)) { - *errorString = ASCIILiteral("Breakpoint at specified location already exists."); + errorString = ASCIILiteral("Breakpoint at specified location already exists."); return; } String condition = emptyString(); bool autoContinue = false; + unsigned ignoreCount = 0; RefPtr actions; if (options) { - (*options)->getString(ASCIILiteral("condition"), &condition); - (*options)->getBoolean(ASCIILiteral("autoContinue"), &autoContinue); - actions = (*options)->getArray(ASCIILiteral("actions")); + options->getString(ASCIILiteral("condition"), condition); + options->getBoolean(ASCIILiteral("autoContinue"), autoContinue); + options->getArray(ASCIILiteral("actions"), actions); + options->getInteger(ASCIILiteral("ignoreCount"), ignoreCount); } - Vector breakpointActions; + BreakpointActions breakpointActions; if (!breakpointActionsFromProtocol(errorString, actions, &breakpointActions)) return; - breakpointActionIdentifiers = Inspector::TypeBuilder::Array::create(); - for (ScriptBreakpointAction& action : breakpointActions) - breakpointActionIdentifiers->addItem(action.identifier); + m_javaScriptBreakpoints.set(breakpointIdentifier, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, actions, isRegex, autoContinue, ignoreCount)); - m_javaScriptBreakpoints.set(breakpointIdentifier, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, actions, isRegex, autoContinue)); + for (auto& entry : m_scripts) { + Script& script = entry.value; + String scriptURLForBreakpoints = !script.sourceURL.isEmpty() ? script.sourceURL : script.url; + if (!matches(scriptURLForBreakpoints, url, isRegex)) + continue; - ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue); - for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) { - String scriptURL = !it->value.sourceURL.isEmpty() ? it->value.sourceURL : it->value.url; - if (!matches(scriptURL, url, isRegex)) + JSC::SourceID sourceID = entry.key; + JSC::Breakpoint breakpoint(sourceID, lineNumber, columnNumber, condition, autoContinue, ignoreCount); + resolveBreakpoint(script, breakpoint); + if (!breakpoint.resolved) continue; - RefPtr location = resolveBreakpoint(breakpointIdentifier, it->key, breakpoint); - if (location) - locations->addItem(location); - } - *outBreakpointIdentifier = breakpointIdentifier; -} + bool existing; + setBreakpoint(breakpoint, existing); + if (existing) + continue; -static bool parseLocation(ErrorString* errorString, InspectorObject* location, JSC::SourceID* sourceID, unsigned* lineNumber, unsigned* columnNumber) -{ - String scriptIDStr; - if (!location->getString(ASCIILiteral("scriptId"), &scriptIDStr) || !location->getNumber(ASCIILiteral("lineNumber"), lineNumber)) { - *sourceID = JSC::noSourceID; - *errorString = ASCIILiteral("scriptId and lineNumber are required."); - return false; + ScriptBreakpoint scriptBreakpoint(breakpoint.line, breakpoint.column, condition, breakpointActions, autoContinue, ignoreCount); + didSetBreakpoint(breakpoint, breakpointIdentifier, scriptBreakpoint); + + locations->addItem(buildDebuggerLocation(breakpoint)); } - *sourceID = scriptIDStr.toIntPtr(); - *columnNumber = 0; - location->getNumber(ASCIILiteral("columnNumber"), columnNumber); - return true; + *outBreakpointIdentifier = breakpointIdentifier; } -void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPtr& location, const RefPtr* options, Inspector::TypeBuilder::Debugger::BreakpointId* outBreakpointIdentifier, RefPtr& actualLocation, RefPtr>& breakpointActionIdentifiers) +void InspectorDebuggerAgent::setBreakpoint(ErrorString& errorString, const InspectorObject& location, const InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId* outBreakpointIdentifier, RefPtr& actualLocation) { JSC::SourceID sourceID; unsigned lineNumber; unsigned columnNumber; - if (!parseLocation(errorString, location.get(), &sourceID, &lineNumber, &columnNumber)) + if (!parseLocation(errorString, location, sourceID, lineNumber, columnNumber)) return; String condition = emptyString(); bool autoContinue = false; + unsigned ignoreCount = 0; RefPtr actions; if (options) { - (*options)->getString(ASCIILiteral("condition"), &condition); - (*options)->getBoolean(ASCIILiteral("autoContinue"), &autoContinue); - actions = (*options)->getArray(ASCIILiteral("actions")); + options->getString(ASCIILiteral("condition"), condition); + options->getBoolean(ASCIILiteral("autoContinue"), autoContinue); + options->getArray(ASCIILiteral("actions"), actions); + options->getInteger(ASCIILiteral("ignoreCount"), ignoreCount); } - Vector breakpointActions; + BreakpointActions breakpointActions; if (!breakpointActionsFromProtocol(errorString, actions, &breakpointActions)) return; - breakpointActionIdentifiers = Inspector::TypeBuilder::Array::create(); - for (ScriptBreakpointAction& action : breakpointActions) - breakpointActionIdentifiers->addItem(action.identifier); + auto scriptIterator = m_scripts.find(sourceID); + if (scriptIterator == m_scripts.end()) { + errorString = ASCIILiteral("No script for id: ") + String::number(sourceID); + return; + } - String breakpointIdentifier = String::number(sourceID) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber); - if (m_breakpointIdentifierToDebugServerBreakpointIDs.find(breakpointIdentifier) != m_breakpointIdentifierToDebugServerBreakpointIDs.end()) { - *errorString = ASCIILiteral("Breakpoint at specified location already exists."); + Script& script = scriptIterator->value; + JSC::Breakpoint breakpoint(sourceID, lineNumber, columnNumber, condition, autoContinue, ignoreCount); + resolveBreakpoint(script, breakpoint); + if (!breakpoint.resolved) { + errorString = ASCIILiteral("Could not resolve breakpoint"); return; } - ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue); - actualLocation = resolveBreakpoint(breakpointIdentifier, sourceID, breakpoint); - if (!actualLocation) { - *errorString = ASCIILiteral("Could not resolve breakpoint"); + bool existing; + setBreakpoint(breakpoint, existing); + if (existing) { + errorString = ASCIILiteral("Breakpoint at specified location already exists"); return; } + String breakpointIdentifier = String::number(sourceID) + ':' + String::number(breakpoint.line) + ':' + String::number(breakpoint.column); + ScriptBreakpoint scriptBreakpoint(breakpoint.line, breakpoint.column, condition, breakpointActions, autoContinue, ignoreCount); + didSetBreakpoint(breakpoint, breakpointIdentifier, scriptBreakpoint); + + actualLocation = buildDebuggerLocation(breakpoint); *outBreakpointIdentifier = breakpointIdentifier; } -void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakpointIdentifier) +void InspectorDebuggerAgent::didSetBreakpoint(const JSC::Breakpoint& breakpoint, const String& breakpointIdentifier, const ScriptBreakpoint& scriptBreakpoint) +{ + JSC::BreakpointID id = breakpoint.id; + m_scriptDebugServer.setBreakpointActions(id, scriptBreakpoint); + + auto debugServerBreakpointIDsIterator = m_breakpointIdentifierToDebugServerBreakpointIDs.find(breakpointIdentifier); + if (debugServerBreakpointIDsIterator == m_breakpointIdentifierToDebugServerBreakpointIDs.end()) + debugServerBreakpointIDsIterator = m_breakpointIdentifierToDebugServerBreakpointIDs.set(breakpointIdentifier, Vector()).iterator; + debugServerBreakpointIDsIterator->value.append(id); + + m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.set(id, breakpointIdentifier); +} + +void InspectorDebuggerAgent::resolveBreakpoint(const Script& script, JSC::Breakpoint& breakpoint) +{ + if (breakpoint.line < static_cast(script.startLine) || static_cast(script.endLine) < breakpoint.line) + return; + + m_scriptDebugServer.resolveBreakpoint(breakpoint, script.sourceProvider.get()); +} + +void InspectorDebuggerAgent::setBreakpoint(JSC::Breakpoint& breakpoint, bool& existing) +{ + JSC::JSLockHolder locker(m_scriptDebugServer.vm()); + m_scriptDebugServer.setBreakpoint(breakpoint, existing); +} + +void InspectorDebuggerAgent::removeBreakpoint(ErrorString&, const String& breakpointIdentifier) { m_javaScriptBreakpoints.remove(breakpointIdentifier); - Vector breakpointIDs = m_breakpointIdentifierToDebugServerBreakpointIDs.take(breakpointIdentifier); - for (auto breakpointID : breakpointIDs) { - const Vector& breakpointActions = scriptDebugServer().getActionsForBreakpoint(breakpointID); + for (JSC::BreakpointID breakpointID : m_breakpointIdentifierToDebugServerBreakpointIDs.take(breakpointIdentifier)) { + m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.remove(breakpointID); + + const BreakpointActions& breakpointActions = m_scriptDebugServer.getActionsForBreakpoint(breakpointID); for (auto& action : breakpointActions) - m_injectedScriptManager->releaseObjectGroup(objectGroupForBreakpointAction(action.identifier)); + m_injectedScriptManager.releaseObjectGroup(objectGroupForBreakpointAction(action)); - scriptDebugServer().removeBreakpoint(breakpointID); + JSC::JSLockHolder locker(m_scriptDebugServer.vm()); + m_scriptDebugServer.removeBreakpointActions(breakpointID); + m_scriptDebugServer.removeBreakpoint(breakpointID); } } -void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr& location) +void InspectorDebuggerAgent::continueUntilNextRunLoop(ErrorString& errorString) +{ + if (!assertPaused(errorString)) + return; + + resume(errorString); + + m_enablePauseWhenIdle = true; + + registerIdleHandler(); +} + +void InspectorDebuggerAgent::continueToLocation(ErrorString& errorString, const InspectorObject& location) { + if (!assertPaused(errorString)) + return; + if (m_continueToLocationBreakpointID != JSC::noBreakpointID) { - scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID); + m_scriptDebugServer.removeBreakpoint(m_continueToLocationBreakpointID); m_continueToLocationBreakpointID = JSC::noBreakpointID; } JSC::SourceID sourceID; unsigned lineNumber; unsigned columnNumber; - if (!parseLocation(errorString, location.get(), &sourceID, &lineNumber, &columnNumber)) + if (!parseLocation(errorString, location, sourceID, lineNumber, columnNumber)) return; - ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", false); - m_continueToLocationBreakpointID = scriptDebugServer().setBreakpoint(sourceID, breakpoint, &lineNumber, &columnNumber); - resume(errorString); -} + auto scriptIterator = m_scripts.find(sourceID); + if (scriptIterator == m_scripts.end()) { + m_scriptDebugServer.continueProgram(); + m_frontendDispatcher->resumed(); + errorString = ASCIILiteral("No script for id: ") + String::number(sourceID); + return; + } -PassRefPtr InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointIdentifier, JSC::SourceID sourceID, const ScriptBreakpoint& breakpoint) -{ - ScriptsMap::iterator scriptIterator = m_scripts.find(sourceID); - if (scriptIterator == m_scripts.end()) - return nullptr; + String condition; + bool autoContinue = false; + unsigned ignoreCount = 0; + JSC::Breakpoint breakpoint(sourceID, lineNumber, columnNumber, condition, autoContinue, ignoreCount); Script& script = scriptIterator->value; - if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.lineNumber) - return nullptr; + resolveBreakpoint(script, breakpoint); + if (!breakpoint.resolved) { + m_scriptDebugServer.continueProgram(); + m_frontendDispatcher->resumed(); + errorString = ASCIILiteral("Could not resolve breakpoint"); + return; + } - unsigned actualLineNumber; - unsigned actualColumnNumber; - JSC::BreakpointID debugServerBreakpointID = scriptDebugServer().setBreakpoint(sourceID, breakpoint, &actualLineNumber, &actualColumnNumber); - if (debugServerBreakpointID == JSC::noBreakpointID) - return nullptr; + bool existing; + setBreakpoint(breakpoint, existing); + if (existing) { + // There is an existing breakpoint at this location. Instead of + // acting like a series of steps, just resume and we will either + // hit this new breakpoint or not. + m_scriptDebugServer.continueProgram(); + m_frontendDispatcher->resumed(); + return; + } - BreakpointIdentifierToDebugServerBreakpointIDsMap::iterator debugServerBreakpointIDsIterator = m_breakpointIdentifierToDebugServerBreakpointIDs.find(breakpointIdentifier); - if (debugServerBreakpointIDsIterator == m_breakpointIdentifierToDebugServerBreakpointIDs.end()) - debugServerBreakpointIDsIterator = m_breakpointIdentifierToDebugServerBreakpointIDs.set(breakpointIdentifier, Vector()).iterator; - debugServerBreakpointIDsIterator->value.append(debugServerBreakpointID); + m_continueToLocationBreakpointID = breakpoint.id; - RefPtr location = Inspector::TypeBuilder::Debugger::Location::create() - .setScriptId(String::number(sourceID)) - .setLineNumber(actualLineNumber); - location->setColumnNumber(actualColumnNumber); - return location; + // Treat this as a series of steps until reaching the new breakpoint. + // So don't issue a resumed event unless we exit the VM without pausing. + willStepAndMayBecomeIdle(); + m_scriptDebugServer.continueProgram(); } -void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& scriptIDStr, const String& query, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr>& results) +void InspectorDebuggerAgent::searchInContent(ErrorString& error, const String& scriptIDStr, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefPtr>& results) { + JSC::SourceID sourceID = scriptIDStr.toIntPtr(); + auto it = m_scripts.find(sourceID); + if (it == m_scripts.end()) { + error = ASCIILiteral("No script for id: ") + scriptIDStr; + return; + } + bool isRegex = optionalIsRegex ? *optionalIsRegex : false; bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; - - JSC::SourceID sourceID = scriptIDStr.toIntPtr(); - ScriptsMap::iterator it = m_scripts.find(sourceID); - if (it != m_scripts.end()) - results = ContentSearchUtilities::searchInTextByLines(it->value.source, query, caseSensitive, isRegex); - else - *error = "No script for id: " + scriptIDStr; + results = ContentSearchUtilities::searchInTextByLines(it->value.source, query, caseSensitive, isRegex); } -void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& scriptIDStr, String* scriptSource) +void InspectorDebuggerAgent::getScriptSource(ErrorString& error, const String& scriptIDStr, String* scriptSource) { JSC::SourceID sourceID = scriptIDStr.toIntPtr(); ScriptsMap::iterator it = m_scripts.find(sourceID); if (it != m_scripts.end()) *scriptSource = it->value.source; else - *error = "No script for id: " + scriptIDStr; + error = ASCIILiteral("No script for id: ") + scriptIDStr; } -void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr& details) +void InspectorDebuggerAgent::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr& details) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(functionId); + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(functionId); if (injectedScript.hasNoValue()) { - *errorString = ASCIILiteral("Function object id is obsolete"); + errorString = ASCIILiteral("Function object id is obsolete"); return; } injectedScript.getFunctionDetails(errorString, functionId, &details); } -void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr data) +void InspectorDebuggerAgent::schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason breakReason, RefPtr&& data) { if (m_javaScriptPauseScheduled) return; + m_javaScriptPauseScheduled = true; + m_breakReason = breakReason; - m_breakAuxData = data; - scriptDebugServer().setPauseOnNextStatement(true); + m_breakAuxData = WTFMove(data); + + JSC::JSLockHolder locker(m_scriptDebugServer.vm()); + m_scriptDebugServer.setPauseOnNextStatement(true); } void InspectorDebuggerAgent::cancelPauseOnNextStatement() { - if (m_javaScriptPauseScheduled) + if (!m_javaScriptPauseScheduled) return; + m_javaScriptPauseScheduled = false; + clearBreakDetails(); - scriptDebugServer().setPauseOnNextStatement(false); + m_scriptDebugServer.setPauseOnNextStatement(false); + m_enablePauseWhenIdle = false; } -void InspectorDebuggerAgent::pause(ErrorString*) +void InspectorDebuggerAgent::pause(ErrorString&) { - if (m_javaScriptPauseScheduled) + schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason::PauseOnNextStatement, nullptr); +} + +void InspectorDebuggerAgent::resume(ErrorString& errorString) +{ + if (!m_pausedScriptState && !m_javaScriptPauseScheduled) { + errorString = ASCIILiteral("Was not paused or waiting to pause"); return; + } - clearBreakDetails(); - scriptDebugServer().setPauseOnNextStatement(true); - m_javaScriptPauseScheduled = true; + cancelPauseOnNextStatement(); + m_scriptDebugServer.continueProgram(); + m_conditionToDispatchResumed = ShouldDispatchResumed::WhenContinued; } -void InspectorDebuggerAgent::resume(ErrorString* errorString) +void InspectorDebuggerAgent::stepOver(ErrorString& errorString) { if (!assertPaused(errorString)) return; - m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup); - scriptDebugServer().continueProgram(); + willStepAndMayBecomeIdle(); + m_scriptDebugServer.stepOverStatement(); } -void InspectorDebuggerAgent::stepOver(ErrorString* errorString) +void InspectorDebuggerAgent::stepInto(ErrorString& errorString) { if (!assertPaused(errorString)) return; - m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup); - scriptDebugServer().stepOverStatement(); + willStepAndMayBecomeIdle(); + m_scriptDebugServer.stepIntoStatement(); } -void InspectorDebuggerAgent::stepInto(ErrorString* errorString) +void InspectorDebuggerAgent::stepOut(ErrorString& errorString) { if (!assertPaused(errorString)) return; - m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup); - scriptDebugServer().stepIntoStatement(); - m_listener->stepInto(); + willStepAndMayBecomeIdle(); + m_scriptDebugServer.stepOutOfFunction(); } -void InspectorDebuggerAgent::stepOut(ErrorString* errorString) +void InspectorDebuggerAgent::registerIdleHandler() { - if (!assertPaused(errorString)) - return; + if (!m_registeredIdleCallback) { + m_registeredIdleCallback = true; + JSC::VM& vm = m_scriptDebugServer.vm(); + vm.whenIdle([this]() { + didBecomeIdle(); + }); + } +} - m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup); - scriptDebugServer().stepOutOfFunction(); +void InspectorDebuggerAgent::willStepAndMayBecomeIdle() +{ + // When stepping the backend must eventually trigger a "paused" or "resumed" event. + // If the step causes us to exit the VM, then we should issue "resumed". + m_conditionToDispatchResumed = ShouldDispatchResumed::WhenIdle; + + registerIdleHandler(); } -void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, const String& stringPauseState) +void InspectorDebuggerAgent::didBecomeIdle() +{ + m_registeredIdleCallback = false; + + if (m_conditionToDispatchResumed == ShouldDispatchResumed::WhenIdle) { + cancelPauseOnNextStatement(); + m_scriptDebugServer.continueProgram(); + m_frontendDispatcher->resumed(); + } + + m_conditionToDispatchResumed = ShouldDispatchResumed::No; + + if (m_enablePauseWhenIdle) { + ErrorString ignored; + pause(ignored); + } +} + +void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString& errorString, const String& stringPauseState) { JSC::Debugger::PauseOnExceptionsState pauseState; if (stringPauseState == "none") @@ -506,114 +807,139 @@ void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons else if (stringPauseState == "uncaught") pauseState = JSC::Debugger::PauseOnUncaughtExceptions; else { - *errorString = "Unknown pause on exceptions mode: " + stringPauseState; + errorString = ASCIILiteral("Unknown pause on exceptions mode: ") + stringPauseState; return; } - scriptDebugServer().setPauseOnExceptionsState(static_cast(pauseState)); - if (scriptDebugServer().pauseOnExceptionsState() != pauseState) - *errorString = ASCIILiteral("Internal error. Could not change pause on exceptions state"); + m_scriptDebugServer.setPauseOnExceptionsState(static_cast(pauseState)); + if (m_scriptDebugServer.pauseOnExceptionsState() != pauseState) + errorString = ASCIILiteral("Internal error. Could not change pause on exceptions state"); +} + +void InspectorDebuggerAgent::setPauseOnAssertions(ErrorString&, bool enabled) +{ + m_pauseOnAssertionFailures = enabled; } -void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId); + if (m_currentCallStack.hasNoValue()) { + errorString = ASCIILiteral("Not paused"); + return; + } + + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(callFrameId); if (injectedScript.hasNoValue()) { - *errorString = ASCIILiteral("Inspected frame has gone"); + errorString = ASCIILiteral("Could not find InjectedScript for callFrameId"); return; } - JSC::Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState(); + JSC::Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = m_scriptDebugServer.pauseOnExceptionsState(); if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) { if (previousPauseOnExceptionsState != JSC::Debugger::DontPauseOnExceptions) - scriptDebugServer().setPauseOnExceptionsState(JSC::Debugger::DontPauseOnExceptions); + m_scriptDebugServer.setPauseOnExceptionsState(JSC::Debugger::DontPauseOnExceptions); muteConsole(); } - injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, &result, wasThrown); + injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, saveResult ? *saveResult : false, &result, wasThrown, savedResultIndex); if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) { unmuteConsole(); - if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState) - scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState); + if (m_scriptDebugServer.pauseOnExceptionsState() != previousPauseOnExceptionsState) + m_scriptDebugServer.setPauseOnExceptionsState(previousPauseOnExceptionsState); } } -void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) +void InspectorDebuggerAgent::setOverlayMessage(ErrorString&, const String*) { } void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText) { - if (scriptDebugServer().pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions) { - RefPtr directive = InspectorObject::create(); - directive->setString(ASCIILiteral("directiveText"), directiveText); - breakProgram(InspectorDebuggerFrontendDispatcher::Reason::CSPViolation, directive.release()); - } + if (m_scriptDebugServer.pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions) + breakProgram(DebuggerFrontendDispatcher::Reason::CSPViolation, buildCSPViolationPauseReason(directiveText)); } -PassRefPtr> InspectorDebuggerAgent::currentCallFrames() +Ref> InspectorDebuggerAgent::currentCallFrames(const InjectedScript& injectedScript) { - if (!m_pausedScriptState) - return Inspector::TypeBuilder::Array::create(); - - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m_pausedScriptState); - if (injectedScript.hasNoValue()) { - ASSERT_NOT_REACHED(); - return Inspector::TypeBuilder::Array::create(); - } + ASSERT(!injectedScript.hasNoValue()); + if (injectedScript.hasNoValue()) + return Inspector::Protocol::Array::create(); return injectedScript.wrapCallFrames(m_currentCallStack); } String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) { - return ContentSearchUtilities::findScriptSourceMapURL(script.source); + return script.sourceMappingURL; } -void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script& inScript) +static bool isWebKitInjectedScript(const String& sourceURL) { - Script script = inScript; - if (script.startLine <= 0 && !script.startColumn) - script.sourceURL = ContentSearchUtilities::findScriptSourceURL(script.source); - script.sourceMappingURL = sourceMapURLForScript(script); + return sourceURL.startsWith("__InjectedScript_") && sourceURL.endsWith(".js"); +} +void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script& script) +{ + String scriptIDStr = String::number(sourceID); bool hasSourceURL = !script.sourceURL.isEmpty(); - String scriptURL = hasSourceURL ? script.sourceURL : script.url; - bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; - String* sourceMapURLParam = script.sourceMappingURL.isNull() ? nullptr : &script.sourceMappingURL; + String sourceURL = script.sourceURL; + String sourceMappingURL = sourceMapURLForScript(script); + + const bool isModule = script.sourceProvider->sourceType() == JSC::SourceProviderSourceType::Module; const bool* isContentScript = script.isContentScript ? &script.isContentScript : nullptr; - String scriptIDStr = String::number(sourceID); - m_frontendDispatcher->scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam); + String* sourceURLParam = hasSourceURL ? &sourceURL : nullptr; + String* sourceMapURLParam = sourceMappingURL.isEmpty() ? nullptr : &sourceMappingURL; + + m_frontendDispatcher->scriptParsed(scriptIDStr, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceURLParam, sourceMapURLParam, isModule ? &isModule : nullptr); m_scripts.set(sourceID, script); - if (scriptURL.isEmpty()) + if (hasSourceURL && isWebKitInjectedScript(sourceURL)) + m_scriptDebugServer.addToBlacklist(sourceID); + + String scriptURLForBreakpoints = hasSourceURL ? script.sourceURL : script.url; + if (scriptURLForBreakpoints.isEmpty()) return; - for (auto it = m_javaScriptBreakpoints.begin(), end = m_javaScriptBreakpoints.end(); it != end; ++it) { - RefPtr breakpointObject = it->value->asObject(); + for (auto& entry : m_javaScriptBreakpoints) { + RefPtr breakpointObject = entry.value; + bool isRegex; - breakpointObject->getBoolean(ASCIILiteral("isRegex"), &isRegex); String url; - breakpointObject->getString(ASCIILiteral("url"), &url); - if (!matches(scriptURL, url, isRegex)) + breakpointObject->getBoolean(ASCIILiteral("isRegex"), isRegex); + breakpointObject->getString(ASCIILiteral("url"), url); + if (!matches(scriptURLForBreakpoints, url, isRegex)) continue; - ScriptBreakpoint breakpoint; - breakpointObject->getNumber(ASCIILiteral("lineNumber"), &breakpoint.lineNumber); - breakpointObject->getNumber(ASCIILiteral("columnNumber"), &breakpoint.columnNumber); - breakpointObject->getString(ASCIILiteral("condition"), &breakpoint.condition); - breakpointObject->getBoolean(ASCIILiteral("autoContinue"), &breakpoint.autoContinue); + + ScriptBreakpoint scriptBreakpoint; + breakpointObject->getInteger(ASCIILiteral("lineNumber"), scriptBreakpoint.lineNumber); + breakpointObject->getInteger(ASCIILiteral("columnNumber"), scriptBreakpoint.columnNumber); + breakpointObject->getString(ASCIILiteral("condition"), scriptBreakpoint.condition); + breakpointObject->getBoolean(ASCIILiteral("autoContinue"), scriptBreakpoint.autoContinue); + breakpointObject->getInteger(ASCIILiteral("ignoreCount"), scriptBreakpoint.ignoreCount); ErrorString errorString; - RefPtr actions = breakpointObject->getArray(ASCIILiteral("actions")); - if (!breakpointActionsFromProtocol(&errorString, actions, &breakpoint.actions)) { + RefPtr actions; + breakpointObject->getArray(ASCIILiteral("actions"), actions); + if (!breakpointActionsFromProtocol(errorString, actions, &scriptBreakpoint.actions)) { ASSERT_NOT_REACHED(); continue; } - RefPtr location = resolveBreakpoint(it->key, sourceID, breakpoint); - if (location) - m_frontendDispatcher->breakpointResolved(it->key, location); + JSC::Breakpoint breakpoint(sourceID, scriptBreakpoint.lineNumber, scriptBreakpoint.columnNumber, scriptBreakpoint.condition, scriptBreakpoint.autoContinue, scriptBreakpoint.ignoreCount); + resolveBreakpoint(script, breakpoint); + if (!breakpoint.resolved) + continue; + + bool existing; + setBreakpoint(breakpoint, existing); + if (existing) + continue; + + String breakpointIdentifier = entry.key; + didSetBreakpoint(breakpoint, breakpointIdentifier, scriptBreakpoint); + + m_frontendDispatcher->breakpointResolved(breakpointIdentifier, buildDebuggerLocation(breakpoint)); } } @@ -622,94 +948,173 @@ void InspectorDebuggerAgent::failedToParseSource(const String& url, const String m_frontendDispatcher->scriptFailedToParse(url, data, firstLine, errorLine, errorMessage); } -void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception) +void InspectorDebuggerAgent::didPause(JSC::ExecState& scriptState, JSC::JSValue callFrames, JSC::JSValue exceptionOrCaughtValue) { - ASSERT(scriptState && !m_pausedScriptState); - m_pausedScriptState = scriptState; - m_currentCallStack = callFrames; - - if (!exception.hasNoValue()) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState); - if (!injectedScript.hasNoValue()) { - m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Exception; - m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors(); - // m_breakAuxData might be null after this. + ASSERT(!m_pausedScriptState); + m_pausedScriptState = &scriptState; + m_currentCallStack = { scriptState.vm(), callFrames }; + + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(&scriptState); + + // If a high level pause pause reason is not already set, try to infer a reason from the debugger. + if (m_breakReason == DebuggerFrontendDispatcher::Reason::Other) { + switch (m_scriptDebugServer.reasonForPause()) { + case JSC::Debugger::PausedForBreakpoint: { + JSC::BreakpointID debuggerBreakpointId = m_scriptDebugServer.pausingBreakpointID(); + if (debuggerBreakpointId != m_continueToLocationBreakpointID) { + m_breakReason = DebuggerFrontendDispatcher::Reason::Breakpoint; + m_breakAuxData = buildBreakpointPauseReason(debuggerBreakpointId); + } + break; } + case JSC::Debugger::PausedForDebuggerStatement: + m_breakReason = DebuggerFrontendDispatcher::Reason::DebuggerStatement; + m_breakAuxData = nullptr; + break; + case JSC::Debugger::PausedForException: + m_breakReason = DebuggerFrontendDispatcher::Reason::Exception; + m_breakAuxData = buildExceptionPauseReason(exceptionOrCaughtValue, injectedScript); + break; + case JSC::Debugger::PausedAtStatement: + case JSC::Debugger::PausedAtExpression: + case JSC::Debugger::PausedBeforeReturn: + case JSC::Debugger::PausedAtEndOfProgram: + // Pause was just stepping. Nothing to report. + break; + case JSC::Debugger::NotPaused: + ASSERT_NOT_REACHED(); + break; + } + } + + // Set $exception to the exception or caught value. + if (exceptionOrCaughtValue && !injectedScript.hasNoValue()) { + injectedScript.setExceptionValue(exceptionOrCaughtValue); + m_hasExceptionValue = true; } - m_frontendDispatcher->paused(currentCallFrames(), m_breakReason, m_breakAuxData); + m_conditionToDispatchResumed = ShouldDispatchResumed::No; + m_enablePauseWhenIdle = false; + + RefPtr asyncStackTrace; + if (m_currentAsyncCallIdentifier) { + auto it = m_pendingAsyncCalls.find(m_currentAsyncCallIdentifier.value()); + if (it != m_pendingAsyncCalls.end()) + asyncStackTrace = it->value->buildInspectorObject(); + } + + m_frontendDispatcher->paused(currentCallFrames(injectedScript), m_breakReason, m_breakAuxData, asyncStackTrace); + m_javaScriptPauseScheduled = false; if (m_continueToLocationBreakpointID != JSC::noBreakpointID) { - scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID); + m_scriptDebugServer.removeBreakpoint(m_continueToLocationBreakpointID); m_continueToLocationBreakpointID = JSC::noBreakpointID; } - if (m_listener) - m_listener->didPause(); + RefPtr stopwatch = m_injectedScriptManager.inspectorEnvironment().executionStopwatch(); + if (stopwatch && stopwatch->isActive()) { + stopwatch->stop(); + m_didPauseStopwatch = true; + } } -void InspectorDebuggerAgent::didSampleProbe(JSC::ExecState* scriptState, int probeIdentifier, int hitCount, const Deprecated::ScriptValue& sample) +void InspectorDebuggerAgent::breakpointActionSound(int breakpointActionIdentifier) { - int sampleId = m_nextProbeSampleId++; - - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState); - RefPtr payload = injectedScript.wrapObject(sample, objectGroupForBreakpointAction(probeIdentifier)); - RefPtr result = TypeBuilder::Debugger::ProbeSample::create() - .setProbeId(probeIdentifier) - .setSampleId(sampleId) - .setBatchId(hitCount) - .setTimestamp(monotonicallyIncreasingTime()) - .setPayload(payload.release()); - - m_frontendDispatcher->didSampleProbe(result.release()); + m_frontendDispatcher->playBreakpointActionSound(breakpointActionIdentifier); } -void InspectorDebuggerAgent::breakpointActionSound() +void InspectorDebuggerAgent::breakpointActionProbe(JSC::ExecState& scriptState, const ScriptBreakpointAction& action, unsigned batchId, unsigned sampleId, JSC::JSValue sample) { - // FIXME: We should send a message to the frontend to make the frontend beep. + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(&scriptState); + auto payload = injectedScript.wrapObject(sample, objectGroupForBreakpointAction(action), true); + auto result = Protocol::Debugger::ProbeSample::create() + .setProbeId(action.identifier) + .setBatchId(batchId) + .setSampleId(sampleId) + .setTimestamp(m_injectedScriptManager.inspectorEnvironment().executionStopwatch()->elapsedTime()) + .setPayload(WTFMove(payload)) + .release(); + m_frontendDispatcher->didSampleProbe(WTFMove(result)); } void InspectorDebuggerAgent::didContinue() { + if (m_didPauseStopwatch) { + m_didPauseStopwatch = false; + m_injectedScriptManager.inspectorEnvironment().executionStopwatch()->start(); + } + m_pausedScriptState = nullptr; - m_currentCallStack = Deprecated::ScriptValue(); + m_currentCallStack = { }; + m_injectedScriptManager.releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup); clearBreakDetails(); + clearExceptionValue(); - m_frontendDispatcher->resumed(); + if (m_conditionToDispatchResumed == ShouldDispatchResumed::WhenContinued) + m_frontendDispatcher->resumed(); } -void InspectorDebuggerAgent::breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr data) +void InspectorDebuggerAgent::breakProgram(DebuggerFrontendDispatcher::Reason breakReason, RefPtr&& data) { m_breakReason = breakReason; - m_breakAuxData = data; - scriptDebugServer().breakProgram(); + m_breakAuxData = WTFMove(data); + m_scriptDebugServer.breakProgram(); } -void InspectorDebuggerAgent::clearResolvedBreakpointState() +void InspectorDebuggerAgent::clearInspectorBreakpointState() { ErrorString dummyError; Vector breakpointIdentifiers; copyKeysToVector(m_breakpointIdentifierToDebugServerBreakpointIDs, breakpointIdentifiers); for (const String& identifier : breakpointIdentifiers) - removeBreakpoint(&dummyError, identifier); + removeBreakpoint(dummyError, identifier); - scriptDebugServer().continueProgram(); + m_javaScriptBreakpoints.clear(); + + clearDebuggerBreakpointState(); +} + +void InspectorDebuggerAgent::clearDebuggerBreakpointState() +{ + { + JSC::JSLockHolder holder(m_scriptDebugServer.vm()); + m_scriptDebugServer.clearBreakpointActions(); + m_scriptDebugServer.clearBreakpoints(); + m_scriptDebugServer.clearBlacklist(); + } m_pausedScriptState = nullptr; - m_currentCallStack = Deprecated::ScriptValue(); + m_currentCallStack = { }; m_scripts.clear(); m_breakpointIdentifierToDebugServerBreakpointIDs.clear(); + m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.clear(); m_continueToLocationBreakpointID = JSC::noBreakpointID; clearBreakDetails(); m_javaScriptPauseScheduled = false; - setOverlayMessage(&dummyError, nullptr); + m_hasExceptionValue = false; + + if (isPaused()) { + m_scriptDebugServer.continueProgram(); + m_frontendDispatcher->resumed(); + } } -bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) +void InspectorDebuggerAgent::didClearGlobalObject() +{ + // Clear breakpoints from the debugger, but keep the inspector's model of which + // pages have what breakpoints, as the mapping is only sent to DebuggerAgent once. + clearDebuggerBreakpointState(); + + clearAsyncStackTraceData(); + + m_frontendDispatcher->globalObjectCleared(); +} + +bool InspectorDebuggerAgent::assertPaused(ErrorString& errorString) { if (!m_pausedScriptState) { - *errorString = ASCIILiteral("Can only perform operation while paused."); + errorString = ASCIILiteral("Can only perform operation while paused."); return false; } @@ -718,18 +1123,22 @@ bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) void InspectorDebuggerAgent::clearBreakDetails() { - m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Other; + m_breakReason = DebuggerFrontendDispatcher::Reason::Other; m_breakAuxData = nullptr; } -void InspectorDebuggerAgent::didClearGlobalObject() +void InspectorDebuggerAgent::clearExceptionValue() { - if (m_frontendDispatcher) - m_frontendDispatcher->globalObjectCleared(); + if (m_hasExceptionValue) { + m_injectedScriptManager.clearExceptionValue(); + m_hasExceptionValue = false; + } +} - clearResolvedBreakpointState(); +void InspectorDebuggerAgent::clearAsyncStackTraceData() +{ + m_pendingAsyncCalls.clear(); + m_currentAsyncCallIdentifier = std::nullopt; } } // namespace Inspector - -#endif // ENABLE(INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h index 0e652499d..6f8132ac2 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h +++ b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. - * Copyright (C) 2010-2011 Google Inc. All rights reserved. + * Copyright (C) 2010, 2013, 2015-2016 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -27,37 +27,32 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorDebuggerAgent_h -#define InspectorDebuggerAgent_h +#pragma once -#if ENABLE(INSPECTOR) - -#include "InspectorJSBackendDispatchers.h" -#include "InspectorJSFrontendDispatchers.h" +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" #include "bindings/ScriptValue.h" #include "debugger/Debugger.h" #include "inspector/InspectorAgentBase.h" #include "inspector/ScriptBreakpoint.h" +#include "inspector/ScriptCallStack.h" #include "inspector/ScriptDebugListener.h" #include #include #include -#include -#include #include -#include namespace Inspector { +class AsyncStackTrace; class InjectedScript; class InjectedScriptManager; class InspectorArray; class InspectorObject; -class InspectorValue; class ScriptDebugServer; typedef String ErrorString; -class JS_EXPORT_PRIVATE InspectorDebuggerAgent : public InspectorAgentBase, public ScriptDebugListener, public InspectorDebuggerBackendDispatcherHandler { +class JS_EXPORT_PRIVATE InspectorDebuggerAgent : public InspectorAgentBase, public ScriptDebugListener, public DebuggerBackendDispatcherHandler { WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent); WTF_MAKE_FAST_ALLOCATED; public: @@ -65,35 +60,48 @@ public: virtual ~InspectorDebuggerAgent(); - virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) override; - virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason) override; - - virtual void enable(ErrorString*) override; - virtual void disable(ErrorString*) override; - virtual void setBreakpointsActive(ErrorString*, bool active) override; - virtual void setBreakpointByUrl(ErrorString*, int lineNumber, const String* optionalURL, const String* optionalURLRegex, const int* optionalColumnNumber, const RefPtr* options, Inspector::TypeBuilder::Debugger::BreakpointId*, RefPtr>& locations, RefPtr>& breakpointActionIdentifiers) override; - virtual void setBreakpoint(ErrorString*, const RefPtr& location, const RefPtr* options, Inspector::TypeBuilder::Debugger::BreakpointId*, RefPtr& actualLocation, RefPtr>& breakpointActionIdentifiers) override; - virtual void removeBreakpoint(ErrorString*, const String& breakpointIdentifier) override; - virtual void continueToLocation(ErrorString*, const RefPtr& location) override; - virtual void searchInContent(ErrorString*, const String& scriptID, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefPtr>&) override; - virtual void getScriptSource(ErrorString*, const String& scriptID, String* scriptSource) override; - virtual void getFunctionDetails(ErrorString*, const String& functionId, RefPtr&) override; - virtual void pause(ErrorString*) override; - virtual void resume(ErrorString*) override; - virtual void stepOver(ErrorString*) override; - virtual void stepInto(ErrorString*) override; - virtual void stepOut(ErrorString*) override; - virtual void setPauseOnExceptions(ErrorString*, const String& pauseState) override; - virtual void evaluateOnCallFrame(ErrorString*, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) override; - virtual void setOverlayMessage(ErrorString*, const String*) override; - - bool isPaused(); - - void handleConsoleAssert(); - - void schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr data); + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) final; + void willDestroyFrontendAndBackend(DisconnectReason) final; + + void enable(ErrorString&) final; + void disable(ErrorString&) final; + void setAsyncStackTraceDepth(ErrorString&, int depth) final; + void setBreakpointsActive(ErrorString&, bool active) final; + void setBreakpointByUrl(ErrorString&, int lineNumber, const String* const optionalURL, const String* const optionalURLRegex, const int* const optionalColumnNumber, const Inspector::InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId*, RefPtr>& locations) final; + void setBreakpoint(ErrorString&, const Inspector::InspectorObject& location, const Inspector::InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId*, RefPtr& actualLocation) final; + void removeBreakpoint(ErrorString&, const String& breakpointIdentifier) final; + void continueUntilNextRunLoop(ErrorString&) final; + void continueToLocation(ErrorString&, const InspectorObject& location) final; + void searchInContent(ErrorString&, const String& scriptID, const String& query, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr>&) final; + void getScriptSource(ErrorString&, const String& scriptID, String* scriptSource) final; + void getFunctionDetails(ErrorString&, const String& functionId, RefPtr&) final; + void pause(ErrorString&) final; + void resume(ErrorString&) final; + void stepOver(ErrorString&) final; + void stepInto(ErrorString&) final; + void stepOut(ErrorString&) final; + void setPauseOnExceptions(ErrorString&, const String& pauseState) final; + void setPauseOnAssertions(ErrorString&, bool enabled) final; + void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* const generatePreview, const bool* const saveResult, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) final; + void setOverlayMessage(ErrorString&, const String* const) override; + + bool isPaused() const; + bool breakpointsActive() const; + + void setSuppressAllPauses(bool); + + void handleConsoleAssert(const String& message); + + void didScheduleAsyncCall(JSC::ExecState*, int asyncCallType, int callbackIdentifier, bool singleShot); + void didCancelAsyncCall(int asyncCallType, int callbackIdentifier); + void willDispatchAsyncCall(int asyncCallType, int callbackIdentifier); + void didDispatchAsyncCall(); + + void schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason breakReason, RefPtr&& data); void cancelPauseOnNextStatement(); - void breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr data); + bool pauseOnNextStatementEnabled() const { return m_javaScriptPauseScheduled; } + + void breakProgram(DebuggerFrontendDispatcher::Reason breakReason, RefPtr&& data); void scriptExecutionBlockedByCSP(const String& directiveText); class Listener { @@ -101,73 +109,91 @@ public: virtual ~Listener() { } virtual void debuggerWasEnabled() = 0; virtual void debuggerWasDisabled() = 0; - virtual void stepInto() = 0; - virtual void didPause() = 0; }; void setListener(Listener* listener) { m_listener = listener; } - virtual ScriptDebugServer& scriptDebugServer() = 0; - protected: - InspectorDebuggerAgent(InjectedScriptManager*); + InspectorDebuggerAgent(AgentContext&); - InjectedScriptManager* injectedScriptManager() const { return m_injectedScriptManager; } - virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0; + InjectedScriptManager& injectedScriptManager() const { return m_injectedScriptManager; } + virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0; + + ScriptDebugServer& scriptDebugServer() { return m_scriptDebugServer; } - virtual void startListeningScriptDebugServer() = 0; - virtual void stopListeningScriptDebugServer(bool skipRecompile) = 0; virtual void muteConsole() = 0; virtual void unmuteConsole() = 0; virtual void enable(); virtual void disable(bool skipRecompile); - virtual void didPause(JSC::ExecState*, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception) override; - virtual void didContinue() override; + void didPause(JSC::ExecState&, JSC::JSValue callFrames, JSC::JSValue exceptionOrCaughtValue) final; + void didContinue() final; virtual String sourceMapURLForScript(const Script&); void didClearGlobalObject(); private: - PassRefPtr> currentCallFrames(); + Ref> currentCallFrames(const InjectedScript&); + + void didParseSource(JSC::SourceID, const Script&) final; + void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) final; - virtual void didParseSource(JSC::SourceID, const Script&) override final; - virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) override final; - virtual void didSampleProbe(JSC::ExecState*, int probeIdentifier, int hitCount, const Deprecated::ScriptValue& sample) override final; + void breakpointActionSound(int breakpointActionIdentifier) final; + void breakpointActionProbe(JSC::ExecState&, const ScriptBreakpointAction&, unsigned batchId, unsigned sampleId, JSC::JSValue sample) final; - virtual void breakpointActionSound() override; + void resolveBreakpoint(const Script&, JSC::Breakpoint&); + void setBreakpoint(JSC::Breakpoint&, bool& existing); + void didSetBreakpoint(const JSC::Breakpoint&, const String&, const ScriptBreakpoint&); - PassRefPtr resolveBreakpoint(const String& breakpointIdentifier, JSC::SourceID, const ScriptBreakpoint&); - bool assertPaused(ErrorString*); - void clearResolvedBreakpointState(); + bool assertPaused(ErrorString&); + void clearDebuggerBreakpointState(); + void clearInspectorBreakpointState(); void clearBreakDetails(); + void clearExceptionValue(); + void clearAsyncStackTraceData(); + + enum class ShouldDispatchResumed { No, WhenIdle, WhenContinued }; + void registerIdleHandler(); + void willStepAndMayBecomeIdle(); + void didBecomeIdle(); - bool breakpointActionsFromProtocol(ErrorString*, RefPtr& actions, Vector* result); + RefPtr buildBreakpointPauseReason(JSC::BreakpointID); + RefPtr buildExceptionPauseReason(JSC::JSValue exception, const InjectedScript&); + + bool breakpointActionsFromProtocol(ErrorString&, RefPtr& actions, BreakpointActions* result); + + typedef std::pair AsyncCallIdentifier; typedef HashMap ScriptsMap; typedef HashMap> BreakpointIdentifierToDebugServerBreakpointIDsMap; typedef HashMap> BreakpointIdentifierToBreakpointMap; - - InjectedScriptManager* m_injectedScriptManager; - std::unique_ptr m_frontendDispatcher; - RefPtr m_backendDispatcher; - Listener* m_listener; - JSC::ExecState* m_pausedScriptState; + typedef HashMap DebugServerBreakpointIDToBreakpointIdentifier; + + InjectedScriptManager& m_injectedScriptManager; + std::unique_ptr m_frontendDispatcher; + RefPtr m_backendDispatcher; + ScriptDebugServer& m_scriptDebugServer; + Listener* m_listener { nullptr }; + JSC::ExecState* m_pausedScriptState { nullptr }; Deprecated::ScriptValue m_currentCallStack; ScriptsMap m_scripts; BreakpointIdentifierToDebugServerBreakpointIDsMap m_breakpointIdentifierToDebugServerBreakpointIDs; BreakpointIdentifierToBreakpointMap m_javaScriptBreakpoints; + DebugServerBreakpointIDToBreakpointIdentifier m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier; JSC::BreakpointID m_continueToLocationBreakpointID; - InspectorDebuggerFrontendDispatcher::Reason::Enum m_breakReason; + DebuggerFrontendDispatcher::Reason m_breakReason; RefPtr m_breakAuxData; - bool m_enabled; - bool m_javaScriptPauseScheduled; - int m_nextProbeSampleId; - int m_nextBreakpointActionIdentifier; + ShouldDispatchResumed m_conditionToDispatchResumed { ShouldDispatchResumed::No }; + bool m_enablePauseWhenIdle { false }; + HashMap> m_pendingAsyncCalls; + std::optional m_currentAsyncCallIdentifier { std::nullopt }; + bool m_enabled { false }; + bool m_javaScriptPauseScheduled { false }; + bool m_hasExceptionValue { false }; + bool m_didPauseStopwatch { false }; + bool m_pauseOnAssertionFailures { false }; + bool m_registeredIdleCallback { false }; + int m_asyncStackTraceDepth { 0 }; }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(InspectorDebuggerAgent_h) diff --git a/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp new file mode 100644 index 000000000..b33ae982d --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp @@ -0,0 +1,314 @@ +/* + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorHeapAgent.h" + +#include "HeapProfiler.h" +#include "InjectedScript.h" +#include "InjectedScriptManager.h" +#include "InspectorEnvironment.h" +#include "JSCInlines.h" +#include "VM.h" +#include + +using namespace JSC; + +namespace Inspector { + +InspectorHeapAgent::InspectorHeapAgent(AgentContext& context) + : InspectorAgentBase(ASCIILiteral("Heap")) + , m_injectedScriptManager(context.injectedScriptManager) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(HeapBackendDispatcher::create(context.backendDispatcher, this)) + , m_environment(context.environment) +{ +} + +InspectorHeapAgent::~InspectorHeapAgent() +{ +} + +void InspectorHeapAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) +{ +} + +void InspectorHeapAgent::willDestroyFrontendAndBackend(DisconnectReason) +{ + // Stop tracking without taking a snapshot. + m_tracking = false; + + ErrorString ignored; + disable(ignored); +} + +void InspectorHeapAgent::enable(ErrorString&) +{ + if (m_enabled) + return; + + m_enabled = true; + + m_environment.vm().heap.addObserver(this); +} + +void InspectorHeapAgent::disable(ErrorString&) +{ + if (!m_enabled) + return; + + m_enabled = false; + + m_environment.vm().heap.removeObserver(this); + + clearHeapSnapshots(); +} + +void InspectorHeapAgent::gc(ErrorString&) +{ + VM& vm = m_environment.vm(); + JSLockHolder lock(vm); + sanitizeStackForVM(&vm); + vm.heap.collectAllGarbage(); +} + +void InspectorHeapAgent::snapshot(ErrorString&, double* timestamp, String* snapshotData) +{ + VM& vm = m_environment.vm(); + JSLockHolder lock(vm); + + HeapSnapshotBuilder snapshotBuilder(vm.ensureHeapProfiler()); + snapshotBuilder.buildSnapshot(); + + *timestamp = m_environment.executionStopwatch()->elapsedTime(); + *snapshotData = snapshotBuilder.json([&] (const HeapSnapshotNode& node) { + if (Structure* structure = node.cell->structure(vm)) { + if (JSGlobalObject* globalObject = structure->globalObject()) { + if (!m_environment.canAccessInspectedScriptState(globalObject->globalExec())) + return false; + } + } + return true; + }); +} + +void InspectorHeapAgent::startTracking(ErrorString& errorString) +{ + if (m_tracking) + return; + + m_tracking = true; + + double timestamp; + String snapshotData; + snapshot(errorString, ×tamp, &snapshotData); + + m_frontendDispatcher->trackingStart(timestamp, snapshotData); +} + +void InspectorHeapAgent::stopTracking(ErrorString& errorString) +{ + if (!m_tracking) + return; + + m_tracking = false; + + double timestamp; + String snapshotData; + snapshot(errorString, ×tamp, &snapshotData); + + m_frontendDispatcher->trackingComplete(timestamp, snapshotData); +} + +std::optional InspectorHeapAgent::nodeForHeapObjectIdentifier(ErrorString& errorString, unsigned heapObjectIdentifier) +{ + HeapProfiler* heapProfiler = m_environment.vm().heapProfiler(); + if (!heapProfiler) { + errorString = ASCIILiteral("No heap snapshot"); + return std::nullopt; + } + + HeapSnapshot* snapshot = heapProfiler->mostRecentSnapshot(); + if (!snapshot) { + errorString = ASCIILiteral("No heap snapshot"); + return std::nullopt; + } + + const std::optional optionalNode = snapshot->nodeForObjectIdentifier(heapObjectIdentifier); + if (!optionalNode) { + errorString = ASCIILiteral("No object for identifier, it may have been collected"); + return std::nullopt; + } + + return optionalNode; +} + +void InspectorHeapAgent::getPreview(ErrorString& errorString, int heapObjectId, Inspector::Protocol::OptOutput* resultString, RefPtr& functionDetails, RefPtr& objectPreview) +{ + // Prevent the cell from getting collected as we look it up. + VM& vm = m_environment.vm(); + JSLockHolder lock(vm); + DeferGC deferGC(vm.heap); + + unsigned heapObjectIdentifier = static_cast(heapObjectId); + const std::optional optionalNode = nodeForHeapObjectIdentifier(errorString, heapObjectIdentifier); + if (!optionalNode) + return; + + // String preview. + JSCell* cell = optionalNode->cell; + if (cell->isString()) { + *resultString = asString(cell)->tryGetValue(); + return; + } + + // FIXME: Provide preview information for Internal Objects? CodeBlock, Executable, etc. + + Structure* structure = cell->structure(vm); + if (!structure) { + errorString = ASCIILiteral("Unable to get object details - Structure"); + return; + } + + JSGlobalObject* globalObject = structure->globalObject(); + if (!globalObject) { + errorString = ASCIILiteral("Unable to get object details - GlobalObject"); + return; + } + + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject->globalExec()); + if (injectedScript.hasNoValue()) { + errorString = ASCIILiteral("Unable to get object details - InjectedScript"); + return; + } + + // Function preview. + if (cell->inherits(vm, JSFunction::info())) { + injectedScript.functionDetails(errorString, cell, &functionDetails); + return; + } + + // Object preview. + objectPreview = injectedScript.previewValue(cell); +} + +void InspectorHeapAgent::getRemoteObject(ErrorString& errorString, int heapObjectId, const String* const optionalObjectGroup, RefPtr& result) +{ + // Prevent the cell from getting collected as we look it up. + VM& vm = m_environment.vm(); + JSLockHolder lock(vm); + DeferGC deferGC(vm.heap); + + unsigned heapObjectIdentifier = static_cast(heapObjectId); + const std::optional optionalNode = nodeForHeapObjectIdentifier(errorString, heapObjectIdentifier); + if (!optionalNode) + return; + + JSCell* cell = optionalNode->cell; + Structure* structure = cell->structure(vm); + if (!structure) { + errorString = ASCIILiteral("Unable to get object details"); + return; + } + + JSGlobalObject* globalObject = structure->globalObject(); + if (!globalObject) { + errorString = ASCIILiteral("Unable to get object details"); + return; + } + + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject->globalExec()); + if (injectedScript.hasNoValue()) { + errorString = ASCIILiteral("Unable to get object details - InjectedScript"); + return; + } + + String objectGroup = optionalObjectGroup ? *optionalObjectGroup : String(); + result = injectedScript.wrapObject(cell, objectGroup, true); +} + +static Inspector::Protocol::Heap::GarbageCollection::Type protocolTypeForHeapOperation(CollectionScope scope) +{ + switch (scope) { + case CollectionScope::Full: + return Inspector::Protocol::Heap::GarbageCollection::Type::Full; + case CollectionScope::Eden: + return Inspector::Protocol::Heap::GarbageCollection::Type::Partial; + } + ASSERT_NOT_REACHED(); + return Inspector::Protocol::Heap::GarbageCollection::Type::Full; +} + +void InspectorHeapAgent::willGarbageCollect() +{ + if (!m_enabled) + return; + + m_gcStartTime = m_environment.executionStopwatch()->elapsedTime(); +} + +void InspectorHeapAgent::didGarbageCollect(CollectionScope scope) +{ + if (!m_enabled) { + m_gcStartTime = NAN; + return; + } + + if (std::isnan(m_gcStartTime)) { + // We were not enabled when the GC began. + return; + } + + // FIXME: Include number of bytes freed by collection. + + double endTime = m_environment.executionStopwatch()->elapsedTime(); + dispatchGarbageCollectedEvent(protocolTypeForHeapOperation(scope), m_gcStartTime, endTime); + + m_gcStartTime = NAN; +} + +void InspectorHeapAgent::clearHeapSnapshots() +{ + VM& vm = m_environment.vm(); + JSLockHolder lock(vm); + + if (HeapProfiler* heapProfiler = vm.heapProfiler()) { + heapProfiler->clearSnapshots(); + HeapSnapshotBuilder::resetNextAvailableObjectIdentifier(); + } +} + +void InspectorHeapAgent::dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type type, double startTime, double endTime) +{ + auto protocolObject = Inspector::Protocol::Heap::GarbageCollection::create() + .setType(type) + .setStartTime(startTime) + .setEndTime(endTime) + .release(); + + m_frontendDispatcher->garbageCollected(WTFMove(protocolObject)); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h new file mode 100644 index 000000000..421566a04 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "HeapSnapshot.h" +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" +#include "heap/HeapObserver.h" +#include "inspector/InspectorAgentBase.h" +#include +#include + +namespace Inspector { + +class InjectedScriptManager; +typedef String ErrorString; + +class JS_EXPORT_PRIVATE InspectorHeapAgent : public InspectorAgentBase, public HeapBackendDispatcherHandler, public JSC::HeapObserver { + WTF_MAKE_NONCOPYABLE(InspectorHeapAgent); +public: + InspectorHeapAgent(AgentContext&); + virtual ~InspectorHeapAgent(); + + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; + void willDestroyFrontendAndBackend(DisconnectReason) override; + + // HeapBackendDispatcherHandler + void enable(ErrorString&) override; + void disable(ErrorString&) override; + void gc(ErrorString&) final; + void snapshot(ErrorString&, double* timestamp, String* snapshotData) final; + void startTracking(ErrorString&) final; + void stopTracking(ErrorString&) final; + void getPreview(ErrorString&, int heapObjectId, Inspector::Protocol::OptOutput* resultString, RefPtr& functionDetails, RefPtr& objectPreview) final; + void getRemoteObject(ErrorString&, int heapObjectId, const String* const optionalObjectGroup, RefPtr& result) final; + + // HeapObserver + void willGarbageCollect() override; + void didGarbageCollect(JSC::CollectionScope) override; + +protected: + void clearHeapSnapshots(); + + virtual void dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type, double startTime, double endTime); + +private: + std::optional nodeForHeapObjectIdentifier(ErrorString&, unsigned heapObjectIdentifier); + + InjectedScriptManager& m_injectedScriptManager; + std::unique_ptr m_frontendDispatcher; + RefPtr m_backendDispatcher; + InspectorEnvironment& m_environment; + + bool m_enabled { false }; + bool m_tracking { false }; + double m_gcStartTime { NAN }; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp index 76a47fb3a..d42c8968c 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp +++ b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2013-2015 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,17 +32,20 @@ #include "config.h" #include "InspectorRuntimeAgent.h" -#if ENABLE(INSPECTOR) - #include "Completion.h" +#include "DFGWorklist.h" +#include "HeapIterationScope.h" #include "InjectedScript.h" #include "InjectedScriptManager.h" +#include "InspectorFrontendRouter.h" #include "InspectorValues.h" #include "JSLock.h" #include "ParserError.h" #include "ScriptDebugServer.h" #include "SourceCode.h" -#include +#include "TypeProfiler.h" +#include "TypeProfilerLog.h" +#include using namespace JSC; @@ -53,11 +56,11 @@ static bool asBool(const bool* const b) return b ? *b : false; } -InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager) +InspectorRuntimeAgent::InspectorRuntimeAgent(AgentContext& context) : InspectorAgentBase(ASCIILiteral("Runtime")) - , m_injectedScriptManager(injectedScriptManager) - , m_scriptDebugServer(nullptr) - , m_enabled(false) + , m_injectedScriptManager(context.injectedScriptManager) + , m_scriptDebugServer(context.environment.scriptDebugServer()) + , m_vm(context.environment.vm()) { } @@ -65,53 +68,51 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent() { } -static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(ScriptDebugServer* scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newState) +static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(ScriptDebugServer& scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newState) { - ASSERT(scriptDebugServer); - ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer->pauseOnExceptionsState(); + ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer.pauseOnExceptionsState(); if (presentState != newState) - scriptDebugServer->setPauseOnExceptionsState(newState); + scriptDebugServer.setPauseOnExceptionsState(newState); return presentState; } -static PassRefPtr buildErrorRangeObject(const JSTokenLocation& tokenLocation) +static Ref buildErrorRangeObject(const JSTokenLocation& tokenLocation) { - RefPtr result = Inspector::TypeBuilder::Runtime::ErrorRange::create() + return Inspector::Protocol::Runtime::ErrorRange::create() .setStartOffset(tokenLocation.startOffset) - .setEndOffset(tokenLocation.endOffset); - return result.release(); + .setEndOffset(tokenLocation.endOffset) + .release(); } -void InspectorRuntimeAgent::parse(ErrorString*, const String& expression, Inspector::TypeBuilder::Runtime::SyntaxErrorType::Enum* result, Inspector::TypeBuilder::OptOutput* message, RefPtr& range) +void InspectorRuntimeAgent::parse(ErrorString&, const String& expression, Inspector::Protocol::Runtime::SyntaxErrorType* result, Inspector::Protocol::OptOutput* message, RefPtr& range) { - VM* vm = globalVM(); - JSLockHolder lock(vm); + JSLockHolder lock(m_vm); ParserError error; - checkSyntax(*vm, JSC::makeSource(expression), error); + checkSyntax(m_vm, JSC::makeSource(expression, { }), error); - switch (error.m_syntaxErrorType) { + switch (error.syntaxErrorType()) { case ParserError::SyntaxErrorNone: - *result = Inspector::TypeBuilder::Runtime::SyntaxErrorType::None; + *result = Inspector::Protocol::Runtime::SyntaxErrorType::None; break; case ParserError::SyntaxErrorIrrecoverable: - *result = Inspector::TypeBuilder::Runtime::SyntaxErrorType::Irrecoverable; + *result = Inspector::Protocol::Runtime::SyntaxErrorType::Irrecoverable; break; case ParserError::SyntaxErrorUnterminatedLiteral: - *result = Inspector::TypeBuilder::Runtime::SyntaxErrorType::UnterminatedLiteral; + *result = Inspector::Protocol::Runtime::SyntaxErrorType::UnterminatedLiteral; break; case ParserError::SyntaxErrorRecoverable: - *result = Inspector::TypeBuilder::Runtime::SyntaxErrorType::Recoverable; + *result = Inspector::Protocol::Runtime::SyntaxErrorType::Recoverable; break; } - if (error.m_syntaxErrorType != ParserError::SyntaxErrorNone) { - *message = error.m_message; - range = buildErrorRangeObject(error.m_token.m_location); + if (error.syntaxErrorType() != ParserError::SyntaxErrorNone) { + *message = error.message(); + range = buildErrorRangeObject(error.token().m_location); } } -void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InspectorRuntimeAgent::evaluate(ErrorString& errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) { InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId); if (injectedScript.hasNoValue()) @@ -123,7 +124,7 @@ void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp if (asBool(doNotPauseOnExceptionsAndMuteConsole)) muteConsole(); - injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasThrown); + injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : String(), asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), asBool(saveResult), &result, wasThrown, savedResultIndex); if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { unmuteConsole(); @@ -131,17 +132,17 @@ void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp } } -void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) +void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const InspectorArray* optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); if (injectedScript.hasNoValue()) { - *errorString = ASCIILiteral("Inspected frame has gone"); + errorString = ASCIILiteral("Could not find InjectedScript for objectId"); return; } String arguments; if (optionalArguments) - arguments = (*optionalArguments)->toJSONString(); + arguments = optionalArguments->toJSONString(); ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions; if (asBool(doNotPauseOnExceptionsAndMuteConsole)) @@ -157,40 +158,224 @@ void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const Strin } } -void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* const ownProperties, RefPtr>& result, RefPtr>& internalProperties) +void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String& objectId, const bool* const ownProperties, const bool* const generatePreview, RefPtr>& result, RefPtr>& internalProperties) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); if (injectedScript.hasNoValue()) { - *errorString = ASCIILiteral("Inspected frame has gone"); + errorString = ASCIILiteral("Could not find InjectedScript for objectId"); return; } ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions); muteConsole(); - injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, &result); - injectedScript.getInternalProperties(errorString, objectId, &internalProperties); + injectedScript.getProperties(errorString, objectId, asBool(ownProperties), asBool(generatePreview), &result); + injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), &internalProperties); unmuteConsole(); setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState); } -void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) +void InspectorRuntimeAgent::getDisplayableProperties(ErrorString& errorString, const String& objectId, const bool* const generatePreview, RefPtr>& result, RefPtr>& internalProperties) { - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); + if (injectedScript.hasNoValue()) { + errorString = ASCIILiteral("Could not find InjectedScript for objectId"); + return; + } + + ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions); + muteConsole(); + + injectedScript.getDisplayableProperties(errorString, objectId, asBool(generatePreview), &result); + injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), &internalProperties); + + unmuteConsole(); + setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState); +} + +void InspectorRuntimeAgent::getCollectionEntries(ErrorString& errorString, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr>& entries) +{ + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); + if (injectedScript.hasNoValue()) { + errorString = ASCIILiteral("Could not find InjectedScript for objectId"); + return; + } + + int start = startIndex && *startIndex >= 0 ? *startIndex : 0; + int fetch = numberToFetch && *numberToFetch >= 0 ? *numberToFetch : 0; + + injectedScript.getCollectionEntries(errorString, objectId, objectGroup ? *objectGroup : String(), start, fetch, &entries); +} + +void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const Inspector::InspectorObject& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput* savedResultIndex) +{ + InjectedScript injectedScript; + + String objectId; + if (callArgument.getString(ASCIILiteral("objectId"), objectId)) { + injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); + if (injectedScript.hasNoValue()) { + errorString = ASCIILiteral("Could not find InjectedScript for objectId"); + return; + } + } else { + injectedScript = injectedScriptForEval(errorString, executionContextId); + if (injectedScript.hasNoValue()) + return; + } + + injectedScript.saveResult(errorString, callArgument.toJSONString(), savedResultIndex); +} + +void InspectorRuntimeAgent::releaseObject(ErrorString&, const String& objectId) +{ + InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); if (!injectedScript.hasNoValue()) injectedScript.releaseObject(objectId); } -void InspectorRuntimeAgent::releaseObjectGroup(ErrorString*, const String& objectGroup) +void InspectorRuntimeAgent::releaseObjectGroup(ErrorString&, const String& objectGroup) +{ + m_injectedScriptManager.releaseObjectGroup(objectGroup); +} + +void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& errorString, const Inspector::InspectorArray& locations, RefPtr>& typeDescriptions) +{ + static const bool verbose = false; + + typeDescriptions = Inspector::Protocol::Array::create(); + if (!m_vm.typeProfiler()) { + errorString = ASCIILiteral("The VM does not currently have Type Information."); + return; + } + + double start = currentTimeMS(); + m_vm.typeProfilerLog()->processLogEntries(ASCIILiteral("User Query")); + + for (size_t i = 0; i < locations.length(); i++) { + RefPtr value = locations.get(i); + RefPtr location; + if (!value->asObject(location)) { + errorString = ASCIILiteral("Array of TypeLocation objects has an object that does not have type of TypeLocation."); + return; + } + + int descriptor; + String sourceIDAsString; + int divot; + location->getInteger(ASCIILiteral("typeInformationDescriptor"), descriptor); + location->getString(ASCIILiteral("sourceID"), sourceIDAsString); + location->getInteger(ASCIILiteral("divot"), divot); + + bool okay; + TypeLocation* typeLocation = m_vm.typeProfiler()->findLocation(divot, sourceIDAsString.toIntPtrStrict(&okay), static_cast(descriptor), m_vm); + ASSERT(okay); + + RefPtr typeSet; + if (typeLocation) { + if (typeLocation->m_globalTypeSet && typeLocation->m_globalVariableID != TypeProfilerNoGlobalIDExists) + typeSet = typeLocation->m_globalTypeSet; + else + typeSet = typeLocation->m_instructionTypeSet; + } + + bool isValid = typeLocation && typeSet && !typeSet->isEmpty(); + auto description = Inspector::Protocol::Runtime::TypeDescription::create() + .setIsValid(isValid) + .release(); + + if (isValid) { + description->setLeastCommonAncestor(typeSet->leastCommonAncestor()); + description->setStructures(typeSet->allStructureRepresentations()); + description->setTypeSet(typeSet->inspectorTypeSet()); + description->setIsTruncated(typeSet->isOverflown()); + } + + typeDescriptions->addItem(WTFMove(description)); + } + + double end = currentTimeMS(); + if (verbose) + dataLogF("Inspector::getRuntimeTypesForVariablesAtOffsets took %lfms\n", end - start); +} + +void InspectorRuntimeAgent::willDestroyFrontendAndBackend(DisconnectReason reason) { - m_injectedScriptManager->releaseObjectGroup(objectGroup); + if (reason != DisconnectReason::InspectedTargetDestroyed && m_isTypeProfilingEnabled) + setTypeProfilerEnabledState(false); } -void InspectorRuntimeAgent::run(ErrorString*) +void InspectorRuntimeAgent::enableTypeProfiler(ErrorString&) { + setTypeProfilerEnabledState(true); } -} // namespace Inspector +void InspectorRuntimeAgent::disableTypeProfiler(ErrorString&) +{ + setTypeProfilerEnabledState(false); +} -#endif // ENABLE(INSPECTOR) +void InspectorRuntimeAgent::enableControlFlowProfiler(ErrorString&) +{ + setControlFlowProfilerEnabledState(true); +} + +void InspectorRuntimeAgent::disableControlFlowProfiler(ErrorString&) +{ + setControlFlowProfilerEnabledState(false); +} + +void InspectorRuntimeAgent::setTypeProfilerEnabledState(bool isTypeProfilingEnabled) +{ + if (m_isTypeProfilingEnabled == isTypeProfilingEnabled) + return; + m_isTypeProfilingEnabled = isTypeProfilingEnabled; + + VM& vm = m_vm; + vm.whenIdle([&vm, isTypeProfilingEnabled] () { + bool shouldRecompileFromTypeProfiler = (isTypeProfilingEnabled ? vm.enableTypeProfiler() : vm.disableTypeProfiler()); + if (shouldRecompileFromTypeProfiler) + vm.deleteAllCode(PreventCollectionAndDeleteAllCode); + }); +} + +void InspectorRuntimeAgent::setControlFlowProfilerEnabledState(bool isControlFlowProfilingEnabled) +{ + if (m_isControlFlowProfilingEnabled == isControlFlowProfilingEnabled) + return; + m_isControlFlowProfilingEnabled = isControlFlowProfilingEnabled; + + VM& vm = m_vm; + vm.whenIdle([&vm, isControlFlowProfilingEnabled] () { + bool shouldRecompileFromControlFlowProfiler = (isControlFlowProfilingEnabled ? vm.enableControlFlowProfiler() : vm.disableControlFlowProfiler()); + + if (shouldRecompileFromControlFlowProfiler) + vm.deleteAllCode(PreventCollectionAndDeleteAllCode); + }); +} + +void InspectorRuntimeAgent::getBasicBlocks(ErrorString& errorString, const String& sourceIDAsString, RefPtr>& basicBlocks) +{ + if (!m_vm.controlFlowProfiler()) { + errorString = ASCIILiteral("The VM does not currently have a Control Flow Profiler."); + return; + } + + bool okay; + intptr_t sourceID = sourceIDAsString.toIntPtrStrict(&okay); + ASSERT(okay); + const Vector& basicBlockRanges = m_vm.controlFlowProfiler()->getBasicBlocksForSourceID(sourceID, m_vm); + basicBlocks = Inspector::Protocol::Array::create(); + for (const BasicBlockRange& block : basicBlockRanges) { + Ref location = Inspector::Protocol::Runtime::BasicBlock::create() + .setStartOffset(block.m_startOffset) + .setEndOffset(block.m_endOffset) + .setHasExecuted(block.m_hasExecuted) + .setExecutionCount(block.m_executionCount) + .release(); + basicBlocks->addItem(WTFMove(location)); + } +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h index 2bc6e2994..2d2f626ec 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h +++ b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,13 +29,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef InspectorRuntimeAgent_h -#define InspectorRuntimeAgent_h +#pragma once -#if ENABLE(INSPECTOR) - -#include "InspectorJSBackendDispatchers.h" -#include "InspectorJSFrontendDispatchers.h" +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" #include "inspector/InspectorAgentBase.h" #include #include @@ -52,43 +49,53 @@ class InspectorArray; class ScriptDebugServer; typedef String ErrorString; -class JS_EXPORT_PRIVATE InspectorRuntimeAgent : public InspectorAgentBase, public InspectorRuntimeBackendDispatcherHandler { +class JS_EXPORT_PRIVATE InspectorRuntimeAgent : public InspectorAgentBase, public RuntimeBackendDispatcherHandler { WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent); public: virtual ~InspectorRuntimeAgent(); - virtual void enable(ErrorString*) override { m_enabled = true; } - virtual void disable(ErrorString*) override { m_enabled = false; } - virtual void parse(ErrorString*, const String& expression, Inspector::TypeBuilder::Runtime::SyntaxErrorType::Enum* result, Inspector::TypeBuilder::OptOutput* message, RefPtr&) override final; - virtual void evaluate(ErrorString*, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) override final; - virtual void callFunctionOn(ErrorString*, const String& objectId, const String& expression, const RefPtr* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr& result, Inspector::TypeBuilder::OptOutput* wasThrown) override final; - virtual void releaseObject(ErrorString*, const ErrorString& objectId) override final; - virtual void getProperties(ErrorString*, const String& objectId, const bool* ownProperties, RefPtr>& result, RefPtr>& internalProperties) override final; - virtual void releaseObjectGroup(ErrorString*, const String& objectGroup) override final; - virtual void run(ErrorString*) override; - - void setScriptDebugServer(ScriptDebugServer* scriptDebugServer) { m_scriptDebugServer = scriptDebugServer; } + void willDestroyFrontendAndBackend(DisconnectReason) override; + + void enable(ErrorString&) override { m_enabled = true; } + void disable(ErrorString&) override { m_enabled = false; } + void parse(ErrorString&, const String& expression, Inspector::Protocol::Runtime::SyntaxErrorType* result, Inspector::Protocol::OptOutput* message, RefPtr&) final; + void evaluate(ErrorString&, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* const executionContextId, const bool* const returnByValue, const bool* const generatePreview, const bool* const saveResult, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown, Inspector::Protocol::OptOutput* savedResultIndex) final; + void callFunctionOn(ErrorString&, const String& objectId, const String& expression, const Inspector::InspectorArray* optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* const generatePreview, RefPtr& result, Inspector::Protocol::OptOutput* wasThrown) final; + void releaseObject(ErrorString&, const ErrorString& objectId) final; + void getProperties(ErrorString&, const String& objectId, const bool* const ownProperties, const bool* const generatePreview, RefPtr>& result, RefPtr>& internalProperties) final; + void getDisplayableProperties(ErrorString&, const String& objectId, const bool* const generatePreview, RefPtr>& result, RefPtr>& internalProperties) final; + void getCollectionEntries(ErrorString&, const String& objectId, const String* const objectGroup, const int* const startIndex, const int* const numberToFetch, RefPtr>& entries) final; + void saveResult(ErrorString&, const Inspector::InspectorObject& callArgument, const int* const executionContextId, Inspector::Protocol::OptOutput* savedResultIndex) final; + void releaseObjectGroup(ErrorString&, const String& objectGroup) final; + void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const Inspector::InspectorArray& locations, RefPtr>&) override; + void enableTypeProfiler(ErrorString&) override; + void disableTypeProfiler(ErrorString&) override; + void enableControlFlowProfiler(ErrorString&) override; + void disableControlFlowProfiler(ErrorString&) override; + void getBasicBlocks(ErrorString&, const String& in_sourceID, RefPtr>& out_basicBlocks) override; bool enabled() const { return m_enabled; } protected: - InspectorRuntimeAgent(InjectedScriptManager*); + InspectorRuntimeAgent(AgentContext&); - InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; } + InjectedScriptManager& injectedScriptManager() { return m_injectedScriptManager; } - virtual JSC::VM* globalVM() = 0; - virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0; + virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0; virtual void muteConsole() = 0; virtual void unmuteConsole() = 0; private: - InjectedScriptManager* m_injectedScriptManager; - ScriptDebugServer* m_scriptDebugServer; - bool m_enabled; + void setTypeProfilerEnabledState(bool); + void setControlFlowProfilerEnabledState(bool); + + InjectedScriptManager& m_injectedScriptManager; + ScriptDebugServer& m_scriptDebugServer; + JSC::VM& m_vm; + bool m_enabled {false}; + bool m_isTypeProfilingEnabled {false}; + bool m_isControlFlowProfilingEnabled {false}; }; } // namespace Inspector - -#endif // ENABLE(INSPECTOR) -#endif // InspectorRuntimeAgent_h diff --git a/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp new file mode 100644 index 000000000..c266f4309 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorScriptProfilerAgent.h" + +#include "DeferGC.h" +#include "HeapInlines.h" +#include "InspectorEnvironment.h" +#include "SamplingProfiler.h" +#include + +using namespace JSC; + +namespace Inspector { + +InspectorScriptProfilerAgent::InspectorScriptProfilerAgent(AgentContext& context) + : InspectorAgentBase(ASCIILiteral("ScriptProfiler")) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(ScriptProfilerBackendDispatcher::create(context.backendDispatcher, this)) + , m_environment(context.environment) +{ +} + +InspectorScriptProfilerAgent::~InspectorScriptProfilerAgent() +{ +} + +void InspectorScriptProfilerAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) +{ +} + +void InspectorScriptProfilerAgent::willDestroyFrontendAndBackend(DisconnectReason) +{ + // Stop tracking without sending results. + if (m_tracking) { + m_tracking = false; + m_activeEvaluateScript = false; + m_environment.scriptDebugServer().setProfilingClient(nullptr); + + // Stop sampling without processing the samples. + stopSamplingWhenDisconnecting(); + } +} + +void InspectorScriptProfilerAgent::startTracking(ErrorString&, const bool* const includeSamples) +{ + if (m_tracking) + return; + + m_tracking = true; + +#if ENABLE(SAMPLING_PROFILER) + if (includeSamples && *includeSamples) { + VM& vm = m_environment.scriptDebugServer().vm(); + SamplingProfiler& samplingProfiler = vm.ensureSamplingProfiler(m_environment.executionStopwatch()); + + LockHolder locker(samplingProfiler.getLock()); + samplingProfiler.setStopWatch(locker, m_environment.executionStopwatch()); + samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(locker); + samplingProfiler.start(locker); + m_enabledSamplingProfiler = true; + } +#else + UNUSED_PARAM(includeSamples); +#endif // ENABLE(SAMPLING_PROFILER) + + m_environment.scriptDebugServer().setProfilingClient(this); + + m_frontendDispatcher->trackingStart(m_environment.executionStopwatch()->elapsedTime()); +} + +void InspectorScriptProfilerAgent::stopTracking(ErrorString&) +{ + if (!m_tracking) + return; + + m_tracking = false; + m_activeEvaluateScript = false; + + m_environment.scriptDebugServer().setProfilingClient(nullptr); + + trackingComplete(); +} + +bool InspectorScriptProfilerAgent::isAlreadyProfiling() const +{ + return m_activeEvaluateScript; +} + +double InspectorScriptProfilerAgent::willEvaluateScript() +{ + m_activeEvaluateScript = true; + +#if ENABLE(SAMPLING_PROFILER) + if (m_enabledSamplingProfiler) { + SamplingProfiler* samplingProfiler = m_environment.scriptDebugServer().vm().samplingProfiler(); + RELEASE_ASSERT(samplingProfiler); + samplingProfiler->noticeCurrentThreadAsJSCExecutionThread(); + } +#endif + + return m_environment.executionStopwatch()->elapsedTime(); +} + +void InspectorScriptProfilerAgent::didEvaluateScript(double startTime, ProfilingReason reason) +{ + m_activeEvaluateScript = false; + + double endTime = m_environment.executionStopwatch()->elapsedTime(); + + addEvent(startTime, endTime, reason); +} + +static Inspector::Protocol::ScriptProfiler::EventType toProtocol(ProfilingReason reason) +{ + switch (reason) { + case ProfilingReason::API: + return Inspector::Protocol::ScriptProfiler::EventType::API; + case ProfilingReason::Microtask: + return Inspector::Protocol::ScriptProfiler::EventType::Microtask; + case ProfilingReason::Other: + return Inspector::Protocol::ScriptProfiler::EventType::Other; + } + + ASSERT_NOT_REACHED(); + return Inspector::Protocol::ScriptProfiler::EventType::Other; +} + +void InspectorScriptProfilerAgent::addEvent(double startTime, double endTime, ProfilingReason reason) +{ + ASSERT(endTime >= startTime); + + auto event = Inspector::Protocol::ScriptProfiler::Event::create() + .setStartTime(startTime) + .setEndTime(endTime) + .setType(toProtocol(reason)) + .release(); + + m_frontendDispatcher->trackingUpdate(WTFMove(event)); +} + +#if ENABLE(SAMPLING_PROFILER) +static Ref buildSamples(VM& vm, Vector&& samplingProfilerStackTraces) +{ + Ref> stackTraces = Protocol::Array::create(); + for (SamplingProfiler::StackTrace& stackTrace : samplingProfilerStackTraces) { + Ref> frames = Protocol::Array::create(); + for (SamplingProfiler::StackFrame& stackFrame : stackTrace.frames) { + Ref frame = Protocol::ScriptProfiler::StackFrame::create() + .setSourceID(String::number(stackFrame.sourceID())) + .setName(stackFrame.displayName(vm)) + .setLine(stackFrame.functionStartLine()) + .setColumn(stackFrame.functionStartColumn()) + .setUrl(stackFrame.url()) + .release(); + + if (stackFrame.hasExpressionInfo()) { + Ref expressionLocation = Protocol::ScriptProfiler::ExpressionLocation::create() + .setLine(stackFrame.lineNumber()) + .setColumn(stackFrame.columnNumber()) + .release(); + frame->setExpressionLocation(WTFMove(expressionLocation)); + } + + frames->addItem(WTFMove(frame)); + } + Ref inspectorStackTrace = Protocol::ScriptProfiler::StackTrace::create() + .setTimestamp(stackTrace.timestamp) + .setStackFrames(WTFMove(frames)) + .release(); + stackTraces->addItem(WTFMove(inspectorStackTrace)); + } + + return Protocol::ScriptProfiler::Samples::create() + .setStackTraces(WTFMove(stackTraces)) + .release(); +} +#endif // ENABLE(SAMPLING_PROFILER) + +void InspectorScriptProfilerAgent::trackingComplete() +{ +#if ENABLE(SAMPLING_PROFILER) + if (m_enabledSamplingProfiler) { + VM& vm = m_environment.scriptDebugServer().vm(); + JSLockHolder lock(vm); + DeferGC deferGC(vm.heap); + SamplingProfiler* samplingProfiler = vm.samplingProfiler(); + RELEASE_ASSERT(samplingProfiler); + + LockHolder locker(samplingProfiler->getLock()); + samplingProfiler->pause(locker); + Vector stackTraces = samplingProfiler->releaseStackTraces(locker); + locker.unlockEarly(); + + Ref samples = buildSamples(vm, WTFMove(stackTraces)); + + m_enabledSamplingProfiler = false; + + m_frontendDispatcher->trackingComplete(WTFMove(samples)); + } else + m_frontendDispatcher->trackingComplete(nullptr); +#else + m_frontendDispatcher->trackingComplete(nullptr); +#endif // ENABLE(SAMPLING_PROFILER) +} + +void InspectorScriptProfilerAgent::stopSamplingWhenDisconnecting() +{ +#if ENABLE(SAMPLING_PROFILER) + if (!m_enabledSamplingProfiler) + return; + + VM& vm = m_environment.scriptDebugServer().vm(); + JSLockHolder lock(vm); + SamplingProfiler* samplingProfiler = vm.samplingProfiler(); + RELEASE_ASSERT(samplingProfiler); + LockHolder locker(samplingProfiler->getLock()); + samplingProfiler->pause(locker); + samplingProfiler->clearData(locker); + + m_enabledSamplingProfiler = false; +#endif +} + +void InspectorScriptProfilerAgent::programmaticCaptureStarted() +{ + m_frontendDispatcher->programmaticCaptureStarted(); +} + +void InspectorScriptProfilerAgent::programmaticCaptureStopped() +{ + m_frontendDispatcher->programmaticCaptureStopped(); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h new file mode 100644 index 000000000..ca1bb8a61 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorBackendDispatchers.h" +#include "InspectorFrontendDispatchers.h" +#include "inspector/InspectorAgentBase.h" +#include "inspector/ScriptDebugServer.h" +#include + +namespace JSC { +class Profile; +} + +namespace Inspector { + +typedef String ErrorString; + +class JS_EXPORT_PRIVATE InspectorScriptProfilerAgent final : public InspectorAgentBase, public ScriptProfilerBackendDispatcherHandler, public JSC::Debugger::ProfilingClient { + WTF_MAKE_NONCOPYABLE(InspectorScriptProfilerAgent); +public: + InspectorScriptProfilerAgent(AgentContext&); + virtual ~InspectorScriptProfilerAgent(); + + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; + void willDestroyFrontendAndBackend(DisconnectReason) override; + + // ScriptProfilerBackendDispatcherHandler + void startTracking(ErrorString&, const bool* const includeSamples) override; + void stopTracking(ErrorString&) override; + + void programmaticCaptureStarted(); + void programmaticCaptureStopped(); + + // Debugger::ProfilingClient + bool isAlreadyProfiling() const override; + double willEvaluateScript() override; + void didEvaluateScript(double, JSC::ProfilingReason) override; + +private: + struct Event { + Event(double start, double end) : startTime(start), endTime(end) { } + double startTime { 0 }; + double endTime { 0 }; + }; + + void addEvent(double startTime, double endTime, JSC::ProfilingReason); + void trackingComplete(); + void stopSamplingWhenDisconnecting(); + + std::unique_ptr m_frontendDispatcher; + RefPtr m_backendDispatcher; + InspectorEnvironment& m_environment; + bool m_tracking { false }; +#if ENABLE(SAMPLING_PROFILER) + bool m_enabledSamplingProfiler { false }; +#endif + bool m_activeEvaluateScript { false }; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.cpp b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.cpp new file mode 100644 index 000000000..401162bc2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectConsoleAgent.h" + +namespace Inspector { + +JSGlobalObjectConsoleAgent::JSGlobalObjectConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent) + : InspectorConsoleAgent(context, heapAgent) +{ +} + +void JSGlobalObjectConsoleAgent::setMonitoringXHREnabled(ErrorString& errorString, bool) +{ + errorString = ASCIILiteral("Not supported for JavaScript context"); +} + +void JSGlobalObjectConsoleAgent::addInspectedNode(ErrorString& errorString, int) +{ + errorString = ASCIILiteral("Not supported for JavaScript context"); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.h b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.h new file mode 100644 index 000000000..91dade3d2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorConsoleAgent.h" +#include "JSGlobalObjectScriptDebugServer.h" + +namespace Inspector { + +class JSGlobalObjectConsoleAgent final : public InspectorConsoleAgent { + WTF_MAKE_NONCOPYABLE(JSGlobalObjectConsoleAgent); + WTF_MAKE_FAST_ALLOCATED; +public: + JSGlobalObjectConsoleAgent(AgentContext&, InspectorHeapAgent*); + virtual ~JSGlobalObjectConsoleAgent() { } + + // FIXME: XHRs and Nodes only makes sense debugging a Web context. Can this be moved to a different agent? + void setMonitoringXHREnabled(ErrorString&, bool enabled) override; + void addInspectedNode(ErrorString&, int nodeId) override; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp new file mode 100644 index 000000000..19ba13db5 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectDebuggerAgent.h" + +#include "ConsoleMessage.h" +#include "InjectedScriptManager.h" +#include "InspectorConsoleAgent.h" +#include "JSGlobalObject.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" + +using namespace JSC; + +namespace Inspector { + +JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent(JSAgentContext& context, InspectorConsoleAgent* consoleAgent) + : InspectorDebuggerAgent(context) + , m_consoleAgent(consoleAgent) +{ +} + +InjectedScript JSGlobalObjectDebuggerAgent::injectedScriptForEval(ErrorString& error, const int* executionContextId) +{ + if (executionContextId) { + error = ASCIILiteral("Execution context id is not supported for JSContext inspection as there is only one execution context."); + return InjectedScript(); + } + + ExecState* exec = static_cast(scriptDebugServer()).globalObject().globalExec(); + return injectedScriptManager().injectedScriptFor(exec); +} + +void JSGlobalObjectDebuggerAgent::breakpointActionLog(JSC::ExecState& state, const String& message) +{ + m_consoleAgent->addMessageToConsole(std::make_unique(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture), 0)); +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.h b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.h new file mode 100644 index 000000000..5476f55ce --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorDebuggerAgent.h" +#include "JSGlobalObjectScriptDebugServer.h" + +namespace Inspector { + +class InspectorConsoleAgent; + +class JSGlobalObjectDebuggerAgent final : public InspectorDebuggerAgent { + WTF_MAKE_NONCOPYABLE(JSGlobalObjectDebuggerAgent); + WTF_MAKE_FAST_ALLOCATED; +public: + JSGlobalObjectDebuggerAgent(JSAgentContext&, InspectorConsoleAgent*); + virtual ~JSGlobalObjectDebuggerAgent() { } + + InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override; + + void breakpointActionLog(JSC::ExecState&, const String&) final; + + // NOTE: JavaScript inspector does not yet need to mute a console because no messages + // are sent to the console outside of the API boundary or console object. + void muteConsole() final { } + void unmuteConsole() final { } + +private: + InspectorConsoleAgent* m_consoleAgent { nullptr }; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp new file mode 100644 index 000000000..b748eeb0a --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObjectRuntimeAgent.h" + +#include "InjectedScript.h" +#include "InjectedScriptManager.h" +#include "JSGlobalObject.h" + +using namespace JSC; + +namespace Inspector { + +JSGlobalObjectRuntimeAgent::JSGlobalObjectRuntimeAgent(JSAgentContext& context) + : InspectorRuntimeAgent(context) + , m_frontendDispatcher(std::make_unique(context.frontendRouter)) + , m_backendDispatcher(RuntimeBackendDispatcher::create(context.backendDispatcher, this)) + , m_globalObject(context.inspectedGlobalObject) +{ +} + +void JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) +{ +} + +InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId) +{ + ASSERT_UNUSED(executionContextId, !executionContextId); + + JSC::ExecState* scriptState = m_globalObject.globalExec(); + InjectedScript injectedScript = injectedScriptManager().injectedScriptFor(scriptState); + if (injectedScript.hasNoValue()) + errorString = ASCIILiteral("Internal error: main world execution context not found."); + + return injectedScript; +} + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h new file mode 100644 index 000000000..06809ad28 --- /dev/null +++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "InspectorRuntimeAgent.h" + +namespace JSC { +class JSGlobalObject; +} + +namespace Inspector { + +class JSGlobalObjectRuntimeAgent final : public InspectorRuntimeAgent { +public: + JSGlobalObjectRuntimeAgent(JSAgentContext&); + + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; + + InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override; + + // NOTE: JavaScript inspector does not yet need to mute a console because no messages + // are sent to the console outside of the API boundary or console object. + void muteConsole() override { } + void unmuteConsole() override { } + +private: + std::unique_ptr m_frontendDispatcher; + RefPtr m_backendDispatcher; + JSC::JSGlobalObject& m_globalObject; +}; + +} // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/augmentable/AlternateDispatchableAgent.h b/Source/JavaScriptCore/inspector/augmentable/AlternateDispatchableAgent.h new file mode 100644 index 000000000..cd3f3c326 --- /dev/null +++ b/Source/JavaScriptCore/inspector/augmentable/AlternateDispatchableAgent.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "InspectorAlternateBackendDispatchers.h" +#include "InspectorBackendDispatchers.h" +#include +#include + +namespace Inspector { + +template +class AlternateDispatchableAgent final : public InspectorAgentBase { + WTF_MAKE_FAST_ALLOCATED; +public: + AlternateDispatchableAgent(const String& domainName, AugmentableInspectorController& controller, std::unique_ptr alternateDispatcher) + : InspectorAgentBase(domainName) + , m_alternateDispatcher(WTFMove(alternateDispatcher)) + , m_backendDispatcher(TBackendDispatcher::create(controller.backendDispatcher(), nullptr)) + { + m_backendDispatcher->setAlternateDispatcher(m_alternateDispatcher.get()); + m_alternateDispatcher->setBackendDispatcher(&controller.backendDispatcher()); + } + + virtual ~AlternateDispatchableAgent() + { + m_alternateDispatcher->setBackendDispatcher(nullptr); + } + + void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override + { + } + + void willDestroyFrontendAndBackend(DisconnectReason) override + { + } + +private: + std::unique_ptr m_alternateDispatcher; + RefPtr m_backendDispatcher; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) diff --git a/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorController.h b/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorController.h new file mode 100644 index 000000000..7025f2355 --- /dev/null +++ b/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorController.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include +#include +#include + +namespace Inspector { + +class InspectorAgentBase; + +class AugmentableInspectorController { +public: + virtual ~AugmentableInspectorController() { } + + virtual AugmentableInspectorControllerClient* augmentableInspectorControllerClient() const = 0; + virtual void setAugmentableInspectorControllerClient(AugmentableInspectorControllerClient*) = 0; + + virtual const FrontendRouter& frontendRouter() const = 0; + virtual BackendDispatcher& backendDispatcher() = 0; + virtual void appendExtraAgent(std::unique_ptr) = 0; + + bool connected() const { return frontendRouter().hasFrontends(); } +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) diff --git a/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorControllerClient.h b/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorControllerClient.h new file mode 100644 index 000000000..7124fca5b --- /dev/null +++ b/Source/JavaScriptCore/inspector/augmentable/AugmentableInspectorControllerClient.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +namespace Inspector { + +class AugmentableInspectorControllerClient { +public: + virtual ~AugmentableInspectorControllerClient() { } + virtual void inspectorControllerDestroyed() = 0; + virtual void inspectorConnected() = 0; + virtual void inspectorDisconnected() = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) diff --git a/Source/JavaScriptCore/inspector/protocol/ApplicationCache.json b/Source/JavaScriptCore/inspector/protocol/ApplicationCache.json new file mode 100644 index 000000000..86a984a12 --- /dev/null +++ b/Source/JavaScriptCore/inspector/protocol/ApplicationCache.json @@ -0,0 +1,87 @@ +{ + "domain": "ApplicationCache", + "availability": "web", + "types": [ + { + "id": "ApplicationCacheResource", + "type": "object", + "description": "Detailed application cache resource information.", + "properties": [ + { "name": "url", "type": "string", "description": "Resource url." }, + { "name": "size", "type": "integer", "description": "Resource size." }, + { "name": "type", "type": "string", "description": "Resource type." } + ] + }, + { + "id": "ApplicationCache", + "type": "object", + "description": "Detailed application cache information.", + "properties": [ + { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, + { "name": "size", "type": "number", "description": "Application cache size." }, + { "name": "creationTime", "type": "number", "description": "Application cache creation time." }, + { "name": "updateTime", "type": "number", "description": "Application cache update time." }, + { "name": "resources", "type": "array", "items": { "$ref": "ApplicationCacheResource" }, "description": "Application cache resources." } + ] + }, + { + "id": "FrameWithManifest", + "type": "object", + "description": "Frame identifier - manifest URL pair.", + "properties": [ + { "name": "frameId", "$ref": "Network.FrameId", "description": "Frame identifier." }, + { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, + { "name": "status", "type": "integer", "description": "Application cache status." } + ] + } + ], + "commands": [ + { + "name": "getFramesWithManifests", + "returns": [ + { "name": "frameIds", "type": "array", "items": { "$ref": "FrameWithManifest" }, "description": "Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache." } + ], + "description": "Returns array of frame identifiers with manifest urls for each frame containing a document associated with some application cache." + }, + { + "name": "enable", + "description": "Enables application cache domain notifications." + }, + { + "name": "getManifestForFrame", + "parameters": [ + { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing document whose manifest is retrieved." } + ], + "returns": [ + { "name": "manifestURL", "type": "string", "description": "Manifest URL for document in the given frame." } + ], + "description": "Returns manifest URL for document in the given frame." + }, + { + "name": "getApplicationCacheForFrame", + "parameters": [ + { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing document whose application cache is retrieved." } + ], + "returns": [ + { "name": "applicationCache", "$ref": "ApplicationCache", "description": "Relevant application cache data for the document in given frame." } + ], + "description": "Returns relevant application cache data for the document in given frame." + } + ], + "events": [ + { + "name": "applicationCacheStatusUpdated", + "parameters": [ + { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing document whose application cache updated status." }, + { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, + { "name": "status", "type": "integer", "description": "Updated application cache status." } + ] + }, + { + "name": "networkStateUpdated", + "parameters": [ + { "name": "isNowOnline", "type": "boolean" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/protocol/CSS.json b/Source/JavaScriptCore/inspector/protocol/CSS.json new file mode 100644 index 000000000..7abbe227f --- /dev/null +++ b/Source/JavaScriptCore/inspector/protocol/CSS.json @@ -0,0 +1,457 @@ +{ + "domain": "CSS", + "description": "This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated id used in subsequent operations on the related object. Each object type has a specific id structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the get*ForNode() calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the getAllStyleSheets() method and subsequently load the required stylesheet contents using the getStyleSheet[Text]() methods.", + "availability": "web", + "types": [ + { + "id": "StyleSheetId", + "type": "string" + }, + { + "id": "CSSStyleId", + "type": "object", + "properties": [ + { "name": "styleSheetId", "$ref": "StyleSheetId", "description": "Enclosing stylesheet identifier." }, + { "name": "ordinal", "type": "integer", "description": "The style ordinal within the stylesheet." } + ], + "description": "This object identifies a CSS style in a unique way." + }, + { + "id": "StyleSheetOrigin", + "type": "string", + "enum": ["user", "user-agent", "inspector", "regular"], + "description": "Stylesheet type: \"user\" for user stylesheets, \"user-agent\" for user-agent stylesheets, \"inspector\" for stylesheets created by the inspector (i.e. those holding the \"via inspector\" rules), \"regular\" for regular stylesheets." + }, + { + "id": "CSSRuleId", + "type": "object", + "properties": [ + { "name": "styleSheetId", "$ref": "StyleSheetId", "description": "Enclosing stylesheet identifier." }, + { "name": "ordinal", "type": "integer", "description": "The rule ordinal within the stylesheet." } + ], + "description": "This object identifies a CSS rule in a unique way." + }, + { + "id": "PseudoIdMatches", + "type": "object", + "properties": [ + { "name": "pseudoId", "type": "integer", "description": "Pseudo style identifier (see enum PseudoId in RenderStyleConstants.h)."}, + { "name": "matches", "type": "array", "items": { "$ref": "RuleMatch" }, "description": "Matches of CSS rules applicable to the pseudo style."} + ], + "description": "CSS rule collection for a single pseudo style." + }, + { + "id": "InheritedStyleEntry", + "type": "object", + "properties": [ + { "name": "inlineStyle", "$ref": "CSSStyle", "optional": true, "description": "The ancestor node's inline style, if any, in the style inheritance chain." }, + { "name": "matchedCSSRules", "type": "array", "items": { "$ref": "RuleMatch" }, "description": "Matches of CSS rules matching the ancestor node in the style inheritance chain." } + ], + "description": "CSS rule collection for a single pseudo style." + }, + { + "id": "RuleMatch", + "type": "object", + "properties": [ + { "name": "rule", "$ref": "CSSRule", "description": "CSS rule in the match." }, + { "name": "matchingSelectors", "type": "array", "items": { "type": "integer" }, "description": "Matching selector indices in the rule's selectorList selectors (0-based)." } + ], + "description": "Match data for a CSS rule." + }, + { + "id": "CSSSelector", + "type": "object", + "properties": [ + { "name": "text", "type": "string", "description": "Canonicalized selector text." }, + { "name": "specificity", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Specificity (a, b, c) tuple. Included if the selector is sent in response to CSS.getMatchedStylesForNode which provides a context element." }, + { "name": "dynamic", "optional": true, "type": "boolean", "description": "Whether or not the specificity can be dynamic. Included if the selector is sent in response to CSS.getMatchedStylesForNode which provides a context element." } + ], + "description": "CSS selector." + }, + { + "id": "SelectorList", + "type": "object", + "properties": [ + { "name": "selectors", "type": "array", "items": { "$ref": "CSSSelector" }, "description": "Selectors in the list." }, + { "name": "text", "type": "string", "description": "Rule selector text." }, + { "name": "range", "$ref": "SourceRange", "optional": true, "description": "Rule selector range in the underlying resource (if available)." } + ], + "description": "Selector list data." + }, + { + "id": "CSSStyleAttribute", + "type": "object", + "properties": [ + { "name": "name", "type": "string", "description": "DOM attribute name (e.g. \"width\")."}, + { "name": "style", "$ref": "CSSStyle", "description": "CSS style generated by the respective DOM attribute."} + ], + "description": "CSS style information for a DOM style attribute." + }, + { + "id": "CSSStyleSheetHeader", + "type": "object", + "properties": [ + { "name": "styleSheetId", "$ref": "StyleSheetId", "description": "The stylesheet identifier."}, + { "name": "frameId", "$ref": "Network.FrameId", "description": "Owner frame identifier."}, + { "name": "sourceURL", "type": "string", "description": "Stylesheet resource URL."}, + { "name": "origin", "$ref": "StyleSheetOrigin", "description": "Stylesheet origin."}, + { "name": "title", "type": "string", "description": "Stylesheet title."}, + { "name": "disabled", "type": "boolean", "description": "Denotes whether the stylesheet is disabled."}, + { "name": "isInline", "type": "boolean", "description": "Whether this stylesheet is a -# - - -import cssmin -import jsmin -import os.path -import re -import sys - - -def main(argv): - - if len(argv) < 2: - print('usage: %s inputFile outputFile' % argv[0]) - return 1 - - inputFileName = argv[1] - outputFileName = argv[2] - importsDir = os.path.dirname(inputFileName) - - inputFile = open(inputFileName, 'r') - inputContent = inputFile.read() - inputFile.close() - - def inline(match, minifier, prefix, postfix): - importFileName = match.group(1) - fullPath = os.path.join(importsDir, importFileName) - if not os.access(fullPath, os.F_OK): - raise Exception('File %s referenced in %s not found' % (importFileName, inputFileName)) - importFile = open(fullPath, 'r') - importContent = minifier(importFile.read()) - importFile.close() - return '%s%s%s' % (prefix, importContent, postfix) - - def inlineStylesheet(match): - return inline(match, cssmin.cssminify, "") - - def inlineScript(match): - return inline(match, jsmin.jsmin, "") - - outputContent = re.sub(r'', inlineStylesheet, inputContent) - outputContent = re.sub(r'', inlineScript, outputContent) - - outputFile = open(outputFileName, 'w') - outputFile.write(outputContent) - outputFile.close() - - # Touch output file directory to make sure that Xcode will copy - # modified resource files. - if sys.platform == 'darwin': - outputDirName = os.path.dirname(outputFileName) - os.utime(outputDirName, None) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/Source/JavaScriptCore/inspector/scripts/jsmin.py b/Source/JavaScriptCore/inspector/scripts/jsmin.py deleted file mode 100644 index 83d2a50ac..000000000 --- a/Source/JavaScriptCore/inspector/scripts/jsmin.py +++ /dev/null @@ -1,238 +0,0 @@ -# This code is original from jsmin by Douglas Crockford, it was translated to -# Python by Baruch Even. It was rewritten by Dave St.Germain for speed. -# -# The MIT License (MIT) -# -# Copyright (c) 2013 Dave St.Germain -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -import sys -is_3 = sys.version_info >= (3, 0) -if is_3: - import io -else: - import StringIO - try: - import cStringIO - except ImportError: - cStringIO = None - - -__all__ = ['jsmin', 'JavascriptMinify'] -__version__ = '2.0.9' - - -def jsmin(js): - """ - returns a minified version of the javascript string - """ - if not is_3: - if cStringIO and not isinstance(js, unicode): - # strings can use cStringIO for a 3x performance - # improvement, but unicode (in python2) cannot - klass = cStringIO.StringIO - else: - klass = StringIO.StringIO - else: - klass = io.StringIO - ins = klass(js) - outs = klass() - JavascriptMinify(ins, outs).minify() - return outs.getvalue() - - -class JavascriptMinify(object): - """ - Minify an input stream of javascript, writing - to an output stream - """ - - def __init__(self, instream=None, outstream=None): - self.ins = instream - self.outs = outstream - - def minify(self, instream=None, outstream=None): - if instream and outstream: - self.ins, self.outs = instream, outstream - - self.is_return = False - self.return_buf = '' - - def write(char): - # all of this is to support literal regular expressions. - # sigh - if char in 'return': - self.return_buf += char - self.is_return = self.return_buf == 'return' - self.outs.write(char) - if self.is_return: - self.return_buf = '' - - read = self.ins.read - - space_strings = "abcdefghijklmnopqrstuvwxyz"\ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\" - starters, enders = '{[(+-', '}])+-"\'' - newlinestart_strings = starters + space_strings - newlineend_strings = enders + space_strings - do_newline = False - do_space = False - escape_slash_count = 0 - doing_single_comment = False - previous_before_comment = '' - doing_multi_comment = False - in_re = False - in_quote = '' - quote_buf = [] - - previous = read(1) - if previous == '\\': - escape_slash_count += 1 - next1 = read(1) - if previous == '/': - if next1 == '/': - doing_single_comment = True - elif next1 == '*': - doing_multi_comment = True - previous = next1 - next1 = read(1) - else: - write(previous) - elif not previous: - return - elif previous >= '!': - if previous in "'\"": - in_quote = previous - write(previous) - previous_non_space = previous - else: - previous_non_space = ' ' - if not next1: - return - - while 1: - next2 = read(1) - if not next2: - last = next1.strip() - if not (doing_single_comment or doing_multi_comment)\ - and last not in ('', '/'): - if in_quote: - write(''.join(quote_buf)) - write(last) - break - if doing_multi_comment: - if next1 == '*' and next2 == '/': - doing_multi_comment = False - next2 = read(1) - elif doing_single_comment: - if next1 in '\r\n': - doing_single_comment = False - while next2 in '\r\n': - next2 = read(1) - if not next2: - break - if previous_before_comment in ')}]': - do_newline = True - elif previous_before_comment in space_strings: - write('\n') - elif in_quote: - quote_buf.append(next1) - - if next1 == in_quote: - numslashes = 0 - for c in reversed(quote_buf[:-1]): - if c != '\\': - break - else: - numslashes += 1 - if numslashes % 2 == 0: - in_quote = '' - write(''.join(quote_buf)) - elif next1 in '\r\n': - if previous_non_space in newlineend_strings \ - or previous_non_space > '~': - while 1: - if next2 < '!': - next2 = read(1) - if not next2: - break - else: - if next2 in newlinestart_strings \ - or next2 > '~' or next2 == '/': - do_newline = True - break - elif next1 < '!' and not in_re: - if (previous_non_space in space_strings \ - or previous_non_space > '~') \ - and (next2 in space_strings or next2 > '~'): - do_space = True - elif previous_non_space in '-+' and next2 == previous_non_space: - # protect against + ++ or - -- sequences - do_space = True - elif self.is_return and next2 == '/': - # returning a regex... - write(' ') - elif next1 == '/': - if do_space: - write(' ') - if in_re: - if previous != '\\' or (not escape_slash_count % 2) or next2 in 'gimy': - in_re = False - write('/') - elif next2 == '/': - doing_single_comment = True - previous_before_comment = previous_non_space - elif next2 == '*': - doing_multi_comment = True - previous = next1 - next1 = next2 - next2 = read(1) - else: - in_re = previous_non_space in '(,=:[?!&|' or self.is_return # literal regular expression - write('/') - else: - if do_space: - do_space = False - write(' ') - if do_newline: - write('\n') - do_newline = False - - write(next1) - if not in_re and next1 in "'\"": - in_quote = next1 - quote_buf = [] - - previous = next1 - next1 = next2 - - if previous >= '!': - previous_non_space = previous - - if previous == '\\': - escape_slash_count += 1 - else: - escape_slash_count = 0 - -if __name__ == '__main__': - minifier = JavascriptMinify(sys.stdin, sys.stdout) - minifier.minify() - sys.stdout.write('\n') diff --git a/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json new file mode 100644 index 000000000..817f135ee --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json @@ -0,0 +1,28 @@ +{ + "domain": "Network", + "types": [ + { + "id": "NetworkError", + "type": "object", + "platform": "macos", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "loadResource", + "platform": "macos", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ], + "events": [ + { + "name": "resourceLoaded", + "platform": "macos", + "description": "A resource was loaded." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result b/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result new file mode 100644 index 000000000..170d57c0a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result @@ -0,0 +1,1203 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network. +InspectorBackend.registerNetworkDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Network"); +InspectorBackend.registerEvent("Network.resourceLoaded", []); +InspectorBackend.registerCommand("Network.loadResource", [], []); +InspectorBackend.activateDomain("Network"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateNetworkBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetworkBackendDispatcher() { } + virtual void loadResource(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateNetworkBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class NetworkBackendDispatcherHandler { +public: + virtual void loadResource(ErrorString&) = 0; +protected: + virtual ~NetworkBackendDispatcherHandler(); +}; + +class NetworkBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, NetworkBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void loadResource(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetworkBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetworkBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + NetworkBackendDispatcher(BackendDispatcher&, NetworkBackendDispatcherHandler*); + NetworkBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +NetworkBackendDispatcherHandler::~NetworkBackendDispatcherHandler() { } + +Ref NetworkBackendDispatcher::create(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) +{ + return adoptRef(*new NetworkBackendDispatcher(backendDispatcher, agent)); +} + +NetworkBackendDispatcher::NetworkBackendDispatcher(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network"), this); +} + +void NetworkBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource") + loadResource(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network", '.', method, "' was not found")); +} + +void NetworkBackendDispatcher::loadResource(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +class NetworkFrontendDispatcher { +public: + NetworkFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void resourceLoaded(); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +void NetworkFrontendDispatcher::resourceLoaded() +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network.resourceLoaded")); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Network { +class NetworkError; +} // Network +// End of forward declarations. + + + + +namespace Network { +class NetworkError : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class NetworkError; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(NetworkError) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = NetworkError::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Network + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolNetworkDomainHandler; + +namespace Inspector { + + +class ObjCInspectorNetworkBackendDispatcher final : public AlternateNetworkBackendDispatcher { +public: + ObjCInspectorNetworkBackendDispatcher(id handler) { m_delegate = handler; } + virtual void loadResource(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorNetworkBackendDispatcher::loadResource(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResourceWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetworkHandler:) id networkHandler; +@property (nonatomic, readonly) TestProtocolNetworkDomainEventDispatcher *networkEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _networkHandler; + TestProtocolNetworkDomainEventDispatcher *_networkEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_networkHandler release]; + [_networkEventDispatcher release]; + [super dealloc]; +} + +- (void)setNetworkHandler:(id)handler +{ + if (handler == _networkHandler) + return; + + [_networkHandler release]; + _networkHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Network"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)networkHandler +{ + return _networkHandler; +} + +- (TestProtocolNetworkDomainEventDispatcher *)networkEventDispatcher +{ + if (!_networkEventDispatcher) + _networkEventDispatcher = [[TestProtocolNetworkDomainEventDispatcher alloc] initWithController:_controller]; + return _networkEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + +@implementation TestProtocolNetworkDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)resourceLoaded +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network.resourceLoaded")); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolNetworkError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolNetworkError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolNetworkDomainHandler +@required +- (void)loadResourceWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolNetworkDomainEventDispatcher : NSObject +- (void)resourceLoaded; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + +@interface TestProtocolNetworkDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (NetworkDomain) + ++ (void)_parseNetworkError:(TestProtocolNetworkError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (NetworkDomain) + ++ (void)_parseNetworkError:(TestProtocolNetworkError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolNetworkError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolNetworkError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json new file mode 100644 index 000000000..11262e889 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json @@ -0,0 +1,109 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "integer", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "enum": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "executeSQLSyncOptionalReturnValues", + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeSQLAsyncOptionalReturnValues", + "async": true, + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeSQLSync", + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + }, + { + "name": "executeSQLAsync", + "async": true, + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json new file mode 100644 index 000000000..361d57d82 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json @@ -0,0 +1,85 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "integer", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "enum": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "executeAllOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeNoOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json new file mode 100644 index 000000000..817f135ee --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json @@ -0,0 +1,28 @@ +{ + "domain": "Network", + "types": [ + { + "id": "NetworkError", + "type": "object", + "platform": "macos", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "loadResource", + "platform": "macos", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ], + "events": [ + { + "name": "resourceLoaded", + "platform": "macos", + "description": "A resource was loaded." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json new file mode 100644 index 000000000..5939996e3 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json @@ -0,0 +1,11 @@ +[ +{ + "domain": "DomainA", + "availability": "web", + "commands": [{"name": "enable"}] +}, +{ + "domain": "DomainB", + "commands": [{"name": "enable"}] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json new file mode 100644 index 000000000..94a8ecb17 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json @@ -0,0 +1,54 @@ +[ +{ + "domain": "Network1", + "commands": [ + { + "name": "loadResource1", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +}, +{ + "domain": "Network2", + "types": [ + { + "id": "LoaderId", + "type": "string", + "description": "Unique loader identifier." + } + ] +}, +{ + "domain": "Network3", + "commands": [ + { + "name": "loadResource1", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource2", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource3", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource4", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource5", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource6", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource7", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json new file mode 100644 index 000000000..cdad61df7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json @@ -0,0 +1,35 @@ +{"domains":[ +{ + "domain": "TypeDomain", + "types": [ + { + "id": "TypeDomainEnum", + "type": "string", + "enum": ["shared", "red", "green", "blue"] + } + ] +}, +{ + "domain": "CommandDomain", + "commands": [ + { + "name": "commandWithEnumReturnValue", + "parameters": [], + "returns": [ + { "name": "returnValue", "type": "string", "enum": ["shared", "cyan", "magenta", "yellow"] } + ] + } + ] +}, +{ + "domain": "EventDomain", + "events": [ + { + "name": "eventWithEnumParameter", + "parameters": [ + { "name": "parameter", "type": "string", "enum": ["shared", "black", "white"] } + ] + } + ] +} +]} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json new file mode 100644 index 000000000..cabbf10b8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json @@ -0,0 +1,59 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "values": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "values": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "didExecuteNoOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "values": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result new file mode 100644 index 000000000..ef9a2488d --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result @@ -0,0 +1,1780 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerDatabaseDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Database"); +InspectorBackend.registerEnum("Database.PrimaryColors", {Red: "red", Green: "green", Blue: "blue"}); +InspectorBackend.registerCommand("Database.executeSQLSyncOptionalReturnValues", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLAsyncOptionalReturnValues", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLSync", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "alternateColors", "screenColor", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLAsync", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateDatabaseBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDatabaseBackendDispatcher() { } + virtual void executeSQLSyncOptionalReturnValues(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLAsyncOptionalReturnValues(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLSync(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLAsync(long callId, int in_databaseId, const String& in_query) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDatabaseBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DatabaseBackendDispatcherHandler { +public: + // Named after parameter 'printColor' while generating command/event executeSQLSyncOptionalReturnValues. + enum class PrintColor { + Cyan = 3, + Magenta = 4, + Yellow = 5, + Black = 6, + }; // enum class PrintColor + virtual void executeSQLSyncOptionalReturnValues(ErrorString&, int in_databaseId, const String& in_query, RefPtr>& opt_out_columnNames, Inspector::Protocol::OptOutput* opt_out_notes, Inspector::Protocol::OptOutput* opt_out_timestamp, Inspector::Protocol::OptOutput* opt_out_values, Inspector::Protocol::OptOutput* opt_out_payload, Inspector::Protocol::OptOutput* opt_out_databaseId, RefPtr& opt_out_sqlError, Inspector::Protocol::Database::PrimaryColors* opt_out_screenColor, RefPtr& opt_out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* opt_out_printColor) = 0; + class ExecuteSQLAsyncOptionalReturnValuesCallback : public BackendDispatcher::CallbackBase { + public: + ExecuteSQLAsyncOptionalReturnValuesCallback(Ref&&, int id); + void sendSuccess(RefPtr>&& columnNames, Inspector::Protocol::OptOutput* notes, Inspector::Protocol::OptOutput* timestamp, Inspector::Protocol::OptOutput* values, Inspector::Protocol::OptOutput* payload, Inspector::Protocol::OptOutput* databaseId, RefPtr&& sqlError, Inspector::Protocol::OptOutput* screenColor, RefPtr&& alternateColors, Inspector::Protocol::OptOutput* printColor); + }; + virtual void executeSQLAsyncOptionalReturnValues(ErrorString&, int in_databaseId, const String& in_query, Ref&& callback) = 0; + virtual void executeSQLSync(ErrorString&, int in_databaseId, const String& in_query, RefPtr>& out_columnNames, String* out_notes, double* out_timestamp, Inspector::InspectorObject* out_values, Inspector::InspectorValue* out_payload, int* out_databaseId, RefPtr& out_sqlError, RefPtr& out_alternateColors, Inspector::Protocol::Database::PrimaryColors* out_screenColor, DatabaseBackendDispatcherHandler::PrintColor* out_printColor) = 0; + class ExecuteSQLAsyncCallback : public BackendDispatcher::CallbackBase { + public: + ExecuteSQLAsyncCallback(Ref&&, int id); + void sendSuccess(RefPtr>&& columnNames, const String& notes, double timestamp, Inspector::InspectorObject values, Inspector::InspectorValue payload, int databaseId, RefPtr&& sqlError, const String& screenColor, RefPtr&& alternateColors, const String& printColor); + }; + virtual void executeSQLAsync(ErrorString&, int in_databaseId, const String& in_query, Ref&& callback) = 0; +protected: + virtual ~DatabaseBackendDispatcherHandler(); +}; + +class DatabaseBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void executeSQLSyncOptionalReturnValues(long requestId, RefPtr&& parameters); + void executeSQLAsyncOptionalReturnValues(long requestId, RefPtr&& parameters); + void executeSQLSync(long requestId, RefPtr&& parameters); + void executeSQLAsync(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDatabaseBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDatabaseBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DatabaseBackendDispatcher(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + DatabaseBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DatabaseBackendDispatcherHandler::~DatabaseBackendDispatcherHandler() { } + +Ref DatabaseBackendDispatcher::create(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) +{ + return adoptRef(*new DatabaseBackendDispatcher(backendDispatcher, agent)); +} + +DatabaseBackendDispatcher::DatabaseBackendDispatcher(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Database"), this); +} + +void DatabaseBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "executeSQLSyncOptionalReturnValues") + executeSQLSyncOptionalReturnValues(requestId, WTFMove(parameters)); + else if (method == "executeSQLAsyncOptionalReturnValues") + executeSQLAsyncOptionalReturnValues(requestId, WTFMove(parameters)); + else if (method == "executeSQLSync") + executeSQLSync(requestId, WTFMove(parameters)); + else if (method == "executeSQLAsync") + executeSQLAsync(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Database", '.', method, "' was not found")); +} + +void DatabaseBackendDispatcher::executeSQLSyncOptionalReturnValues(long requestId, RefPtr&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLSyncOptionalReturnValues")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLSyncOptionalReturnValues(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + RefPtr> out_columnNames; + Inspector::Protocol::OptOutput out_notes; + Inspector::Protocol::OptOutput out_timestamp; + Inspector::Protocol::OptOutput out_values; + Inspector::Protocol::OptOutput out_payload; + Inspector::Protocol::OptOutput out_databaseId; + RefPtr out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeSQLSyncOptionalReturnValues(error, in_databaseId, in_query, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + if (out_columnNames) + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + if (out_notes.isAssigned()) + result->setString(ASCIILiteral("notes"), out_notes.getValue()); + if (out_timestamp.isAssigned()) + result->setDouble(ASCIILiteral("timestamp"), out_timestamp.getValue()); + if (out_values.isAssigned()) + result->setObject(ASCIILiteral("values"), out_values.getValue()); + if (out_payload.isAssigned()) + result->setValue(ASCIILiteral("payload"), out_payload.getValue()); + if (out_databaseId.isAssigned()) + result->setInteger(ASCIILiteral("databaseId"), out_databaseId.getValue()); + if (out_sqlError) + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + if (out_screenColor.isAssigned()) + result->setString(ASCIILiteral("screenColor"), out_screenColor.getValue()); + if (out_alternateColors) + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + if (out_printColor.isAssigned()) + result->setString(ASCIILiteral("printColor"), out_printColor.getValue()); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::ExecuteSQLAsyncOptionalReturnValuesCallback(Ref&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } + +void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::sendSuccess(RefPtr>&& columnNames, Inspector::Protocol::OptOutput* notes, Inspector::Protocol::OptOutput* timestamp, Inspector::Protocol::OptOutput* values, Inspector::Protocol::OptOutput* payload, Inspector::Protocol::OptOutput* databaseId, RefPtr&& sqlError, Inspector::Protocol::OptOutput* screenColor, RefPtr&& alternateColors, Inspector::Protocol::OptOutput* printColor) +{ + Ref jsonMessage = InspectorObject::create(); + if (columnNames) + jsonMessage->setArray(ASCIILiteral("columnNames"), columnNames); + if (notes.isAssigned()) + jsonMessage->setString(ASCIILiteral("notes"), notes.getValue()); + if (timestamp.isAssigned()) + jsonMessage->setDouble(ASCIILiteral("timestamp"), timestamp.getValue()); + if (values.isAssigned()) + jsonMessage->setObject(ASCIILiteral("values"), values.getValue()); + if (payload.isAssigned()) + jsonMessage->setValue(ASCIILiteral("payload"), payload.getValue()); + if (databaseId.isAssigned()) + jsonMessage->setInteger(ASCIILiteral("databaseId"), databaseId.getValue()); + if (sqlError) + jsonMessage->setObject(ASCIILiteral("sqlError"), sqlError); + if (screenColor.isAssigned()) + jsonMessage->setString(ASCIILiteral("screenColor"), screenColor.getValue()); + if (alternateColors) + jsonMessage->setArray(ASCIILiteral("alternateColors"), alternateColors); + if (printColor.isAssigned()) + jsonMessage->setString(ASCIILiteral("printColor"), printColor.getValue()); + CallbackBase::sendSuccess(WTFMove(jsonMessage)); +} + +void DatabaseBackendDispatcher::executeSQLAsyncOptionalReturnValues(long requestId, RefPtr&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLAsyncOptionalReturnValues")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLAsyncOptionalReturnValues(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + Ref callback = adoptRef(*new DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback(m_backendDispatcher.copyRef(), requestId)); + m_agent->executeSQLAsyncOptionalReturnValues(error, in_databaseId, in_query, callback.copyRef()); + + if (error.length()) { + callback->disable(); + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, error); + return; + } +} + +void DatabaseBackendDispatcher::executeSQLSync(long requestId, RefPtr&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLSync")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLSync(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + RefPtr> out_columnNames; + String out_notes; + double out_timestamp; + Inspector::InspectorObject out_values; + Inspector::InspectorValue out_payload; + Inspector::Protocol::Database::DatabaseId out_databaseId; + RefPtr out_sqlError; + RefPtr out_alternateColors; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeSQLSync(error, in_databaseId, in_query, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, out_alternateColors, &out_screenColor, &out_printColor); + + if (!error.length()) { + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + result->setString(ASCIILiteral("notes"), out_notes); + result->setDouble(ASCIILiteral("timestamp"), out_timestamp); + result->setObject(ASCIILiteral("values"), out_values); + result->setValue(ASCIILiteral("payload"), out_payload); + result->setInteger(ASCIILiteral("databaseId"), out_databaseId); + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + result->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_screenColor)); + result->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_printColor)); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::ExecuteSQLAsyncCallback(Ref&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } + +void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::sendSuccess(RefPtr>&& columnNames, const String& notes, double timestamp, Inspector::InspectorObject values, Inspector::InspectorValue payload, int databaseId, RefPtr&& sqlError, const String& screenColor, RefPtr&& alternateColors, const String& printColor) +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setArray(ASCIILiteral("columnNames"), columnNames); + jsonMessage->setString(ASCIILiteral("notes"), notes); + jsonMessage->setDouble(ASCIILiteral("timestamp"), timestamp); + jsonMessage->setObject(ASCIILiteral("values"), values); + jsonMessage->setValue(ASCIILiteral("payload"), payload); + jsonMessage->setInteger(ASCIILiteral("databaseId"), databaseId); + jsonMessage->setObject(ASCIILiteral("sqlError"), sqlError); + jsonMessage->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(screenColor)); + jsonMessage->setArray(ASCIILiteral("alternateColors"), alternateColors); + jsonMessage->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(printColor)); + CallbackBase::sendSuccess(WTFMove(jsonMessage)); +} + +void DatabaseBackendDispatcher::executeSQLAsync(long requestId, RefPtr&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLAsync")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLAsync(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + Ref callback = adoptRef(*new DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback(m_backendDispatcher.copyRef(), requestId)); + m_agent->executeSQLAsync(error, in_databaseId, in_query, callback.copyRef()); + + if (error.length()) { + callback->disable(); + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, error); + return; + } +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +enum class PrimaryColors; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef int DatabaseId; +typedef Inspector::Protocol::Array ColorList; +} // Database +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Database { +/* */ +enum class PrimaryColors { + Red = 0, + Green = 1, + Blue = 2, +}; // enum class PrimaryColors +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Database + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Database' Domain +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "red", + "green", + "blue", + "cyan", + "magenta", + "yellow", + "black", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Database' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Database::PrimaryColors::Red, + (size_t)Inspector::Protocol::Database::PrimaryColors::Green, + (size_t)Inspector::Protocol::Database::PrimaryColors::Blue, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Database::PrimaryColors)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolDatabaseDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDatabaseBackendDispatcher final : public AlternateDatabaseBackendDispatcher { +public: + ObjCInspectorDatabaseBackendDispatcher(id handler) { m_delegate = handler; } + virtual void executeSQLSyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLAsyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLSync(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLAsync(long requestId, int in_databaseId, const String& in_query) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLSyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor *printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLSyncOptionalReturnValuesWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLAsyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor *printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLAsyncOptionalReturnValuesWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLSync(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, NSArray/**/ *alternateColors, TestProtocolDatabasePrimaryColors screenColor, TestProtocolDatabaseExecuteSQLSyncPrintColor printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLSyncWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLAsync(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/**/ *alternateColors, TestProtocolDatabaseExecuteSQLAsyncPrintColor printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLAsyncWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDatabaseHandler:) id databaseHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _databaseHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseHandler release]; + [super dealloc]; +} + +- (void)setDatabaseHandler:(id)handler +{ + if (handler == _databaseHandler) + return; + + [_databaseHandler release]; + _databaseHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Database"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)databaseHandler +{ + return _databaseHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) { + TestProtocolDatabasePrimaryColorsRed, + TestProtocolDatabasePrimaryColorsGreen, + TestProtocolDatabasePrimaryColorsBlue, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor) { + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor) { + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLSyncPrintColor) { + TestProtocolDatabaseExecuteSQLSyncPrintColorCyan, + TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta, + TestProtocolDatabaseExecuteSQLSyncPrintColorYellow, + TestProtocolDatabaseExecuteSQLSyncPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLAsyncPrintColor) { + TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan, + TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta, + TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow, + TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolDatabaseDomainHandler +@required +- (void)executeSQLSyncOptionalReturnValuesWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor *printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLAsyncOptionalReturnValuesWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor *printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLSyncWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, NSArray/**/ *alternateColors, TestProtocolDatabasePrimaryColors screenColor, TestProtocolDatabaseExecuteSQLSyncPrintColor printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLAsyncWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/**/ *alternateColors, TestProtocolDatabaseExecuteSQLAsyncPrintColor printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDatabasePrimaryColors value) +{ + switch(value) { + case TestProtocolDatabasePrimaryColorsRed: + return ASCIILiteral("red"); + case TestProtocolDatabasePrimaryColorsGreen: + return ASCIILiteral("green"); + case TestProtocolDatabasePrimaryColorsBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "red") + return TestProtocolDatabasePrimaryColorsRed; + if (value == "green") + return TestProtocolDatabasePrimaryColorsGreen; + if (value == "blue") + return TestProtocolDatabasePrimaryColorsBlue; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLSyncPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLSyncPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLSyncPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLSyncPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors"); + *outValue = @(result.value()); +} + ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result new file mode 100644 index 000000000..4c9e42618 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result @@ -0,0 +1,1643 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerEnum("Database.PrimaryColors", {Red: "red", Green: "green", Blue: "blue"}); +InspectorBackend.registerCommand("Database.executeAllOptionalParameters", [{"name": "columnNames", "type": "object", "optional": true}, {"name": "notes", "type": "string", "optional": true}, {"name": "timestamp", "type": "number", "optional": true}, {"name": "values", "type": "object", "optional": true}, {"name": "payload", "type": "object", "optional": true}, {"name": "databaseId", "type": "number", "optional": true}, {"name": "sqlError", "type": "object", "optional": true}, {"name": "screenColor", "type": "string", "optional": true}, {"name": "alternateColors", "type": "object", "optional": true}, {"name": "printColor", "type": "string", "optional": true}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeNoOptionalParameters", [{"name": "columnNames", "type": "object", "optional": false}, {"name": "notes", "type": "string", "optional": false}, {"name": "timestamp", "type": "number", "optional": false}, {"name": "values", "type": "object", "optional": false}, {"name": "payload", "type": "object", "optional": false}, {"name": "databaseId", "type": "number", "optional": false}, {"name": "sqlError", "type": "object", "optional": false}, {"name": "screenColor", "type": "string", "optional": false}, {"name": "alternateColors", "type": "object", "optional": false}, {"name": "printColor", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateDatabaseBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDatabaseBackendDispatcher() { } + virtual void executeAllOptionalParameters(long callId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) = 0; + virtual void executeNoOptionalParameters(long callId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDatabaseBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DatabaseBackendDispatcherHandler { +public: + // Named after parameter 'printColor' while generating command/event executeAllOptionalParameters. + enum class PrintColor { + Cyan = 3, + Magenta = 4, + Yellow = 5, + Black = 6, + }; // enum class PrintColor + virtual void executeAllOptionalParameters(ErrorString&, const Inspector::InspectorArray* opt_in_columnNames, const String* const opt_in_notes, const double* const opt_in_timestamp, const Inspector::InspectorObject* opt_in_values, const Inspector::InspectorValue* const opt_in_payload, const int* const opt_in_databaseId, const Inspector::InspectorObject* opt_in_sqlError, const String* const opt_in_screenColor, const Inspector::InspectorArray* opt_in_alternateColors, const String* const opt_in_printColor, RefPtr>& opt_out_columnNames, Inspector::Protocol::OptOutput* opt_out_notes, Inspector::Protocol::OptOutput* opt_out_timestamp, Inspector::Protocol::OptOutput* opt_out_values, Inspector::Protocol::OptOutput* opt_out_payload, Inspector::Protocol::OptOutput* opt_out_databaseId, RefPtr& opt_out_sqlError, Inspector::Protocol::Database::PrimaryColors* opt_out_screenColor, RefPtr& opt_out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* opt_out_printColor) = 0; + virtual void executeNoOptionalParameters(ErrorString&, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor, RefPtr>& out_columnNames, String* out_notes, double* out_timestamp, Inspector::InspectorObject* out_values, Inspector::InspectorValue* out_payload, int* out_databaseId, RefPtr& out_sqlError, Inspector::Protocol::Database::PrimaryColors* out_screenColor, RefPtr& out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* out_printColor) = 0; +protected: + virtual ~DatabaseBackendDispatcherHandler(); +}; + +class DatabaseBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void executeAllOptionalParameters(long requestId, RefPtr&& parameters); + void executeNoOptionalParameters(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDatabaseBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDatabaseBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DatabaseBackendDispatcher(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + DatabaseBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DatabaseBackendDispatcherHandler::~DatabaseBackendDispatcherHandler() { } + +Ref DatabaseBackendDispatcher::create(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) +{ + return adoptRef(*new DatabaseBackendDispatcher(backendDispatcher, agent)); +} + +DatabaseBackendDispatcher::DatabaseBackendDispatcher(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Database"), this); +} + +void DatabaseBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "executeAllOptionalParameters") + executeAllOptionalParameters(requestId, WTFMove(parameters)); + else if (method == "executeNoOptionalParameters") + executeNoOptionalParameters(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Database", '.', method, "' was not found")); +} + +void DatabaseBackendDispatcher::executeAllOptionalParameters(long requestId, RefPtr&& parameters) +{ + bool opt_in_columnNames_valueFound = false; + RefPtr opt_in_columnNames = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("columnNames"), &opt_in_columnNames_valueFound); + bool opt_in_notes_valueFound = false; + String opt_in_notes = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("notes"), &opt_in_notes_valueFound); + bool opt_in_timestamp_valueFound = false; + Inspector::Protocol::OptOutput opt_in_timestamp = m_backendDispatcher->getDouble(parameters.get(), ASCIILiteral("timestamp"), &opt_in_timestamp_valueFound); + bool opt_in_values_valueFound = false; + RefPtr opt_in_values = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("values"), &opt_in_values_valueFound); + bool opt_in_payload_valueFound = false; + RefPtr opt_in_payload = m_backendDispatcher->getValue(parameters.get(), ASCIILiteral("payload"), &opt_in_payload_valueFound); + bool opt_in_databaseId_valueFound = false; + int opt_in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), &opt_in_databaseId_valueFound); + bool opt_in_sqlError_valueFound = false; + RefPtr opt_in_sqlError = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("sqlError"), &opt_in_sqlError_valueFound); + bool opt_in_screenColor_valueFound = false; + String opt_in_screenColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("screenColor"), &opt_in_screenColor_valueFound); + bool opt_in_alternateColors_valueFound = false; + RefPtr opt_in_alternateColors = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("alternateColors"), &opt_in_alternateColors_valueFound); + bool opt_in_printColor_valueFound = false; + String opt_in_printColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("printColor"), &opt_in_printColor_valueFound); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeAllOptionalParameters")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeAllOptionalParameters(requestId, opt_in_columnNames_valueFound ? opt_in_columnNames.get() : nullptr, opt_in_notes_valueFound ? &opt_in_notes : nullptr, opt_in_timestamp_valueFound ? &opt_in_timestamp : nullptr, opt_in_values_valueFound ? opt_in_values.get() : nullptr, opt_in_payload_valueFound ? opt_in_payload.get() : nullptr, opt_in_databaseId_valueFound ? &opt_in_databaseId : nullptr, opt_in_sqlError_valueFound ? opt_in_sqlError.get() : nullptr, opt_in_screenColor_valueFound ? &opt_in_screenColor : nullptr, opt_in_alternateColors_valueFound ? opt_in_alternateColors.get() : nullptr, opt_in_printColor_valueFound ? &opt_in_printColor : nullptr); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + RefPtr> out_columnNames; + Inspector::Protocol::OptOutput out_notes; + Inspector::Protocol::OptOutput out_timestamp; + Inspector::Protocol::OptOutput out_values; + Inspector::Protocol::OptOutput out_payload; + Inspector::Protocol::OptOutput out_databaseId; + RefPtr out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeAllOptionalParameters(error, opt_in_columnNames_valueFound ? opt_in_columnNames.get() : nullptr, opt_in_notes_valueFound ? &opt_in_notes : nullptr, opt_in_timestamp_valueFound ? &opt_in_timestamp : nullptr, opt_in_values_valueFound ? opt_in_values.get() : nullptr, opt_in_payload_valueFound ? opt_in_payload.get() : nullptr, opt_in_databaseId_valueFound ? &opt_in_databaseId : nullptr, opt_in_sqlError_valueFound ? opt_in_sqlError.get() : nullptr, opt_in_screenColor_valueFound ? &opt_in_screenColor : nullptr, opt_in_alternateColors_valueFound ? opt_in_alternateColors.get() : nullptr, opt_in_printColor_valueFound ? &opt_in_printColor : nullptr, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + if (out_columnNames) + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + if (out_notes.isAssigned()) + result->setString(ASCIILiteral("notes"), out_notes.getValue()); + if (out_timestamp.isAssigned()) + result->setDouble(ASCIILiteral("timestamp"), out_timestamp.getValue()); + if (out_values.isAssigned()) + result->setObject(ASCIILiteral("values"), out_values.getValue()); + if (out_payload.isAssigned()) + result->setValue(ASCIILiteral("payload"), out_payload.getValue()); + if (out_databaseId.isAssigned()) + result->setInteger(ASCIILiteral("databaseId"), out_databaseId.getValue()); + if (out_sqlError) + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + if (out_screenColor.isAssigned()) + result->setString(ASCIILiteral("screenColor"), out_screenColor.getValue()); + if (out_alternateColors) + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + if (out_printColor.isAssigned()) + result->setString(ASCIILiteral("printColor"), out_printColor.getValue()); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void DatabaseBackendDispatcher::executeNoOptionalParameters(long requestId, RefPtr&& parameters) +{ + RefPtr in_columnNames = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("columnNames"), nullptr); + String in_notes = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("notes"), nullptr); + double in_timestamp = m_backendDispatcher->getDouble(parameters.get(), ASCIILiteral("timestamp"), nullptr); + RefPtr in_values = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("values"), nullptr); + RefPtr in_payload = m_backendDispatcher->getValue(parameters.get(), ASCIILiteral("payload"), nullptr); + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + RefPtr in_sqlError = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("sqlError"), nullptr); + String in_screenColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("screenColor"), nullptr); + RefPtr in_alternateColors = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("alternateColors"), nullptr); + String in_printColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("printColor"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeNoOptionalParameters")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeNoOptionalParameters(requestId, *in_columnNames, in_notes, in_timestamp, *in_values, *in_payload, in_databaseId, *in_sqlError, in_screenColor, *in_alternateColors, in_printColor); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + RefPtr> out_columnNames; + String out_notes; + double out_timestamp; + Inspector::InspectorObject out_values; + Inspector::InspectorValue out_payload; + Inspector::Protocol::Database::DatabaseId out_databaseId; + RefPtr out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeNoOptionalParameters(error, *in_columnNames, in_notes, in_timestamp, *in_values, *in_payload, in_databaseId, *in_sqlError, in_screenColor, *in_alternateColors, in_printColor, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + result->setString(ASCIILiteral("notes"), out_notes); + result->setDouble(ASCIILiteral("timestamp"), out_timestamp); + result->setObject(ASCIILiteral("values"), out_values); + result->setValue(ASCIILiteral("payload"), out_payload); + result->setInteger(ASCIILiteral("databaseId"), out_databaseId); + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + result->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_screenColor)); + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + result->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_printColor)); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +enum class PrimaryColors; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef int DatabaseId; +typedef Inspector::Protocol::Array ColorList; +} // Database +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Database { +/* */ +enum class PrimaryColors { + Red = 0, + Green = 1, + Blue = 2, +}; // enum class PrimaryColors +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Database + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Database' Domain +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "red", + "green", + "blue", + "cyan", + "magenta", + "yellow", + "black", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Database' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Database::PrimaryColors::Red, + (size_t)Inspector::Protocol::Database::PrimaryColors::Green, + (size_t)Inspector::Protocol::Database::PrimaryColors::Blue, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Database::PrimaryColors)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolDatabaseDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDatabaseBackendDispatcher final : public AlternateDatabaseBackendDispatcher { +public: + ObjCInspectorDatabaseBackendDispatcher(id handler) { m_delegate = handler; } + virtual void executeAllOptionalParameters(long requestId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) override; + virtual void executeNoOptionalParameters(long requestId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorDatabaseBackendDispatcher::executeAllOptionalParameters(long requestId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + NSArray/**/ *o_in_columnNames; + if (in_columnNames) + o_in_columnNames = objcStringArray(in_columnNames); + NSString *o_in_notes; + if (in_notes) + o_in_notes = *in_notes; + double o_in_timestamp; + if (in_timestamp) + o_in_timestamp = *in_timestamp; + RWIProtocolJSONObject *o_in_values; + if (in_values) + o_in_values = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:in_values] autorelease]; + RWIProtocolJSONObject *o_in_payload; + if (in_payload) + o_in_payload = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:in_payload] autorelease]; + int o_in_databaseId; + if (in_databaseId) + o_in_databaseId = *in_databaseId; + TestProtocolDatabaseError *o_in_sqlError; + if (in_sqlError) + o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:in_sqlError] autorelease]; + std::optional o_in_screenColor; + if (in_screenColor) + o_in_screenColor = fromProtocolString(*in_screenColor); + NSArray/**/ *o_in_alternateColors; + if (in_alternateColors) + o_in_alternateColors = objcStringArray(in_alternateColors); + std::optional o_in_printColor; + if (in_printColor) + o_in_printColor = fromProtocolString(*in_printColor); + + [m_delegate executeAllOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:(in_columnNames ? &o_in_columnNames : nil) notes:(in_notes ? &o_in_notes : nil) timestamp:(in_timestamp ? &o_in_timestamp : nil) values:(in_values ? &o_in_values : nil) payload:(in_payload ? &o_in_payload : nil) databaseId:(in_databaseId ? &o_in_databaseId : nil) sqlError:(in_sqlError ? &o_in_sqlError : nil) screenColor:(in_screenColor ? &o_in_screenColor : nil) alternateColors:(in_alternateColors ? &o_in_alternateColors : nil) printColor:(in_printColor ? &o_in_printColor : nil)]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeNoOptionalParameters(long requestId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/**/ *alternateColors, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor printColor) { + Ref resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + NSArray/**/ *o_in_columnNames = objcStringArray(&in_columnNames); + NSString *o_in_notes = in_notes; + double o_in_timestamp = in_timestamp; + RWIProtocolJSONObject *o_in_values = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:&in_values] autorelease]; + RWIProtocolJSONObject *o_in_payload = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:&in_payload] autorelease]; + int o_in_databaseId = in_databaseId; + TestProtocolDatabaseError *o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:&in_sqlError] autorelease]; + std::optional o_in_screenColor = fromProtocolString(in_screenColor); + if (!o_in_screenColor) { + backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "screenColor", "Database.executeNoOptionalParameters")); + return; + } + NSArray/**/ *o_in_alternateColors = objcStringArray(&in_alternateColors); + std::optional o_in_printColor = fromProtocolString(in_printColor); + if (!o_in_printColor) { + backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "printColor", "Database.executeNoOptionalParameters")); + return; + } + + [m_delegate executeNoOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:o_in_columnNames notes:o_in_notes timestamp:o_in_timestamp values:o_in_values payload:o_in_payload databaseId:o_in_databaseId sqlError:o_in_sqlError screenColor:o_in_screenColor.value() alternateColors:o_in_alternateColors printColor:o_in_printColor.value()]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDatabaseHandler:) id databaseHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _databaseHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseHandler release]; + [super dealloc]; +} + +- (void)setDatabaseHandler:(id)handler +{ + if (handler == _databaseHandler) + return; + + [_databaseHandler release]; + _databaseHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Database"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)databaseHandler +{ + return _databaseHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) { + TestProtocolDatabasePrimaryColorsRed, + TestProtocolDatabasePrimaryColorsGreen, + TestProtocolDatabasePrimaryColorsBlue, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolDatabaseDomainHandler +@required +- (void)executeAllOptionalParametersWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/**/ **alternateColors, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *printColor))successCallback columnNames:(NSArray/**/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload databaseId:(int *)databaseId sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(TestProtocolDatabasePrimaryColors *)screenColor alternateColors:(NSArray/**/ **)alternateColors printColor:(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *)printColor; +- (void)executeNoOptionalParametersWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/**/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/**/ *alternateColors, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor printColor))successCallback columnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload databaseId:(int)databaseId sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(TestProtocolDatabasePrimaryColors)screenColor alternateColors:(NSArray/**/ *)alternateColors printColor:(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor)printColor; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDatabasePrimaryColors value) +{ + switch(value) { + case TestProtocolDatabasePrimaryColorsRed: + return ASCIILiteral("red"); + case TestProtocolDatabasePrimaryColorsGreen: + return ASCIILiteral("green"); + case TestProtocolDatabasePrimaryColorsBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "red") + return TestProtocolDatabasePrimaryColorsRed; + if (value == "green") + return TestProtocolDatabasePrimaryColorsGreen; + if (value == "blue") + return TestProtocolDatabasePrimaryColorsBlue; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors"); + *outValue = @(result.value()); +} + ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result new file mode 100644 index 000000000..d9cec9c61 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result @@ -0,0 +1,866 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result new file mode 100644 index 000000000..0c4c30499 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result @@ -0,0 +1,1120 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// DomainA. +InspectorBackend.registerCommand("DomainA.enable", [], []); +InspectorBackend.activateDomain("DomainA", "web"); + +// DomainB. +InspectorBackend.registerCommand("DomainB.enable", [], []); +InspectorBackend.activateDomain("DomainB"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateDomainABackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainABackendDispatcher() { } + virtual void enable(long callId) = 0; +}; +class AlternateDomainBBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainBBackendDispatcher() { } + virtual void enable(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDomainABackendDispatcher; +class AlternateDomainBBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DomainABackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainABackendDispatcherHandler(); +}; + +class DomainBBackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainBBackendDispatcherHandler(); +}; + +class DomainABackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DomainABackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void enable(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainABackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainABackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainABackendDispatcher(BackendDispatcher&, DomainABackendDispatcherHandler*); + DomainABackendDispatcherHandler* m_agent { nullptr }; +}; + +class DomainBBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DomainBBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void enable(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainBBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainBBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainBBackendDispatcher(BackendDispatcher&, DomainBBackendDispatcherHandler*); + DomainBBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DomainABackendDispatcherHandler::~DomainABackendDispatcherHandler() { } +DomainBBackendDispatcherHandler::~DomainBBackendDispatcherHandler() { } + +Ref DomainABackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainABackendDispatcher(backendDispatcher, agent)); +} + +DomainABackendDispatcher::DomainABackendDispatcher(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainA"), this); +} + +void DomainABackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainA", '.', method, "' was not found")); +} + +void DomainABackendDispatcher::enable(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref DomainBBackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainBBackendDispatcher(backendDispatcher, agent)); +} + +DomainBBackendDispatcher::DomainBBackendDispatcher(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainB"), this); +} + +void DomainBBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainB", '.', method, "' was not found")); +} + +void DomainBBackendDispatcher::enable(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolDomainADomainHandler; +@protocol TestProtocolDomainBDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDomainABackendDispatcher final : public AlternateDomainABackendDispatcher { +public: + ObjCInspectorDomainABackendDispatcher(id handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +class ObjCInspectorDomainBBackendDispatcher final : public AlternateDomainBBackendDispatcher { +public: + ObjCInspectorDomainBBackendDispatcher(id handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorDomainABackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorDomainBBackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDomainAHandler:) id domainAHandler; +@property (nonatomic, retain, setter=setDomainBHandler:) id domainBHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _domainAHandler; + id _domainBHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_domainAHandler release]; + [_domainBHandler release]; + [super dealloc]; +} + +- (void)setDomainAHandler:(id)handler +{ + if (handler == _domainAHandler) + return; + + [_domainAHandler release]; + _domainAHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("DomainA"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)domainAHandler +{ + return _domainAHandler; +} + +- (void)setDomainBHandler:(id)handler +{ + if (handler == _domainBHandler) + return; + + [_domainBHandler release]; + _domainBHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("DomainB"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)domainBHandler +{ + return _domainBHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolDomainADomainHandler +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolDomainBDomainHandler +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result new file mode 100644 index 000000000..e9afc2a18 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result @@ -0,0 +1,1399 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network1. +InspectorBackend.registerCommand("Network1.loadResource1", [], []); +InspectorBackend.activateDomain("Network1"); + +// Network3. +InspectorBackend.registerCommand("Network3.loadResource1", [], []); +InspectorBackend.registerCommand("Network3.loadResource2", [], []); +InspectorBackend.registerCommand("Network3.loadResource3", [], []); +InspectorBackend.registerCommand("Network3.loadResource4", [], []); +InspectorBackend.registerCommand("Network3.loadResource5", [], []); +InspectorBackend.registerCommand("Network3.loadResource6", [], []); +InspectorBackend.registerCommand("Network3.loadResource7", [], []); +InspectorBackend.activateDomain("Network3"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateNetwork1BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork1BackendDispatcher() { } + virtual void loadResource1(long callId) = 0; +}; +class AlternateNetwork3BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork3BackendDispatcher() { } + virtual void loadResource1(long callId) = 0; + virtual void loadResource2(long callId) = 0; + virtual void loadResource3(long callId) = 0; + virtual void loadResource4(long callId) = 0; + virtual void loadResource5(long callId) = 0; + virtual void loadResource6(long callId) = 0; + virtual void loadResource7(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateNetwork1BackendDispatcher; +class AlternateNetwork3BackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class Network1BackendDispatcherHandler { +public: + virtual void loadResource1(ErrorString&) = 0; +protected: + virtual ~Network1BackendDispatcherHandler(); +}; + +class Network3BackendDispatcherHandler { +public: + virtual void loadResource1(ErrorString&) = 0; + virtual void loadResource2(ErrorString&) = 0; + virtual void loadResource3(ErrorString&) = 0; + virtual void loadResource4(ErrorString&) = 0; + virtual void loadResource5(ErrorString&) = 0; + virtual void loadResource6(ErrorString&) = 0; + virtual void loadResource7(ErrorString&) = 0; +protected: + virtual ~Network3BackendDispatcherHandler(); +}; + +class Network1BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, Network1BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void loadResource1(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork1BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork1BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network1BackendDispatcher(BackendDispatcher&, Network1BackendDispatcherHandler*); + Network1BackendDispatcherHandler* m_agent { nullptr }; +}; + +class Network3BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, Network3BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void loadResource1(long requestId, RefPtr&& parameters); + void loadResource2(long requestId, RefPtr&& parameters); + void loadResource3(long requestId, RefPtr&& parameters); + void loadResource4(long requestId, RefPtr&& parameters); + void loadResource5(long requestId, RefPtr&& parameters); + void loadResource6(long requestId, RefPtr&& parameters); + void loadResource7(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork3BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork3BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network3BackendDispatcher(BackendDispatcher&, Network3BackendDispatcherHandler*); + Network3BackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +Network1BackendDispatcherHandler::~Network1BackendDispatcherHandler() { } +Network3BackendDispatcherHandler::~Network3BackendDispatcherHandler() { } + +Ref Network1BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network1BackendDispatcher(backendDispatcher, agent)); +} + +Network1BackendDispatcher::Network1BackendDispatcher(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network1"), this); +} + +void Network1BackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource1") + loadResource1(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network1", '.', method, "' was not found")); +} + +void Network1BackendDispatcher::loadResource1(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource1(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource1(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref Network3BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network3BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network3BackendDispatcher(backendDispatcher, agent)); +} + +Network3BackendDispatcher::Network3BackendDispatcher(BackendDispatcher& backendDispatcher, Network3BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network3"), this); +} + +void Network3BackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + typedef void (Network3BackendDispatcher::*CallHandler)(long requestId, RefPtr&& message); + typedef HashMap DispatchMap; + static NeverDestroyed dispatchMap; + if (dispatchMap.get().isEmpty()) { + static const struct MethodTable { + const char* name; + CallHandler handler; + } commands[] = { + { "loadResource1", &Network3BackendDispatcher::loadResource1 }, + { "loadResource2", &Network3BackendDispatcher::loadResource2 }, + { "loadResource3", &Network3BackendDispatcher::loadResource3 }, + { "loadResource4", &Network3BackendDispatcher::loadResource4 }, + { "loadResource5", &Network3BackendDispatcher::loadResource5 }, + { "loadResource6", &Network3BackendDispatcher::loadResource6 }, + { "loadResource7", &Network3BackendDispatcher::loadResource7 }, + }; + size_t length = WTF_ARRAY_LENGTH(commands); + for (size_t i = 0; i < length; ++i) + dispatchMap.get().add(commands[i].name, commands[i].handler); + } + + auto findResult = dispatchMap.get().find(method); + if (findResult == dispatchMap.get().end()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network3", '.', method, "' was not found")); + return; + } + + ((*this).*findResult->value)(requestId, WTFMove(parameters)); +} + +void Network3BackendDispatcher::loadResource1(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource1(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource1(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource2(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource2(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource2(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource3(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource3(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource3(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource4(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource4(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource4(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource5(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource5(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource5(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource6(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource6(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource6(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource7(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource7(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource7(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Network2 { +/* Unique loader identifier. */ +typedef String LoaderId; +} // Network2 +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolNetwork1DomainHandler; +@protocol TestProtocolNetwork3DomainHandler; + +namespace Inspector { + + +class ObjCInspectorNetwork1BackendDispatcher final : public AlternateNetwork1BackendDispatcher { +public: + ObjCInspectorNetwork1BackendDispatcher(id handler) { m_delegate = handler; } + virtual void loadResource1(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +class ObjCInspectorNetwork3BackendDispatcher final : public AlternateNetwork3BackendDispatcher { +public: + ObjCInspectorNetwork3BackendDispatcher(id handler) { m_delegate = handler; } + virtual void loadResource1(long requestId) override; + virtual void loadResource2(long requestId) override; + virtual void loadResource3(long requestId) override; + virtual void loadResource4(long requestId) override; + virtual void loadResource5(long requestId) override; + virtual void loadResource6(long requestId) override; + virtual void loadResource7(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorNetwork1BackendDispatcher::loadResource1(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource1WithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorNetwork3BackendDispatcher::loadResource1(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource1WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource2(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource2WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource3(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource3WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource4(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource4WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource5(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource5WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource6(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource6WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource7(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource7WithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetwork1Handler:) id network1Handler; +@property (nonatomic, retain, setter=setNetwork3Handler:) id network3Handler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _network1Handler; + id _network3Handler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_network1Handler release]; + [_network3Handler release]; + [super dealloc]; +} + +- (void)setNetwork1Handler:(id)handler +{ + if (handler == _network1Handler) + return; + + [_network1Handler release]; + _network1Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Network1"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)network1Handler +{ + return _network1Handler; +} + +- (void)setNetwork3Handler:(id)handler +{ + if (handler == _network3Handler) + return; + + [_network3Handler release]; + _network3Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Network3"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)network3Handler +{ + return _network3Handler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolNetwork1DomainHandler +@required +- (void)loadResource1WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolNetwork3DomainHandler +@required +- (void)loadResource1WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource2WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource3WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource4WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource5WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource6WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource7WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseLoaderId:(NSString **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseLoaderId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result new file mode 100644 index 000000000..d2a01c84e --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result @@ -0,0 +1,1208 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// TypeDomain. +InspectorBackend.registerEnum("TypeDomain.TypeDomainEnum", {Shared: "shared", Red: "red", Green: "green", Blue: "blue"}); + +// CommandDomain. +InspectorBackend.registerCommand("CommandDomain.commandWithEnumReturnValue", [], ["returnValue"]); +InspectorBackend.activateDomain("CommandDomain"); + +// EventDomain. +InspectorBackend.registerEventDomainDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "EventDomain"); +InspectorBackend.registerEnum("EventDomain.EventWithEnumParameterParameter", {Shared: "shared", Black: "black", White: "white"}); +InspectorBackend.registerEvent("EventDomain.eventWithEnumParameter", ["parameter"]); +InspectorBackend.activateDomain("EventDomain"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateCommandDomainBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateCommandDomainBackendDispatcher() { } + virtual void commandWithEnumReturnValue(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateCommandDomainBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class CommandDomainBackendDispatcherHandler { +public: + // Named after parameter 'returnValue' while generating command/event commandWithEnumReturnValue. + enum class ReturnValue { + Shared = 0, + Cyan = 6, + Magenta = 7, + Yellow = 8, + }; // enum class ReturnValue + virtual void commandWithEnumReturnValue(ErrorString&, CommandDomainBackendDispatcherHandler::ReturnValue* out_returnValue) = 0; +protected: + virtual ~CommandDomainBackendDispatcherHandler(); +}; + +class CommandDomainBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, CommandDomainBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void commandWithEnumReturnValue(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateCommandDomainBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateCommandDomainBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + CommandDomainBackendDispatcher(BackendDispatcher&, CommandDomainBackendDispatcherHandler*); + CommandDomainBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +CommandDomainBackendDispatcherHandler::~CommandDomainBackendDispatcherHandler() { } + +Ref CommandDomainBackendDispatcher::create(BackendDispatcher& backendDispatcher, CommandDomainBackendDispatcherHandler* agent) +{ + return adoptRef(*new CommandDomainBackendDispatcher(backendDispatcher, agent)); +} + +CommandDomainBackendDispatcher::CommandDomainBackendDispatcher(BackendDispatcher& backendDispatcher, CommandDomainBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("CommandDomain"), this); +} + +void CommandDomainBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "commandWithEnumReturnValue") + commandWithEnumReturnValue(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "CommandDomain", '.', method, "' was not found")); +} + +void CommandDomainBackendDispatcher::commandWithEnumReturnValue(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->commandWithEnumReturnValue(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + CommandDomainBackendDispatcherHandler::ReturnValue out_returnValue; + m_agent->commandWithEnumReturnValue(error, &out_returnValue); + + if (!error.length()) + result->setString(ASCIILiteral("returnValue"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_returnValue)); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +class EventDomainFrontendDispatcher { +public: + EventDomainFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + // Named after parameter 'parameter' while generating command/event eventWithEnumParameter. + enum class Parameter { + Shared = 0, + Black = 4, + White = 5, + }; // enum class Parameter + void eventWithEnumParameter(Parameter parameter); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +void EventDomainFrontendDispatcher::eventWithEnumParameter(Parameter parameter) +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("EventDomain.eventWithEnumParameter")); + Ref paramsObject = InspectorObject::create(); + paramsObject->setString(ASCIILiteral("parameter"), Inspector::Protocol::TestHelpers::getEnumConstantValue(parameter)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace TypeDomain { +enum class TypeDomainEnum; +} // TypeDomain +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace TypeDomain { +/* */ +enum class TypeDomainEnum { + Shared = 0, + Red = 1, + Green = 2, + Blue = 3, +}; // enum class TypeDomainEnum +} // TypeDomain + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'TypeDomain' Domain +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "shared", + "red", + "green", + "blue", + "black", + "white", + "cyan", + "magenta", + "yellow", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'TypeDomain' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Shared, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Red, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Green, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Blue, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::TypeDomain::TypeDomainEnum)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolCommandDomainDomainHandler; + +namespace Inspector { + + +class ObjCInspectorCommandDomainBackendDispatcher final : public AlternateCommandDomainBackendDispatcher { +public: + ObjCInspectorCommandDomainBackendDispatcher(id handler) { m_delegate = handler; } + virtual void commandWithEnumReturnValue(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorCommandDomainBackendDispatcher::commandWithEnumReturnValue(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(TestProtocolCommandDomainCommandWithEnumReturnValueReturnValue returnValue) { + Ref resultObject = InspectorObject::create(); + resultObject->setString(ASCIILiteral("returnValue"), toProtocolString(returnValue)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + [m_delegate commandWithEnumReturnValueWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setCommandDomainHandler:) id commandDomainHandler; +@property (nonatomic, readonly) TestProtocolEventDomainDomainEventDispatcher *eventDomainEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _commandDomainHandler; + TestProtocolEventDomainDomainEventDispatcher *_eventDomainEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_commandDomainHandler release]; + [_eventDomainEventDispatcher release]; + [super dealloc]; +} + +- (void)setCommandDomainHandler:(id)handler +{ + if (handler == _commandDomainHandler) + return; + + [_commandDomainHandler release]; + _commandDomainHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("CommandDomain"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)commandDomainHandler +{ + return _commandDomainHandler; +} + +- (TestProtocolEventDomainDomainEventDispatcher *)eventDomainEventDispatcher +{ + if (!_eventDomainEventDispatcher) + _eventDomainEventDispatcher = [[TestProtocolEventDomainDomainEventDispatcher alloc] initWithController:_controller]; + return _eventDomainEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + +@implementation TestProtocolEventDomainDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)eventWithEnumParameterWithParameter:(TestProtocolEventDomainEventWithEnumParameterParameter)parameter +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("EventDomain.eventWithEnumParameter")); + Ref paramsObject = InspectorObject::create(); + paramsObject->setString(ASCIILiteral("parameter"), toProtocolString(parameter)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolTypeDomainEnum) { + TestProtocolTypeDomainEnumShared, + TestProtocolTypeDomainEnumRed, + TestProtocolTypeDomainEnumGreen, + TestProtocolTypeDomainEnumBlue, +}; + + + +@protocol TestProtocolCommandDomainDomainHandler +@required +- (void)commandWithEnumReturnValueWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(TestProtocolCommandDomainCommandWithEnumReturnValueReturnValue returnValue))successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolEventDomainDomainEventDispatcher : NSObject +- (void)eventWithEnumParameterWithParameter:(TestProtocolEventDomainEventWithEnumParameterParameter)parameter; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + +@interface TestProtocolEventDomainDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolTypeDomainEnum value) +{ + switch(value) { + case TestProtocolTypeDomainEnumShared: + return ASCIILiteral("shared"); + case TestProtocolTypeDomainEnumRed: + return ASCIILiteral("red"); + case TestProtocolTypeDomainEnumGreen: + return ASCIILiteral("green"); + case TestProtocolTypeDomainEnumBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "shared") + return TestProtocolTypeDomainEnumShared; + if (value == "red") + return TestProtocolTypeDomainEnumRed; + if (value == "green") + return TestProtocolTypeDomainEnumGreen; + if (value == "blue") + return TestProtocolTypeDomainEnumBlue; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (TypeDomainDomain) + ++ (void)_parseTypeDomainEnum:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (TypeDomainDomain) + ++ (void)_parseTypeDomainEnum:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TypeDomainEnum"); + *outValue = @(result.value()); +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result new file mode 100644 index 000000000..137d1827e --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result @@ -0,0 +1,1210 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerDatabaseDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Database"); +InspectorBackend.registerEvent("Database.didExecuteOptionalParameters", ["columnNames", "notes", "timestamp", "values", "payload", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerEvent("Database.didExecuteNoOptionalParameters", ["columnNames", "notes", "timestamp", "values", "payload", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +class DatabaseFrontendDispatcher { +public: + DatabaseFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void didExecuteOptionalParameters(RefPtr> columnNames, const String* const notes, const double* const timestamp, RefPtr values, RefPtr payload, RefPtr sqlError, const Inspector::Protocol::Database::PrimaryColors* const screenColor, RefPtr alternateColors, const String* const printColor); + void didExecuteNoOptionalParameters(RefPtr> columnNames, const String& notes, double timestamp, RefPtr values, RefPtr payload, RefPtr sqlError, const Inspector::Protocol::Database::PrimaryColors& screenColor, RefPtr alternateColors, const String& printColor); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +void DatabaseFrontendDispatcher::didExecuteOptionalParameters(RefPtr> columnNames, const String* const notes, const double* const timestamp, RefPtr values, RefPtr payload, RefPtr sqlError, const Inspector::Protocol::Database::PrimaryColors* const screenColor, RefPtr alternateColors, const String* const printColor) +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteOptionalParameters")); + Ref paramsObject = InspectorObject::create(); + if (columnNames) + paramsObject->setArray(ASCIILiteral("columnNames"), columnNames); + if (notes) + paramsObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + paramsObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + paramsObject->setObject(ASCIILiteral("values"), values); + if (payload) + paramsObject->setValue(ASCIILiteral("payload"), *payload); + if (sqlError) + paramsObject->setObject(ASCIILiteral("sqlError"), sqlError); + if (screenColor) + paramsObject->setString(ASCIILiteral("screenColor"), *screenColor); + if (alternateColors) + paramsObject->setArray(ASCIILiteral("alternateColors"), alternateColors); + if (printColor) + paramsObject->setString(ASCIILiteral("printColor"), *printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +void DatabaseFrontendDispatcher::didExecuteNoOptionalParameters(RefPtr> columnNames, const String& notes, double timestamp, RefPtr values, RefPtr payload, RefPtr sqlError, const Inspector::Protocol::Database::PrimaryColors& screenColor, RefPtr alternateColors, const String& printColor) +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteNoOptionalParameters")); + Ref paramsObject = InspectorObject::create(); + paramsObject->setArray(ASCIILiteral("columnNames"), columnNames); + paramsObject->setString(ASCIILiteral("notes"), notes); + paramsObject->setDouble(ASCIILiteral("timestamp"), timestamp); + paramsObject->setObject(ASCIILiteral("values"), values); + paramsObject->setValue(ASCIILiteral("payload"), payload); + paramsObject->setObject(ASCIILiteral("sqlError"), sqlError); + paramsObject->setString(ASCIILiteral("screenColor"), screenColor); + paramsObject->setArray(ASCIILiteral("alternateColors"), alternateColors); + paramsObject->setString(ASCIILiteral("printColor"), printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef String DatabaseId; +typedef String PrimaryColors; +typedef Inspector::Protocol::Array ColorList; +} // Database +// End of typedefs. + +namespace Database { +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Database + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, readonly) TestProtocolDatabaseDomainEventDispatcher *databaseEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + TestProtocolDatabaseDomainEventDispatcher *_databaseEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseEventDispatcher release]; + [super dealloc]; +} + +- (TestProtocolDatabaseDomainEventDispatcher *)databaseEventDispatcher +{ + if (!_databaseEventDispatcher) + _databaseEventDispatcher = [[TestProtocolDatabaseDomainEventDispatcher alloc] initWithController:_controller]; + return _databaseEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + +@implementation TestProtocolDatabaseDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)didExecuteOptionalParametersWithColumnNames:(NSArray/**/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(NSString **)screenColor alternateColors:(NSArray/**/ **)alternateColors printColor:(NSString **)printColor +{ + const FrontendRouter& router = _controller->frontendRouter(); + + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(screenColor, @"screenColor"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(printColor, @"printColor"); + + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteOptionalParameters")); + Ref paramsObject = InspectorObject::create(); + if (columnNames) + paramsObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray((*columnNames))); + if (notes) + paramsObject->setString(ASCIILiteral("notes"), (*notes)); + if (timestamp) + paramsObject->setDouble(ASCIILiteral("timestamp"), (*timestamp)); + if (values) + paramsObject->setObject(ASCIILiteral("values"), [(*values) toInspectorObject]); + if (payload) + paramsObject->setValue(ASCIILiteral("payload"), [(*payload) toInspectorObject]); + if (sqlError) + paramsObject->setObject(ASCIILiteral("sqlError"), [(*sqlError) toInspectorObject]); + if (screenColor) + paramsObject->setString(ASCIILiteral("screenColor"), (*screenColor)); + if (alternateColors) + paramsObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray((*alternateColors))); + if (printColor) + paramsObject->setString(ASCIILiteral("printColor"), (*printColor)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +- (void)didExecuteNoOptionalParametersWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(NSString *)screenColor alternateColors:(NSArray/**/ *)alternateColors printColor:(NSString *)printColor +{ + const FrontendRouter& router = _controller->frontendRouter(); + + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(screenColor, @"screenColor"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(printColor, @"printColor"); + + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteNoOptionalParameters")); + Ref paramsObject = InspectorObject::create(); + paramsObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + paramsObject->setString(ASCIILiteral("notes"), notes); + paramsObject->setDouble(ASCIILiteral("timestamp"), timestamp); + paramsObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + paramsObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + paramsObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + paramsObject->setString(ASCIILiteral("screenColor"), screenColor); + paramsObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + paramsObject->setString(ASCIILiteral("printColor"), printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseDomainEventDispatcher : NSObject +- (void)didExecuteOptionalParametersWithColumnNames:(NSArray/**/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(NSString **)screenColor alternateColors:(NSArray/**/ **)alternateColors printColor:(NSString **)printColor; +- (void)didExecuteNoOptionalParametersWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(NSString *)screenColor alternateColors:(NSArray/**/ *)alternateColors printColor:(NSString *)printColor; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + +@interface TestProtocolDatabaseDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSString **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSString **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + ++ (void)_parsePrimaryColors:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + ++ (void)_parseColorList:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error new file mode 100644 index 000000000..ec636c54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error @@ -0,0 +1 @@ +ERROR: Unknown platform: invalid diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error new file mode 100644 index 000000000..90d7195d6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: availability is an unsupported string. Was: "webb", Allowed values: web diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error new file mode 100644 index 000000000..3f756de32 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: call parameter list for command processPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error new file mode 100644 index 000000000..ea148ff67 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: return parameter list for command processPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error new file mode 100644 index 000000000..c71bbd21c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: parameter list for event processedPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error new file mode 100644 index 000000000..447cdf8e2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error @@ -0,0 +1 @@ +ERROR: Duplicate type declaration: Runtime.RemoteObjectId diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error new file mode 100644 index 000000000..d5376a77a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: type declaration for Point has duplicate member names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error new file mode 100644 index 000000000..2655c2b90 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error @@ -0,0 +1 @@ +ERROR: Type reference with enum values must have at least one enum value. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error new file mode 100644 index 000000000..97b2af0e4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a parameter must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error new file mode 100644 index 000000000..86df3750c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a type member must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error new file mode 100644 index 000000000..97b2af0e4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a parameter must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error new file mode 100644 index 000000000..86df3750c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a type member must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error new file mode 100644 index 000000000..42f5753a4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error @@ -0,0 +1 @@ +ERROR: Type reference cannot have both 'type' and '$ref' keys. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error new file mode 100644 index 000000000..d76bc1c77 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error @@ -0,0 +1 @@ +ERROR: Type reference 'DatabaseId' is not a primitive type. Allowed values: integer, number, string, boolean, enum, object, array, any diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error new file mode 100644 index 000000000..ec636c54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error @@ -0,0 +1 @@ +ERROR: Unknown platform: invalid diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error new file mode 100644 index 000000000..4e462250c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error @@ -0,0 +1 @@ +ERROR: Types must begin with an uppercase character. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error new file mode 100644 index 000000000..2d38e6467 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error @@ -0,0 +1 @@ +ERROR: Type reference 'dragon' is not a primitive type. Allowed values: integer, number, string, boolean, enum, object, array, any diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error new file mode 100644 index 000000000..faf6672cb --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error @@ -0,0 +1 @@ +ERROR: Lookup failed for type reference: Color (referenced from domain: Fantasy) diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result new file mode 100644 index 000000000..9eeb0b1c9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result @@ -0,0 +1,1230 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network1. +InspectorBackend.registerCommand("Network1.loadResource", [], []); +InspectorBackend.activateDomain("Network1"); + +// Network3. +InspectorBackend.registerNetwork3Dispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Network3"); +InspectorBackend.registerEvent("Network3.resourceLoaded", []); +InspectorBackend.activateDomain("Network3"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +#if PLATFORM(WEB_COMMANDS) +class AlternateNetwork1BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork1BackendDispatcher() { } + virtual void loadResource(long callId) = 0; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#if PLATFORM(WEB_COMMANDS) +class AlternateNetwork1BackendDispatcher; +#endif // PLATFORM(WEB_COMMANDS) +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#if PLATFORM(WEB_COMMANDS) +class Network1BackendDispatcherHandler { +public: + virtual void loadResource(ErrorString&) = 0; +protected: + virtual ~Network1BackendDispatcherHandler(); +}; +#endif // PLATFORM(WEB_COMMANDS) + +#if PLATFORM(WEB_COMMANDS) +class Network1BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, Network1BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void loadResource(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork1BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork1BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network1BackendDispatcher(BackendDispatcher&, Network1BackendDispatcherHandler*); + Network1BackendDispatcherHandler* m_agent { nullptr }; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +#if PLATFORM(WEB_COMMANDS) +Network1BackendDispatcherHandler::~Network1BackendDispatcherHandler() { } +#endif // PLATFORM(WEB_COMMANDS) + +#if PLATFORM(WEB_COMMANDS) +Ref Network1BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network1BackendDispatcher(backendDispatcher, agent)); +} + +Network1BackendDispatcher::Network1BackendDispatcher(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network1"), this); +} + +void Network1BackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource") + loadResource(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network1", '.', method, "' was not found")); +} + +void Network1BackendDispatcher::loadResource(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->loadResource(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +#if PLATFORM(WEB_EVENTS) +class Network3FrontendDispatcher { +public: + Network3FrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void resourceLoaded(); +private: + FrontendRouter& m_frontendRouter; +}; +#endif // PLATFORM(WEB_EVENTS) + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +#if PLATFORM(WEB_EVENTS) +void Network3FrontendDispatcher::resourceLoaded() +{ + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network3.resourceLoaded")); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} +#endif // PLATFORM(WEB_EVENTS) + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +#if PLATFORM(WEB_TYPES) +namespace Network2 { +class NetworkError; +} // Network2 +#endif // PLATFORM(WEB_TYPES) +// End of forward declarations. + + + + +#if PLATFORM(WEB_TYPES) +namespace Network2 { +class NetworkError : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class NetworkError; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(NetworkError) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = NetworkError::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Network2 +#endif // PLATFORM(WEB_TYPES) + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolNetwork1DomainHandler; + +namespace Inspector { + + +#if PLATFORM(WEB_COMMANDS) +class ObjCInspectorNetwork1BackendDispatcher final : public AlternateNetwork1BackendDispatcher { +public: + ObjCInspectorNetwork1BackendDispatcher(id handler) { m_delegate = handler; } + virtual void loadResource(long requestId) override; +private: + RetainPtr> m_delegate; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +#if PLATFORM(WEB_COMMANDS) +void ObjCInspectorNetwork1BackendDispatcher::loadResource(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResourceWithErrorCallback:errorCallback successCallback:successCallback]; +} + +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetwork1Handler:) id network1Handler; +@property (nonatomic, readonly) TestProtocolNetwork3DomainEventDispatcher *network3EventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _network1Handler; + TestProtocolNetwork3DomainEventDispatcher *_network3EventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_network1Handler release]; + [_network3EventDispatcher release]; + [super dealloc]; +} + +- (void)setNetwork1Handler:(id)handler +{ + if (handler == _network1Handler) + return; + + [_network1Handler release]; + _network1Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("Network1"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)network1Handler +{ + return _network1Handler; +} + +- (TestProtocolNetwork3DomainEventDispatcher *)network3EventDispatcher +{ + if (!_network3EventDispatcher) + _network3EventDispatcher = [[TestProtocolNetwork3DomainEventDispatcher alloc] initWithController:_controller]; + return _network3EventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + +@implementation TestProtocolNetwork3DomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)resourceLoaded +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network3.resourceLoaded")); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolNetwork2NetworkError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolNetwork2NetworkError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolNetwork1DomainHandler +@required +- (void)loadResourceWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolNetwork3DomainEventDispatcher : NSObject +- (void)resourceLoaded; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + +@interface TestProtocolNetwork3DomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseNetworkError:(TestProtocolNetwork2NetworkError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseNetworkError:(TestProtocolNetwork2NetworkError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolNetwork2NetworkError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolNetwork2NetworkError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result new file mode 100644 index 000000000..d65129eb8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result @@ -0,0 +1,910 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Runtime { +/* Unique object identifier. */ +typedef String RemoteObjectId; +} // Runtime + +namespace Runtime2 { +/* Unique object identifier. */ +typedef String RemoteObjectId; +} // Runtime2 +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (Runtime2Domain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end +@implementation TestProtocolTypeConversions (Runtime2Domain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result new file mode 100644 index 000000000..b7eff1b15 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result @@ -0,0 +1,1119 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Runtime { +class KeyPath; +} // Runtime +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Runtime { +/* Key path. */ +class KeyPath : public Inspector::InspectorObjectBase { +public: + // Named after property name 'type' while generating KeyPath. + enum class Type { + Null = 0, + String = 1, + Array = 2, + }; // enum class Type + enum { + NoFieldsSet = 0, + TypeSet = 1 << 0, + AllFieldsSet = (TypeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class KeyPath; + public: + + Builder& setType(Type value) + { + COMPILE_ASSERT(!(STATE & TypeSet), property_type_already_set); + m_result->setString(ASCIILiteral("type"), Inspector::Protocol::TestHelpers::getEnumConstantValue(value)); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(KeyPath) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = KeyPath::create() + * .setType(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } + + void setString(const String& value) + { + InspectorObjectBase::setString(ASCIILiteral("string"), value); + } + + void setArray(RefPtr> value) + { + InspectorObjectBase::setArray(ASCIILiteral("array"), WTFMove(value)); + } +}; + +} // Runtime + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Runtime' Domain +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "null", + "string", + "array", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Runtime' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::Null, + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::String, + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::Array, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::KeyPath::Type)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolRuntimeKeyPath; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeKeyPathType) { + TestProtocolRuntimeKeyPathTypeNull, + TestProtocolRuntimeKeyPathTypeString, + TestProtocolRuntimeKeyPathTypeArray, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolRuntimeKeyPath : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type; +/* required */ @property (nonatomic, assign) TestProtocolRuntimeKeyPathType type; +/* optional */ @property (nonatomic, copy) NSString *string; +/* optional */ @property (nonatomic, copy) NSArray/**/ *array; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolRuntimeKeyPathType value) +{ + switch(value) { + case TestProtocolRuntimeKeyPathTypeNull: + return ASCIILiteral("null"); + case TestProtocolRuntimeKeyPathTypeString: + return ASCIILiteral("string"); + case TestProtocolRuntimeKeyPathTypeArray: + return ASCIILiteral("array"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "null") + return TestProtocolRuntimeKeyPathTypeNull; + if (value == "string") + return TestProtocolRuntimeKeyPathTypeString; + if (value == "array") + return TestProtocolRuntimeKeyPathTypeArray; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseKeyPath:(TestProtocolRuntimeKeyPath **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseKeyPath:(TestProtocolRuntimeKeyPath **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolRuntimeKeyPath alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolRuntimeKeyPath + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"type"], @"type"); + std::optional type = fromProtocolString(payload[@"type"]); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(type, @"type"); + self.type = type.value(); + + self.string = payload[@"string"]; + + self.array = objcArrayFromPayload(payload[@"array"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type +{ + if (!(self = [super init])) + return nil; + + self.type = type; + + return self; +} + +- (void)setType:(TestProtocolRuntimeKeyPathType)type +{ + [super setString:toProtocolString(type) forKey:@"type"]; +} + +- (TestProtocolRuntimeKeyPathType)type +{ + return fromProtocolString([super stringForKey:@"type"]).value(); +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setArray:(NSArray/**/ *)array +{ + [super setInspectorArray:inspectorStringArray(array) forKey:@"array"]; +} + +- (NSArray/**/ *)array +{ + return objcStringArray([super inspectorArrayForKey:@"array"]); +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result new file mode 100644 index 000000000..6ece43d9c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result @@ -0,0 +1,887 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Runtime { +/* Unique object identifier. */ +typedef int RemoteObjectId; +} // Runtime +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result new file mode 100644 index 000000000..d2a62c9ff --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result @@ -0,0 +1,1055 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Debugger. +InspectorBackend.registerEnum("Debugger.Reason", {Died: "Died", Fainted: "Fainted", Hungry: "Hungry"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Debugger { +enum class Reason; +} // Debugger +// End of forward declarations. + + +// Typedefs. +namespace Debugger { +typedef int BreakpointId; +} // Debugger + +namespace Runtime { +typedef int ObjectId; +typedef Inspector::Protocol::Array LuckyNumbers; +typedef Inspector::Protocol::Array BabyNames; +typedef Inspector::Protocol::Array NewObjects; +typedef Inspector::Protocol::Array OldObjects; +typedef Inspector::Protocol::Array StopReasons; +} // Runtime +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Debugger { +/* */ +enum class Reason { + Died = 0, + Fainted = 1, + Hungry = 2, +}; // enum class Reason +} // Debugger + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Debugger' Domain +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Died", + "Fainted", + "Hungry", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Debugger' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Debugger::Reason::Died, + (size_t)Inspector::Protocol::Debugger::Reason::Fainted, + (size_t)Inspector::Protocol::Debugger::Reason::Hungry, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Debugger::Reason)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDebuggerReason) { + TestProtocolDebuggerReasonDied, + TestProtocolDebuggerReasonFainted, + TestProtocolDebuggerReasonHungry, +}; + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDebuggerReason value) +{ + switch(value) { + case TestProtocolDebuggerReasonDied: + return ASCIILiteral("Died"); + case TestProtocolDebuggerReasonFainted: + return ASCIILiteral("Fainted"); + case TestProtocolDebuggerReasonHungry: + return ASCIILiteral("Hungry"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "Died") + return TestProtocolDebuggerReasonDied; + if (value == "Fainted") + return TestProtocolDebuggerReasonFainted; + if (value == "Hungry") + return TestProtocolDebuggerReasonHungry; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DebuggerDomain) + ++ (void)_parseBreakpointId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseReason:(NSNumber **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseLuckyNumbers:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseBabyNames:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseNewObjects:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseOldObjects:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseStopReasons:(NSArray/**/ **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DebuggerDomain) + ++ (void)_parseBreakpointId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseReason:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"Reason"); + *outValue = @(result.value()); +} + +@end +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseLuckyNumbers:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseBabyNames:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseNewObjects:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseOldObjects:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseStopReasons:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result new file mode 100644 index 000000000..a1cfcf54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result @@ -0,0 +1,1064 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Runtime. +InspectorBackend.registerEnum("Runtime.FarmAnimals", {Pigs: "Pigs", Cows: "Cows", Cats: "Cats", Hens: "Hens"}); +InspectorBackend.registerEnum("Runtime.TwoLeggedAnimals", {Ducks: "Ducks", Hens: "Hens", Crows: "Crows", Flamingos: "Flamingos"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Runtime { +enum class FarmAnimals; +enum class TwoLeggedAnimals; +} // Runtime +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Runtime { +/* */ +enum class FarmAnimals { + Pigs = 0, + Cows = 1, + Cats = 2, + Hens = 3, +}; // enum class FarmAnimals +/* */ +enum class TwoLeggedAnimals { + Ducks = 4, + Hens = 3, + Crows = 5, + Flamingos = 6, +}; // enum class TwoLeggedAnimals +} // Runtime + + + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Runtime' Domain +template<> +std::optional parseEnumValueFromString(const String&); +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Pigs", + "Cows", + "Cats", + "Hens", + "Ducks", + "Crows", + "Flamingos", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Runtime' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Pigs, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Cows, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Cats, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Hens, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::FarmAnimals)constantValues[i]; + + return std::nullopt; +} + +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Ducks, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Hens, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Crows, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Flamingos, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::TwoLeggedAnimals)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeFarmAnimals) { + TestProtocolRuntimeFarmAnimalsPigs, + TestProtocolRuntimeFarmAnimalsCows, + TestProtocolRuntimeFarmAnimalsCats, + TestProtocolRuntimeFarmAnimalsHens, +}; + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeTwoLeggedAnimals) { + TestProtocolRuntimeTwoLeggedAnimalsDucks, + TestProtocolRuntimeTwoLeggedAnimalsHens, + TestProtocolRuntimeTwoLeggedAnimalsCrows, + TestProtocolRuntimeTwoLeggedAnimalsFlamingos, +}; + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolRuntimeFarmAnimals value) +{ + switch(value) { + case TestProtocolRuntimeFarmAnimalsPigs: + return ASCIILiteral("Pigs"); + case TestProtocolRuntimeFarmAnimalsCows: + return ASCIILiteral("Cows"); + case TestProtocolRuntimeFarmAnimalsCats: + return ASCIILiteral("Cats"); + case TestProtocolRuntimeFarmAnimalsHens: + return ASCIILiteral("Hens"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "Pigs") + return TestProtocolRuntimeFarmAnimalsPigs; + if (value == "Cows") + return TestProtocolRuntimeFarmAnimalsCows; + if (value == "Cats") + return TestProtocolRuntimeFarmAnimalsCats; + if (value == "Hens") + return TestProtocolRuntimeFarmAnimalsHens; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolRuntimeTwoLeggedAnimals value) +{ + switch(value) { + case TestProtocolRuntimeTwoLeggedAnimalsDucks: + return ASCIILiteral("Ducks"); + case TestProtocolRuntimeTwoLeggedAnimalsHens: + return ASCIILiteral("Hens"); + case TestProtocolRuntimeTwoLeggedAnimalsCrows: + return ASCIILiteral("Crows"); + case TestProtocolRuntimeTwoLeggedAnimalsFlamingos: + return ASCIILiteral("Flamingos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "Ducks") + return TestProtocolRuntimeTwoLeggedAnimalsDucks; + if (value == "Hens") + return TestProtocolRuntimeTwoLeggedAnimalsHens; + if (value == "Crows") + return TestProtocolRuntimeTwoLeggedAnimalsCrows; + if (value == "Flamingos") + return TestProtocolRuntimeTwoLeggedAnimalsFlamingos; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseFarmAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseTwoLeggedAnimals:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseFarmAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"FarmAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseTwoLeggedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TwoLeggedAnimals"); + *outValue = @(result.value()); +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result new file mode 100644 index 000000000..1b23ab2a9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result @@ -0,0 +1,2012 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +class OptionalParameterBundle; +class ParameterBundle; +class ObjectWithPropertyNameConflicts; +class DummyObject; +} // Database + +namespace Test { +class ParameterBundle; +} // Test +// End of forward declarations. + + +// Typedefs. +namespace Database { +typedef Inspector::Protocol::Array ErrorList; +} // Database +// End of typedefs. + +namespace Database { +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState(); + } + + Builder& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +class OptionalParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class OptionalParameterBundle; + public: + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(OptionalParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = OptionalParameterBundle::create() + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } + + void setColumnNames(RefPtr> value) + { + InspectorObjectBase::setArray(ASCIILiteral("columnNames"), WTFMove(value)); + } + + void setNotes(const String& value) + { + InspectorObjectBase::setString(ASCIILiteral("notes"), value); + } + + void setTimestamp(double value) + { + InspectorObjectBase::setDouble(ASCIILiteral("timestamp"), value); + } + + void setValues(RefPtr value) + { + InspectorObjectBase::setObject(ASCIILiteral("values"), WTFMove(value)); + } + + void setPayload(RefPtr value) + { + InspectorObjectBase::setValue(ASCIILiteral("payload"), WTFMove(value)); + } + + void setError(RefPtr value) + { + InspectorObjectBase::setObject(ASCIILiteral("error"), WTFMove(value)); + } + + void setErrorList(RefPtr value) + { + InspectorObjectBase::setArray(ASCIILiteral("errorList"), WTFMove(value)); + } +}; + +class ParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + ColumnNamesSet = 1 << 0, + NotesSet = 1 << 1, + TimestampSet = 1 << 2, + ValuesSet = 1 << 3, + PayloadSet = 1 << 4, + ErrorSet = 1 << 5, + ErrorListSet = 1 << 6, + AllFieldsSet = (ColumnNamesSet | NotesSet | TimestampSet | ValuesSet | PayloadSet | ErrorSet | ErrorListSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ParameterBundle; + public: + + Builder& setColumnNames(RefPtr> value) + { + COMPILE_ASSERT(!(STATE & ColumnNamesSet), property_columnNames_already_set); + m_result->setArray(ASCIILiteral("columnNames"), value); + return castState(); + } + + Builder& setNotes(const String& value) + { + COMPILE_ASSERT(!(STATE & NotesSet), property_notes_already_set); + m_result->setString(ASCIILiteral("notes"), value); + return castState(); + } + + Builder& setTimestamp(double value) + { + COMPILE_ASSERT(!(STATE & TimestampSet), property_timestamp_already_set); + m_result->setDouble(ASCIILiteral("timestamp"), value); + return castState(); + } + + Builder& setValues(RefPtr value) + { + COMPILE_ASSERT(!(STATE & ValuesSet), property_values_already_set); + m_result->setObject(ASCIILiteral("values"), value); + return castState(); + } + + Builder& setPayload(RefPtr value) + { + COMPILE_ASSERT(!(STATE & PayloadSet), property_payload_already_set); + m_result->setValue(ASCIILiteral("payload"), value); + return castState(); + } + + Builder& setError(RefPtr value) + { + COMPILE_ASSERT(!(STATE & ErrorSet), property_error_already_set); + m_result->setObject(ASCIILiteral("error"), value); + return castState(); + } + + Builder& setErrorList(RefPtr value) + { + COMPILE_ASSERT(!(STATE & ErrorListSet), property_errorList_already_set); + m_result->setArray(ASCIILiteral("errorList"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = ParameterBundle::create() + * .setColumnNames(...) + * .setNotes(...) + * .setTimestamp(...) + * .setValues(...) + * .setPayload(...) + * .setError(...) + * .setErrorList(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +/* Conflicted names may cause generated getters/setters to clash with built-in InspectorObject methods. */ +class ObjectWithPropertyNameConflicts : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + IntegerSet = 1 << 0, + ArraySet = 1 << 1, + StringSet = 1 << 2, + ValueSet = 1 << 3, + ObjectSet = 1 << 4, + AllFieldsSet = (IntegerSet | ArraySet | StringSet | ValueSet | ObjectSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ObjectWithPropertyNameConflicts; + public: + + Builder& setInteger(const String& value) + { + COMPILE_ASSERT(!(STATE & IntegerSet), property_integer_already_set); + m_result->setString(ASCIILiteral("integer"), value); + return castState(); + } + + Builder& setArray(const String& value) + { + COMPILE_ASSERT(!(STATE & ArraySet), property_array_already_set); + m_result->setString(ASCIILiteral("array"), value); + return castState(); + } + + Builder& setString(const String& value) + { + COMPILE_ASSERT(!(STATE & StringSet), property_string_already_set); + m_result->setString(ASCIILiteral("string"), value); + return castState(); + } + + Builder& setValue(const String& value) + { + COMPILE_ASSERT(!(STATE & ValueSet), property_value_already_set); + m_result->setString(ASCIILiteral("value"), value); + return castState(); + } + + Builder& setObject(const String& value) + { + COMPILE_ASSERT(!(STATE & ObjectSet), property_object_already_set); + m_result->setString(ASCIILiteral("object"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ObjectWithPropertyNameConflicts) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = ObjectWithPropertyNameConflicts::create() + * .setInteger(...) + * .setArray(...) + * .setString(...) + * .setValue(...) + * .setObject(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Database + +namespace Test { +class ParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + ColumnNamesSet = 1 << 0, + NotesSet = 1 << 1, + TimestampSet = 1 << 2, + ValuesSet = 1 << 3, + PayloadSet = 1 << 4, + ErrorSet = 1 << 5, + AllFieldsSet = (ColumnNamesSet | NotesSet | TimestampSet | ValuesSet | PayloadSet | ErrorSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ParameterBundle; + public: + + Builder& setColumnNames(RefPtr> value) + { + COMPILE_ASSERT(!(STATE & ColumnNamesSet), property_columnNames_already_set); + m_result->setArray(ASCIILiteral("columnNames"), value); + return castState(); + } + + Builder& setNotes(const String& value) + { + COMPILE_ASSERT(!(STATE & NotesSet), property_notes_already_set); + m_result->setString(ASCIILiteral("notes"), value); + return castState(); + } + + Builder& setTimestamp(double value) + { + COMPILE_ASSERT(!(STATE & TimestampSet), property_timestamp_already_set); + m_result->setDouble(ASCIILiteral("timestamp"), value); + return castState(); + } + + Builder& setValues(RefPtr value) + { + COMPILE_ASSERT(!(STATE & ValuesSet), property_values_already_set); + m_result->setObject(ASCIILiteral("values"), value); + return castState(); + } + + Builder& setPayload(RefPtr value) + { + COMPILE_ASSERT(!(STATE & PayloadSet), property_payload_already_set); + m_result->setValue(ASCIILiteral("payload"), value); + return castState(); + } + + Builder& setError(RefPtr value) + { + COMPILE_ASSERT(!(STATE & ErrorSet), property_error_already_set); + m_result->setObject(ASCIILiteral("error"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = ParameterBundle::create() + * .setColumnNames(...) + * .setNotes(...) + * .setTimestamp(...) + * .setValues(...) + * .setPayload(...) + * .setError(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +} // Test + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolDatabaseError; +@class TestProtocolDatabaseOptionalParameterBundle; +@class TestProtocolDatabaseParameterBundle; +@class TestProtocolDatabaseObjectWithPropertyNameConflicts; +@class TestProtocolDatabaseDummyObject; +@class TestProtocolTestParameterBundle; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseOptionalParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, copy) NSArray/**/ *columnNames; +/* optional */ @property (nonatomic, copy) NSString *notes; +/* optional */ @property (nonatomic, assign) double timestamp; +/* optional */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* optional */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* optional */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +/* optional */ @property (nonatomic, copy) NSArray/**/ *errorList; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/**/ *)errorList; +/* required */ @property (nonatomic, copy) NSArray/**/ *columnNames; +/* required */ @property (nonatomic, copy) NSString *notes; +/* required */ @property (nonatomic, assign) double timestamp; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* required */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +/* required */ @property (nonatomic, copy) NSArray/**/ *errorList; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseObjectWithPropertyNameConflicts : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object; +/* required */ @property (nonatomic, copy) NSString *integer; +/* required */ @property (nonatomic, copy) NSString *array; +/* required */ @property (nonatomic, copy) NSString *string; +/* required */ @property (nonatomic, copy) NSString *value; +/* required */ @property (nonatomic, copy) NSString *object; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseDummyObject : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error; +/* required */ @property (nonatomic, copy) NSArray/**/ *columnNames; +/* required */ @property (nonatomic, copy) NSString *notes; +/* required */ @property (nonatomic, assign) double timestamp; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* required */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; ++ (void)_parseErrorList:(NSArray/**/ **)outValue fromPayload:(id)payload; ++ (void)_parseOptionalParameterBundle:(TestProtocolDatabaseOptionalParameterBundle **)outValue fromPayload:(id)payload; ++ (void)_parseParameterBundle:(TestProtocolDatabaseParameterBundle **)outValue fromPayload:(id)payload; ++ (void)_parseObjectWithPropertyNameConflicts:(TestProtocolDatabaseObjectWithPropertyNameConflicts **)outValue fromPayload:(id)payload; ++ (void)_parseDummyObject:(TestProtocolDatabaseDummyObject **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (TestDomain) + ++ (void)_parseParameterBundle:(TestProtocolTestParameterBundle **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + ++ (void)_parseErrorList:(NSArray/**/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/**/ class]); + *outValue = (NSArray/**/ *)payload; +} + ++ (void)_parseOptionalParameterBundle:(TestProtocolDatabaseOptionalParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseOptionalParameterBundle alloc] initWithPayload:payload]; +} + ++ (void)_parseParameterBundle:(TestProtocolDatabaseParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseParameterBundle alloc] initWithPayload:payload]; +} + ++ (void)_parseObjectWithPropertyNameConflicts:(TestProtocolDatabaseObjectWithPropertyNameConflicts **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseObjectWithPropertyNameConflicts alloc] initWithPayload:payload]; +} + ++ (void)_parseDummyObject:(TestProtocolDatabaseDummyObject **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseDummyObject alloc] initWithPayload:payload]; +} + +@end +@implementation TestProtocolTypeConversions (TestDomain) + ++ (void)_parseParameterBundle:(TestProtocolTestParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestParameterBundle alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + +@implementation TestProtocolDatabaseOptionalParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + self.columnNames = objcArrayFromPayload(payload[@"columnNames"]); + + self.notes = payload[@"notes"]; + + self.timestamp = [payload[@"timestamp"] doubleValue]; + + self.values = payload[@"values"]; + + self.payload = payload[@"payload"]; + + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + self.errorList = objcArrayFromPayload(payload[@"errorList"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setColumnNames:(NSArray/**/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/**/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +- (void)setErrorList:(NSArray/**/ *)errorList +{ + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + [super setInspectorArray:inspectorObjectArray(errorList) forKey:@"errorList"]; +} + +- (NSArray/**/ *)errorList +{ + return objcArray([super inspectorArrayForKey:@"errorList"]); +} + +@end + +@implementation TestProtocolDatabaseParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"columnNames"], @"columnNames"); + self.columnNames = objcArrayFromPayload(payload[@"columnNames"]); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"notes"], @"notes"); + self.notes = payload[@"notes"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"timestamp"], @"timestamp"); + self.timestamp = [payload[@"timestamp"] doubleValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"values"], @"values"); + self.values = payload[@"values"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"payload"], @"payload"); + self.payload = payload[@"payload"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"error"], @"error"); + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"errorList"], @"errorList"); + self.errorList = objcArrayFromPayload(payload[@"errorList"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/**/ *)errorList +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(error, @"error"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(errorList, @"errorList"); + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + + self.columnNames = columnNames; + self.notes = notes; + self.timestamp = timestamp; + self.values = values; + self.payload = payload; + self.error = error; + self.errorList = errorList; + + return self; +} + +- (void)setColumnNames:(NSArray/**/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/**/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +- (void)setErrorList:(NSArray/**/ *)errorList +{ + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + [super setInspectorArray:inspectorObjectArray(errorList) forKey:@"errorList"]; +} + +- (NSArray/**/ *)errorList +{ + return objcArray([super inspectorArrayForKey:@"errorList"]); +} + +@end + +@implementation TestProtocolDatabaseObjectWithPropertyNameConflicts + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"integer"], @"integer"); + self.integer = payload[@"integer"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"array"], @"array"); + self.array = payload[@"array"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"string"], @"string"); + self.string = payload[@"string"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"value"], @"value"); + self.value = payload[@"value"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"object"], @"object"); + self.object = payload[@"object"]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(integer, @"integer"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(array, @"array"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(string, @"string"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(value, @"value"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(object, @"object"); + + self.integer = integer; + self.array = array; + self.string = string; + self.value = value; + self.object = object; + + return self; +} + +- (void)setInteger:(NSString *)integer +{ + [super setString:integer forKey:@"integer"]; +} + +- (NSString *)integer +{ + return [super stringForKey:@"integer"]; +} + +- (void)setArray:(NSString *)array +{ + [super setString:array forKey:@"array"]; +} + +- (NSString *)array +{ + return [super stringForKey:@"array"]; +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setValue:(NSString *)value +{ + [super setString:value forKey:@"value"]; +} + +- (NSString *)value +{ + return [super stringForKey:@"value"]; +} + +- (void)setObject:(NSString *)object +{ + [super setString:object forKey:@"object"]; +} + +- (NSString *)object +{ + return [super stringForKey:@"object"]; +} + +@end + +@implementation TestProtocolDatabaseDummyObject + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +@end + + +@implementation TestProtocolTestParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"columnNames"], @"columnNames"); + self.columnNames = objcArrayFromPayload(payload[@"columnNames"]); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"notes"], @"notes"); + self.notes = payload[@"notes"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"timestamp"], @"timestamp"); + self.timestamp = [payload[@"timestamp"] doubleValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"values"], @"values"); + self.values = payload[@"values"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"payload"], @"payload"); + self.payload = payload[@"payload"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"error"], @"error"); + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithColumnNames:(NSArray/**/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(error, @"error"); + + self.columnNames = columnNames; + self.notes = notes; + self.timestamp = timestamp; + self.values = values; + self.payload = payload; + self.error = error; + + return self; +} + +- (void)setColumnNames:(NSArray/**/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/**/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result new file mode 100644 index 000000000..893692982 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result @@ -0,0 +1,1617 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Test. +InspectorBackend.registerEnum("Test.UncastedAnimals", {Pigs: "Pigs", Cows: "Cows", Cats: "Cats", Hens: "Hens"}); +InspectorBackend.registerEnum("Test.CastedAnimals", {Ducks: "Ducks", Hens: "Hens", Crows: "Crows", Flamingos: "Flamingos"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Test { +class TypeNeedingCast; +class RecursiveObject1; +class RecursiveObject2; +enum class UncastedAnimals; +enum class CastedAnimals; +} // Test +// End of forward declarations. + + +// Typedefs. +namespace Test { +typedef int CastedObjectId; +typedef int UncastedObjectId; +} // Test +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast(enumValue)); +} + +} // namespace TestHelpers + +namespace Test { +/* A dummy type that requires runtime casts, and forces non-primitive referenced types to also emit runtime cast helpers. */ +class TypeNeedingCast : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + StringSet = 1 << 0, + NumberSet = 1 << 1, + AnimalsSet = 1 << 2, + IdSet = 1 << 3, + TreeSet = 1 << 4, + AllFieldsSet = (StringSet | NumberSet | AnimalsSet | IdSet | TreeSet) + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class TypeNeedingCast; + public: + + Builder& setString(const String& value) + { + COMPILE_ASSERT(!(STATE & StringSet), property_string_already_set); + m_result->setString(ASCIILiteral("string"), value); + return castState(); + } + + Builder& setNumber(int value) + { + COMPILE_ASSERT(!(STATE & NumberSet), property_number_already_set); + m_result->setInteger(ASCIILiteral("number"), value); + return castState(); + } + + Builder& setAnimals(Inspector::Protocol::Test::CastedAnimals value) + { + COMPILE_ASSERT(!(STATE & AnimalsSet), property_animals_already_set); + m_result->setString(ASCIILiteral("animals"), Inspector::Protocol::TestHelpers::getEnumConstantValue(value)); + return castState(); + } + + Builder& setId(int value) + { + COMPILE_ASSERT(!(STATE & IdSet), property_id_already_set); + m_result->setInteger(ASCIILiteral("id"), value); + return castState(); + } + + Builder& setTree(RefPtr value) + { + COMPILE_ASSERT(!(STATE & TreeSet), property_tree_already_set); + m_result->setObject(ASCIILiteral("tree"), value); + return castState(); + } + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(TypeNeedingCast) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = TypeNeedingCast::create() + * .setString(...) + * .setNumber(...) + * .setAnimals(...) + * .setId(...) + * .setTree(...) + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } +}; + +/* */ +enum class UncastedAnimals { + Pigs = 4, + Cows = 5, + Cats = 6, + Hens = 1, +}; // enum class UncastedAnimals +/* */ +enum class CastedAnimals { + Ducks = 0, + Hens = 1, + Crows = 2, + Flamingos = 3, +}; // enum class CastedAnimals +class RecursiveObject1 : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class RecursiveObject1; + public: + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(RecursiveObject1) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = RecursiveObject1::create() + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } + + void setObj(RefPtr value) + { + InspectorObjectBase::setObject(ASCIILiteral("obj"), WTFMove(value)); + } +}; + +class RecursiveObject2 : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template + class Builder { + private: + RefPtr m_result; + + template Builder& castState() + { + return *reinterpret_cast*>(this); + } + + Builder(Ref&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class RecursiveObject2; + public: + + Ref release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(RecursiveObject2) == sizeof(InspectorObject), cannot_cast); + + Ref result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref result = RecursiveObject2::create() + * .release(); + */ + static Builder create() + { + return Builder(InspectorObject::create()); + } + + void setObj(RefPtr value) + { + InspectorObjectBase::setObject(ASCIILiteral("obj"), WTFMove(value)); + } +}; + +} // Test + +template<> struct BindingTraits { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits { +static RefPtr runtimeCast(RefPtr&& value); +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; + +namespace TestHelpers { + +template +std::optional parseEnumValueFromString(const String&); + +// Enums in the 'Test' Domain +template<> +std::optional parseEnumValueFromString(const String&); +template<> +std::optional parseEnumValueFromString(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Ducks", + "Hens", + "Crows", + "Flamingos", + "Pigs", + "Cows", + "Cats", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Test' Domain +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Test::UncastedAnimals::Pigs, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Cows, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Cats, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Hens, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Test::UncastedAnimals)constantValues[i]; + + return std::nullopt; +} + +template<> +std::optional parseEnumValueFromString(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Test::CastedAnimals::Ducks, + (size_t)Inspector::Protocol::Test::CastedAnimals::Hens, + (size_t)Inspector::Protocol::Test::CastedAnimals::Crows, + (size_t)Inspector::Protocol::Test::CastedAnimals::Flamingos, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Test::CastedAnimals)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +#if !ASSERT_DISABLED +void BindingTraits::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + String result; + bool castSucceeded = value->asString(result); + ASSERT(castSucceeded); + ASSERT(result == "Ducks" || result == "Hens" || result == "Crows" || result == "Flamingos"); +} +#endif // !ASSERT_DISABLED + +#if !ASSERT_DISABLED +void BindingTraits::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + { + InspectorObject::iterator stringPos = object->find(ASCIILiteral("string")); + ASSERT(stringPos != object->end()); + BindingTraits::assertValueHasExpectedType(stringPos->value.get()); + } + { + InspectorObject::iterator numberPos = object->find(ASCIILiteral("number")); + ASSERT(numberPos != object->end()); + BindingTraits::assertValueHasExpectedType(numberPos->value.get()); + } + { + InspectorObject::iterator animalsPos = object->find(ASCIILiteral("animals")); + ASSERT(animalsPos != object->end()); + BindingTraits::assertValueHasExpectedType(animalsPos->value.get()); + } + { + InspectorObject::iterator idPos = object->find(ASCIILiteral("id")); + ASSERT(idPos != object->end()); + BindingTraits::assertValueHasExpectedType(idPos->value.get()); + } + { + InspectorObject::iterator treePos = object->find(ASCIILiteral("tree")); + ASSERT(treePos != object->end()); + BindingTraits::assertValueHasExpectedType(treePos->value.get()); + } + + int foundPropertiesCount = 5; + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +RefPtr BindingTraits::runtimeCast(RefPtr&& value) +{ + RefPtr result; + bool castSucceeded = value->asObject(result); + ASSERT_UNUSED(castSucceeded, castSucceeded); +#if !ASSERT_DISABLED + BindingTraits::assertValueHasExpectedType(result.get()); +#endif // !ASSERT_DISABLED + COMPILE_ASSERT(sizeof(Inspector::Protocol::Test::TypeNeedingCast) == sizeof(InspectorObjectBase), type_cast_problem); + return static_cast(static_cast(result.get())); +} + + +#if !ASSERT_DISABLED +void BindingTraits::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + int foundPropertiesCount = 0; + { + InspectorObject::iterator objPos = object->find(ASCIILiteral("obj")); + if (objPos != object->end()) { + BindingTraits::assertValueHasExpectedType(objPos->value.get()); + ++foundPropertiesCount; + } + } + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +#if !ASSERT_DISABLED +void BindingTraits::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + int foundPropertiesCount = 0; + { + InspectorObject::iterator objPos = object->find(ASCIILiteral("obj")); + if (objPos != object->end()) { + BindingTraits::assertValueHasExpectedType(objPos->value.get()); + ++foundPropertiesCount; + } + } + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + +@class TestProtocolTestTypeNeedingCast; +@class TestProtocolTestRecursiveObject1; +@class TestProtocolTestRecursiveObject2; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolTestUncastedAnimals) { + TestProtocolTestUncastedAnimalsPigs, + TestProtocolTestUncastedAnimalsCows, + TestProtocolTestUncastedAnimalsCats, + TestProtocolTestUncastedAnimalsHens, +}; + +typedef NS_ENUM(NSInteger, TestProtocolTestCastedAnimals) { + TestProtocolTestCastedAnimalsDucks, + TestProtocolTestCastedAnimalsHens, + TestProtocolTestCastedAnimalsCrows, + TestProtocolTestCastedAnimalsFlamingos, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolTestTypeNeedingCast : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree; +/* required */ @property (nonatomic, copy) NSString *string; +/* required */ @property (nonatomic, assign) int number; +/* required */ @property (nonatomic, assign) TestProtocolTestCastedAnimals animals; +/* required */ @property (nonatomic, assign) int identifier; +/* required */ @property (nonatomic, retain) TestProtocolTestRecursiveObject1 *tree; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestRecursiveObject1 : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject2 *obj; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestRecursiveObject2 : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject1 *obj; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolTestUncastedAnimals value) +{ + switch(value) { + case TestProtocolTestUncastedAnimalsPigs: + return ASCIILiteral("Pigs"); + case TestProtocolTestUncastedAnimalsCows: + return ASCIILiteral("Cows"); + case TestProtocolTestUncastedAnimalsCats: + return ASCIILiteral("Cats"); + case TestProtocolTestUncastedAnimalsHens: + return ASCIILiteral("Hens"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "Pigs") + return TestProtocolTestUncastedAnimalsPigs; + if (value == "Cows") + return TestProtocolTestUncastedAnimalsCows; + if (value == "Cats") + return TestProtocolTestUncastedAnimalsCats; + if (value == "Hens") + return TestProtocolTestUncastedAnimalsHens; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolTestCastedAnimals value) +{ + switch(value) { + case TestProtocolTestCastedAnimalsDucks: + return ASCIILiteral("Ducks"); + case TestProtocolTestCastedAnimalsHens: + return ASCIILiteral("Hens"); + case TestProtocolTestCastedAnimalsCrows: + return ASCIILiteral("Crows"); + case TestProtocolTestCastedAnimalsFlamingos: + return ASCIILiteral("Flamingos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "Ducks") + return TestProtocolTestCastedAnimalsDucks; + if (value == "Hens") + return TestProtocolTestCastedAnimalsHens; + if (value == "Crows") + return TestProtocolTestCastedAnimalsCrows; + if (value == "Flamingos") + return TestProtocolTestCastedAnimalsFlamingos; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + +@interface TestProtocolTypeConversions (TestDomain) + ++ (void)_parseTypeNeedingCast:(TestProtocolTestTypeNeedingCast **)outValue fromPayload:(id)payload; ++ (void)_parseCastedObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseUncastedObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseUncastedAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseCastedAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseRecursiveObject1:(TestProtocolTestRecursiveObject1 **)outValue fromPayload:(id)payload; ++ (void)_parseRecursiveObject2:(TestProtocolTestRecursiveObject2 **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (TestDomain) + ++ (void)_parseTypeNeedingCast:(TestProtocolTestTypeNeedingCast **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestTypeNeedingCast alloc] initWithPayload:payload]; +} + ++ (void)_parseCastedObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseUncastedObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseUncastedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"UncastedAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseCastedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional result = Inspector::fromProtocolString(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"CastedAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseRecursiveObject1:(TestProtocolTestRecursiveObject1 **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload]; +} + ++ (void)_parseRecursiveObject2:(TestProtocolTestRecursiveObject2 **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestRecursiveObject2 alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +@implementation TestProtocolTestTypeNeedingCast + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"string"], @"string"); + self.string = payload[@"string"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"number"], @"number"); + self.number = [payload[@"number"] integerValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"animals"], @"animals"); + std::optional animals = fromProtocolString(payload[@"animals"]); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(animals, @"animals"); + self.animals = animals.value(); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"id"], @"id"); + self.identifier = [payload[@"id"] integerValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"tree"], @"tree"); + self.tree = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload[@"tree"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(string, @"string"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(tree, @"tree"); + + self.string = string; + self.number = number; + self.animals = animals; + self.identifier = identifier; + self.tree = tree; + + return self; +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setNumber:(int)number +{ + [super setInteger:number forKey:@"number"]; +} + +- (int)number +{ + return [super integerForKey:@"number"]; +} + +- (void)setAnimals:(TestProtocolTestCastedAnimals)animals +{ + [super setString:toProtocolString(animals) forKey:@"animals"]; +} + +- (TestProtocolTestCastedAnimals)animals +{ + return fromProtocolString([super stringForKey:@"animals"]).value(); +} + +- (void)setIdentifier:(int)identifier +{ + [super setInteger:identifier forKey:@"id"]; +} + +- (int)identifier +{ + return [super integerForKey:@"id"]; +} + +- (void)setTree:(TestProtocolTestRecursiveObject1 *)tree +{ + [super setObject:tree forKey:@"tree"]; +} + +- (TestProtocolTestRecursiveObject1 *)tree +{ + return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"tree"] toInspectorObject].get()]; +} + +@end + +@implementation TestProtocolTestRecursiveObject1 + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + self.obj = [[TestProtocolTestRecursiveObject2 alloc] initWithPayload:payload[@"obj"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setObj:(TestProtocolTestRecursiveObject2 *)obj +{ + [super setObject:obj forKey:@"obj"]; +} + +- (TestProtocolTestRecursiveObject2 *)obj +{ + return [[TestProtocolTestRecursiveObject2 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()]; +} + +@end + +@implementation TestProtocolTestRecursiveObject2 + +- (instancetype)initWithPayload:(nonnull NSDictionary *)payload +{ + if (!(self = [super init])) + return nil; + + self.obj = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload[@"obj"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setObj:(TestProtocolTestRecursiveObject1 *)obj +{ + [super setObject:obj forKey:@"obj"]; +} + +- (TestProtocolTestRecursiveObject1 *)obj +{ + return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result new file mode 100644 index 000000000..bb4dc2213 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result @@ -0,0 +1,1121 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// DomainA. +InspectorBackend.registerCommand("DomainA.enable", [], []); +InspectorBackend.activateDomain("DomainA"); +InspectorBackend.workerSupportedDomain("DomainA"); + +// DomainB. +InspectorBackend.registerCommand("DomainB.enable", [], []); +InspectorBackend.activateDomain("DomainB"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include +#include + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr m_backendDispatcher; +}; + + +class AlternateDomainABackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainABackendDispatcher() { } + virtual void enable(long callId) = 0; +}; +class AlternateDomainBBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainBBackendDispatcher() { } + virtual void enable(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDomainABackendDispatcher; +class AlternateDomainBBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DomainABackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainABackendDispatcherHandler(); +}; + +class DomainBBackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainBBackendDispatcherHandler(); +}; + +class DomainABackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DomainABackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void enable(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainABackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainABackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainABackendDispatcher(BackendDispatcher&, DomainABackendDispatcherHandler*); + DomainABackendDispatcherHandler* m_agent { nullptr }; +}; + +class DomainBBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref create(BackendDispatcher&, DomainBBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref&& message) override; +private: + void enable(long requestId, RefPtr&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainBBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainBBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainBBackendDispatcher(BackendDispatcher&, DomainBBackendDispatcherHandler*); + DomainBBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include +#include +#include +#include + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DomainABackendDispatcherHandler::~DomainABackendDispatcherHandler() { } +DomainBBackendDispatcherHandler::~DomainBBackendDispatcherHandler() { } + +Ref DomainABackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainABackendDispatcher(backendDispatcher, agent)); +} + +DomainABackendDispatcher::DomainABackendDispatcher(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainA"), this); +} + +void DomainABackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainA", '.', method, "' was not found")); +} + +void DomainABackendDispatcher::enable(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref DomainBBackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainBBackendDispatcher(backendDispatcher, agent)); +} + +DomainBBackendDispatcher::DomainBBackendDispatcher(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainB"), this); +} + +void DomainBBackendDispatcher::dispatch(long requestId, const String& method, Ref&& message) +{ + Ref protect(*this); + + RefPtr parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainB", '.', method, "' was not found")); +} + +void DomainBBackendDispatcher::enable(long requestId, RefPtr&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include +#include + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include +#include + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include +#include + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include +#include + +@protocol TestProtocolDomainADomainHandler; +@protocol TestProtocolDomainBDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDomainABackendDispatcher final : public AlternateDomainABackendDispatcher { +public: + ObjCInspectorDomainABackendDispatcher(id handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +class ObjCInspectorDomainBBackendDispatcher final : public AlternateDomainBBackendDispatcher { +public: + ObjCInspectorDomainBBackendDispatcher(id handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include + +namespace Inspector { + +void ObjCInspectorDomainABackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorDomainBBackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDomainAHandler:) id domainAHandler; +@property (nonatomic, retain, setter=setDomainBHandler:) id domainBHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import +#import +#import +#import + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id _domainAHandler; + id _domainBHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_domainAHandler release]; + [_domainBHandler release]; + [super dealloc]; +} + +- (void)setDomainAHandler:(id)handler +{ + if (handler == _domainAHandler) + return; + + [_domainAHandler release]; + _domainAHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("DomainA"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)domainAHandler +{ + return _domainAHandler; +} + +- (void)setDomainBHandler:(id)handler +{ + if (handler == _domainBHandler) + return; + + [_domainBHandler release]; + _domainBHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique(handler); + auto alternateAgent = std::make_unique>(ASCIILiteral("DomainB"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id)domainBHandler +{ + return _domainBHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import + +#import + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolDomainADomainHandler +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolDomainBDomainHandler +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import +#import + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import + +namespace Inspector { + +template +std::optional fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import +#import +#import + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json new file mode 100644 index 000000000..a180cae9b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "platform": "invalid", + "parameters": [ + { "name": "point1", "type": "number" }, + { "name": "point2", "type": "number" } + ], + "returns": [ + { "name": "result", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json new file mode 100644 index 000000000..36ee2c600 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json @@ -0,0 +1,9 @@ +{ + "domain": "WebOnly", + "availability": "webb", + "commands": [ + { + "name": "enable" + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json new file mode 100644 index 000000000..bab76ca62 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "parameters": [ + { "name": "point", "type": "number" }, + { "name": "point", "type": "number" } + ], + "returns": [ + { "name": "result1", "type": "string" }, + { "name": "result2", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json new file mode 100644 index 000000000..c8bb15c04 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "parameters": [ + { "name": "point1", "type": "number" }, + { "name": "point2", "type": "number" } + ], + "returns": [ + { "name": "result", "type": "string" }, + { "name": "result", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json new file mode 100644 index 000000000..d3d3b3cc6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json @@ -0,0 +1,12 @@ +{ + "domain": "Overlay", + "events": [ + { + "name": "processedPoints", + "parameters": [ + { "name": "point", "type": "number" }, + { "name": "point", "type": "number" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json new file mode 100644 index 000000000..702fc6a32 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json @@ -0,0 +1,15 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + }, + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json new file mode 100644 index 000000000..aebacee8b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json @@ -0,0 +1,15 @@ +[ +{ + "domain": "OverlayTypes", + "types": [ + { + "id": "Point", + "type": "object", + "properties": [ + { "name": "x", "type": "integer" }, + { "name": "x", "type": "integer" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json new file mode 100644 index 000000000..232a7c324 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json @@ -0,0 +1,10 @@ +{ + "domain": "Database", + "types": [ + { + "id": "PrimaryColors", + "type": "string", + "enum": [] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json new file mode 100644 index 000000000..7308db992 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "string", "optional": 0 } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json new file mode 100644 index 000000000..afea555ec --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json @@ -0,0 +1,16 @@ +[ +{ + "domain": "Database", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code.", "optional": 0 } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json new file mode 100644 index 000000000..4012c79b6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "string", "optional": "true" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json new file mode 100644 index 000000000..ca3ef28a8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json @@ -0,0 +1,16 @@ +[ +{ + "domain": "Database", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code.", "optional": "false" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json new file mode 100644 index 000000000..19b7590cc --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json @@ -0,0 +1,13 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "object", + "$ref": "SomeType", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json new file mode 100644 index 000000000..8c83bbfce --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "DatabaseId" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json new file mode 100644 index 000000000..a9fd2e995 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json @@ -0,0 +1,11 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "platform": "invalid", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json new file mode 100644 index 000000000..531901e4a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json @@ -0,0 +1,10 @@ +{ + "domain": "Database", + "types": [ + { + "id": "databaseId", + "type": "integer", + "description": "Unique identifier of Database object." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json new file mode 100644 index 000000000..d6887a274 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json @@ -0,0 +1,12 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "dragon", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json new file mode 100644 index 000000000..b817db504 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json @@ -0,0 +1,15 @@ +[ +{ + "domain": "Fantasy", + "types": [ + { + "id": "DragonEgg", + "type": "object", + "description": "A dragon egg.", + "properties": [ + { "name": "color", "$ref": "Color" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json new file mode 100644 index 000000000..67cf8e582 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json @@ -0,0 +1,36 @@ +[ +{ + "domain": "Network1", + "featureGuard": "PLATFORM(WEB_COMMANDS)", + "commands": [ + { + "name": "loadResource", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +}, +{ + "domain": "Network2", + "featureGuard": "PLATFORM(WEB_TYPES)", + "types": [ + { + "id": "NetworkError", + "type": "object", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ] +}, +{ + "domain": "Network3", + "featureGuard": "PLATFORM(WEB_EVENTS)", + "events": [ + { + "name": "resourceLoaded", + "description": "A resource was loaded." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json new file mode 100644 index 000000000..3bf4dff5c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json @@ -0,0 +1,22 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +}, +{ + "domain": "Runtime2", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json new file mode 100644 index 000000000..20a0c1552 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json @@ -0,0 +1,31 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "KeyPath", + "type": "object", + "description": "Key path.", + "properties": [ + { + "name": "type", + "type": "string", + "enum": ["null", "string", "array"], + "description": "Key path type." + }, + { + "name": "string", + "type": "string", + "optional": true, + "description": "String value." + }, + { + "name": "array", + "type": "array", + "optional": true, + "items": { "type": "string" }, + "description": "Array value." + } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json new file mode 100644 index 000000000..cbc9d5394 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json @@ -0,0 +1,10 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "integer", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json new file mode 100644 index 000000000..cfb08bd94 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json @@ -0,0 +1,50 @@ +[ +{ + "domain": "Debugger", + "types": [ + { + "id": "BreakpointId", + "type": "integer" + }, + { + "id": "Reason", + "type": "string", + "enum": ["Died", "Fainted", "Hungry"] + } + ] +}, +{ + "domain": "Runtime", + "types": [ + { + "id": "ObjectId", + "type": "integer" + }, + { + "id": "LuckyNumbers", + "type": "array", + "items": { "type": "integer" } + }, + { + "id": "BabyNames", + "type": "array", + "items": { "type": "string" } + }, + { + "id": "NewObjects", + "type": "array", + "items": { "$ref": "ObjectId" } + }, + { + "id": "OldObjects", + "type": "array", + "items": { "$ref": "Debugger.BreakpointId" } + }, + { + "id": "StopReasons", + "type": "array", + "items": { "$ref": "Debugger.Reason" } + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json new file mode 100644 index 000000000..9f0aee9c9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json @@ -0,0 +1,15 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "FarmAnimals", + "type": "string", + "enum": ["Pigs", "Cows", "Cats", "Hens"] + }, + { + "id": "TwoLeggedAnimals", + "type": "string", + "enum": ["Ducks", "Hens", "Crows", "Flamingos"] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json new file mode 100644 index 000000000..178309197 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json @@ -0,0 +1,83 @@ +[ +{ + "domain": "Database", + "description": "Test type builder generation of various object types.", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + }, + { + "id": "ErrorList", + "type": "array", + "items": { "$ref": "Error" } + }, + { + "id": "OptionalParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "error", "$ref": "Error", "optional": true }, + { "name": "errorList", "$ref": "ErrorList", "optional": true } + ] + }, + { + "id": "ParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "error", "$ref": "Error" }, + { "name": "errorList", "$ref": "ErrorList" } + ] + }, + { + "id": "ObjectWithPropertyNameConflicts", + "description": "Conflicted names may cause generated getters/setters to clash with built-in InspectorObject methods.", + "type": "object", + "properties": [ + { "name": "integer", "type": "string" }, + { "name": "array", "type": "string" }, + { "name": "string", "type": "string" }, + { "name": "value", "type": "string" }, + { "name": "object", "type": "string" } + ] + }, + { + "id": "DummyObject", + "description": "An open object that doesn't have any predefined fields.", + "type": "object" + } + ] +}, +{ + "domain": "Test", + "description": "Test the generation of special behaviors that only apply to specific classes.", + "types": [ + { + "id": "ParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "error", "$ref": "Database.Error" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json new file mode 100644 index 000000000..83d94be89 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json @@ -0,0 +1,51 @@ +[ +{ + "domain": "Test", + "types": [ + { + "id": "TypeNeedingCast", + "type": "object", + "description": "A dummy type that requires runtime casts, and forces non-primitive referenced types to also emit runtime cast helpers.", + "properties": [ + { "name": "string", "type": "string", "description": "String member." }, + { "name": "number", "type": "integer", "description": "Number member." }, + { "name": "animals", "$ref": "CastedAnimals", "description": "Enum member." }, + { "name": "id", "$ref": "CastedObjectId", "description": "Aliased member." }, + { "name": "tree", "$ref": "RecursiveObject1", "description": "Recursive object member." } + ] + }, + { + "id": "CastedObjectId", + "type": "integer" + }, + { + "id": "UncastedObjectId", + "type": "integer" + }, + { + "id": "UncastedAnimals", + "type": "string", + "enum": ["Pigs", "Cows", "Cats", "Hens"] + }, + { + "id": "CastedAnimals", + "type": "string", + "enum": ["Ducks", "Hens", "Crows", "Flamingos"] + }, + { + "id": "RecursiveObject1", + "type": "object", + "properties": [ + { "name": "obj", "$ref": "RecursiveObject2", "optional": true } + ] + }, + { + "id": "RecursiveObject2", + "type": "object", + "properties": [ + { "name": "obj", "$ref": "RecursiveObject1", "optional": true } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json new file mode 100644 index 000000000..5e5889afc --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json @@ -0,0 +1,11 @@ +[ +{ + "domain": "DomainA", + "workerSupported": true, + "commands": [{"name": "enable"}] +}, +{ + "domain": "DomainB", + "commands": [{"name": "enable"}] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/xxd.pl b/Source/JavaScriptCore/inspector/scripts/xxd.pl deleted file mode 100644 index 5ee08a52d..000000000 --- a/Source/JavaScriptCore/inspector/scripts/xxd.pl +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/perl - -# Copyright (C) 2010-2011 Google Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# # Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# # Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# # Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -$varname = shift; -$fname = shift; -$output = shift; - -open($input, '<', $fname) or die "Can't open file for read: $fname $!"; -$/ = undef; -$text = <$input>; -close($input); - -$text = join(', ', map('0x' . unpack("H*", $_), split(undef, $text))); - -open($output, '>', $output) or die "Can't open file for write: $output $!"; -print $output "const unsigned char $varname\[\] = {\n$text\n};\n"; -close($output); -- cgit v1.2.1