Diff
Modified: trunk/LayoutTests/ChangeLog (210133 => 210134)
--- trunk/LayoutTests/ChangeLog 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/LayoutTests/ChangeLog 2016-12-23 17:09:04 UTC (rev 210134)
@@ -1,3 +1,14 @@
+2016-12-22 Sam Weinig <[email protected]>
+
+ [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 <[email protected]>
Nested calls to setDocument can omit firing 'unload' events
Modified: trunk/LayoutTests/storage/websql/execute-sql-args-expected.txt (210133 => 210134)
--- trunk/LayoutTests/storage/websql/execute-sql-args-expected.txt 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/LayoutTests/storage/websql/execute-sql-args-expected.txt 2016-12-23 17:09:04 UTC (rev 210134)
@@ -6,15 +6,10 @@
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("", [ 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.
Modified: trunk/LayoutTests/storage/websql/execute-sql-args.js (210133 => 210134)
--- trunk/LayoutTests/storage/websql/execute-sql-args.js 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/LayoutTests/storage/websql/execute-sql-args.js 2016-12-23 17:09:04 UTC (rev 210134)
@@ -16,15 +16,10 @@
'"", 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 @@
'"", [ 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 runTest()
{
-
var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
db.transaction(runTransactionTests);
}
Modified: trunk/Source/WebCore/CMakeLists.txt (210133 => 210134)
--- trunk/Source/WebCore/CMakeLists.txt 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-12-23 17:09:04 UTC (rev 210134)
@@ -1172,8 +1172,6 @@
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 @@
platform/network/SocketStreamHandle.cpp
platform/network/SynchronousLoaderClient.cpp
- platform/sql/SQLValue.cpp
platform/sql/SQLiteAuthorizer.cpp
platform/sql/SQLiteDatabase.cpp
platform/sql/SQLiteDatabaseTracker.cpp
Modified: trunk/Source/WebCore/ChangeLog (210133 => 210134)
--- trunk/Source/WebCore/ChangeLog 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/ChangeLog 2016-12-23 17:09:04 UTC (rev 210134)
@@ -1,3 +1,62 @@
+2016-12-22 Sam Weinig <[email protected]>
+
+ [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 <[email protected]>
[GTK] GLES build broken since r208997
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -29,11 +29,13 @@
#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 @@
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);
}
+
+}
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -28,8 +28,10 @@
#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 @@
void addResult(const SQLValue& result) { m_result.append(result); }
unsigned length() const;
+ ExceptionOr<HashMap<String, SQLValue>> item(unsigned index) const;
private:
SQLResultSetRowList() { }
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.idl (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.idl 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.idl 2016-12-23 17:09:04 UTC (rev 210134)
@@ -26,9 +26,11 @@
* 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);
};
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLStatement.cpp (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLStatement.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLStatement.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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)
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLStatement.h (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLStatement.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLStatement.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -45,7 +45,7 @@
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&);
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -73,7 +73,7 @@
{
}
-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 @@
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();
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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 SQLTransactionBackend;
class SQLTransactionCallback;
class SQLTransactionErrorCallback;
-class SQLValue;
class VoidCallback;
class SQLTransactionWrapper : public ThreadSafeRefCounted<SQLTransactionWrapper> {
@@ -60,7 +61,7 @@
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();
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.idl (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.idl 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.idl 2016-12-23 17:09:04 UTC (rev 210134)
@@ -26,8 +26,10 @@
* 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);
};
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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>
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h (210133 => 210134)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -44,7 +44,6 @@
class SQLStatement;
class SQLTransaction;
class SQLTransactionWrapper;
-class SQLValue;
class SQLTransactionBackend : public SQLTransactionStateMachine<SQLTransactionBackend> {
public:
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210133 => 210134)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-12-23 17:09:04 UTC (rev 210134)
@@ -693,7 +693,6 @@
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 */; };
@@ -883,7 +882,6 @@
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 */; };
@@ -2222,7 +2220,6 @@
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 */; };
@@ -7728,7 +7725,6 @@
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>"; };
@@ -7942,7 +7938,6 @@
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>"; };
@@ -9464,7 +9459,6 @@
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>"; };
@@ -15745,7 +15739,6 @@
1A2246460CC98DDB00C05240 /* SQLiteStatement.h */,
1A2246470CC98DDB00C05240 /* SQLiteTransaction.cpp */,
1A2246480CC98DDB00C05240 /* SQLiteTransaction.h */,
- 1A2E6E570CC55213004A2062 /* SQLValue.cpp */,
1A2E6E580CC55213004A2062 /* SQLValue.h */,
);
path = sql;
@@ -22148,8 +22141,6 @@
A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */,
- 51DCE8010CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp */,
- 1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */,
51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */,
A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */,
57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
@@ -30241,12 +30232,10 @@
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 */,
@@ -31280,7 +31269,6 @@
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 */,
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (210133 => 210134)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -106,8 +106,6 @@
#include "JSPluginElementFunctions.cpp"
#include "JSPopStateEventCustom.cpp"
#include "JSReadableStreamPrivateConstructors.cpp"
-#include "JSSQLResultSetRowListCustom.cpp"
-#include "JSSQLTransactionCustom.cpp"
#include "JSSVGPathSegCustom.cpp"
#include "JSStorageCustom.cpp"
#include "JSStyleSheetCustom.cpp"
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (210133 => 210134)
--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -331,6 +331,26 @@
};
// 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> {
Deleted: trunk/Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp (210133 => 210134)
--- trunk/Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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
Deleted: trunk/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp (210133 => 210134)
--- trunk/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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
Modified: trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp (210133 => 210134)
--- trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -85,12 +85,11 @@
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 @@
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;
}
Deleted: trunk/Source/WebCore/platform/sql/SQLValue.cpp (210133 => 210134)
--- trunk/Source/WebCore/platform/sql/SQLValue.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/platform/sql/SQLValue.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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;
-}
-
-}
Modified: trunk/Source/WebCore/platform/sql/SQLValue.h (210133 => 210134)
--- trunk/Source/WebCore/platform/sql/SQLValue.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/platform/sql/SQLValue.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -26,33 +26,13 @@
* 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
Modified: trunk/Source/WebCore/platform/sql/SQLiteStatement.cpp (210133 => 210134)
--- trunk/Source/WebCore/platform/sql/SQLiteStatement.cpp 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/platform/sql/SQLiteStatement.cpp 2016-12-23 17:09:04 UTC (rev 210134)
@@ -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::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 @@
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 @@
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)
Modified: trunk/Source/WebCore/platform/sql/SQLiteStatement.h (210133 => 210134)
--- trunk/Source/WebCore/platform/sql/SQLiteStatement.h 2016-12-23 14:36:50 UTC (rev 210133)
+++ trunk/Source/WebCore/platform/sql/SQLiteStatement.h 2016-12-23 17:09:04 UTC (rev 210134)
@@ -23,9 +23,9 @@
* 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;
@@ -32,8 +32,6 @@
namespace WebCore {
-class SQLValue;
-
class SQLiteStatement {
WTF_MAKE_NONCOPYABLE(SQLiteStatement); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -104,5 +102,3 @@
};
} // namespace WebCore
-
-#endif // SQLiteStatement_h