Forward declare structs with 'struct' in the message headers
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Sep 2010 18:42:06 +0000 (18:42 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Sep 2010 18:42:06 +0000 (18:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=46925
<rdar://problem/8497940>

Reviewed by Adam Roben.

* Scripts/webkit2/messages.py:
(struct_or_class): New function which given a type and a namespace returns the correct
forward declaration syntax (struct or class).

* Scripts/webkit2/messages_unittest.py:
Update expected results.

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

WebKit2/ChangeLog
WebKit2/Scripts/webkit2/messages.py
WebKit2/Scripts/webkit2/messages_unittest.py

index 3471d5c732b59ac0661792649a39d03b7d0dbed0..08fcb966cf503c98274c9eda84dda501c12ffcad 100644 (file)
@@ -1,3 +1,18 @@
+2010-09-30  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Forward declare structs with 'struct' in the message headers
+        https://bugs.webkit.org/show_bug.cgi?id=46925
+        <rdar://problem/8497940>
+
+        * Scripts/webkit2/messages.py:
+        (struct_or_class): New function which given a type and a namespace returns the correct
+        forward declaration syntax (struct or class).
+
+        * Scripts/webkit2/messages_unittest.py:
+        Update expected results.
+
 2010-09-30  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         Reviewed by Antti Koivisto.
index 3e61902d63826d201ce7b515e46fd7c865e7fe3c..7c6f1bb050c0503c495466cc2239bb232fd270a5 100644 (file)
@@ -198,10 +198,21 @@ def message_to_struct_declaration(message):
     return surround_in_condition(''.join(result), message.condition)
 
 
+def struct_or_class(namespace, type):
+    structs = frozenset([
+        'WebKit::WebPreferencesStore',
+    ])
+
+    qualified_name = '%s::%s' % (namespace, type)
+    if qualified_name in structs:
+        return 'struct %s' % type
+
+    return 'class %s' % type
+
 def forward_declarations_for_namespace(namespace, types):
     result = []
     result.append('namespace %s {\n' % namespace)
-    result += ['    class %s;\n' % x for x in types]
+    result += ['    %s;\n' % struct_or_class(namespace, x) for x in types]
     result.append('}\n')
     return ''.join(result)
 
index ecc289fa2f96d8c8089fb9b6add153512b840376..f4ed5fc825e1e6347ba79381f7762d29cd5e3e2f 100644 (file)
@@ -57,6 +57,7 @@ messages -> WebPage {
     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)
 
@@ -81,7 +82,6 @@ _expected_results = {
                 ('WTF::String', 'url'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments1<const WTF::String&>',
         },
         {
             'name': 'TouchEvent',
@@ -89,7 +89,6 @@ _expected_results = {
                 ('WebKit::WebTouchEvent', 'event'),
             ),
             'condition': 'ENABLE(TOUCH_EVENTS)',
-            'base_class': 'CoreIPC::Arguments1<const WebKit::WebTouchEvent&>',
         },
         {
             'name': 'DidReceivePolicyDecision',
@@ -99,13 +98,18 @@ _expected_results = {
                 ('uint32_t', 'policyAction'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t>',
         },
         {
             'name': 'Close',
             'parameters': (),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments0',
+        },
+        {
+            'name': 'PreferencesDidChange',
+            'parameters': (
+                ('WebKit::WebPreferencesStore', 'store'),
+            ),
+            'condition': None,
         },
         {
             'name': 'SendDoubleAndFloat',
@@ -114,7 +118,6 @@ _expected_results = {
                 ('float', 'f'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments2<double, float>',
         },
         {
             'name': 'SendInts',
@@ -123,7 +126,6 @@ _expected_results = {
                 ('Vector<Vector<uint64_t> >', 'intVectors')
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments1<const Vector<uint64_t>&>',
         },
         {
             'name': 'CreatePlugin',
@@ -135,8 +137,6 @@ _expected_results = {
                 ('bool', 'result'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&>',
-            'reply_base_class': 'CoreIPC::Arguments1<bool>',
         },
         {
             'name': 'RunJavaScriptAlert',
@@ -146,8 +146,6 @@ _expected_results = {
             ),
             'reply_parameters': (),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments2<uint64_t, const WTF::String&>',
-            'reply_base_class': 'CoreIPC::Arguments0',
         },
         {
             'name': 'GetPlugins',
@@ -158,8 +156,6 @@ _expected_results = {
                 ('Vector<WebCore::PluginInfo>', 'plugins'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments1<bool>',
-            'reply_base_class': 'CoreIPC::Arguments1<Vector<WebCore::PluginInfo>&>',
         },
         {
             'name': 'GetPluginProcessConnection',
@@ -170,9 +166,6 @@ _expected_results = {
                 ('CoreIPC::Connection::Handle', 'connectionHandle'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments1<const WTF::String&>',
-            'reply_base_class': 'CoreIPC::Arguments1<CoreIPC::Connection::Handle&>',
-            'delayed_reply_base_class': 'CoreIPC::Arguments1<const CoreIPC::Connection::Handle&>',
         },
         {
             'name': 'DidCreateWebProcessConnection',
@@ -180,7 +173,6 @@ _expected_results = {
                 ('CoreIPC::MachPort', 'connectionIdentifier'),
             ),
             'condition': None,
-            'base_class': 'CoreIPC::Arguments2<double, float>',
         },
     ),
 }
@@ -256,6 +248,7 @@ namespace WTF {
 }
 
 namespace WebKit {
+    struct WebPreferencesStore;
     class WebTouchEvent;
 }
 
@@ -270,6 +263,7 @@ enum Kind {
 #endif
     DidReceivePolicyDecisionID,
     CloseID,
+    PreferencesDidChangeID,
     SendDoubleAndFloatID,
     SendIntsID,
     CreatePluginID,
@@ -309,6 +303,14 @@ struct Close : CoreIPC::Arguments0 {
     static const Kind messageID = CloseID;
 };
 
+struct PreferencesDidChange : CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> {
+    static const Kind messageID = PreferencesDidChangeID;
+    explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store)
+        : CoreIPC::Arguments1<const WebKit::WebPreferencesStore&>(store)
+    {
+    }
+};
+
 struct SendDoubleAndFloat : CoreIPC::Arguments2<double, float> {
     static const Kind messageID = SendDoubleAndFloatID;
     SendDoubleAndFloat(double d, float f)
@@ -421,6 +423,7 @@ _expected_receiver_implementation = """/*
 #include "Plugin.h"
 #include "WebEvent.h"
 #include "WebPageMessages.h"
+#include "WebPreferencesStore.h"
 
 namespace WebKit {
 
@@ -441,6 +444,9 @@ void WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID
     case Messages::WebPage::CloseID:
         CoreIPC::handleMessage<Messages::WebPage::Close>(arguments, this, &WebPage::close);
         return;
+    case Messages::WebPage::PreferencesDidChangeID:
+        CoreIPC::handleMessage<Messages::WebPage::PreferencesDidChange>(arguments, this, &WebPage::preferencesDidChange);
+        return;
     case Messages::WebPage::SendDoubleAndFloatID:
         CoreIPC::handleMessage<Messages::WebPage::SendDoubleAndFloat>(arguments, this, &WebPage::sendDoubleAndFloat);
         return;