Replace use of OwnArrayPtr<Foo> with std::unique_ptr<Foo[]> in Tools
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 16:06:06 +0000 (16:06 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 16:06:06 +0000 (16:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121588

Reviewed by Anders Carlsson.

* DumpRenderTree/TestRunner.cpp:
* ImageDiff/efl/ImageDiff.cpp:
* TestWebKitAPI/JavaScriptTest.cpp:
* TestWebKitAPI/PlatformUtilities.cpp:
* TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
* WebKitTestRunner/StringFunctions.h:
* WebKitTestRunner/TestInvocation.cpp:
* WebKitTestRunner/efl/EventSenderProxyEfl.cpp:
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:

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

12 files changed:
Tools/ChangeLog
Tools/DumpRenderTree/TestRunner.cpp
Tools/ImageDiff/efl/ImageDiff.cpp
Tools/TestWebKitAPI/JavaScriptTest.cpp
Tools/TestWebKitAPI/PlatformUtilities.cpp
Tools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/StringFunctions.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp
Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp

index ea017dc..be672ae 100644 (file)
@@ -1,3 +1,22 @@
+2013-09-18  Sam Weinig  <sam@webkit.org>
+
+        Replace use of OwnArrayPtr<Foo> with std::unique_ptr<Foo[]> in Tools
+        https://bugs.webkit.org/show_bug.cgi?id=121588
+
+        Reviewed by Anders Carlsson.
+
+        * DumpRenderTree/TestRunner.cpp:
+        * ImageDiff/efl/ImageDiff.cpp:
+        * TestWebKitAPI/JavaScriptTest.cpp:
+        * TestWebKitAPI/PlatformUtilities.cpp:
+        * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        * WebKitTestRunner/StringFunctions.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        * WebKitTestRunner/efl/EventSenderProxyEfl.cpp:
+        * WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
+
 2013-09-18  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         W3C Test Import script reformats test HTML
index 26a542a..5c0d03c 100644 (file)
@@ -42,8 +42,8 @@
 #include <wtf/Assertions.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/StdLibExtras.h>
 
 #if PLATFORM(MAC)
 #include <Carbon/Carbon.h>
@@ -337,7 +337,7 @@ static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef
     ASSERT(!*exception);
     
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
-    OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
+    auto encodedAudioDataBuffer = std::make_unique<char[]>(maxLength + 1);
     JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -388,11 +388,11 @@ static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef fun
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
-    OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
+    auto originBuffer = std::make_unique<char[]>(maxLength + 1);
     JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
 
     maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
-    OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
+    auto destinationBuffer = std::make_unique<char[]>(maxLength + 1);
     JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1417,7 +1417,7 @@ static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JS
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
-    OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
+    auto headerBuffer = std::make_unique<char[]>(maxLength + 1);
     JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
index 129b6ca..6520f4e 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/efl/RefPtrEfl.h>
 
 enum PixelComponent {
@@ -119,7 +119,7 @@ static float calculateDifference(Evas_Object* baselineImage, Evas_Object* actual
         return 100; // Completely different.
     }
 
-    OwnArrayPtr<unsigned char> diffBuffer = adoptArrayPtr(new unsigned char[width * height]);
+    auto diffBuffer = std::make_unique<unsigned char[]>(width * height);
     if (!diffBuffer)
         abortWithErrorMessage("could not create difference buffer");
 
@@ -258,7 +258,7 @@ static void resizeEcoreEvasIfNeeded(Evas_Object* image)
 
 static PassRefPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize)
 {
-    OwnArrayPtr<unsigned char> imageBuffer = adoptArrayPtr(new unsigned char[imageSize]);
+    auto imageBuffer = std::make_unique<unsigned char[]>(imageSize);
     if (!imageBuffer)
         abortWithErrorMessage("cannot allocate image");
 
index 85be892..de1848f 100644 (file)
@@ -32,7 +32,7 @@
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <WebKit2/WKSerializedScriptValue.h>
-#include <wtf/OwnArrayPtr.h>
+#include <wtf/StdLibExtras.h>
 
 namespace TestWebKitAPI {
 
@@ -72,7 +72,7 @@ static void javaScriptCallback(WKSerializedScriptValueRef resultSerializedScript
     Util::run(&context.didFinish);
 
     size_t bufferSize = JSStringGetMaximumUTF8CStringSize(context.actualString.get());
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     JSStringGetUTF8CString(context.actualString.get(), buffer.get(), bufferSize);
     
     return compareJSResult(script, buffer.get(), expectedResult);
index e38747c..3f48676 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "PlatformUtilities.h"
 
-#include <wtf/OwnArrayPtr.h>
+#include <wtf/StdLibExtras.h>
 
 namespace TestWebKitAPI {
 namespace Util {
@@ -66,7 +66,7 @@ WKContextRef createContextForInjectedBundleTest(const std::string& testName, WKT
 std::string toSTD(WKStringRef string)
 {
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
     return std::string(buffer.get(), stringLength - 1);
 }
index 1e73adb..6f90dcd 100644 (file)
@@ -30,8 +30,8 @@
 #include <WebKit2/WKStringCF.h>
 #include <WebKit2/WKURLCF.h>
 #include <WebKit2/WKURLResponseNS.h>
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/StdLibExtras.h>
 
 namespace TestWebKitAPI {
 namespace Util {
@@ -82,7 +82,7 @@ std::string toSTD(NSString *string)
         return std::string();
 
     size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     NSUInteger stringLength;
     [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0];
     return std::string(buffer.get(), stringLength);
index 15680a1..f702b5c 100644 (file)
@@ -37,6 +37,7 @@
 #include <WebKit2/WKContextMenuItem.h>
 #include <WebKit2/WKMutableDictionary.h>
 #include <WebKit2/WKNumber.h>
+#include <wtf/StdLibExtras.h>
 
 namespace WTR {
 
@@ -381,7 +382,7 @@ JSValueRef EventSendingController::contextClick()
 
     WKRetainPtr<WKArrayRef> menuEntries = adoptWK(WKBundlePageCopyContextMenuItems(page));
     size_t entriesSize = WKArrayGetSize(menuEntries.get());
-    OwnArrayPtr<JSValueRef> jsValuesArray = adoptArrayPtr(new JSValueRef[entriesSize]);
+    auto jsValuesArray = std::make_unique<JSValueRef[]>(entriesSize);
     for (size_t i = 0; i < entriesSize; ++i) {
         ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(menuEntries.get(), i)) == WKContextMenuItemGetTypeID());
 
index 6824dcb..3f2d038 100644 (file)
@@ -49,7 +49,7 @@
 #include <WebKit2/WebKit2_C.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/HashMap.h>
-#include <wtf/OwnArrayPtr.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -279,7 +279,7 @@ static inline JSValueRef stringArrayToJS(JSContextRef context, WKArrayRef string
 {
     const size_t count = WKArrayGetSize(strings);
 
-    OwnArrayPtr<JSValueRef> jsStringsArray = adoptArrayPtr(new JSValueRef[count]);
+    auto jsStringsArray = std::make_unique<JSValueRef[]>(count);
     for (size_t i = 0; i < count; ++i) {
         WKStringRef stringRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(strings, i));
         JSRetainPtr<JSStringRef> stringJS = toJS(stringRef);
index 7b8fd4e..551d867 100644 (file)
 #include <WebKit2/WKString.h>
 #include <WebKit2/WKStringPrivate.h>
 #include <WebKit2/WKURL.h>
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/Platform.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/Vector.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
 
 namespace WTR {
 
@@ -73,7 +73,7 @@ inline JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)
 inline std::string toSTD(WKStringRef string)
 {
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
     return std::string(buffer.get(), stringLength - 1);
 }
@@ -86,7 +86,7 @@ inline std::string toSTD(const WKRetainPtr<WKStringRef>& string)
 inline WTF::String toWTFString(WKStringRef string)
 {
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
     return WTF::String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1);
 }
index 9842434..7229a84 100644 (file)
@@ -37,8 +37,8 @@
 #include <WebKit2/WKDictionary.h>
 #include <WebKit2/WKInspector.h>
 #include <WebKit2/WKRetainPtr.h>
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 
 #if PLATFORM(MAC)
@@ -81,13 +81,13 @@ static WKURLRef createWKURL(const char* pathOrURL)
 #endif
     static const size_t prefixLength = strlen(filePrefix);
 
-    OwnArrayPtr<char> buffer;
+    std::unique_ptr<char[]> buffer;
     if (isAbsolutePath) {
-        buffer = adoptArrayPtr(new char[prefixLength + length + 1]);
+        buffer = std::make_unique<char[]>(prefixLength + length + 1);
         strcpy(buffer.get(), filePrefix);
         strcpy(buffer.get() + prefixLength, pathOrURL);
     } else {
-        buffer = adoptArrayPtr(new char[prefixLength + PATH_MAX + length + 2]); // 1 for the separator
+        buffer = std::make_unique<char[]>(prefixLength + PATH_MAX + length + 2); // 1 for the separator
         strcpy(buffer.get(), filePrefix);
         if (!getcwd(buffer.get() + prefixLength, PATH_MAX))
             return 0;
index 7664c5a..46d05cd 100644 (file)
@@ -38,7 +38,7 @@
 #include <Ecore.h>
 #include <Ecore_Evas.h>
 #include <unistd.h>
-#include <wtf/OwnArrayPtr.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -191,7 +191,7 @@ static const PassRefPtr<KeyEventInfo> keyPadName(WKStringRef keyRef)
         return adoptRef(new KeyEventInfo("KP_Delete", ""));
 
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
     return adoptRef(new KeyEventInfo(buffer.get(), buffer.get()));
 }
@@ -260,7 +260,7 @@ static const PassRefPtr<KeyEventInfo> keyName(WKStringRef keyRef)
         return adoptRef(new KeyEventInfo("F12", ""));
 
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
     char charCode = buffer.get()[0];
 
index 3732f83..380438c 100644 (file)
@@ -35,9 +35,9 @@
 
 #include "PlatformWebView.h"
 #include "TestController.h"
-#include <wtf/OwnArrayPtr.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/gobject/GOwnPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -266,7 +266,7 @@ int getGDKKeySymForKeyRef(WKStringRef keyRef, unsigned location, guint* modifier
         return GDK_KEY_F12;
 
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
-    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    auto buffer = std::make_unique<char[]>(bufferSize);
     WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
     char charCode = buffer.get()[0];