diff options
Diffstat (limited to 'Source/WebKit2/Scripts')
17 files changed, 2417 insertions, 180 deletions
diff --git a/Source/WebKit2/Scripts/generate-forwarding-headers.pl b/Source/WebKit2/Scripts/generate-forwarding-headers.pl index 73675b359..b61db7877 100755 --- a/Source/WebKit2/Scripts/generate-forwarding-headers.pl +++ b/Source/WebKit2/Scripts/generate-forwarding-headers.pl @@ -32,39 +32,49 @@ use File::Find; use File::Basename; use File::Path qw(mkpath); use File::Spec::Functions; +use Getopt::Long; my $srcRoot = realpath(File::Spec->catfile(dirname(abs_path($0)), "../..")); -my $incFromRoot = abs_path($ARGV[0]); -my @platformPrefixes = ("cf", "Cocoa", "CoordinatedGraphics", "curl", "efl", "gtk", "mac", "soup", "win"); -my @frameworks = ("JavaScriptCore", "WebCore", "WebKit2"); +my @platformPrefixes = ("ca", "cf", "cocoa", "Cocoa", "CoordinatedGraphics", "curl", "efl", "gtk", "ios", "mac", "soup", "win"); +my @frameworks = ("JavaScriptCore", "WebCore", "WebKit"); my @skippedPrefixes; my @frameworkHeaders; my $framework; +my $frameworkDirectoryName; my %neededHeaders; +my $verbose = 0; # enable it for debugging purpose -shift; -my $outputDirectory = $ARGV[0]; -shift; -my $platform = $ARGV[0]; +my @incFromRoot; +my $outputDirectory; +my @platform; + +my %options = ( + 'include-path=s' => \@incFromRoot, + 'output=s' => \$outputDirectory, + 'platform=s' => \@platform +); + +GetOptions(%options); foreach my $prefix (@platformPrefixes) { - push(@skippedPrefixes, $prefix) unless ($prefix =~ $platform); + push(@skippedPrefixes, $prefix) if grep($_ =~ "$prefix", @platform) == 0; } foreach (@frameworks) { $framework = $_; + $frameworkDirectoryName = ($framework eq "WebKit") ? "WebKit2" : $framework; @frameworkHeaders = (); %neededHeaders = (); - find(\&collectNeededHeaders, $incFromRoot); - find(\&collectFameworkHeaderPaths, File::Spec->catfile($srcRoot, $framework)); + foreach (@incFromRoot) { find(\&collectNeededHeaders, abs_path($_) ); }; + find(\&collectFrameworkHeaderPaths, File::Spec->catfile($srcRoot, $frameworkDirectoryName)); createForwardingHeadersForFramework(); } sub collectNeededHeaders { my $filePath = $File::Find::name; my $file = $_; - if ($filePath =~ '\.h$|\.cpp$|\.c$|\.mm$') { + if ($filePath =~ '\.h$|\.cpp$|\.c$') { open(FILE, "<$file") or die "Could not open $filePath.\n"; while (<FILE>) { if (m/^#.*<$framework\/(.*\.h)/) { @@ -75,11 +85,11 @@ sub collectNeededHeaders { } } -sub collectFameworkHeaderPaths { +sub collectFrameworkHeaderPaths { my $filePath = $File::Find::name; my $file = $_; if ($filePath =~ '\.h$' && $filePath !~ "ForwardingHeaders" && grep{$file eq $_} keys %neededHeaders) { - my $headerPath = substr($filePath, length(File::Spec->catfile($srcRoot, $framework)) + 1 ); + my $headerPath = substr($filePath, length(File::Spec->catfile($srcRoot, $frameworkDirectoryName)) + 1 ); push(@frameworkHeaders, $headerPath) unless (grep($headerPath =~ "$_/", @skippedPrefixes) || $headerPath =~ "config.h"); } } @@ -90,23 +100,28 @@ sub createForwardingHeadersForFramework { foreach my $header (@frameworkHeaders) { my $headerName = basename($header); - # If we found more headers with the same name, only generate a forwarding header for the current platform - if(grep($_ =~ "/$headerName\$", @frameworkHeaders) == 1 || $header =~ "/$platform/" ) { - my $forwardingHeaderPath = File::Spec->catfile($targetDirectory, $headerName); - my $expectedIncludeStatement = "#include \"$framework/$header\""; - my $foundIncludeStatement = 0; + # If we found more headers with the same name, exit immediately. + my @headers = grep($_ =~ "/$headerName\$", @frameworkHeaders); + if (@headers != 1) { + print("ERROR: Can't create $headerName forwarding header, because there are more headers with the same name:\n"); + foreach (@headers) { print " - $_\n" }; + die(); + } - $foundIncludeStatement = <EXISTING_HEADER> if open(EXISTING_HEADER, "<$forwardingHeaderPath"); - chomp($foundIncludeStatement); + my $forwardingHeaderPath = File::Spec->catfile($targetDirectory, $headerName); + my $expectedIncludeStatement = "#include \"$frameworkDirectoryName/$header\""; + my $foundIncludeStatement = 0; - if (! $foundIncludeStatement || $foundIncludeStatement ne $expectedIncludeStatement) { - print "[Creating forwarding header for $framework/$header]\n"; - open(FORWARDING_HEADER, ">$forwardingHeaderPath") or die "Could not open $forwardingHeaderPath."; - print FORWARDING_HEADER "$expectedIncludeStatement\n"; - close(FORWARDING_HEADER); - } + $foundIncludeStatement = <EXISTING_HEADER> if open(EXISTING_HEADER, "<$forwardingHeaderPath"); + chomp($foundIncludeStatement); - close(EXISTING_HEADER); + if (! $foundIncludeStatement || $foundIncludeStatement ne $expectedIncludeStatement) { + print "[Creating forwarding header for $framework/$header]\n" if $verbose; + open(FORWARDING_HEADER, ">$forwardingHeaderPath") or die "Could not open $forwardingHeaderPath."; + print FORWARDING_HEADER "$expectedIncludeStatement\n"; + close(FORWARDING_HEADER); } + + close(EXISTING_HEADER); } } diff --git a/Source/WebKit2/Scripts/generate-message-receiver.py b/Source/WebKit2/Scripts/generate-message-receiver.py index 8fae2f006..6413a8bf3 100644 --- a/Source/WebKit2/Scripts/generate-message-receiver.py +++ b/Source/WebKit2/Scripts/generate-message-receiver.py @@ -25,7 +25,7 @@ from __future__ import with_statement import sys -import webkit2.messages +import webkit.messages def main(argv=None): @@ -33,8 +33,8 @@ def main(argv=None): argv = sys.argv input_path = argv[1] with open(input_path) as input_file: - # Python 3, change to: print(webkit2.messages.generate_message_handler(input_file), end='') - sys.stdout.write(webkit2.messages.generate_message_handler(input_file)) + # Python 3, change to: print(webkit.messages.generate_message_handler(input_file), end='') + sys.stdout.write(webkit.messages.generate_message_handler(input_file)) return 0 if __name__ == '__main__': diff --git a/Source/WebKit2/Scripts/generate-messages-header.py b/Source/WebKit2/Scripts/generate-messages-header.py index 854f0f0d4..ad73a5283 100644 --- a/Source/WebKit2/Scripts/generate-messages-header.py +++ b/Source/WebKit2/Scripts/generate-messages-header.py @@ -25,7 +25,7 @@ from __future__ import with_statement import sys -import webkit2.messages +import webkit.messages def main(argv=None): @@ -33,8 +33,8 @@ def main(argv=None): argv = sys.argv input_path = argv[1] with open(input_path) as input_file: - # Python 3, change to: print(webkit2.messages.generate_messages_header(input_file), end='') - sys.stdout.write(webkit2.messages.generate_messages_header(input_file)) + # Python 3, change to: print(webkit.messages.generate_messages_header(input_file), end='') + sys.stdout.write(webkit.messages.generate_messages_header(input_file)) return 0 if __name__ == '__main__': 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/webkit2/__init__.py b/Source/WebKit2/Scripts/webkit/__init__.py index 27e3fc3b1..27e3fc3b1 100644 --- a/Source/WebKit2/Scripts/webkit2/__init__.py +++ b/Source/WebKit2/Scripts/webkit/__init__.py diff --git a/Source/WebKit2/Scripts/webkit2/messages.py b/Source/WebKit2/Scripts/webkit/messages.py index 6190eb0cf..228731f08 100644 --- a/Source/WebKit2/Scripts/webkit2/messages.py +++ b/Source/WebKit2/Scripts/webkit/messages.py @@ -23,12 +23,11 @@ import collections import re import sys -from webkit2 import parser +from webkit import parser WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection' LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver' DELAYED_ATTRIBUTE = 'Delayed' -VARIADIC_ATTRIBUTE = 'Variadic' _license_header = """/* * Copyright (C) 2010 Apple Inc. All rights reserved. @@ -67,7 +66,7 @@ def surround_in_condition(string, condition): return '#if %s\n%s#endif\n' % (condition, string) -def function_parameter_type(type): +def function_parameter_type(type, kind): # Don't use references for built-in types. builtin_types = frozenset([ 'bool', @@ -86,6 +85,9 @@ def function_parameter_type(type): if type in builtin_types: return type + if kind == 'enum': + return type + return 'const %s&' % type @@ -93,42 +95,20 @@ def reply_parameter_type(type): return '%s&' % type -def arguments_type_old(parameters, parameter_type_function): - arguments_type = 'IPC::Arguments%d' % len(parameters) - if len(parameters): - arguments_type = '%s<%s>' % (arguments_type, ', '.join(parameter_type_function(parameter.type) for parameter in parameters)) - return arguments_type - - def arguments_type(message): - return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type) for parameter in message.parameters) - -def base_class(message): - return arguments_type(message.parameters, function_parameter_type) + return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type, parameter.kind) for parameter in message.parameters) def reply_type(message): - return arguments_type_old(message.reply_parameters, reply_parameter_type) - - -def decode_type(message): - parameters = message.parameters - - if message.has_attribute(VARIADIC_ATTRIBUTE): - parameters = parameters[:-1] - - return 'std::tuple<%s>' % ', '.join(parameter.type for parameter in parameters) - -def delayed_reply_type(message): - return arguments_type_old(message.reply_parameters, function_parameter_type) + 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.name) for x in message.parameters] + 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 DecodeType;\n' % decode_type(message)) + 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) @@ -136,16 +116,16 @@ def message_to_struct_declaration(message): result.append('\n') if message.reply_parameters != None: if message.has_attribute(DELAYED_ATTRIBUTE): - send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters] + 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(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::MessageEncoder>);\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::MessageEncoder> m_encoder;\n') + result.append(' std::unique_ptr<IPC::Encoder> m_encoder;\n') result.append(' };\n\n') result.append(' typedef %s Reply;\n' % reply_type(message)) @@ -155,89 +135,32 @@ def message_to_struct_declaration(message): 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 %s arguments() const\n' % arguments_type(message)) + 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(' %s m_arguments;\n' % arguments_type(message)) + result.append(' Arguments m_arguments;\n') result.append('};\n') return surround_in_condition(''.join(result), message.condition) -def struct_or_class(namespace, type): - structs = frozenset([ - 'WebCore::Animation', - 'WebCore::EditorCommandsForKeyEvent', - 'WebCore::CompositionUnderline', - 'WebCore::Cookie', - 'WebCore::DragSession', - 'WebCore::FloatPoint3D', - 'WebCore::FileChooserSettings', - 'WebCore::GrammarDetail', - 'WebCore::IDBDatabaseMetadata', - 'WebCore::IDBGetResult', - 'WebCore::IDBIndexMetadata', - 'WebCore::IDBKeyData', - 'WebCore::IDBKeyRangeData', - 'WebCore::IDBObjectStoreMetadata', - 'WebCore::IdentityTransformOperation', - 'WebCore::KeypressCommand', - 'WebCore::Length', - 'WebCore::MatrixTransformOperation', - 'WebCore::Matrix3DTransformOperation', - 'WebCore::NotificationContents', - 'WebCore::PasteboardImage', - 'WebCore::PasteboardWebContent', - 'WebCore::PerspectiveTransformOperation', - 'WebCore::PluginInfo', - 'WebCore::PrintInfo', - 'WebCore::RotateTransformOperation', - 'WebCore::ScaleTransformOperation', - 'WebCore::SkewTransformOperation', - 'WebCore::TimingFunction', - 'WebCore::TransformationMatrix', - 'WebCore::TransformOperation', - 'WebCore::TransformOperations', - 'WebCore::TranslateTransformOperation', - 'WebCore::ViewportArguments', - 'WebCore::ViewportAttributes', - 'WebCore::WindowFeatures', - 'WebKit::AttributedString', - 'WebKit::ColorSpaceData', - 'WebKit::ContextMenuState', - 'WebKit::DatabaseProcessCreationParameters', - 'WebKit::DictionaryPopupInfo', - 'WebKit::DrawingAreaInfo', - 'WebKit::EditorState', - 'WebKit::InteractionInformationAtPosition', - 'WebKit::NavigationActionData', - 'WebKit::NetworkProcessCreationParameters', - 'WebKit::PlatformPopupMenuData', - 'WebKit::PluginCreationParameters', - 'WebKit::PluginProcessCreationParameters', - 'WebKit::PrintInfo', - 'WebKit::SecurityOriginData', - 'WebKit::StatisticsData', - 'WebKit::TextCheckerState', - 'WebKit::WebNavigationDataStore', - 'WebKit::WebPageCreationParameters', - 'WebKit::WebPreferencesStore', - 'WebKit::WebProcessCreationParameters', - 'WebKit::WindowGeometry', - ]) +def forward_declaration(namespace, kind_and_type): + kind, type = kind_and_type qualified_name = '%s::%s' % (namespace, type) - if qualified_name in structs: + if kind == 'struct': return 'struct %s' % type + elif kind == 'enum': + return 'enum class %s' % type + else: + return 'class %s' % type - return 'class %s' % type - -def forward_declarations_for_namespace(namespace, types): +def forward_declarations_for_namespace(namespace, kind_and_types): result = [] result.append('namespace %s {\n' % namespace) - result += [' %s;\n' % struct_or_class(namespace, x) for x in types] + result += [' %s;\n' % forward_declaration(namespace, x) for x in kind_and_types] result.append('}\n') return ''.join(result) @@ -246,9 +169,7 @@ def forward_declarations_and_headers(receiver): types_by_namespace = collections.defaultdict(set) headers = set([ - '"Arguments.h"', - '"MessageEncoder.h"', - '"StringReference.h"', + '"ArgumentCoders.h"', ]) non_template_wtf_types = frozenset([ @@ -258,9 +179,10 @@ def forward_declarations_and_headers(receiver): 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(['Connection']) + types_by_namespace['IPC'].update([('class', 'Connection')]) for parameter in receiver.iterparameters(): + kind = parameter.kind type = parameter.type if type.find('<') != -1: @@ -277,7 +199,7 @@ def forward_declarations_and_headers(receiver): if len(split) == 2: namespace = split[0] inner_type = split[1] - types_by_namespace[namespace].add(inner_type) + 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. @@ -290,14 +212,13 @@ def forward_declarations_and_headers(receiver): def generate_messages_header(file): receiver = parser.parse(file) - header_guard = messages_header_filename(receiver).replace('.', '_') result = [] result.append(_license_header) - result.append('#ifndef %s\n' % header_guard) - result.append('#define %s\n\n' % header_guard) + result.append('#pragma once\n') + result.append('\n') if receiver.condition: result.append('#if %s\n\n' % receiver.condition) @@ -324,8 +245,6 @@ def generate_messages_header(file): if receiver.condition: result.append('\n#endif // %s\n' % receiver.condition) - result.append('\n#endif // %s\n' % header_guard) - return ''.join(result) @@ -339,8 +258,6 @@ def async_message_statement(receiver, message): dispatch_function_args = ['decoder', 'this', '&%s' % handler_function(receiver, message)] dispatch_function = 'handleMessage' - if message.has_attribute(VARIADIC_ATTRIBUTE): - dispatch_function += 'Variadic' if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE): dispatch_function_args.insert(0, 'connection') @@ -357,8 +274,6 @@ def sync_message_statement(receiver, message): dispatch_function = 'handleMessage' if message.has_attribute(DELAYED_ATTRIBUTE): dispatch_function += 'Delayed' - if message.has_attribute(VARIADIC_ATTRIBUTE): - dispatch_function += 'Variadic' wants_connection = message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(WANTS_CONNECTION_ATTRIBUTE) @@ -374,8 +289,10 @@ def class_template_headers(template_string): template_string = template_string.strip() class_template_types = { - 'Vector': {'headers': ['<wtf/Vector.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']}, '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"']}, } @@ -405,8 +322,7 @@ def argument_coder_headers_for_type(type): special_cases = { 'String': '"ArgumentCoders.h"', - 'WebKit::InjectedBundleUserMessageEncoder': '"InjectedBundleUserMessageCoders.h"', - 'WebKit::WebContextUserMessageEncoder': '"WebContextUserMessageCoders.h"', + 'WebKit::ScriptMessageHandlerHandle': '"WebScriptMessageHandler.h"', } headers = [] @@ -432,24 +348,38 @@ def headers_for_type(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::GraphicsLayerAnimations': ['<WebCore/GraphicsLayerAnimation.h>'], + 'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'], + 'WebCore::Highlight': ['<WebCore/InspectorOverlay.h>'], 'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'], 'WebCore::KeypressCommand': ['<WebCore/KeyboardEvent.h>'], - 'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'], - 'WebCore::PluginInfo': ['<WebCore/PluginData.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>'], - 'WebKit::InjectedBundleUserMessageEncoder': [], - 'WebKit::WebContextUserMessageEncoder': [], + '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 = [] @@ -470,7 +400,7 @@ def headers_for_type(type): if split[0] == 'WebKit' or split[0] == 'IPC': headers.append('"%s.h"' % split[1]) else: - headers.append('<%s/%s.h>' % tuple(split)) + headers.append('<%s/%s.h>' % tuple(split[0:2])) return headers @@ -479,7 +409,7 @@ def generate_message_handler(file): header_conditions = { '"%s"' % messages_header_filename(receiver): [None], '"HandleMessage.h"': [None], - '"MessageDecoder.h"': [None], + '"Decoder.h"': [None], } type_conditions = {} @@ -553,14 +483,14 @@ def generate_message_handler(file): 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.name) for x in message.reply_parameters] + 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(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::MessageEncoder> encoder)\n' % message.name) - result.append(' : m_connection(connection)\n') - result.append(' , m_encoder(std::move(encoder))\n') + 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') @@ -573,9 +503,9 @@ def generate_message_handler(file): 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(std::move(m_encoder));\n') + result.append(' bool _result = m_connection->sendSyncReply(WTFMove(m_encoder));\n') result.append(' m_connection = nullptr;\n') - result.append(' return result;\n') + result.append(' return _result;\n') result.append('}\n') result.append('\n') @@ -595,31 +525,25 @@ def generate_message_handler(file): async_messages.append(message) if async_messages: - if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE): - result.append('void %s::didReceive%sMessage(IPC::Connection*, IPC::MessageDecoder& decoder)\n' % (receiver.name, receiver.name)) - else: - result.append('void %s::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)\n' % (receiver.name)) - + 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: - if not receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE): - result.append(' UNUSED_PARAM(connection);\n') + 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') - if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE): - result.append('void %s::didReceiveSync%sMessage(IPC::Connection*%s, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)\n' % (receiver.name, receiver.name, ' connection' if sync_delayed_messages else '')) - else: - result.append('void %s::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)\n' % (receiver.name)) + 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] - if not receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE): - result.append(' UNUSED_PARAM(connection);\n') + 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') 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/webkit2/model.py b/Source/WebKit2/Scripts/webkit/model.py index 153619e45..ebf75ccd4 100644 --- a/Source/WebKit2/Scripts/webkit2/model.py +++ b/Source/WebKit2/Scripts/webkit/model.py @@ -51,7 +51,8 @@ class Message(object): class Parameter(object): - def __init__(self, type, name, attributes=None, condition=None): + def __init__(self, kind, type, name, attributes=None, condition=None): + self.kind = kind self.type = type self.name = name self.attributes = frozenset(attributes or []) diff --git a/Source/WebKit2/Scripts/webkit2/parser.py b/Source/WebKit2/Scripts/webkit/parser.py index 52df5a881..1e4cadee5 100644 --- a/Source/WebKit2/Scripts/webkit2/parser.py +++ b/Source/WebKit2/Scripts/webkit/parser.py @@ -22,7 +22,7 @@ import re -from webkit2 import model +from webkit import model def combine_condition(conditions): @@ -127,6 +127,18 @@ def parse_parameters_string(parameters_string): 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') - parameter_type, parameter_name = type_and_name_string.rsplit(' ', 1) - parameters.append(model.Parameter(type=parameter_type, name=parameter_name, attributes=parse_attributes_string(attributes_string))) + + 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) +} |