2011-06-14 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jun 2011 20:20:55 +0000 (20:20 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jun 2011 20:20:55 +0000 (20:20 +0000)
        Reviewed by Sam Weinig.

        Move string ArgumentCoder template specializations out into a .cpp file
        https://bugs.webkit.org/show_bug.cgi?id=62660

        * GNUmakefile.am:
        * Platform/CoreIPC/ArgumentCoders.cpp: Added.
        (CoreIPC::::encode):
        (CoreIPC::::decode):
        * Platform/CoreIPC/ArgumentCoders.h:
        * WebKit2.pro:
        * WebKit2.xcodeproj/project.pbxproj:
        * win/WebKit2.vcproj:

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

Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp [new file with mode: 0644]
Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h
Source/WebKit2/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/win/WebKit2.vcproj

index 9c9b351..ec00dce 100644 (file)
@@ -2,6 +2,22 @@
 
         Reviewed by Sam Weinig.
 
+        Move string ArgumentCoder template specializations out into a .cpp file
+        https://bugs.webkit.org/show_bug.cgi?id=62660
+
+        * GNUmakefile.am:
+        * Platform/CoreIPC/ArgumentCoders.cpp: Added.
+        (CoreIPC::::encode):
+        (CoreIPC::::decode):
+        * Platform/CoreIPC/ArgumentCoders.h:
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+
+2011-06-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
         Remove PluginInfoStore::Plugin typedef
         https://bugs.webkit.org/show_bug.cgi?id=62657
 
index 05f8c62..49eca4f 100644 (file)
@@ -76,6 +76,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit/gtk/webkit/webkiterror.h \
        Source/WebKit/gtk/webkit/webkiterror.cpp \
        Source/WebKit2/Platform/CoreIPC/ArgumentCoder.h \
+       Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp \
        Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h \
        Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp \
        Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h \
diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp
new file mode 100644 (file)
index 0000000..b837a39
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (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 "ArgumentCoders.h"
+
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace CoreIPC {
+
+void ArgumentCoder<AtomicString>::encode(ArgumentEncoder* encoder, const AtomicString& atomicString)
+{
+    encoder->encode(atomicString.string());
+}
+
+bool ArgumentCoder<AtomicString>::decode(ArgumentDecoder* decoder, AtomicString& atomicString)
+{
+    String string;
+    if (!decoder->decode(string))
+        return false;
+
+    atomicString = string;
+    return true;
+}
+
+void ArgumentCoder<CString>::encode(ArgumentEncoder* encoder, const CString& string)
+{
+    // Special case the null string.
+    if (string.isNull()) {
+        encoder->encodeUInt32(std::numeric_limits<uint32_t>::max());
+        return;
+    }
+
+    uint32_t length = string.length();
+    encoder->encode(length);
+    encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.data()), length);
+}
+
+bool ArgumentCoder<CString>::decode(ArgumentDecoder* decoder, CString& result)
+{
+    uint32_t length;
+    if (!decoder->decode(length))
+        return false;
+
+    if (length == std::numeric_limits<uint32_t>::max()) {
+        // This is the null string.
+        result = CString();
+        return true;
+    }
+
+    // Before allocating the string, make sure that the decoder buffer is big enough.
+    if (!decoder->bufferIsLargeEnoughToContain<char>(length)) {
+        decoder->markInvalid();
+        return false;
+    }
+
+    char* buffer;
+    CString string = CString::newUninitialized(length, buffer);
+    if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length))
+        return false;
+
+    result = string;
+    return true;
+}
+
+
+void ArgumentCoder<String>::encode(ArgumentEncoder* encoder, const String& string)
+{
+    // Special case the null string.
+    if (string.isNull()) {
+        encoder->encodeUInt32(std::numeric_limits<uint32_t>::max());
+        return;
+    }
+
+    uint32_t length = string.length();
+    encoder->encode(length);
+    encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar));
+}
+
+bool ArgumentCoder<String>::decode(ArgumentDecoder* decoder, String& result)
+{
+    uint32_t length;
+    if (!decoder->decode(length))
+        return false;
+
+    if (length == std::numeric_limits<uint32_t>::max()) {
+        // This is the null string.
+        result = String();
+        return true;
+    }
+
+    // Before allocating the string, make sure that the decoder buffer is big enough.
+    if (!decoder->bufferIsLargeEnoughToContain<UChar>(length)) {
+        decoder->markInvalid();
+        return false;
+    }
+    
+    UChar* buffer;
+    String string = String::createUninitialized(length, buffer);
+    if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar)))
+        return false;
+    
+    result = string;
+    return true;
+}
+
+} // namespace CoreIPC
index 1cc1a7d..c493d05 100644 (file)
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
 #include <utility>
+#include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/TypeTraits.h>
 #include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
 
@@ -195,105 +193,19 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai
     }
 };
 
-template<> struct ArgumentCoder<CString> {
-    static void encode(ArgumentEncoder* encoder, const CString& string)
-    {
-        // Special case the null string.
-        if (string.isNull()) {
-            encoder->encodeUInt32(std::numeric_limits<uint32_t>::max());
-            return;
-        }
-
-        uint32_t length = string.length();
-        encoder->encode(length);
-        encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.data()), length);
-    }
-
-    static bool decode(ArgumentDecoder* decoder, CString& result)
-    {
-        uint32_t length;
-        if (!decoder->decode(length))
-            return false;
-
-        if (length == std::numeric_limits<uint32_t>::max()) {
-            // This is the null string.
-            result = CString();
-            return true;
-        }
-
-        // Before allocating the string, make sure that the decoder buffer is big enough.
-        if (!decoder->bufferIsLargeEnoughToContain<char>(length)) {
-            decoder->markInvalid();
-            return false;
-        }
-
-        char* buffer;
-        CString string = CString::newUninitialized(length, buffer);
-        if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length))
-            return false;
-
-        result = string;
-        return true;
-    }
+template<> struct ArgumentCoder<AtomicString> {
+    static void encode(ArgumentEncoder*, const AtomicString&);
+    static bool decode(ArgumentDecoder*, AtomicString&);
 };
 
-template<> struct ArgumentCoder<String> {
-    static void encode(ArgumentEncoder* encoder, const String& string)
-    {
-        // Special case the null string.
-        if (string.isNull()) {
-            encoder->encodeUInt32(std::numeric_limits<uint32_t>::max());
-            return;
-        }
-
-        uint32_t length = string.length();
-        encoder->encode(length);
-        encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar));
-    }
-    
-    static bool decode(ArgumentDecoder* decoder, String& result)
-    {
-        uint32_t length;
-        if (!decoder->decode(length))
-            return false;
-
-        if (length == std::numeric_limits<uint32_t>::max()) {
-            // This is the null string.
-            result = String();
-            return true;
-        }
-
-        // Before allocating the string, make sure that the decoder buffer is big enough.
-        if (!decoder->bufferIsLargeEnoughToContain<UChar>(length)) {
-            decoder->markInvalid();
-            return false;
-        }
-        
-        UChar* buffer;
-        String string = String::createUninitialized(length, buffer);
-        if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar)))
-            return false;
-        
-        result = string;
-        return true;
-    }
+template<> struct ArgumentCoder<CString> {
+    static void encode(ArgumentEncoder*, const CString&);
+    static bool decode(ArgumentDecoder*, CString&);
 };
 
-template<> struct ArgumentCoder<AtomicString> {
-    static void encode(ArgumentEncoder* encoder, const AtomicString& atomicString)
-    {
-        encoder->encode(atomicString.string());
-    }
-
-    static bool decode(ArgumentDecoder* decoder, AtomicString& atomicString)
-    {
-        String string;
-        if (!decoder->decode(string))
-            return false;
-
-        atomicString = string;
-        return true;
-    }
+template<> struct ArgumentCoder<String> {
+    static void encode(ArgumentEncoder*, const String&);
+    static bool decode(ArgumentDecoder*, String&);
 };
 
 } // namespace CoreIPC
index 63aeb09..5988c46 100644 (file)
@@ -303,6 +303,7 @@ HEADERS += \
     $$WEBKIT2_GENERATED_HEADERS
 
 SOURCES += \
+    Platform/CoreIPC/ArgumentCoders.cpp \
     Platform/CoreIPC/ArgumentDecoder.cpp \
     Platform/CoreIPC/ArgumentEncoder.cpp \
     Platform/CoreIPC/Attachment.cpp \
index 4c36127..5d070b3 100644 (file)
                1A3979F71332983F00E00300 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
                1A3D610113A7CC2A00F95D4E /* PluginModuleInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3D60FF13A7CC2A00F95D4E /* PluginModuleInfo.cpp */; };
                1A3D610213A7CC2A00F95D4E /* PluginModuleInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3D610013A7CC2A00F95D4E /* PluginModuleInfo.h */; };
+               1A3D610513A7F03A00F95D4E /* ArgumentCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3D610413A7F03A00F95D4E /* ArgumentCoders.cpp */; };
                1A3DD1FD125E59F3004515E6 /* WebFindClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3DD1FC125E59F3004515E6 /* WebFindClient.cpp */; };
                1A3DD202125E5A1F004515E6 /* WebFindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3DD201125E5A1F004515E6 /* WebFindClient.h */; };
                1A3DD206125E5A2F004515E6 /* APIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3DD205125E5A2F004515E6 /* APIClient.h */; };
                1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectionMac.cpp; sourceTree = "<group>"; };
                1A3D60FF13A7CC2A00F95D4E /* PluginModuleInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginModuleInfo.cpp; sourceTree = "<group>"; };
                1A3D610013A7CC2A00F95D4E /* PluginModuleInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginModuleInfo.h; sourceTree = "<group>"; };
+               1A3D610413A7F03A00F95D4E /* ArgumentCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArgumentCoders.cpp; sourceTree = "<group>"; };
                1A3DD1FC125E59F3004515E6 /* WebFindClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFindClient.cpp; sourceTree = "<group>"; };
                1A3DD201125E5A1F004515E6 /* WebFindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFindClient.h; sourceTree = "<group>"; };
                1A3DD205125E5A2F004515E6 /* APIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIClient.h; sourceTree = "<group>"; };
                        children = (
                                BCC56F751159955E001CCAF9 /* mac */,
                                1AEFD27811D16C81008219D3 /* ArgumentCoder.h */,
+                               1A3D610413A7F03A00F95D4E /* ArgumentCoders.cpp */,
                                1AEFD2F611D1807B008219D3 /* ArgumentCoders.h */,
                                BC032D9D10F437D10058C15A /* ArgumentDecoder.cpp */,
                                BC032D9E10F437D10058C15A /* ArgumentDecoder.h */,
                                512DF70A138C26C700A22FC6 /* KeychainAttribute.cpp in Sources */,
                                93C01DAD139AC91700ED51D7 /* CoreIPCClientRunLoop.mm in Sources */,
                                1A3D610113A7CC2A00F95D4E /* PluginModuleInfo.cpp in Sources */,
+                               1A3D610513A7F03A00F95D4E /* ArgumentCoders.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7aa8bc5..9077f96 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\Platform\CoreIPC\ArgumentCoders.cpp"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\Platform\CoreIPC\ArgumentCoders.h"
                                        >
                                </File>