forked from mirrors/gecko-dev
Bug 1552547 part 2. Stop using [array] in mozIStorageBindingParams. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D31659 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f1f2d7ade1
commit
202f15eaec
5 changed files with 45 additions and 12 deletions
|
|
@ -270,6 +270,10 @@ NS_DEFINE_STATIC_IID_ACCESSOR(StorageBaseStatementInternal,
|
|||
(const nsACString& aWhere, const uint8_t* aValue, uint32_t aValueSize), \
|
||||
(uint32_t aWhere, const uint8_t* aValue, uint32_t aValueSize), \
|
||||
(aWhere, aValue, aValueSize)) \
|
||||
BIND_GEN_IMPL(_class, _optionalGuard, BlobArray, \
|
||||
(const nsACString& aWhere, const nsTArray<uint8_t>& aValue), \
|
||||
(uint32_t aWhere, const nsTArray<uint8_t>& aValue), \
|
||||
(aWhere, aValue)) \
|
||||
BIND_GEN_IMPL(_class, _optionalGuard, StringAsBlob, \
|
||||
(const nsACString& aWhere, const nsAString& aValue), \
|
||||
(uint32_t aWhere, const nsAString& aValue), (aWhere, aValue)) \
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, uuid(2d09f42f-966e-4663-b4b3-b0c8676bf2bf)]
|
||||
[ptr] native octetPtr(uint8_t);
|
||||
|
||||
[scriptable, builtinclass, uuid(2d09f42f-966e-4663-b4b3-b0c8676bf2bf)]
|
||||
interface mozIStorageBindingParams : nsISupports {
|
||||
/**
|
||||
* Binds aValue to the parameter with the name aName.
|
||||
|
|
@ -31,9 +33,16 @@ interface mozIStorageBindingParams : nsISupports {
|
|||
[noscript] void bindInt64ByName(in AUTF8String aName,
|
||||
in long long aValue);
|
||||
[noscript] void bindNullByName(in AUTF8String aName);
|
||||
void bindBlobByName(in AUTF8String aName,
|
||||
[array, const, size_is(aValueSize)] in octet aValue,
|
||||
in unsigned long aValueSize);
|
||||
|
||||
// The noscript version of bindBlobByName can be used with any (const
|
||||
// uint8_t*, length) pair. The scriptable version is meant for use with
|
||||
// nsTArray<uint8_t>, which is what xpconnect has to work with.
|
||||
[noscript, binaryname(BindBlobByName)]
|
||||
void bindBlobByNameNoscript(in AUTF8String aName,
|
||||
[const] in octetPtr aValue,
|
||||
in unsigned long aValueSize);
|
||||
[binaryname(BindBlobArrayByName)]
|
||||
void bindBlobByName(in AUTF8String aName, in Array<octet> aValue);
|
||||
|
||||
// Convenience routines for storing strings as blobs.
|
||||
void bindStringAsBlobByName(in AUTF8String aName, in AString aValue);
|
||||
|
|
@ -44,7 +53,7 @@ interface mozIStorageBindingParams : nsISupports {
|
|||
// underlying pointer.
|
||||
[noscript]
|
||||
void bindAdoptedBlobByName(in AUTF8String aName,
|
||||
[array, size_is(aValueSize)] in octet aValue,
|
||||
in octetPtr aValue,
|
||||
in unsigned long aValueSize);
|
||||
|
||||
/**
|
||||
|
|
@ -68,9 +77,17 @@ interface mozIStorageBindingParams : nsISupports {
|
|||
[noscript] void bindInt64ByIndex(in unsigned long aIndex,
|
||||
in long long aValue);
|
||||
[noscript] void bindNullByIndex(in unsigned long aIndex);
|
||||
|
||||
// The noscript version of bindBlobByIndex can be used with any (const
|
||||
// uint8_t*, length) pair. The scriptable version is meant for use with
|
||||
// nsTArray<uint8_t>, which is what xpconnect has to work with.
|
||||
[noscript, binaryname(BindBlobByIndex)]
|
||||
void bindBlobByIndexNoscript(in unsigned long aIndex,
|
||||
[const] in octetPtr aValue,
|
||||
in unsigned long aValueSize);
|
||||
[binaryname(BindBlobArrayByIndex)]
|
||||
void bindBlobByIndex(in unsigned long aIndex,
|
||||
[array, const, size_is(aValueSize)] in octet aValue,
|
||||
in unsigned long aValueSize);
|
||||
in Array<octet> aValue);
|
||||
|
||||
// Convenience routines for storing strings as blobs.
|
||||
void bindStringAsBlobByIndex(in unsigned long aIndex, in AString aValue);
|
||||
|
|
@ -81,6 +98,6 @@ interface mozIStorageBindingParams : nsISupports {
|
|||
// underlying pointer.
|
||||
[noscript]
|
||||
void bindAdoptedBlobByIndex(in unsigned long aIndex,
|
||||
[array, size_is(aValueSize)] in octet aValue,
|
||||
in octetPtr aValue,
|
||||
in unsigned long aValueSize);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -277,6 +277,12 @@ BindingParams::BindBlobByName(const nsACString& aName, const uint8_t* aValue,
|
|||
return BindByName(aName, value);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BindingParams::BindBlobArrayByName(const nsACString& aName,
|
||||
const nsTArray<uint8_t>& aValue) {
|
||||
return BindBlobByName(aName, aValue.Elements(), aValue.Length());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BindingParams::BindStringAsBlobByName(const nsACString& aName,
|
||||
const nsAString& aValue) {
|
||||
|
|
@ -397,6 +403,12 @@ BindingParams::BindBlobByIndex(uint32_t aIndex, const uint8_t* aValue,
|
|||
return BindByIndex(aIndex, value);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BindingParams::BindBlobArrayByIndex(uint32_t aIndex,
|
||||
const nsTArray<uint8_t>& aValue) {
|
||||
return BindBlobByIndex(aIndex, aValue.Elements(), aValue.Length());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BindingParams::BindStringAsBlobByIndex(uint32_t aIndex,
|
||||
const nsAString& aValue) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ add_task(async function test_last_multiple_bindings_on_statements() {
|
|||
bp.bindByName("text", TEXT);
|
||||
bp.bindByName("real", REAL);
|
||||
bp.bindByName("null", null);
|
||||
bp.bindBlobByName("blob", BLOB, BLOB.length);
|
||||
bp.bindBlobByName("blob", BLOB);
|
||||
params.addParams(bp);
|
||||
}
|
||||
stmts[i].bindParameters(params);
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ function test_bind_direct_binding_params_by_name() {
|
|||
stmt.bindByName("text", TEXT);
|
||||
stmt.bindByName("real", REAL);
|
||||
stmt.bindByName("null", null);
|
||||
stmt.bindBlobByName("blob", BLOB, BLOB.length);
|
||||
stmt.bindBlobByName("blob", BLOB);
|
||||
execAsync(stmt);
|
||||
stmt.finalize();
|
||||
verifyQuery("SELECT string, number, nuller, blober FROM test WHERE id = ?",
|
||||
|
|
@ -563,7 +563,7 @@ function test_bind_multiple_rows_by_name() {
|
|||
bp.bindByName("text", TEXT);
|
||||
bp.bindByName("real", REAL);
|
||||
bp.bindByName("null", null);
|
||||
bp.bindBlobByName("blob", BLOB, BLOB.length);
|
||||
bp.bindBlobByName("blob", BLOB);
|
||||
array.addParams(bp);
|
||||
Assert.equal(array.length, i + 1);
|
||||
}
|
||||
|
|
@ -639,7 +639,7 @@ function test_bind_no_such_name_sync_immediate() {
|
|||
() => bp.bindByName("doesnotexist", INTEGER));
|
||||
// Check blob binding.
|
||||
expectError(Cr.NS_ERROR_INVALID_ARG,
|
||||
() => bp.bindBlobByName("doesnotexist", BLOB, BLOB.length));
|
||||
() => bp.bindBlobByName("doesnotexist", BLOB));
|
||||
|
||||
stmt.finalize();
|
||||
run_next_test();
|
||||
|
|
|
|||
Loading…
Reference in a new issue