diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Scripts/webkit | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/Scripts/webkit')
-rw-r--r-- | Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp | 226 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h | 590 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp | 228 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp | 46 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/Messages-expected.h | 590 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h | 69 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/__init__.py | 23 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/messages.py | 555 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/messages_unittest.py | 357 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/model.py | 62 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/parser.py | 144 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/test-legacy-messages.in | 77 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/test-messages.in | 77 | ||||
-rw-r--r-- | Source/WebKit2/Scripts/webkit/test-superclass-messages.in | 25 |
14 files changed, 3069 insertions, 0 deletions
diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp new file mode 100644 index 000000000..2a0556a71 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp @@ -0,0 +1,226 @@ +/* + * Copyright (C) 2010 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" + +#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#include "WebPage.h" + +#include "ArgumentCoders.h" +#include "Connection.h" +#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE) +#include "DummyType.h" +#endif +#include "HandleMessage.h" +#if PLATFORM(MAC) +#include "MachPort.h" +#endif +#include "Decoder.h" +#include "Plugin.h" +#include "WebCoreArgumentCoders.h" +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +#include "WebEvent.h" +#endif +#include "WebPageMessages.h" +#include "WebPreferencesStore.h" +#include <WebCore/GraphicsLayer.h> +#if PLATFORM(MAC) +#include <WebCore/KeyboardEvent.h> +#endif +#include <WebCore/PluginData.h> +#include <utility> +#include <wtf/HashMap.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + +namespace Messages { + +namespace WebPage { + +GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::Encoder> encoder) + : m_connection(connection) + , m_encoder(WTFMove(encoder)) +{ +} + +GetPluginProcessConnection::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool GetPluginProcessConnection::DelayedReply::send(const IPC::Connection::Handle& connectionHandle) +{ + ASSERT(m_encoder); + *m_encoder << connectionHandle; + bool _result = m_connection->sendSyncReply(WTFMove(m_encoder)); + m_connection = nullptr; + return _result; +} + +TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::Encoder> encoder) + : m_connection(connection) + , m_encoder(WTFMove(encoder)) +{ +} + +TestMultipleAttributes::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool TestMultipleAttributes::DelayedReply::send() +{ + ASSERT(m_encoder); + bool _result = m_connection->sendSyncReply(WTFMove(m_encoder)); + m_connection = nullptr; + return _result; +} + +} // namespace WebPage + +} // namespace Messages + +namespace WebKit { + +void WebPage::didReceiveWebPageMessage(IPC::Connection*, IPC::Decoder& decoder) +{ + if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { + IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); + return; + } +#if ENABLE(TOUCH_EVENTS) + if (decoder.messageName() == Messages::WebPage::LoadSomething::name()) { + IPC::handleMessage<Messages::WebPage::LoadSomething>(decoder, this, &WebPage::loadSomething); + return; + } +#endif +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) + if (decoder.messageName() == Messages::WebPage::TouchEvent::name()) { + IPC::handleMessage<Messages::WebPage::TouchEvent>(decoder, this, &WebPage::touchEvent); + return; + } +#endif +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) + if (decoder.messageName() == Messages::WebPage::AddEvent::name()) { + IPC::handleMessage<Messages::WebPage::AddEvent>(decoder, this, &WebPage::addEvent); + return; + } +#endif +#if ENABLE(TOUCH_EVENTS) + if (decoder.messageName() == Messages::WebPage::LoadSomethingElse::name()) { + IPC::handleMessage<Messages::WebPage::LoadSomethingElse>(decoder, this, &WebPage::loadSomethingElse); + return; + } +#endif + if (decoder.messageName() == Messages::WebPage::DidReceivePolicyDecision::name()) { + IPC::handleMessage<Messages::WebPage::DidReceivePolicyDecision>(decoder, this, &WebPage::didReceivePolicyDecision); + return; + } + if (decoder.messageName() == Messages::WebPage::Close::name()) { + IPC::handleMessage<Messages::WebPage::Close>(decoder, this, &WebPage::close); + return; + } + if (decoder.messageName() == Messages::WebPage::PreferencesDidChange::name()) { + IPC::handleMessage<Messages::WebPage::PreferencesDidChange>(decoder, this, &WebPage::preferencesDidChange); + return; + } + if (decoder.messageName() == Messages::WebPage::SendDoubleAndFloat::name()) { + IPC::handleMessage<Messages::WebPage::SendDoubleAndFloat>(decoder, this, &WebPage::sendDoubleAndFloat); + return; + } + if (decoder.messageName() == Messages::WebPage::SendInts::name()) { + IPC::handleMessage<Messages::WebPage::SendInts>(decoder, this, &WebPage::sendInts); + return; + } + if (decoder.messageName() == Messages::WebPage::TestParameterAttributes::name()) { + IPC::handleMessage<Messages::WebPage::TestParameterAttributes>(decoder, this, &WebPage::testParameterAttributes); + return; + } + if (decoder.messageName() == Messages::WebPage::TemplateTest::name()) { + IPC::handleMessage<Messages::WebPage::TemplateTest>(decoder, this, &WebPage::templateTest); + return; + } + if (decoder.messageName() == Messages::WebPage::SetVideoLayerID::name()) { + IPC::handleMessage<Messages::WebPage::SetVideoLayerID>(decoder, this, &WebPage::setVideoLayerID); + return; + } +#if PLATFORM(MAC) + if (decoder.messageName() == Messages::WebPage::DidCreateWebProcessConnection::name()) { + IPC::handleMessage<Messages::WebPage::DidCreateWebProcessConnection>(decoder, this, &WebPage::didCreateWebProcessConnection); + return; + } +#endif +#if ENABLE(DEPRECATED_FEATURE) + if (decoder.messageName() == Messages::WebPage::DeprecatedOperation::name()) { + IPC::handleMessage<Messages::WebPage::DeprecatedOperation>(decoder, this, &WebPage::deprecatedOperation); + return; + } +#endif +#if ENABLE(EXPERIMENTAL_FEATURE) + if (decoder.messageName() == Messages::WebPage::ExperimentalOperation::name()) { + IPC::handleMessage<Messages::WebPage::ExperimentalOperation>(decoder, this, &WebPage::experimentalOperation); + return; + } +#endif + UNUSED_PARAM(decoder); + ASSERT_NOT_REACHED(); +} + +void WebPage::didReceiveSyncWebPageMessage(IPC::Connection* connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) +{ + if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) { + IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin); + return; + } + if (decoder.messageName() == Messages::WebPage::RunJavaScriptAlert::name()) { + IPC::handleMessage<Messages::WebPage::RunJavaScriptAlert>(decoder, *replyEncoder, this, &WebPage::runJavaScriptAlert); + return; + } + if (decoder.messageName() == Messages::WebPage::GetPlugins::name()) { + IPC::handleMessage<Messages::WebPage::GetPlugins>(decoder, *replyEncoder, this, &WebPage::getPlugins); + return; + } + if (decoder.messageName() == Messages::WebPage::GetPluginProcessConnection::name()) { + IPC::handleMessageDelayed<Messages::WebPage::GetPluginProcessConnection>(connection, decoder, replyEncoder, this, &WebPage::getPluginProcessConnection); + return; + } + if (decoder.messageName() == Messages::WebPage::TestMultipleAttributes::name()) { + IPC::handleMessageDelayed<Messages::WebPage::TestMultipleAttributes>(connection, decoder, replyEncoder, this, &WebPage::testMultipleAttributes); + return; + } +#if PLATFORM(MAC) + if (decoder.messageName() == Messages::WebPage::InterpretKeyEvent::name()) { + IPC::handleMessage<Messages::WebPage::InterpretKeyEvent>(decoder, *replyEncoder, this, &WebPage::interpretKeyEvent); + return; + } +#endif + UNUSED_PARAM(decoder); + UNUSED_PARAM(replyEncoder); + ASSERT_NOT_REACHED(); +} + +} // namespace WebKit + +#endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h new file mode 100644 index 000000000..d0c7625ff --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h @@ -0,0 +1,590 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef WebPageMessages_h +#define WebPageMessages_h + +#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#include "Arguments.h" +#include "Connection.h" +#include "Encoder.h" +#include "Plugin.h" +#include "StringReference.h" +#include <WebCore/GraphicsLayer.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/PluginData.h> +#include <utility> +#include <wtf/HashMap.h> +#include <wtf/ThreadSafeRefCounted.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + +namespace IPC { + class Connection; + class DummyType; + class MachPort; +} + +namespace WTF { + class String; +} + +namespace WebKit { + struct WebPreferencesStore; + class WebTouchEvent; +} + +namespace Messages { +namespace WebPage { + +static inline IPC::StringReference messageReceiverName() +{ + return IPC::StringReference("WebPage"); +} + +class LoadURL { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadURL"); } + static const bool isSync = false; + + explicit LoadURL(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; + +#if ENABLE(TOUCH_EVENTS) +class LoadSomething { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadSomething"); } + static const bool isSync = false; + + explicit LoadSomething(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; +#endif + +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +class TouchEvent { +public: + typedef std::tuple<WebKit::WebTouchEvent> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TouchEvent"); } + static const bool isSync = false; + + explicit TouchEvent(const WebKit::WebTouchEvent& event) + : m_arguments(event) + { + } + + const std::tuple<const WebKit::WebTouchEvent&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebTouchEvent&> m_arguments; +}; +#endif + +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) +class AddEvent { +public: + typedef std::tuple<WebKit::WebTouchEvent> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("AddEvent"); } + static const bool isSync = false; + + explicit AddEvent(const WebKit::WebTouchEvent& event) + : m_arguments(event) + { + } + + const std::tuple<const WebKit::WebTouchEvent&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebTouchEvent&> m_arguments; +}; +#endif + +#if ENABLE(TOUCH_EVENTS) +class LoadSomethingElse { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadSomethingElse"); } + static const bool isSync = false; + + explicit LoadSomethingElse(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; +#endif + +class DidReceivePolicyDecision { +public: + typedef std::tuple<uint64_t, uint64_t, uint32_t> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DidReceivePolicyDecision"); } + static const bool isSync = false; + + DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) + : m_arguments(frameID, listenerID, policyAction) + { + } + + const std::tuple<uint64_t, uint64_t, uint32_t>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, uint64_t, uint32_t> m_arguments; +}; + +class Close { +public: + typedef std::tuple<> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("Close"); } + static const bool isSync = false; + + const std::tuple<>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<> m_arguments; +}; + +class PreferencesDidChange { +public: + typedef std::tuple<WebKit::WebPreferencesStore> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("PreferencesDidChange"); } + static const bool isSync = false; + + explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store) + : m_arguments(store) + { + } + + const std::tuple<const WebKit::WebPreferencesStore&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebPreferencesStore&> m_arguments; +}; + +class SendDoubleAndFloat { +public: + typedef std::tuple<double, float> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SendDoubleAndFloat"); } + static const bool isSync = false; + + SendDoubleAndFloat(double d, float f) + : m_arguments(d, f) + { + } + + const std::tuple<double, float>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<double, float> m_arguments; +}; + +class SendInts { +public: + typedef std::tuple<Vector<uint64_t>, Vector<Vector<uint64_t>>> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SendInts"); } + static const bool isSync = false; + + SendInts(const Vector<uint64_t>& ints, const Vector<Vector<uint64_t>>& intVectors) + : m_arguments(ints, intVectors) + { + } + + const std::tuple<const Vector<uint64_t>&, const Vector<Vector<uint64_t>>&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const Vector<uint64_t>&, const Vector<Vector<uint64_t>>&> m_arguments; +}; + +class CreatePlugin { +public: + typedef std::tuple<uint64_t, WebKit::Plugin::Parameters> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("CreatePlugin"); } + static const bool isSync = true; + + typedef IPC::Arguments<bool&> Reply; + CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters) + : m_arguments(pluginInstanceID, parameters) + { + } + + const std::tuple<uint64_t, const WebKit::Plugin::Parameters&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, const WebKit::Plugin::Parameters&> m_arguments; +}; + +class RunJavaScriptAlert { +public: + typedef std::tuple<uint64_t, String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("RunJavaScriptAlert"); } + static const bool isSync = true; + + typedef IPC::Arguments<> Reply; + RunJavaScriptAlert(uint64_t frameID, const String& message) + : m_arguments(frameID, message) + { + } + + const std::tuple<uint64_t, const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, const String&> m_arguments; +}; + +class GetPlugins { +public: + typedef std::tuple<bool> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("GetPlugins"); } + static const bool isSync = true; + + typedef IPC::Arguments<Vector<WebCore::PluginInfo>&> Reply; + explicit GetPlugins(bool refresh) + : m_arguments(refresh) + { + } + + const std::tuple<bool>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<bool> m_arguments; +}; + +class GetPluginProcessConnection { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("GetPluginProcessConnection"); } + static const bool isSync = true; + + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::Encoder>); + ~DelayedReply(); + + bool send(const IPC::Connection::Handle& connectionHandle); + + private: + RefPtr<IPC::Connection> m_connection; + std::unique_ptr<IPC::Encoder> m_encoder; + }; + + typedef IPC::Arguments<IPC::Connection::Handle&> Reply; + explicit GetPluginProcessConnection(const String& pluginPath) + : m_arguments(pluginPath) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; + +class TestMultipleAttributes { +public: + typedef std::tuple<> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TestMultipleAttributes"); } + static const bool isSync = true; + + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::Encoder>); + ~DelayedReply(); + + bool send(); + + private: + RefPtr<IPC::Connection> m_connection; + std::unique_ptr<IPC::Encoder> m_encoder; + }; + + typedef IPC::Arguments<> Reply; + const std::tuple<>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<> m_arguments; +}; + +class TestParameterAttributes { +public: + typedef std::tuple<uint64_t, double, double> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TestParameterAttributes"); } + static const bool isSync = false; + + TestParameterAttributes(uint64_t foo, double bar, double baz) + : m_arguments(foo, bar, baz) + { + } + + const std::tuple<uint64_t, double, double>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, double, double> m_arguments; +}; + +class TemplateTest { +public: + typedef std::tuple<HashMap<String, std::pair<String, uint64_t>>> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TemplateTest"); } + static const bool isSync = false; + + explicit TemplateTest(const HashMap<String, std::pair<String, uint64_t>>& a) + : m_arguments(a) + { + } + + const std::tuple<const HashMap<String, std::pair<String, uint64_t>>&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const HashMap<String, std::pair<String, uint64_t>>&> m_arguments; +}; + +class SetVideoLayerID { +public: + typedef std::tuple<WebCore::GraphicsLayer::PlatformLayerID> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SetVideoLayerID"); } + static const bool isSync = false; + + explicit SetVideoLayerID(const WebCore::GraphicsLayer::PlatformLayerID& videoLayerID) + : m_arguments(videoLayerID) + { + } + + const std::tuple<const WebCore::GraphicsLayer::PlatformLayerID&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebCore::GraphicsLayer::PlatformLayerID&> m_arguments; +}; + +#if PLATFORM(MAC) +class DidCreateWebProcessConnection { +public: + typedef std::tuple<IPC::MachPort> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DidCreateWebProcessConnection"); } + static const bool isSync = false; + + explicit DidCreateWebProcessConnection(const IPC::MachPort& connectionIdentifier) + : m_arguments(connectionIdentifier) + { + } + + const std::tuple<const IPC::MachPort&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::MachPort&> m_arguments; +}; +#endif + +#if PLATFORM(MAC) +class InterpretKeyEvent { +public: + typedef std::tuple<uint32_t> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("InterpretKeyEvent"); } + static const bool isSync = true; + + typedef IPC::Arguments<Vector<WebCore::KeypressCommand>&> Reply; + explicit InterpretKeyEvent(uint32_t type) + : m_arguments(type) + { + } + + const std::tuple<uint32_t>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint32_t> m_arguments; +}; +#endif + +#if ENABLE(DEPRECATED_FEATURE) +class DeprecatedOperation { +public: + typedef std::tuple<IPC::DummyType> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DeprecatedOperation"); } + static const bool isSync = false; + + explicit DeprecatedOperation(const IPC::DummyType& dummy) + : m_arguments(dummy) + { + } + + const std::tuple<const IPC::DummyType&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::DummyType&> m_arguments; +}; +#endif + +#if ENABLE(EXPERIMENTAL_FEATURE) +class ExperimentalOperation { +public: + typedef std::tuple<IPC::DummyType> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("ExperimentalOperation"); } + static const bool isSync = false; + + explicit ExperimentalOperation(const IPC::DummyType& dummy) + : m_arguments(dummy) + { + } + + const std::tuple<const IPC::DummyType&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::DummyType&> m_arguments; +}; +#endif + +} // namespace WebPage +} // namespace Messages + +#endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#endif // WebPageMessages_h diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp new file mode 100644 index 000000000..b4a149690 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2010 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" + +#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#include "WebPage.h" + +#include "ArgumentCoders.h" +#include "Connection.h" +#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE) +#include "DummyType.h" +#endif +#include "HandleMessage.h" +#if PLATFORM(MAC) +#include "MachPort.h" +#endif +#include "Decoder.h" +#include "Plugin.h" +#include "WebCoreArgumentCoders.h" +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +#include "WebEvent.h" +#endif +#include "WebPageMessages.h" +#include "WebPreferencesStore.h" +#include <WebCore/GraphicsLayer.h> +#if PLATFORM(MAC) +#include <WebCore/KeyboardEvent.h> +#endif +#include <WebCore/PluginData.h> +#include <utility> +#include <wtf/HashMap.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + +namespace Messages { + +namespace WebPage { + +GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::Encoder> encoder) + : m_connection(connection) + , m_encoder(WTFMove(encoder)) +{ +} + +GetPluginProcessConnection::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool GetPluginProcessConnection::DelayedReply::send(const IPC::Connection::Handle& connectionHandle) +{ + ASSERT(m_encoder); + *m_encoder << connectionHandle; + bool _result = m_connection->sendSyncReply(WTFMove(m_encoder)); + m_connection = nullptr; + return _result; +} + +TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::Encoder> encoder) + : m_connection(connection) + , m_encoder(WTFMove(encoder)) +{ +} + +TestMultipleAttributes::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool TestMultipleAttributes::DelayedReply::send() +{ + ASSERT(m_encoder); + bool _result = m_connection->sendSyncReply(WTFMove(m_encoder)); + m_connection = nullptr; + return _result; +} + +} // namespace WebPage + +} // namespace Messages + +namespace WebKit { + +void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::Decoder& decoder) +{ + if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { + IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); + return; + } +#if ENABLE(TOUCH_EVENTS) + if (decoder.messageName() == Messages::WebPage::LoadSomething::name()) { + IPC::handleMessage<Messages::WebPage::LoadSomething>(decoder, this, &WebPage::loadSomething); + return; + } +#endif +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) + if (decoder.messageName() == Messages::WebPage::TouchEvent::name()) { + IPC::handleMessage<Messages::WebPage::TouchEvent>(decoder, this, &WebPage::touchEvent); + return; + } +#endif +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) + if (decoder.messageName() == Messages::WebPage::AddEvent::name()) { + IPC::handleMessage<Messages::WebPage::AddEvent>(decoder, this, &WebPage::addEvent); + return; + } +#endif +#if ENABLE(TOUCH_EVENTS) + if (decoder.messageName() == Messages::WebPage::LoadSomethingElse::name()) { + IPC::handleMessage<Messages::WebPage::LoadSomethingElse>(decoder, this, &WebPage::loadSomethingElse); + return; + } +#endif + if (decoder.messageName() == Messages::WebPage::DidReceivePolicyDecision::name()) { + IPC::handleMessage<Messages::WebPage::DidReceivePolicyDecision>(decoder, this, &WebPage::didReceivePolicyDecision); + return; + } + if (decoder.messageName() == Messages::WebPage::Close::name()) { + IPC::handleMessage<Messages::WebPage::Close>(decoder, this, &WebPage::close); + return; + } + if (decoder.messageName() == Messages::WebPage::PreferencesDidChange::name()) { + IPC::handleMessage<Messages::WebPage::PreferencesDidChange>(decoder, this, &WebPage::preferencesDidChange); + return; + } + if (decoder.messageName() == Messages::WebPage::SendDoubleAndFloat::name()) { + IPC::handleMessage<Messages::WebPage::SendDoubleAndFloat>(decoder, this, &WebPage::sendDoubleAndFloat); + return; + } + if (decoder.messageName() == Messages::WebPage::SendInts::name()) { + IPC::handleMessage<Messages::WebPage::SendInts>(decoder, this, &WebPage::sendInts); + return; + } + if (decoder.messageName() == Messages::WebPage::TestParameterAttributes::name()) { + IPC::handleMessage<Messages::WebPage::TestParameterAttributes>(decoder, this, &WebPage::testParameterAttributes); + return; + } + if (decoder.messageName() == Messages::WebPage::TemplateTest::name()) { + IPC::handleMessage<Messages::WebPage::TemplateTest>(decoder, this, &WebPage::templateTest); + return; + } + if (decoder.messageName() == Messages::WebPage::SetVideoLayerID::name()) { + IPC::handleMessage<Messages::WebPage::SetVideoLayerID>(decoder, this, &WebPage::setVideoLayerID); + return; + } +#if PLATFORM(MAC) + if (decoder.messageName() == Messages::WebPage::DidCreateWebProcessConnection::name()) { + IPC::handleMessage<Messages::WebPage::DidCreateWebProcessConnection>(decoder, this, &WebPage::didCreateWebProcessConnection); + return; + } +#endif +#if ENABLE(DEPRECATED_FEATURE) + if (decoder.messageName() == Messages::WebPage::DeprecatedOperation::name()) { + IPC::handleMessage<Messages::WebPage::DeprecatedOperation>(decoder, this, &WebPage::deprecatedOperation); + return; + } +#endif +#if ENABLE(EXPERIMENTAL_FEATURE) + if (decoder.messageName() == Messages::WebPage::ExperimentalOperation::name()) { + IPC::handleMessage<Messages::WebPage::ExperimentalOperation>(decoder, this, &WebPage::experimentalOperation); + return; + } +#endif + UNUSED_PARAM(connection); + UNUSED_PARAM(decoder); + ASSERT_NOT_REACHED(); +} + +void WebPage::didReceiveSyncMessage(IPC::Connection* connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) +{ + if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) { + IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin); + return; + } + if (decoder.messageName() == Messages::WebPage::RunJavaScriptAlert::name()) { + IPC::handleMessage<Messages::WebPage::RunJavaScriptAlert>(decoder, *replyEncoder, this, &WebPage::runJavaScriptAlert); + return; + } + if (decoder.messageName() == Messages::WebPage::GetPlugins::name()) { + IPC::handleMessage<Messages::WebPage::GetPlugins>(decoder, *replyEncoder, this, &WebPage::getPlugins); + return; + } + if (decoder.messageName() == Messages::WebPage::GetPluginProcessConnection::name()) { + IPC::handleMessageDelayed<Messages::WebPage::GetPluginProcessConnection>(connection, decoder, replyEncoder, this, &WebPage::getPluginProcessConnection); + return; + } + if (decoder.messageName() == Messages::WebPage::TestMultipleAttributes::name()) { + IPC::handleMessageDelayed<Messages::WebPage::TestMultipleAttributes>(connection, decoder, replyEncoder, this, &WebPage::testMultipleAttributes); + return; + } +#if PLATFORM(MAC) + if (decoder.messageName() == Messages::WebPage::InterpretKeyEvent::name()) { + IPC::handleMessage<Messages::WebPage::InterpretKeyEvent>(decoder, *replyEncoder, this, &WebPage::interpretKeyEvent); + return; + } +#endif + UNUSED_PARAM(connection); + UNUSED_PARAM(decoder); + UNUSED_PARAM(replyEncoder); + ASSERT_NOT_REACHED(); +} + +} // namespace WebKit + +#endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp new file mode 100644 index 000000000..5fe092505 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 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 "WebPage.h" + +#include "ArgumentCoders.h" +#include "HandleMessage.h" +#include "MessageDecoder.h" +#include "WebPageMessages.h" +#include <wtf/text/WTFString.h> + +namespace WebKit { + +void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::Decoder& decoder) +{ + if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { + IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); + return; + } + WebPageBase::didReceiveMessage(connection, decoder); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Scripts/webkit/Messages-expected.h b/Source/WebKit2/Scripts/webkit/Messages-expected.h new file mode 100644 index 000000000..d0c7625ff --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/Messages-expected.h @@ -0,0 +1,590 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef WebPageMessages_h +#define WebPageMessages_h + +#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#include "Arguments.h" +#include "Connection.h" +#include "Encoder.h" +#include "Plugin.h" +#include "StringReference.h" +#include <WebCore/GraphicsLayer.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/PluginData.h> +#include <utility> +#include <wtf/HashMap.h> +#include <wtf/ThreadSafeRefCounted.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + +namespace IPC { + class Connection; + class DummyType; + class MachPort; +} + +namespace WTF { + class String; +} + +namespace WebKit { + struct WebPreferencesStore; + class WebTouchEvent; +} + +namespace Messages { +namespace WebPage { + +static inline IPC::StringReference messageReceiverName() +{ + return IPC::StringReference("WebPage"); +} + +class LoadURL { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadURL"); } + static const bool isSync = false; + + explicit LoadURL(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; + +#if ENABLE(TOUCH_EVENTS) +class LoadSomething { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadSomething"); } + static const bool isSync = false; + + explicit LoadSomething(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; +#endif + +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +class TouchEvent { +public: + typedef std::tuple<WebKit::WebTouchEvent> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TouchEvent"); } + static const bool isSync = false; + + explicit TouchEvent(const WebKit::WebTouchEvent& event) + : m_arguments(event) + { + } + + const std::tuple<const WebKit::WebTouchEvent&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebTouchEvent&> m_arguments; +}; +#endif + +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) +class AddEvent { +public: + typedef std::tuple<WebKit::WebTouchEvent> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("AddEvent"); } + static const bool isSync = false; + + explicit AddEvent(const WebKit::WebTouchEvent& event) + : m_arguments(event) + { + } + + const std::tuple<const WebKit::WebTouchEvent&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebTouchEvent&> m_arguments; +}; +#endif + +#if ENABLE(TOUCH_EVENTS) +class LoadSomethingElse { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadSomethingElse"); } + static const bool isSync = false; + + explicit LoadSomethingElse(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; +#endif + +class DidReceivePolicyDecision { +public: + typedef std::tuple<uint64_t, uint64_t, uint32_t> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DidReceivePolicyDecision"); } + static const bool isSync = false; + + DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) + : m_arguments(frameID, listenerID, policyAction) + { + } + + const std::tuple<uint64_t, uint64_t, uint32_t>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, uint64_t, uint32_t> m_arguments; +}; + +class Close { +public: + typedef std::tuple<> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("Close"); } + static const bool isSync = false; + + const std::tuple<>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<> m_arguments; +}; + +class PreferencesDidChange { +public: + typedef std::tuple<WebKit::WebPreferencesStore> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("PreferencesDidChange"); } + static const bool isSync = false; + + explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store) + : m_arguments(store) + { + } + + const std::tuple<const WebKit::WebPreferencesStore&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebKit::WebPreferencesStore&> m_arguments; +}; + +class SendDoubleAndFloat { +public: + typedef std::tuple<double, float> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SendDoubleAndFloat"); } + static const bool isSync = false; + + SendDoubleAndFloat(double d, float f) + : m_arguments(d, f) + { + } + + const std::tuple<double, float>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<double, float> m_arguments; +}; + +class SendInts { +public: + typedef std::tuple<Vector<uint64_t>, Vector<Vector<uint64_t>>> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SendInts"); } + static const bool isSync = false; + + SendInts(const Vector<uint64_t>& ints, const Vector<Vector<uint64_t>>& intVectors) + : m_arguments(ints, intVectors) + { + } + + const std::tuple<const Vector<uint64_t>&, const Vector<Vector<uint64_t>>&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const Vector<uint64_t>&, const Vector<Vector<uint64_t>>&> m_arguments; +}; + +class CreatePlugin { +public: + typedef std::tuple<uint64_t, WebKit::Plugin::Parameters> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("CreatePlugin"); } + static const bool isSync = true; + + typedef IPC::Arguments<bool&> Reply; + CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters) + : m_arguments(pluginInstanceID, parameters) + { + } + + const std::tuple<uint64_t, const WebKit::Plugin::Parameters&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, const WebKit::Plugin::Parameters&> m_arguments; +}; + +class RunJavaScriptAlert { +public: + typedef std::tuple<uint64_t, String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("RunJavaScriptAlert"); } + static const bool isSync = true; + + typedef IPC::Arguments<> Reply; + RunJavaScriptAlert(uint64_t frameID, const String& message) + : m_arguments(frameID, message) + { + } + + const std::tuple<uint64_t, const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, const String&> m_arguments; +}; + +class GetPlugins { +public: + typedef std::tuple<bool> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("GetPlugins"); } + static const bool isSync = true; + + typedef IPC::Arguments<Vector<WebCore::PluginInfo>&> Reply; + explicit GetPlugins(bool refresh) + : m_arguments(refresh) + { + } + + const std::tuple<bool>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<bool> m_arguments; +}; + +class GetPluginProcessConnection { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("GetPluginProcessConnection"); } + static const bool isSync = true; + + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::Encoder>); + ~DelayedReply(); + + bool send(const IPC::Connection::Handle& connectionHandle); + + private: + RefPtr<IPC::Connection> m_connection; + std::unique_ptr<IPC::Encoder> m_encoder; + }; + + typedef IPC::Arguments<IPC::Connection::Handle&> Reply; + explicit GetPluginProcessConnection(const String& pluginPath) + : m_arguments(pluginPath) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; + +class TestMultipleAttributes { +public: + typedef std::tuple<> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TestMultipleAttributes"); } + static const bool isSync = true; + + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::Encoder>); + ~DelayedReply(); + + bool send(); + + private: + RefPtr<IPC::Connection> m_connection; + std::unique_ptr<IPC::Encoder> m_encoder; + }; + + typedef IPC::Arguments<> Reply; + const std::tuple<>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<> m_arguments; +}; + +class TestParameterAttributes { +public: + typedef std::tuple<uint64_t, double, double> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TestParameterAttributes"); } + static const bool isSync = false; + + TestParameterAttributes(uint64_t foo, double bar, double baz) + : m_arguments(foo, bar, baz) + { + } + + const std::tuple<uint64_t, double, double>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint64_t, double, double> m_arguments; +}; + +class TemplateTest { +public: + typedef std::tuple<HashMap<String, std::pair<String, uint64_t>>> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("TemplateTest"); } + static const bool isSync = false; + + explicit TemplateTest(const HashMap<String, std::pair<String, uint64_t>>& a) + : m_arguments(a) + { + } + + const std::tuple<const HashMap<String, std::pair<String, uint64_t>>&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const HashMap<String, std::pair<String, uint64_t>>&> m_arguments; +}; + +class SetVideoLayerID { +public: + typedef std::tuple<WebCore::GraphicsLayer::PlatformLayerID> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("SetVideoLayerID"); } + static const bool isSync = false; + + explicit SetVideoLayerID(const WebCore::GraphicsLayer::PlatformLayerID& videoLayerID) + : m_arguments(videoLayerID) + { + } + + const std::tuple<const WebCore::GraphicsLayer::PlatformLayerID&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const WebCore::GraphicsLayer::PlatformLayerID&> m_arguments; +}; + +#if PLATFORM(MAC) +class DidCreateWebProcessConnection { +public: + typedef std::tuple<IPC::MachPort> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DidCreateWebProcessConnection"); } + static const bool isSync = false; + + explicit DidCreateWebProcessConnection(const IPC::MachPort& connectionIdentifier) + : m_arguments(connectionIdentifier) + { + } + + const std::tuple<const IPC::MachPort&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::MachPort&> m_arguments; +}; +#endif + +#if PLATFORM(MAC) +class InterpretKeyEvent { +public: + typedef std::tuple<uint32_t> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("InterpretKeyEvent"); } + static const bool isSync = true; + + typedef IPC::Arguments<Vector<WebCore::KeypressCommand>&> Reply; + explicit InterpretKeyEvent(uint32_t type) + : m_arguments(type) + { + } + + const std::tuple<uint32_t>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<uint32_t> m_arguments; +}; +#endif + +#if ENABLE(DEPRECATED_FEATURE) +class DeprecatedOperation { +public: + typedef std::tuple<IPC::DummyType> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("DeprecatedOperation"); } + static const bool isSync = false; + + explicit DeprecatedOperation(const IPC::DummyType& dummy) + : m_arguments(dummy) + { + } + + const std::tuple<const IPC::DummyType&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::DummyType&> m_arguments; +}; +#endif + +#if ENABLE(EXPERIMENTAL_FEATURE) +class ExperimentalOperation { +public: + typedef std::tuple<IPC::DummyType> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("ExperimentalOperation"); } + static const bool isSync = false; + + explicit ExperimentalOperation(const IPC::DummyType& dummy) + : m_arguments(dummy) + { + } + + const std::tuple<const IPC::DummyType&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const IPC::DummyType&> m_arguments; +}; +#endif + +} // namespace WebPage +} // namespace Messages + +#endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) + +#endif // WebPageMessages_h diff --git a/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h new file mode 100644 index 000000000..9b353a040 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef WebPageMessages_h +#define WebPageMessages_h + +#include "Arguments.h" +#include "MessageEncoder.h" +#include "StringReference.h" + +namespace WTF { + class String; +} + +namespace Messages { +namespace WebPage { + +static inline IPC::StringReference messageReceiverName() +{ + return IPC::StringReference("WebPage"); +} + +class LoadURL { +public: + typedef std::tuple<String> DecodeType; + + static IPC::StringReference receiverName() { return messageReceiverName(); } + static IPC::StringReference name() { return IPC::StringReference("LoadURL"); } + static const bool isSync = false; + + explicit LoadURL(const String& url) + : m_arguments(url) + { + } + + const std::tuple<const String&>& arguments() const + { + return m_arguments; + } + +private: + std::tuple<const String&> m_arguments; +}; + +} // namespace WebPage +} // namespace Messages + +#endif // WebPageMessages_h diff --git a/Source/WebKit2/Scripts/webkit/__init__.py b/Source/WebKit2/Scripts/webkit/__init__.py new file mode 100644 index 000000000..27e3fc3b1 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/__init__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2010 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. + +# Required for Python to search this directory for module files diff --git a/Source/WebKit2/Scripts/webkit/messages.py b/Source/WebKit2/Scripts/webkit/messages.py new file mode 100644 index 000000000..228731f08 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/messages.py @@ -0,0 +1,555 @@ +# Copyright (C) 2010, 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. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import collections +import re +import sys +from webkit import parser + +WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection' +LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver' +DELAYED_ATTRIBUTE = 'Delayed' + +_license_header = """/* + * Copyright (C) 2010 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. + */ + +""" + + +def messages_header_filename(receiver): + return '%sMessages.h' % receiver.name + + +def surround_in_condition(string, condition): + if not condition: + return string + return '#if %s\n%s#endif\n' % (condition, string) + + +def function_parameter_type(type, kind): + # Don't use references for built-in types. + builtin_types = frozenset([ + 'bool', + 'float', + 'double', + 'uint8_t', + 'uint16_t', + 'uint32_t', + 'uint64_t', + 'int8_t', + 'int16_t', + 'int32_t', + 'int64_t', + ]) + + if type in builtin_types: + return type + + if kind == 'enum': + return type + + return 'const %s&' % type + + +def reply_parameter_type(type): + return '%s&' % type + + +def arguments_type(message): + return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type, parameter.kind) for parameter in message.parameters) + + +def reply_type(message): + return 'std::tuple<%s>' % (', '.join(reply_parameter_type(parameter.type) for parameter in message.reply_parameters)) + + +def message_to_struct_declaration(message): + result = [] + function_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.parameters] + result.append('class %s {\n' % message.name) + result.append('public:\n') + result.append(' typedef %s Arguments;\n' % arguments_type(message)) + result.append('\n') + result.append(' static IPC::StringReference receiverName() { return messageReceiverName(); }\n') + result.append(' static IPC::StringReference name() { return IPC::StringReference("%s"); }\n' % message.name) + result.append(' static const bool isSync = %s;\n' % ('false', 'true')[message.reply_parameters != None]) + result.append('\n') + if message.reply_parameters != None: + if message.has_attribute(DELAYED_ATTRIBUTE): + send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters] + result.append(' struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {\n') + result.append(' DelayedReply(Ref<IPC::Connection>&&, std::unique_ptr<IPC::Encoder>);\n') + result.append(' ~DelayedReply();\n') + result.append('\n') + result.append(' bool send(%s);\n' % ', '.join([' '.join(x) for x in send_parameters])) + result.append('\n') + result.append(' private:\n') + result.append(' RefPtr<IPC::Connection> m_connection;\n') + result.append(' std::unique_ptr<IPC::Encoder> m_encoder;\n') + result.append(' };\n\n') + + result.append(' typedef %s Reply;\n' % reply_type(message)) + + if len(function_parameters): + result.append(' %s%s(%s)' % (len(function_parameters) == 1 and 'explicit ' or '', message.name, ', '.join([' '.join(x) for x in function_parameters]))) + result.append('\n : m_arguments(%s)\n' % ', '.join([x[1] for x in function_parameters])) + result.append(' {\n') + result.append(' }\n\n') + result.append(' const Arguments& arguments() const\n') + result.append(' {\n') + result.append(' return m_arguments;\n') + result.append(' }\n') + result.append('\n') + result.append('private:\n') + result.append(' Arguments m_arguments;\n') + result.append('};\n') + return surround_in_condition(''.join(result), message.condition) + + +def forward_declaration(namespace, kind_and_type): + kind, type = kind_and_type + + qualified_name = '%s::%s' % (namespace, type) + if kind == 'struct': + return 'struct %s' % type + elif kind == 'enum': + return 'enum class %s' % type + else: + return 'class %s' % type + +def forward_declarations_for_namespace(namespace, kind_and_types): + result = [] + result.append('namespace %s {\n' % namespace) + result += [' %s;\n' % forward_declaration(namespace, x) for x in kind_and_types] + result.append('}\n') + return ''.join(result) + + +def forward_declarations_and_headers(receiver): + types_by_namespace = collections.defaultdict(set) + + headers = set([ + '"ArgumentCoders.h"', + ]) + + non_template_wtf_types = frozenset([ + 'String', + ]) + + for message in receiver.messages: + if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE): + headers.add('<wtf/ThreadSafeRefCounted.h>') + types_by_namespace['IPC'].update([('class', 'Connection')]) + + for parameter in receiver.iterparameters(): + kind = parameter.kind + type = parameter.type + + if type.find('<') != -1: + # Don't forward declare class templates. + headers.update(headers_for_type(type)) + continue + + split = type.split('::') + + # Handle WTF types even if the WTF:: prefix is not given + if split[0] in non_template_wtf_types: + split.insert(0, 'WTF') + + if len(split) == 2: + namespace = split[0] + inner_type = split[1] + types_by_namespace[namespace].add((kind, inner_type)) + elif len(split) > 2: + # We probably have a nested struct, which means we can't forward declare it. + # Include its header instead. + headers.update(headers_for_type(type)) + + forward_declarations = '\n'.join([forward_declarations_for_namespace(namespace, types) for (namespace, types) in sorted(types_by_namespace.items())]) + headers = ['#include %s\n' % header for header in sorted(headers)] + + return (forward_declarations, headers) + +def generate_messages_header(file): + receiver = parser.parse(file) + + result = [] + + result.append(_license_header) + + result.append('#pragma once\n') + result.append('\n') + + if receiver.condition: + result.append('#if %s\n\n' % receiver.condition) + + forward_declarations, headers = forward_declarations_and_headers(receiver) + + result += headers + result.append('\n') + + result.append(forward_declarations) + result.append('\n') + + result.append('namespace Messages {\nnamespace %s {\n' % receiver.name) + result.append('\n') + result.append('static inline IPC::StringReference messageReceiverName()\n') + result.append('{\n') + result.append(' return IPC::StringReference("%s");\n' % receiver.name) + result.append('}\n') + result.append('\n') + result.append('\n'.join([message_to_struct_declaration(x) for x in receiver.messages])) + result.append('\n') + result.append('} // namespace %s\n} // namespace Messages\n' % receiver.name) + + if receiver.condition: + result.append('\n#endif // %s\n' % receiver.condition) + + return ''.join(result) + + +def handler_function(receiver, message): + if message.name.find('URL') == 0: + return '%s::%s' % (receiver.name, 'url' + message.name[3:]) + return '%s::%s' % (receiver.name, message.name[0].lower() + message.name[1:]) + + +def async_message_statement(receiver, message): + dispatch_function_args = ['decoder', 'this', '&%s' % handler_function(receiver, message)] + + dispatch_function = 'handleMessage' + + if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE): + dispatch_function_args.insert(0, 'connection') + + result = [] + result.append(' if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name)) + result.append(' IPC::%s<Messages::%s::%s>(%s);\n' % (dispatch_function, receiver.name, message.name, ', '.join(dispatch_function_args))) + result.append(' return;\n') + result.append(' }\n') + return surround_in_condition(''.join(result), message.condition) + + +def sync_message_statement(receiver, message): + dispatch_function = 'handleMessage' + if message.has_attribute(DELAYED_ATTRIBUTE): + dispatch_function += 'Delayed' + + wants_connection = message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(WANTS_CONNECTION_ATTRIBUTE) + + result = [] + result.append(' if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name)) + result.append(' IPC::%s<Messages::%s::%s>(%sdecoder, %sreplyEncoder, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if wants_connection else '', '' if message.has_attribute(DELAYED_ATTRIBUTE) else '*', handler_function(receiver, message))) + result.append(' return;\n') + result.append(' }\n') + return surround_in_condition(''.join(result), message.condition) + + +def class_template_headers(template_string): + template_string = template_string.strip() + + class_template_types = { + 'HashMap': {'headers': ['<wtf/HashMap.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, + 'std::optional': {'headers': ['<wtf/Optional.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, + 'OptionSet': {'headers': ['<wtf/OptionSet.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, + 'Vector': {'headers': ['<wtf/Vector.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, + 'std::pair': {'headers': ['<utility>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, + } + + match = re.match('(?P<template_name>.+?)<(?P<parameter_string>.+)>', template_string) + if not match: + return {'header_infos':[], 'types':[template_string]} + + template_name = match.groupdict()['template_name'] + if template_name not in class_template_types: + sys.stderr.write("Error: no class template type is defined for '%s'\n" % (template_string)) + sys.exit(1) + + header_infos = [class_template_types[template_name]] + types = [] + + for parameter in parser.split_parameters_string(match.groupdict()['parameter_string']): + parameter_header_infos_and_types = class_template_headers(parameter) + + header_infos += parameter_header_infos_and_types['header_infos']; + types += parameter_header_infos_and_types['types'] + + return {'header_infos':header_infos, 'types':types} + + +def argument_coder_headers_for_type(type): + header_infos_and_types = class_template_headers(type) + + special_cases = { + 'String': '"ArgumentCoders.h"', + 'WebKit::ScriptMessageHandlerHandle': '"WebScriptMessageHandler.h"', + } + + headers = [] + for header_info in header_infos_and_types['header_infos']: + headers += header_info['argument_coder_headers'] + + for type in header_infos_and_types['types']: + if type in special_cases: + headers.append(special_cases[type]) + continue + + split = type.split('::') + if len(split) < 2: + continue + if split[0] == 'WebCore': + headers.append('"WebCoreArgumentCoders.h"') + + return headers + +def headers_for_type(type): + header_infos_and_types = class_template_headers(type) + + special_cases = { + 'String': ['<wtf/text/WTFString.h>'], + 'WebCore::CompositionUnderline': ['<WebCore/Editor.h>'], + 'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'], + 'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'], + 'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'], + 'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'], + 'WebCore::Highlight': ['<WebCore/InspectorOverlay.h>'], + 'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'], + 'WebCore::KeypressCommand': ['<WebCore/KeyboardEvent.h>'], + 'WebCore::MediaConstraintsData': ['<WebCore/MediaConstraintsImpl.h>'], + 'WebCore::PasteboardImage': ['<WebCore/Pasteboard.h>'], + 'WebCore::PasteboardWebContent': ['<WebCore/Pasteboard.h>'], + 'WebCore::PluginInfo': ['<WebCore/PluginData.h>'], + 'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'], + 'WebCore::ShouldSample': ['<WebCore/DiagnosticLoggingClient.h>'], + 'WebCore::TextCheckingRequestData': ['<WebCore/TextChecking.h>'], + 'WebCore::TextCheckingResult': ['<WebCore/TextCheckerClient.h>'], + 'WebCore::TextIndicatorData': ['<WebCore/TextIndicator.h>'], + 'WebCore::TextureMapperAnimations': ['<WebCore/TextureMapperAnimation.h>'], + 'WebCore::ViewportAttributes': ['<WebCore/ViewportArguments.h>'], + 'WebCore::SelectionRect': ['"EditorState.h"'], + 'WebKit::BackForwardListItemState': ['"SessionState.h"'], + 'WebKit::LayerHostingMode': ['"LayerTreeContext.h"'], + 'WebKit::PageState': ['"SessionState.h"'], + 'WebKit::WebGestureEvent': ['"WebEvent.h"'], + 'WebKit::WebKeyboardEvent': ['"WebEvent.h"'], + 'WebKit::WebMouseEvent': ['"WebEvent.h"'], + 'WebKit::WebTouchEvent': ['"WebEvent.h"'], + 'WebKit::WebWheelEvent': ['"WebEvent.h"'], + 'struct WebKit::WebUserScriptData': ['"WebUserContentControllerDataTypes.h"'], + 'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'], + 'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'], + 'std::chrono::system_clock::time_point': ['<chrono>'], + 'WebKit::LayerHostingMode': ['"LayerTreeContext.h"'], + } + + headers = [] + for header_info in header_infos_and_types['header_infos']: + headers += header_info['headers'] + + for type in header_infos_and_types['types']: + if type in special_cases: + headers += special_cases[type] + continue + + # We assume that we must include a header for a type iff it has a scope + # resolution operator (::). + split = type.split('::') + if len(split) < 2: + continue + + if split[0] == 'WebKit' or split[0] == 'IPC': + headers.append('"%s.h"' % split[1]) + else: + headers.append('<%s/%s.h>' % tuple(split[0:2])) + + return headers + +def generate_message_handler(file): + receiver = parser.parse(file) + header_conditions = { + '"%s"' % messages_header_filename(receiver): [None], + '"HandleMessage.h"': [None], + '"Decoder.h"': [None], + } + + type_conditions = {} + for parameter in receiver.iterparameters(): + if not parameter.type in type_conditions: + type_conditions[parameter.type] = [] + + if not parameter.condition in type_conditions[parameter.type]: + type_conditions[parameter.type].append(parameter.condition) + + for parameter in receiver.iterparameters(): + type = parameter.type + conditions = type_conditions[type] + + argument_encoder_headers = argument_coder_headers_for_type(type) + if argument_encoder_headers: + for header in argument_encoder_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].extend(conditions) + + type_headers = headers_for_type(type) + for header in type_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].extend(conditions) + + for message in receiver.messages: + if message.reply_parameters is not None: + for reply_parameter in message.reply_parameters: + type = reply_parameter.type + argument_encoder_headers = argument_coder_headers_for_type(type) + if argument_encoder_headers: + for header in argument_encoder_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].append(message.condition) + + type_headers = headers_for_type(type) + for header in type_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].append(message.condition) + + + result = [] + + result.append(_license_header) + result.append('#include "config.h"\n') + result.append('\n') + + if receiver.condition: + result.append('#if %s\n\n' % receiver.condition) + + result.append('#include "%s.h"\n\n' % receiver.name) + for header in sorted(header_conditions): + if header_conditions[header] and not None in header_conditions[header]: + result.append('#if %s\n' % ' || '.join(set(header_conditions[header]))) + result += ['#include %s\n' % header] + result.append('#endif\n') + else: + result += ['#include %s\n' % header] + result.append('\n') + + sync_delayed_messages = [] + for message in receiver.messages: + if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE): + sync_delayed_messages.append(message) + + if sync_delayed_messages: + result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name) + + for message in sync_delayed_messages: + send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters] + + if message.condition: + result.append('#if %s\n\n' % message.condition) + + result.append('%s::DelayedReply::DelayedReply(Ref<IPC::Connection>&& connection, std::unique_ptr<IPC::Encoder> encoder)\n' % message.name) + result.append(' : m_connection(WTFMove(connection))\n') + result.append(' , m_encoder(WTFMove(encoder))\n') + result.append('{\n') + result.append('}\n') + result.append('\n') + result.append('%s::DelayedReply::~DelayedReply()\n' % message.name) + result.append('{\n') + result.append(' ASSERT(!m_connection);\n') + result.append('}\n') + result.append('\n') + result.append('bool %s::DelayedReply::send(%s)\n' % (message.name, ', '.join([' '.join(x) for x in send_parameters]))) + result.append('{\n') + result.append(' ASSERT(m_encoder);\n') + result += [' *m_encoder << %s;\n' % x.name for x in message.reply_parameters] + result.append(' bool _result = m_connection->sendSyncReply(WTFMove(m_encoder));\n') + result.append(' m_connection = nullptr;\n') + result.append(' return _result;\n') + result.append('}\n') + result.append('\n') + + if message.condition: + result.append('#endif\n\n') + + result.append('} // namespace %s\n\n} // namespace Messages\n\n' % receiver.name) + + result.append('namespace WebKit {\n\n') + + async_messages = [] + sync_messages = [] + for message in receiver.messages: + if message.reply_parameters is not None: + sync_messages.append(message) + else: + async_messages.append(message) + + if async_messages: + result.append('void %s::didReceive%sMessage(IPC::Connection& connection, IPC::Decoder& decoder)\n' % (receiver.name, receiver.name if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE) else '')) + result.append('{\n') + result += [async_message_statement(receiver, message) for message in async_messages] + if (receiver.superclass): + result.append(' %s::didReceiveMessage(connection, decoder);\n' % (receiver.superclass)) + else: + result.append(' UNUSED_PARAM(connection);\n') + result.append(' UNUSED_PARAM(decoder);\n') + result.append(' ASSERT_NOT_REACHED();\n') + result.append('}\n') + + if sync_messages: + result.append('\n') + result.append('void %s::didReceiveSync%sMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)\n' % (receiver.name, receiver.name if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE) else '')) + result.append('{\n') + result += [sync_message_statement(receiver, message) for message in sync_messages] + result.append(' UNUSED_PARAM(connection);\n') + result.append(' UNUSED_PARAM(decoder);\n') + result.append(' UNUSED_PARAM(replyEncoder);\n') + result.append(' ASSERT_NOT_REACHED();\n') + result.append('}\n') + + result.append('\n} // namespace WebKit\n') + + if receiver.condition: + result.append('\n#endif // %s\n' % receiver.condition) + + return ''.join(result) diff --git a/Source/WebKit2/Scripts/webkit/messages_unittest.py b/Source/WebKit2/Scripts/webkit/messages_unittest.py new file mode 100644 index 000000000..e12dfd41e --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/messages_unittest.py @@ -0,0 +1,357 @@ +# Copyright (C) 2010 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. + +import os +import unittest +from StringIO import StringIO + +import messages +import parser + +print os.getcwd() + +script_directory = os.path.dirname(os.path.realpath(__file__)) + +with open(os.path.join(script_directory, 'test-messages.in')) as file: + _messages_file_contents = file.read() + +with open(os.path.join(script_directory, 'test-legacy-messages.in')) as file: + _legacy_messages_file_contents = file.read() + +with open(os.path.join(script_directory, 'test-superclass-messages.in')) as file: + _superclass_messages_file_contents = file.read() + + +with open(os.path.join(script_directory, 'Messages-expected.h')) as file: + _expected_receiver_header = file.read() + +with open(os.path.join(script_directory, 'LegacyMessages-expected.h')) as file: + _expected_legacy_receiver_header = file.read() + +with open(os.path.join(script_directory, 'MessagesSuperclass-expected.h')) as file: + _expected_superclass_receiver_header = file.read() + + +with open(os.path.join(script_directory, 'MessageReceiver-expected.cpp')) as file: + _expected_receiver_implementation = file.read() + +with open(os.path.join(script_directory, 'LegacyMessageReceiver-expected.cpp')) as file: + _expected_legacy_receiver_implementation = file.read() + +with open(os.path.join(script_directory, 'MessageReceiverSuperclass-expected.cpp')) as file: + _expected_superclass_receiver_implementation = file.read() + +_expected_results = { + 'name': 'WebPage', + 'conditions': ('(ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND))'), + 'messages': ( + { + 'name': 'LoadURL', + 'parameters': ( + ('String', 'url'), + ), + 'conditions': (None), + }, + { + 'name': 'LoadSomething', + 'parameters': ( + ('String', 'url'), + ), + 'conditions': ('ENABLE(TOUCH_EVENTS)'), + }, + { + 'name': 'TouchEvent', + 'parameters': ( + ('WebKit::WebTouchEvent', 'event'), + ), + 'conditions': ('(ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION))'), + }, + { + 'name': 'AddEvent', + 'parameters': ( + ('WebKit::WebTouchEvent', 'event'), + ), + 'conditions': ('(ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION))'), + }, + { + 'name': 'LoadSomethingElse', + 'parameters': ( + ('String', 'url'), + ), + 'conditions': ('ENABLE(TOUCH_EVENTS)'), + }, + { + 'name': 'DidReceivePolicyDecision', + 'parameters': ( + ('uint64_t', 'frameID'), + ('uint64_t', 'listenerID'), + ('uint32_t', 'policyAction'), + ), + 'conditions': (None), + }, + { + 'name': 'Close', + 'parameters': (), + 'conditions': (None), + }, + { + 'name': 'PreferencesDidChange', + 'parameters': ( + ('WebKit::WebPreferencesStore', 'store'), + ), + 'conditions': (None), + }, + { + 'name': 'SendDoubleAndFloat', + 'parameters': ( + ('double', 'd'), + ('float', 'f'), + ), + 'conditions': (None), + }, + { + 'name': 'SendInts', + 'parameters': ( + ('Vector<uint64_t>', 'ints'), + ('Vector<Vector<uint64_t>>', 'intVectors') + ), + 'conditions': (None), + }, + { + 'name': 'CreatePlugin', + 'parameters': ( + ('uint64_t', 'pluginInstanceID'), + ('WebKit::Plugin::Parameters', 'parameters') + ), + 'reply_parameters': ( + ('bool', 'result'), + ), + 'conditions': (None), + }, + { + 'name': 'RunJavaScriptAlert', + 'parameters': ( + ('uint64_t', 'frameID'), + ('String', 'message') + ), + 'reply_parameters': (), + 'conditions': (None), + }, + { + 'name': 'GetPlugins', + 'parameters': ( + ('bool', 'refresh'), + ), + 'reply_parameters': ( + ('Vector<WebCore::PluginInfo>', 'plugins'), + ), + 'conditions': (None), + }, + { + 'name': 'GetPluginProcessConnection', + 'parameters': ( + ('String', 'pluginPath'), + ), + 'reply_parameters': ( + ('IPC::Connection::Handle', 'connectionHandle'), + ), + 'conditions': (None), + }, + { + 'name': 'TestMultipleAttributes', + 'parameters': ( + ), + 'reply_parameters': ( + ), + 'conditions': (None), + }, + { + 'name': 'TestParameterAttributes', + 'parameters': ( + ('uint64_t', 'foo', ('AttributeOne', 'AttributeTwo')), + ('double', 'bar'), + ('double', 'baz', ('AttributeThree',)), + ), + 'conditions': (None), + }, + { + 'name': 'TemplateTest', + 'parameters': ( + ('HashMap<String, std::pair<String, uint64_t>>', 'a'), + ), + 'conditions': (None), + }, + { + 'name': 'SetVideoLayerID', + 'parameters': ( + ('WebCore::GraphicsLayer::PlatformLayerID', 'videoLayerID'), + ), + 'conditions': (None), + }, + { + 'name': 'DidCreateWebProcessConnection', + 'parameters': ( + ('IPC::MachPort', 'connectionIdentifier'), + ), + 'conditions': ('PLATFORM(MAC)'), + }, + { + 'name': 'InterpretKeyEvent', + 'parameters': ( + ('uint32_t', 'type'), + ), + 'reply_parameters': ( + ('Vector<WebCore::KeypressCommand>', 'commandName'), + ), + 'conditions': ('PLATFORM(MAC)'), + }, + { + 'name': 'DeprecatedOperation', + 'parameters': ( + ('IPC::DummyType', 'dummy'), + ), + 'conditions': ('ENABLE(DEPRECATED_FEATURE)'), + }, + { + 'name': 'ExperimentalOperation', + 'parameters': ( + ('IPC::DummyType', 'dummy'), + ), + 'conditions': ('ENABLE(EXPERIMENTAL_FEATURE)'), + } + ), +} + +_expected_superclass_results = { + 'name': 'WebPage', + 'superclass' : 'WebPageBase', + 'conditions': None, + 'messages': ( + { + 'name': 'LoadURL', + 'parameters': ( + ('String', 'url'), + ), + 'conditions': (None), + }, + ), +} + + +class MessagesTest(unittest.TestCase): + def setUp(self): + self.receiver = parser.parse(StringIO(_messages_file_contents)) + self.legacy_receiver = parser.parse(StringIO(_legacy_messages_file_contents)) + self.superclass_receiver = parser.parse(StringIO(_superclass_messages_file_contents)) + + +class ParsingTest(MessagesTest): + def check_message(self, message, expected_message): + self.assertEquals(message.name, expected_message['name']) + self.assertEquals(len(message.parameters), len(expected_message['parameters'])) + for index, parameter in enumerate(message.parameters): + expected_parameter = expected_message['parameters'][index] + self.assertEquals(parameter.type, expected_parameter[0]) + self.assertEquals(parameter.name, expected_parameter[1]) + if len(expected_parameter) > 2: + self.assertEquals(parameter.attributes, frozenset(expected_parameter[2])) + for attribute in expected_parameter[2]: + self.assertTrue(parameter.has_attribute(attribute)) + else: + self.assertEquals(parameter.attributes, frozenset()) + if message.reply_parameters != None: + for index, parameter in enumerate(message.reply_parameters): + self.assertEquals(parameter.type, expected_message['reply_parameters'][index][0]) + self.assertEquals(parameter.name, expected_message['reply_parameters'][index][1]) + else: + self.assertFalse('reply_parameters' in expected_message) + self.assertEquals(message.condition, expected_message['conditions']) + + def test_receiver(self): + """Receiver should be parsed as expected""" + self.assertEquals(self.receiver.name, _expected_results['name']) + self.assertEquals(self.receiver.condition, _expected_results['conditions']) + self.assertEquals(len(self.receiver.messages), len(_expected_results['messages'])) + for index, message in enumerate(self.receiver.messages): + self.check_message(message, _expected_results['messages'][index]) + + self.assertEquals(self.legacy_receiver.name, _expected_results['name']) + self.assertEquals(self.legacy_receiver.condition, _expected_results['conditions']) + self.assertEquals(len(self.legacy_receiver.messages), len(_expected_results['messages'])) + for index, message in enumerate(self.legacy_receiver.messages): + self.check_message(message, _expected_results['messages'][index]) + + self.assertEquals(self.superclass_receiver.name, _expected_superclass_results['name']) + self.assertEquals(self.superclass_receiver.superclass, _expected_superclass_results['superclass']) + self.assertEquals(len(self.superclass_receiver.messages), len(_expected_superclass_results['messages'])) + for index, message in enumerate(self.superclass_receiver.messages): + self.check_message(message, _expected_superclass_results['messages'][index]) + + + +class GeneratedFileContentsTest(unittest.TestCase): + def assertGeneratedFileContentsEqual(self, first, second): + first_list = first.split('\n') + second_list = second.split('\n') + + for index, first_line in enumerate(first_list): + self.assertEquals(first_line, second_list[index]) + + self.assertEquals(len(first_list), len(second_list)) + + +class HeaderTest(GeneratedFileContentsTest): + def test_header(self): + file_contents = messages.generate_messages_header(StringIO(_messages_file_contents)) + self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_header) + + legacy_file_contents = messages.generate_messages_header(StringIO(_legacy_messages_file_contents)) + self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_header) + + superclass_file_contents = messages.generate_messages_header(StringIO(_superclass_messages_file_contents)) + self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_header) + + +class ReceiverImplementationTest(GeneratedFileContentsTest): + def test_receiver_implementation(self): + file_contents = messages.generate_message_handler(StringIO(_messages_file_contents)) + self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_implementation) + + legacy_file_contents = messages.generate_message_handler(StringIO(_legacy_messages_file_contents)) + self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_implementation) + + superclass_file_contents = messages.generate_message_handler(StringIO(_superclass_messages_file_contents)) + self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_implementation) + + +class UnsupportedPrecompilerDirectiveTest(unittest.TestCase): + def test_error_at_else(self): + with self.assertRaisesRegexp(Exception, r"ERROR: '#else.*' is not supported in the \*\.in files"): + messages.generate_message_handler(StringIO("asd\n#else bla\nfoo")) + + def test_error_at_elif(self): + with self.assertRaisesRegexp(Exception, r"ERROR: '#elif.*' is not supported in the \*\.in files"): + messages.generate_message_handler(StringIO("asd\n#elif bla\nfoo")) + + +if __name__ == '__main__': + unittest.main() diff --git a/Source/WebKit2/Scripts/webkit/model.py b/Source/WebKit2/Scripts/webkit/model.py new file mode 100644 index 000000000..ebf75ccd4 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/model.py @@ -0,0 +1,62 @@ +# Copyright (C) 2010, 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. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import itertools + + +class MessageReceiver(object): + def __init__(self, name, superclass, attributes, messages, condition): + self.name = name + self.superclass = superclass + self.attributes = frozenset(attributes or []) + self.messages = messages + self.condition = condition + + def iterparameters(self): + return itertools.chain((parameter for message in self.messages for parameter in message.parameters), + (reply_parameter for message in self.messages if message.reply_parameters for reply_parameter in message.reply_parameters)) + + def has_attribute(self, attribute): + return attribute in self.attributes + +class Message(object): + def __init__(self, name, parameters, reply_parameters, attributes, condition): + self.name = name + self.parameters = parameters + self.reply_parameters = reply_parameters + self.attributes = frozenset(attributes or []) + self.condition = condition + + def has_attribute(self, attribute): + return attribute in self.attributes + + +class Parameter(object): + def __init__(self, kind, type, name, attributes=None, condition=None): + self.kind = kind + self.type = type + self.name = name + self.attributes = frozenset(attributes or []) + self.condition = condition + + def has_attribute(self, attribute): + return attribute in self.attributes diff --git a/Source/WebKit2/Scripts/webkit/parser.py b/Source/WebKit2/Scripts/webkit/parser.py new file mode 100644 index 000000000..1e4cadee5 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/parser.py @@ -0,0 +1,144 @@ +# Copyright (C) 2010, 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. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import re + +from webkit import model + + +def combine_condition(conditions): + if conditions: + if len(conditions) == 1: + return conditions[0] + else: + return bracket_if_needed(' && '.join(map(bracket_if_needed, conditions))) + else: + return None + + +def bracket_if_needed(condition): + if re.match(r'.*(&&|\|\|).*', condition): + return '(%s)' % condition + else: + return condition + + +def parse(file): + receiver_attributes = None + destination = None + messages = [] + conditions = [] + master_condition = None + superclass = [] + for line in file: + match = re.search(r'messages -> (?P<destination>[A-Za-z_0-9]+) \s*(?::\s*(?P<superclass>.*?) \s*)?(?:(?P<attributes>.*?)\s+)?{', line) + if match: + receiver_attributes = parse_attributes_string(match.group('attributes')) + if match.group('superclass'): + superclass = match.group('superclass') + if conditions: + master_condition = conditions + conditions = [] + destination = match.group('destination') + continue + if line.startswith('#'): + trimmed = line.rstrip() + if line.startswith('#if '): + conditions.append(trimmed[4:]) + elif line.startswith('#endif') and conditions: + conditions.pop() + elif line.startswith('#else') or line.startswith('#elif'): + raise Exception("ERROR: '%s' is not supported in the *.in files" % trimmed) + continue + match = re.search(r'([A-Za-z_0-9]+)\((.*?)\)(?:(?:\s+->\s+)\((.*?)\))?(?:\s+(.*))?', line) + if match: + name, parameters_string, reply_parameters_string, attributes_string = match.groups() + if parameters_string: + parameters = parse_parameters_string(parameters_string) + for parameter in parameters: + parameter.condition = combine_condition(conditions) + else: + parameters = [] + + attributes = parse_attributes_string(attributes_string) + + if reply_parameters_string: + reply_parameters = parse_parameters_string(reply_parameters_string) + for reply_parameter in reply_parameters: + reply_parameter.condition = combine_condition(conditions) + elif reply_parameters_string == '': + reply_parameters = [] + else: + reply_parameters = None + + messages.append(model.Message(name, parameters, reply_parameters, attributes, combine_condition(conditions))) + return model.MessageReceiver(destination, superclass, receiver_attributes, messages, combine_condition(master_condition)) + + +def parse_attributes_string(attributes_string): + if not attributes_string: + return None + return attributes_string.split() + + +def split_parameters_string(parameters_string): + parameters = [] + current_parameter_string = '' + + nest_level = 0 + for character in parameters_string: + if character == ',' and nest_level == 0: + parameters.append(current_parameter_string) + current_parameter_string = '' + continue + + if character == '<': + nest_level += 1 + elif character == '>': + nest_level -= 1 + + current_parameter_string += character + + parameters.append(current_parameter_string) + return parameters + +def parse_parameters_string(parameters_string): + parameters = [] + + for parameter_string in split_parameters_string(parameters_string): + match = re.search(r'\s*(?:\[(?P<attributes>.*?)\]\s+)?(?P<type_and_name>.*)', parameter_string) + attributes_string, type_and_name_string = match.group('attributes', 'type_and_name') + + split = type_and_name_string.rsplit(' ', 1) + parameter_kind = 'class' + if split[0].startswith('struct '): + parameter_kind = 'struct' + split[0] = split[0][7:] + elif split[0].startswith('enum '): + parameter_kind = 'enum' + split[0] = split[0][5:] + + parameter_type = split[0] + parameter_name = split[1] + + parameters.append(model.Parameter(kind=parameter_kind, type=parameter_type, name=parameter_name, attributes=parse_attributes_string(attributes_string))) + return parameters diff --git a/Source/WebKit2/Scripts/webkit/test-legacy-messages.in b/Source/WebKit2/Scripts/webkit/test-legacy-messages.in new file mode 100644 index 000000000..c91f1a8ff --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/test-legacy-messages.in @@ -0,0 +1,77 @@ +# Copyright (C) 2010 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. + +#if ENABLE(WEBKIT2) +#if NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND + +messages -> WebPage LegacyReceiver { + LoadURL(String url) +#if ENABLE(TOUCH_EVENTS) + LoadSomething(String url) +#if NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION + TouchEvent(WebKit::WebTouchEvent event) +#endif +#if NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION + AddEvent(WebKit::WebTouchEvent event) +#endif + LoadSomethingElse(String url) +#endif + DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) + Close() + + PreferencesDidChange(WebKit::WebPreferencesStore store) + SendDoubleAndFloat(double d, float f) + SendInts(Vector<uint64_t> ints, Vector<Vector<uint64_t>> intVectors) + + CreatePlugin(uint64_t pluginInstanceID, WebKit::Plugin::Parameters parameters) -> (bool result) + RunJavaScriptAlert(uint64_t frameID, String message) -> () + GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins) + GetPluginProcessConnection(String pluginPath) -> (IPC::Connection::Handle connectionHandle) Delayed + + TestMultipleAttributes() -> () WantsConnection Delayed + + TestParameterAttributes([AttributeOne AttributeTwo] uint64_t foo, double bar, [AttributeThree] double baz) + + TemplateTest(HashMap<String, std::pair<String, uint64_t>> a) + + SetVideoLayerID(WebCore::GraphicsLayer::PlatformLayerID videoLayerID) + +#if PLATFORM(MAC) + DidCreateWebProcessConnection(IPC::MachPort connectionIdentifier) +#endif + +#if PLATFORM(MAC) + # Keyboard support + InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName) +#endif + +#if ENABLE(DEPRECATED_FEATURE) + DeprecatedOperation(IPC::DummyType dummy) +#endif + +#if ENABLE(EXPERIMENTAL_FEATURE) + ExperimentalOperation(IPC::DummyType dummy) +#endif +} + +#endif +#endif diff --git a/Source/WebKit2/Scripts/webkit/test-messages.in b/Source/WebKit2/Scripts/webkit/test-messages.in new file mode 100644 index 000000000..7215b764e --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/test-messages.in @@ -0,0 +1,77 @@ +# Copyright (C) 2010 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. + +#if ENABLE(WEBKIT2) +#if NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND + +messages -> WebPage { + LoadURL(String url) +#if ENABLE(TOUCH_EVENTS) + LoadSomething(String url) +#if NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION + TouchEvent(WebKit::WebTouchEvent event) +#endif +#if NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION + AddEvent(WebKit::WebTouchEvent event) +#endif + LoadSomethingElse(String url) +#endif + DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) + Close() + + PreferencesDidChange(WebKit::WebPreferencesStore store) + SendDoubleAndFloat(double d, float f) + SendInts(Vector<uint64_t> ints, Vector<Vector<uint64_t>> intVectors) + + CreatePlugin(uint64_t pluginInstanceID, WebKit::Plugin::Parameters parameters) -> (bool result) + RunJavaScriptAlert(uint64_t frameID, String message) -> () + GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins) + GetPluginProcessConnection(String pluginPath) -> (IPC::Connection::Handle connectionHandle) Delayed + + TestMultipleAttributes() -> () WantsConnection Delayed + + TestParameterAttributes([AttributeOne AttributeTwo] uint64_t foo, double bar, [AttributeThree] double baz) + + TemplateTest(HashMap<String, std::pair<String, uint64_t>> a) + + SetVideoLayerID(WebCore::GraphicsLayer::PlatformLayerID videoLayerID) + +#if PLATFORM(MAC) + DidCreateWebProcessConnection(IPC::MachPort connectionIdentifier) +#endif + +#if PLATFORM(MAC) + # Keyboard support + InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName) +#endif + +#if ENABLE(DEPRECATED_FEATURE) + DeprecatedOperation(IPC::DummyType dummy) +#endif + +#if ENABLE(EXPERIMENTAL_FEATURE) + ExperimentalOperation(IPC::DummyType dummy) +#endif +} + +#endif +#endif diff --git a/Source/WebKit2/Scripts/webkit/test-superclass-messages.in b/Source/WebKit2/Scripts/webkit/test-superclass-messages.in new file mode 100644 index 000000000..c4e8a86f1 --- /dev/null +++ b/Source/WebKit2/Scripts/webkit/test-superclass-messages.in @@ -0,0 +1,25 @@ +# Copyright (C) 2010 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. + +messages -> WebPage : WebPageBase { + LoadURL(String url) +} |