[WebIDL] Remove custom bindings for WebSQL code
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Dec 2016 17:09:04 +0000 (17:09 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Dec 2016 17:09:04 +0000 (17:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166441

Reviewed by Darin Adler.

Source/WebCore:

- Replace custom variant type SQLValue with a type alias of a Variant.
- Use the newly representable SQLValue to remove custom bindings for
  SQLResultSetRowList::item and SQLTransaction::executeSql.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSSQLResultSetRowListCustom.cpp: Removed.
* bindings/js/JSSQLTransactionCustom.cpp: Removed.
* platform/sql/SQLValue.cpp: Removed.
Remove files.

* Modules/webdatabase/SQLResultSetRowList.cpp:
(WebCore::SQLResultSetRowList::length):
(WebCore::SQLResultSetRowList::item):
* Modules/webdatabase/SQLResultSetRowList.h:
* Modules/webdatabase/SQLResultSetRowList.idl:
Sink the implementation of item() into the implementation. Use a
record type to bridge to javascript.

* Modules/webdatabase/SQLStatement.cpp:
(WebCore::SQLStatement::SQLStatement):
* Modules/webdatabase/SQLStatement.h:
Update to take arguments by rvalue reference.

* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::executeSql):
* Modules/webdatabase/SQLTransaction.h:
* Modules/webdatabase/SQLTransaction.idl:
Remove custom annotation, and update signature to match the IDL.

* Modules/webdatabase/SQLTransactionBackend.cpp:
* Modules/webdatabase/SQLTransactionBackend.h:
Remove unneeded #includes of SQLValue.h

* bindings/js/JSDOMConvert.h:
(WebCore::Converter<IDLNull>::convert):
(WebCore::JSConverter<IDLNull>::convert):
Implement conversion for the null type so it can be used in the SQLValue union.

* inspector/InspectorDatabaseAgent.cpp:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::bindValue):
(WebCore::SQLiteStatement::getColumnValue):
* platform/sql/SQLiteStatement.h:
Replace old switch with a WTF::switchOn that operates on the new variant.

* platform/sql/SQLValue.h:
(WebCore::SQLValue::SQLValue): Deleted.
(WebCore::SQLValue::type): Deleted.
Replace implementation with a Variant.

LayoutTests:

* storage/websql/execute-sql-args-expected.txt:
* storage/websql/execute-sql-args.js:
Update test and result to be slightly more strict about functions taking sequences.

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/websql/execute-sql-args-expected.txt
LayoutTests/storage/websql/execute-sql-args.js
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp
Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h
Source/WebCore/Modules/webdatabase/SQLResultSetRowList.idl
Source/WebCore/Modules/webdatabase/SQLStatement.cpp
Source/WebCore/Modules/webdatabase/SQLStatement.h
Source/WebCore/Modules/webdatabase/SQLTransaction.cpp
Source/WebCore/Modules/webdatabase/SQLTransaction.h
Source/WebCore/Modules/webdatabase/SQLTransaction.idl
Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp
Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp [deleted file]
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/platform/sql/SQLValue.cpp [deleted file]
Source/WebCore/platform/sql/SQLValue.h
Source/WebCore/platform/sql/SQLiteStatement.cpp
Source/WebCore/platform/sql/SQLiteStatement.h

index dddb875..d9ff5b3 100644 (file)
@@ -1,3 +1,14 @@
+2016-12-22  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for WebSQL code
+        https://bugs.webkit.org/show_bug.cgi?id=166441
+
+        Reviewed by Darin Adler.
+
+        * storage/websql/execute-sql-args-expected.txt:
+        * storage/websql/execute-sql-args.js:
+        Update test and result to be slightly more strict about functions taking sequences.
+
 2016-12-22  Brent Fulgham  <bfulgham@apple.com>
 
         Nested calls to setDocument can omit firing 'unload' events
index 0e30b4b..0d8a1da 100644 (file)
@@ -6,15 +6,10 @@ PASS. executeSql("", null) did not throw an exception
 PASS. executeSql("", undefined) did not throw an exception
 PASS. executeSql("", []) did not throw an exception
 PASS. executeSql("", [ "arg0" ]) did not throw an exception
-PASS. executeSql("", { }) did not throw an exception
-PASS. executeSql("", { length: 0 }) did not throw an exception
-PASS. executeSql("", { length: 1, 0: "arg0" }) did not throw an exception
 PASS. executeSql("", null, null) did not throw an exception
 PASS. executeSql("", null, undefined) did not throw an exception
-PASS. executeSql("", null, { }) did not throw an exception
 PASS. executeSql("", null, null, null) did not throw an exception
 PASS. executeSql("", null, null, undefined) did not throw an exception
-PASS. executeSql("", null, null, { }) did not throw an exception
 PASS. executeSql() threw an exception as expected.
 PASS. executeSql(throwOnToStringObject) threw an exception as expected.
 PASS. executeSql("", throwOnGetLengthObject) threw an exception as expected.
@@ -22,8 +17,13 @@ PASS. executeSql("", throwOnGetZeroObject) threw an exception as expected.
 PASS. executeSql("", [ throwOnToStringObject ]) threw an exception as expected.
 PASS. executeSql("", 0) threw an exception as expected.
 PASS. executeSql("", "") threw an exception as expected.
+PASS. executeSql("", { }) threw an exception as expected.
+PASS. executeSql("", { length: 0 }) threw an exception as expected.
+PASS. executeSql("", { length: 1, 0: "arg0" }) threw an exception as expected.
 PASS. executeSql("", null, 0) threw an exception as expected.
 PASS. executeSql("", null, "") threw an exception as expected.
 PASS. executeSql("", null, null, 0) threw an exception as expected.
 PASS. executeSql("", null, null, "") threw an exception as expected.
+PASS. executeSql("", null, { }) threw an exception as expected.
+PASS. executeSql("", null, null, { }) threw an exception as expected.
 
index 3fd453b..0d6dbde 100644 (file)
@@ -16,15 +16,10 @@ var expectNoException = [
     '"", undefined',
     '"", []',
     '"", [ "arg0" ]',
-    '"", { }',
-    '"", { length: 0 }',
-    '"", { length: 1, 0: "arg0" }',
     '"", null, null',
     '"", null, undefined',
-    '"", null, { }',
     '"", null, null, null',
     '"", null, null, undefined',
-    '"", null, null, { }',
 ];
 
 var expectException = [
@@ -35,10 +30,15 @@ var expectException = [
     '"", [ throwOnToStringObject ]',
     '"", 0',
     '"", ""',
+    '"", { }',
+    '"", { length: 0 }',
+    '"", { length: 1, 0: "arg0" }',
     '"", null, 0',
     '"", null, ""',
     '"", null, null, 0',
     '"", null, null, ""',
+    '"", null, { }',
+    '"", null, null, { }',
 ];
 
 function tryExecuteSql(transaction, parameterList)
@@ -80,7 +80,6 @@ function runTransactionTests(transaction)
 
 function runTest()
 {
-
     var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
     db.transaction(runTransactionTests);
 }
index 5451bba..679d8eb 100644 (file)
@@ -1172,8 +1172,6 @@ set(WebCore_SOURCES
     bindings/js/JSReadableStreamPrivateConstructors.cpp
     bindings/js/JSReadableStreamSourceCustom.cpp
     bindings/js/JSRTCStatsResponseCustom.cpp
-    bindings/js/JSSQLResultSetRowListCustom.cpp
-    bindings/js/JSSQLTransactionCustom.cpp
     bindings/js/JSSVGPathSegCustom.cpp
     bindings/js/JSStorageCustom.cpp
     bindings/js/JSStyleSheetCustom.cpp
@@ -2373,7 +2371,6 @@ set(WebCore_SOURCES
     platform/network/SocketStreamHandle.cpp
     platform/network/SynchronousLoaderClient.cpp
 
-    platform/sql/SQLValue.cpp
     platform/sql/SQLiteAuthorizer.cpp
     platform/sql/SQLiteDatabase.cpp
     platform/sql/SQLiteDatabaseTracker.cpp
index fc5017d..b6893c1 100644 (file)
@@ -1,3 +1,62 @@
+2016-12-22  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for WebSQL code
+        https://bugs.webkit.org/show_bug.cgi?id=166441
+
+        Reviewed by Darin Adler.
+
+        - Replace custom variant type SQLValue with a type alias of a Variant.
+        - Use the newly representable SQLValue to remove custom bindings for 
+          SQLResultSetRowList::item and SQLTransaction::executeSql.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSSQLResultSetRowListCustom.cpp: Removed.
+        * bindings/js/JSSQLTransactionCustom.cpp: Removed.
+        * platform/sql/SQLValue.cpp: Removed.
+        Remove files.
+
+        * Modules/webdatabase/SQLResultSetRowList.cpp:
+        (WebCore::SQLResultSetRowList::length):
+        (WebCore::SQLResultSetRowList::item):
+        * Modules/webdatabase/SQLResultSetRowList.h:
+        * Modules/webdatabase/SQLResultSetRowList.idl:
+        Sink the implementation of item() into the implementation. Use a
+        record type to bridge to javascript.
+
+        * Modules/webdatabase/SQLStatement.cpp:
+        (WebCore::SQLStatement::SQLStatement):
+        * Modules/webdatabase/SQLStatement.h:
+        Update to take arguments by rvalue reference.
+
+        * Modules/webdatabase/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::executeSql):
+        * Modules/webdatabase/SQLTransaction.h:
+        * Modules/webdatabase/SQLTransaction.idl:
+        Remove custom annotation, and update signature to match the IDL.
+
+        * Modules/webdatabase/SQLTransactionBackend.cpp:
+        * Modules/webdatabase/SQLTransactionBackend.h:
+        Remove unneeded #includes of SQLValue.h
+
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::Converter<IDLNull>::convert):
+        (WebCore::JSConverter<IDLNull>::convert):
+        Implement conversion for the null type so it can be used in the SQLValue union.
+
+        * inspector/InspectorDatabaseAgent.cpp:
+        * platform/sql/SQLiteStatement.cpp:
+        (WebCore::SQLiteStatement::bindValue):
+        (WebCore::SQLiteStatement::getColumnValue):
+        * platform/sql/SQLiteStatement.h:
+        Replace old switch with a WTF::switchOn that operates on the new variant.
+
+        * platform/sql/SQLValue.h:
+        (WebCore::SQLValue::SQLValue): Deleted.
+        (WebCore::SQLValue::type): Deleted.
+        Replace implementation with a Variant.
+
 2016-12-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] GLES build broken since r208997
index 657ae94..a6c258b 100644 (file)
 #include "config.h"
 #include "SQLResultSetRowList.h"
 
+#include "ExceptionCode.h"
+
 namespace WebCore {
 
 unsigned SQLResultSetRowList::length() const
 {
-    if (m_result.size() == 0)
+    if (m_result.isEmpty())
         return 0;
 
     ASSERT(m_result.size() % m_columns.size() == 0);
@@ -41,4 +43,19 @@ unsigned SQLResultSetRowList::length() const
     return m_result.size() / m_columns.size();
 }
 
+ExceptionOr<HashMap<String, SQLValue>> SQLResultSetRowList::item(unsigned index) const
+{
+    if (index >= length())
+        return Exception { INDEX_SIZE_ERR };
+
+    HashMap<String, SQLValue> result;
+
+    unsigned numberOfColumns = m_columns.size();
+    unsigned valuesIndex = index * numberOfColumns;
+    for (unsigned i = 0; i < numberOfColumns; i++)
+        result.set(m_columns[i], m_result[valuesIndex + i]);
+
+    return WTFMove(result);
+}
+
 }
index ed067b0..55bf437 100644 (file)
 
 #pragma once
 
-#include <wtf/RefCounted.h>
+#include "ExceptionOr.h"
 #include "SQLValue.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
@@ -44,6 +46,7 @@ public:
     void addResult(const SQLValue& result) { m_result.append(result); }
 
     unsigned length() const;
+    ExceptionOr<HashMap<String, SQLValue>> item(unsigned index) const;
 
 private:
     SQLResultSetRowList() { }
index 2b5233f..5541c35 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+typedef (DOMString? or unrestricted double) SQLValue;
+
 [
     ImplementationLacksVTable,
 ] interface SQLResultSetRowList {
     readonly attribute unsigned long length;
-    [Custom] any item(unsigned long index);
+    [MayThrowException] record<DOMString, SQLValue> item(unsigned long index);
 };
index 7710b18..ea89243 100644 (file)
@@ -74,9 +74,9 @@
 
 namespace WebCore {
 
-SQLStatement::SQLStatement(Database& database, const String& statement, const Vector<SQLValue>& arguments, RefPtr<SQLStatementCallback>&& callback, RefPtr<SQLStatementErrorCallback>&& errorCallback, int permissions)
+SQLStatement::SQLStatement(Database& database, const String& statement, Vector<SQLValue>&& arguments, RefPtr<SQLStatementCallback>&& callback, RefPtr<SQLStatementErrorCallback>&& errorCallback, int permissions)
     : m_statement(statement.isolatedCopy())
-    , m_arguments(arguments)
+    , m_arguments(WTFMove(arguments))
     , m_statementCallbackWrapper(WTFMove(callback), &database.scriptExecutionContext())
     , m_statementErrorCallbackWrapper(WTFMove(errorCallback), &database.scriptExecutionContext())
     , m_permissions(permissions)
index 92d0ee7..239ea93 100644 (file)
@@ -45,7 +45,7 @@ class SQLTransactionBackend;
 
 class SQLStatement {
 public:
-    SQLStatement(Database&, const String&, const Vector<SQLValue>&, RefPtr<SQLStatementCallback>&&, RefPtr<SQLStatementErrorCallback>&&, int permissions);
+    SQLStatement(Database&, const String&, Vector<SQLValue>&&, RefPtr<SQLStatementCallback>&&, RefPtr<SQLStatementErrorCallback>&&, int permissions);
     ~SQLStatement();
 
     bool execute(Database&);
index f9871eb..76cdd7c 100644 (file)
@@ -73,7 +73,7 @@ SQLTransaction::~SQLTransaction()
 {
 }
 
-ExceptionOr<void> SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, RefPtr<SQLStatementCallback>&& callback, RefPtr<SQLStatementErrorCallback>&& callbackError)
+ExceptionOr<void> SQLTransaction::executeSql(const String& sqlStatement, std::optional<Vector<SQLValue>>&& arguments, RefPtr<SQLStatementCallback>&& callback, RefPtr<SQLStatementErrorCallback>&& callbackError)
 {
     if (!m_executeSqlAllowed || !m_database->opened())
         return Exception { INVALID_STATE_ERR };
@@ -84,7 +84,7 @@ ExceptionOr<void> SQLTransaction::executeSQL(const String& sqlStatement, const V
     else if (m_readOnly)
         permissions |= DatabaseAuthorizer::ReadOnlyMask;
 
-    auto statement = std::make_unique<SQLStatement>(m_database, sqlStatement, arguments, WTFMove(callback), WTFMove(callbackError), permissions);
+    auto statement = std::make_unique<SQLStatement>(m_database, sqlStatement, arguments.value_or(Vector<SQLValue> { }), WTFMove(callback), WTFMove(callbackError), permissions);
 
     if (m_database->deleted())
         statement->setDatabaseDeletedError();
index 545d001..81b668f 100644 (file)
@@ -33,6 +33,8 @@
 #include "SQLCallbackWrapper.h"
 #include "SQLTransactionBackend.h"
 #include "SQLTransactionStateMachine.h"
+#include "SQLValue.h"
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -43,7 +45,6 @@ class SQLStatementErrorCallback;
 class SQLTransactionBackend;
 class SQLTransactionCallback;
 class SQLTransactionErrorCallback;
-class SQLValue;
 class VoidCallback;
 
 class SQLTransactionWrapper : public ThreadSafeRefCounted<SQLTransactionWrapper> {
@@ -60,7 +61,7 @@ public:
     static Ref<SQLTransaction> create(Ref<Database>&&, RefPtr<SQLTransactionCallback>&&, RefPtr<VoidCallback>&& successCallback, RefPtr<SQLTransactionErrorCallback>&&, RefPtr<SQLTransactionWrapper>&&, bool readOnly);
     ~SQLTransaction();
 
-    ExceptionOr<void> executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, RefPtr<SQLStatementCallback>&&, RefPtr<SQLStatementErrorCallback>&&);
+    ExceptionOr<void> executeSql(const String& sqlStatement, std::optional<Vector<SQLValue>>&& arguments, RefPtr<SQLStatementCallback>&&, RefPtr<SQLStatementErrorCallback>&&);
 
     void lockAcquired();
     void performNextStep();
index 4841b26..1f53a1f 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+typedef (DOMString? or unrestricted double) SQLValue;
+
 [
     SkipVTableValidation,
 ] interface SQLTransaction {
-    [Custom, MayThrowException] void executeSql(DOMString sqlStatement, ObjectArray arguments, optional SQLStatementCallback? callback, optional SQLStatementErrorCallback? errorCallback);
+    [MayThrowException] void executeSql(DOMString sqlStatement, optional sequence<SQLValue>? arguments = [], optional SQLStatementCallback? callback, optional SQLStatementErrorCallback? errorCallback);
 };
index ff7c737..2ea93dd 100644 (file)
@@ -42,7 +42,6 @@
 #include "SQLStatementErrorCallback.h"
 #include "SQLTransaction.h"
 #include "SQLTransactionCoordinator.h"
-#include "SQLValue.h"
 #include "SQLiteTransaction.h"
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
index a8209b0..29e603c 100644 (file)
@@ -44,7 +44,6 @@ class SQLiteTransaction;
 class SQLStatement;
 class SQLTransaction;
 class SQLTransactionWrapper;
-class SQLValue;
 
 class SQLTransactionBackend : public SQLTransactionStateMachine<SQLTransactionBackend> {
 public:
index 0651f92..2c950a1 100644 (file)
                1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2A68220B5BEDE70002A480 /* ProgressTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A2AAC580DC2A3B100A20D9A /* ApplicationCacheStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */; };
                1A2AAC590DC2A3B100A20D9A /* ApplicationCacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               1A2E6E590CC55213004A2062 /* SQLValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E570CC55213004A2062 /* SQLValue.cpp */; };
                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E580CC55213004A2062 /* SQLValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
                1A3586DF15264C450022A659 /* RenderMultiColumnFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3586DD15264C450022A659 /* RenderMultiColumnFlowThread.cpp */; };
                1ACE53EB0A8D18E70022947D /* XMLSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACE53E50A8D18E70022947D /* XMLSerializer.h */; };
                1ACE53F60A8D19470022947D /* JSXMLSerializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ACE53F40A8D19470022947D /* JSXMLSerializer.cpp */; };
                1ACE53F70A8D19470022947D /* JSXMLSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACE53F50A8D19470022947D /* JSXMLSerializer.h */; };
-               1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */; };
                1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */; };
                1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */; };
                51D7236D1BB6174900478CA3 /* IDBResultData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D7236B1BB60BFE00478CA3 /* IDBResultData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51D7EFEA1BDE8F8C00E93E10 /* ThreadSafeDataBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 511FAEA91BDC989A00B4AFE4 /* ThreadSafeDataBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51D7EFEC1BDEFA5100E93E10 /* TransactionOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D7EFEB1BDEFA4700E93E10 /* TransactionOperation.cpp */; };
-               51DCE8020CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51DCE8010CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp */; };
                51DF6D7E0B92A16D00C2DC85 /* ThreadCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */; };
                51E0BABB0DA5547100A9E417 /* StorageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E0BAB90DA5547100A9E417 /* StorageEvent.h */; };
                1A2A68220B5BEDE70002A480 /* ProgressTracker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ProgressTracker.h; sourceTree = "<group>"; };
                1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheStorage.cpp; sourceTree = "<group>"; };
                1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheStorage.h; sourceTree = "<group>"; };
-               1A2E6E570CC55213004A2062 /* SQLValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLValue.cpp; sourceTree = "<group>"; };
                1A2E6E580CC55213004A2062 /* SQLValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLValue.h; sourceTree = "<group>"; };
                1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
                1A3586DD15264C450022A659 /* RenderMultiColumnFlowThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMultiColumnFlowThread.cpp; sourceTree = "<group>"; };
                1ACE53E60A8D18E70022947D /* XMLSerializer.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = XMLSerializer.idl; sourceTree = "<group>"; };
                1ACE53F40A8D19470022947D /* JSXMLSerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLSerializer.cpp; sourceTree = "<group>"; };
                1ACE53F50A8D19470022947D /* JSXMLSerializer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXMLSerializer.h; sourceTree = "<group>"; };
-               1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionCustom.cpp; sourceTree = "<group>"; };
                1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformStrategies.h; sourceTree = "<group>"; };
                1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformStrategies.cpp; sourceTree = "<group>"; };
                1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentMerchantSessionCocoa.mm; sourceTree = "<group>"; };
                51D7236A1BB60BFE00478CA3 /* IDBResultData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBResultData.cpp; sourceTree = "<group>"; };
                51D7236B1BB60BFE00478CA3 /* IDBResultData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBResultData.h; sourceTree = "<group>"; };
                51D7EFEB1BDEFA4700E93E10 /* TransactionOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransactionOperation.cpp; sourceTree = "<group>"; };
-               51DCE8010CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLResultSetRowListCustom.cpp; sourceTree = "<group>"; };
                51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadCheck.h; sourceTree = "<group>"; };
                51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadCheck.mm; sourceTree = "<group>"; };
                51E0BAB90DA5547100A9E417 /* StorageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageEvent.h; sourceTree = "<group>"; };
                                1A2246460CC98DDB00C05240 /* SQLiteStatement.h */,
                                1A2246470CC98DDB00C05240 /* SQLiteTransaction.cpp */,
                                1A2246480CC98DDB00C05240 /* SQLiteTransaction.h */,
-                               1A2E6E570CC55213004A2062 /* SQLValue.cpp */,
                                1A2E6E580CC55213004A2062 /* SQLValue.h */,
                        );
                        path = sql;
                                A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
                                07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */,
-                               51DCE8010CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp */,
-                               1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */,
                                51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */,
                                A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */,
                                57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
                                B525A96611CA2340003A23A8 /* JSSQLException.cpp in Sources */,
                                1AE82FEC0CAB07EE002237AE /* JSSQLResultSet.cpp in Sources */,
                                1AFE11990CBFFCC4003017FA /* JSSQLResultSetRowList.cpp in Sources */,
-                               51DCE8020CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp in Sources */,
                                B59DD6A611902A62007E9684 /* JSSQLStatementCallback.cpp in Sources */,
                                B59DD6AA11902A71007E9684 /* JSSQLStatementErrorCallback.cpp in Sources */,
                                514C76380CE9225E007EF3CD /* JSSQLTransaction.cpp in Sources */,
                                B59DD69E11902A42007E9684 /* JSSQLTransactionCallback.cpp in Sources */,
-                               1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */,
                                B59DD6A211902A52007E9684 /* JSSQLTransactionErrorCallback.cpp in Sources */,
                                A86629D409DA2B48009633A7 /* JSStaticRange.cpp in Sources */,
                                51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
                                FEE1811316C319E800084849 /* SQLTransactionBackend.cpp in Sources */,
                                97BC6A561505F081001B74AC /* SQLTransactionCoordinator.cpp in Sources */,
                                FE36FD1616C7826500F887C1 /* SQLTransactionStateMachine.cpp in Sources */,
-                               1A2E6E590CC55213004A2062 /* SQLValue.cpp in Sources */,
                                4476531B133170990006B789 /* SSLKeyGeneratorIOS.cpp in Sources */,
                                93F19AE608245E59001E9ABC /* SSLKeyGeneratorMac.mm in Sources */,
                                BC7FA62E0D1F0EFF00DB22A9 /* StaticNodeList.cpp in Sources */,
index ff8ed5d..198ea08 100644 (file)
 #include "JSPluginElementFunctions.cpp"
 #include "JSPopStateEventCustom.cpp"
 #include "JSReadableStreamPrivateConstructors.cpp"
-#include "JSSQLResultSetRowListCustom.cpp"
-#include "JSSQLTransactionCustom.cpp"
 #include "JSSVGPathSegCustom.cpp"
 #include "JSStorageCustom.cpp"
 #include "JSStyleSheetCustom.cpp"
index f667b14..0e4a02d 100644 (file)
@@ -331,6 +331,26 @@ template<typename T> struct JSConverter<IDLNullable<T>> {
 };
 
 // MARK: -
+// MARK: Null type
+
+template<> struct Converter<IDLNull> : DefaultConverter<IDLNull> {
+    static std::nullptr_t convert(JSC::ExecState&, JSC::JSValue)
+    {
+        return nullptr;
+    }
+};
+
+template<> struct JSConverter<IDLNull> {
+    static constexpr bool needsState = false;
+    static constexpr bool needsGlobalObject = false;
+
+    static JSC::JSValue convert(std::nullptr_t)
+    {
+        return JSC::jsNull();
+    }
+};
+
+// MARK: -
 // MARK: Boolean type
 
 template<> struct Converter<IDLBoolean> : DefaultConverter<IDLBoolean> {
diff --git a/Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp b/Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp
deleted file mode 100644 (file)
index 3eaef26..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "JSSQLResultSetRowList.h"
-#include "ExceptionCode.h"
-#include "JSDOMBinding.h"
-#include "SQLValue.h"
-#include <runtime/IdentifierInlines.h>
-#include <runtime/ObjectConstructor.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSSQLResultSetRowList::item(ExecState& state)
-{
-    bool indexOk;
-    int index = finiteInt32Value(state.argument(0), &state, indexOk);
-    if (!indexOk) {
-        setDOMException(&state, TYPE_MISMATCH_ERR);
-        return jsUndefined();
-    }
-    if (index < 0 || (unsigned)index >= wrapped().length()) {
-        setDOMException(&state, INDEX_SIZE_ERR);
-        return jsUndefined();
-    }
-
-    JSObject* object = constructEmptyObject(&state);
-
-    unsigned numColumns = wrapped().columnNames().size();
-    unsigned valuesIndex = index * numColumns;
-    for (unsigned i = 0; i < numColumns; i++) {
-        const SQLValue& value = wrapped().values()[valuesIndex + i];
-        JSValue jsValue;
-
-        switch (value.type()) {
-        case SQLValue::StringValue:
-            jsValue = jsStringWithCache(&state, value.string());
-            break;
-        case SQLValue::NullValue:
-            jsValue = jsNull();
-            break;
-        case SQLValue::NumberValue:
-            jsValue = jsNumber(value.number());
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-        }
-
-        object->putDirect(state.vm(), Identifier::fromString(&state, wrapped().columnNames()[i]), jsValue, DontDelete | ReadOnly);
-    }
-
-    return object;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp b/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp
deleted file mode 100644 (file)
index 5b713a9..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "JSSQLTransaction.h"
-#include "DOMWindow.h"
-#include "ExceptionCode.h"
-#include "JSSQLStatementCallback.h"
-#include "JSSQLStatementErrorCallback.h"
-#include "JSDOMWindowCustom.h"
-#include "SQLTransaction.h"
-#include "SQLValue.h"
-#include <runtime/JSObjectInlines.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSSQLTransaction::executeSql(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (!state.argumentCount()) {
-        setDOMException(&state, SYNTAX_ERR);
-        return jsUndefined();
-    }
-
-    String sqlStatement = state.argument(0).toWTFString(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-
-    // Now assemble the list of SQL arguments
-    Vector<SQLValue> sqlValues;
-    if (!state.argument(1).isUndefinedOrNull()) {
-        JSObject* object = state.argument(1).getObject();
-        if (!object) {
-            setDOMException(&state, TYPE_MISMATCH_ERR);
-            return jsUndefined();
-        }
-
-        JSValue lengthValue = object->get(&state, state.propertyNames().length);
-        RETURN_IF_EXCEPTION(scope, JSValue());
-        unsigned length = lengthValue.toUInt32(&state);
-        RETURN_IF_EXCEPTION(scope, JSValue());
-
-        for (unsigned i = 0 ; i < length; ++i) {
-            JSValue value = object->get(&state, i);
-            RETURN_IF_EXCEPTION(scope, JSValue());
-
-            if (value.isUndefinedOrNull())
-                sqlValues.append(SQLValue());
-            else if (value.isNumber())
-                sqlValues.append(value.asNumber());
-            else {
-                // Convert the argument to a string and append it
-                sqlValues.append(value.toWTFString(&state));
-                RETURN_IF_EXCEPTION(scope, JSValue());
-            }
-        }
-    }
-
-    RefPtr<SQLStatementCallback> callback;
-    if (!state.argument(2).isUndefinedOrNull()) {
-        JSObject* object = state.argument(2).getObject();
-        if (!object) {
-            setDOMException(&state, TYPE_MISMATCH_ERR);
-            return jsUndefined();
-        }
-
-        callback = JSSQLStatementCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject()));
-    }
-
-    RefPtr<SQLStatementErrorCallback> errorCallback;
-    if (!state.argument(3).isUndefinedOrNull()) {
-        JSObject* object = state.argument(3).getObject();
-        if (!object) {
-            setDOMException(&state, TYPE_MISMATCH_ERR);
-            return jsUndefined();
-        }
-
-        errorCallback = JSSQLStatementErrorCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject()));
-    }
-
-    propagateException(state, scope, wrapped().executeSQL(sqlStatement, sqlValues, WTFMove(callback), WTFMove(errorCallback)));
-
-    return jsUndefined();
-}
-
-} // namespace WebCore
index db4c02e..5090186 100644 (file)
@@ -85,12 +85,11 @@ private:
 
         auto values = Inspector::Protocol::Array<InspectorValue>::create();
         for (auto& value : rowList.values()) {
-            RefPtr<InspectorValue> inspectorValue;
-            switch (value.type()) {
-            case SQLValue::StringValue: inspectorValue = InspectorValue::create(value.string()); break;
-            case SQLValue::NumberValue: inspectorValue = InspectorValue::create(value.number()); break;
-            case SQLValue::NullValue: inspectorValue = InspectorValue::null(); break;
-            }
+            auto inspectorValue = WTF::switchOn(value,
+                [] (const std::nullptr_t&) { return InspectorValue::null(); },
+                [] (const String& string) { return InspectorValue::create(string); },
+                [] (double number) { return InspectorValue::create(number); }
+            );
             values->addItem(WTFMove(inspectorValue));
         }
         m_requestCallback->sendSuccess(WTFMove(columnNames), WTFMove(values), nullptr);
@@ -137,10 +136,9 @@ private:
         if (!m_requestCallback->isActive())
             return true;
 
-        Vector<SQLValue> sqlValues;
         Ref<SQLStatementCallback> callback(StatementCallback::create(m_requestCallback.copyRef()));
         Ref<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(m_requestCallback.copyRef()));
-        transaction->executeSQL(m_sqlStatement, sqlValues, WTFMove(callback), WTFMove(errorCallback));
+        transaction->executeSql(m_sqlStatement, { }, WTFMove(callback), WTFMove(errorCallback));
         return true;
     }
 
diff --git a/Source/WebCore/platform/sql/SQLValue.cpp b/Source/WebCore/platform/sql/SQLValue.cpp
deleted file mode 100644 (file)
index ef1b19c..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following condition
- * 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.
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "SQLValue.h"
-
-namespace WebCore {
-
-SQLValue::SQLValue(const SQLValue& val)
-    : m_type(val.m_type)
-    , m_number(val.m_number)
-    , m_string(val.m_string.isolatedCopy())
-{
-}
-
-String SQLValue::string() const
-{
-    ASSERT(m_type == StringValue);
-
-    // Must return a copy since ref-shared Strings are not thread safe
-    return m_string.isolatedCopy();
-}
-
-double SQLValue::number() const
-{
-    ASSERT(m_type == NumberValue);
-
-    return m_number;
-}
-
-}
index f4428f5..d0ca03c 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef SQLValue_h
-#define SQLValue_h
+#pragma once
 
-#include <wtf/Threading.h>
+#include <wtf/Variant.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-    class SQLValue {
-    public:
-        enum Type { NullValue, NumberValue, StringValue };
+using SQLValue = Variant<std::nullptr_t, String, double>;
 
-        SQLValue() : m_type(NullValue), m_number(0.0) { }
-        SQLValue(double number) : m_type(NumberValue), m_number(number) { }
-        SQLValue(const String& s) : m_type(StringValue), m_number(0.0), m_string(s) { }
-        SQLValue(const SQLValue&);
-
-        Type type() const { return m_type; }
-
-        String string() const;
-        double number() const;
-
-    private:
-        Type m_type;
-        double m_number;
-        String m_string;
-    };
 };
-
-#endif
index e4c771d..c8f30ba 100644 (file)
@@ -30,6 +30,7 @@
 #include "SQLValue.h"
 #include <sqlite3.h>
 #include <wtf/Assertions.h>
+#include <wtf/Variant.h>
 #include <wtf/text/StringView.h>
 
 // SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the statement
@@ -240,17 +241,11 @@ int SQLiteStatement::bindNull(int index)
 
 int SQLiteStatement::bindValue(int index, const SQLValue& value)
 {
-    switch (value.type()) {
-        case SQLValue::StringValue:
-            return bindText(index, value.string());
-        case SQLValue::NumberValue:
-            return bindDouble(index, value.number());
-        case SQLValue::NullValue:
-            return bindNull(index);
-    }
-
-    ASSERT_NOT_REACHED();
-    return SQLITE_ERROR;
+    return WTF::switchOn(value,
+        [&] (const std::nullptr_t&) { return bindNull(index); },
+        [&] (const String& string) { return bindText(index, string); },
+        [&] (double number) { return bindDouble(index, number); }
+    );
 }
 
 unsigned SQLiteStatement::bindParameterCount() const
@@ -307,9 +302,9 @@ SQLValue SQLiteStatement::getColumnValue(int col)
     ASSERT(col >= 0);
     if (!m_statement)
         if (prepareAndStep() != SQLITE_ROW)
-            return SQLValue();
+            return nullptr;
     if (columnCount() <= col)
-        return SQLValue();
+        return nullptr;
 
     // SQLite is typed per value. optional column types are
     // "(mostly) ignored"
@@ -317,19 +312,20 @@ SQLValue SQLiteStatement::getColumnValue(int col)
     switch (sqlite3_value_type(value)) {
         case SQLITE_INTEGER:    // SQLValue and JS don't represent integers, so use FLOAT -case
         case SQLITE_FLOAT:
-            return SQLValue(sqlite3_value_double(value));
+            return sqlite3_value_double(value);
         case SQLITE_BLOB:       // SQLValue and JS don't represent blobs, so use TEXT -case
         case SQLITE_TEXT: {
             const UChar* string = reinterpret_cast<const UChar*>(sqlite3_value_text16(value));
-            return SQLValue(StringImpl::create8BitIfPossible(string));
+            return StringImpl::create8BitIfPossible(string);
         }
         case SQLITE_NULL:
-            return SQLValue();
+            return nullptr;
         default:
             break;
     }
+
     ASSERT_NOT_REACHED();
-    return SQLValue();
+    return nullptr;
 }
 
 String SQLiteStatement::getColumnText(int col)
index 645a043..a193d8c 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef SQLiteStatement_h
-#define SQLiteStatement_h
+#pragma once
 
+#include "SQLValue.h"
 #include "SQLiteDatabase.h"
 
 struct sqlite3_stmt;
 
 namespace WebCore {
 
-class SQLValue;
-
 class SQLiteStatement {
     WTF_MAKE_NONCOPYABLE(SQLiteStatement); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -104,5 +102,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // SQLiteStatement_h