1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
13 #include "mozilla/dom/MozStorageAsyncStatementParamsBinding.h"
14 #include "mozStoragePrivateHelpers.h"
19 ////////////////////////////////////////////////////////////////////////////////
20 //// AsyncStatementParams
22 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AsyncStatementParams
, mWindow
)
24 NS_INTERFACE_TABLE_HEAD(AsyncStatementParams
)
25 NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
26 NS_INTERFACE_TABLE(AsyncStatementParams
, nsISupports
)
27 NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(AsyncStatementParams
)
30 NS_IMPL_CYCLE_COLLECTING_ADDREF(AsyncStatementParams
)
31 NS_IMPL_CYCLE_COLLECTING_RELEASE(AsyncStatementParams
)
33 AsyncStatementParams::AsyncStatementParams(nsPIDOMWindowInner
* aWindow
, AsyncStatement
*aStatement
)
35 mStatement(aStatement
)
37 NS_ASSERTION(mStatement
!= nullptr, "mStatement is null");
41 AsyncStatementParams::WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
)
43 return dom::MozStorageAsyncStatementParamsBinding::Wrap(aCx
, this, aGivenProto
);
47 AsyncStatementParams::NamedGetter(JSContext
* aCx
,
48 const nsAString
& aName
,
50 JS::MutableHandle
<JS::Value
> aResult
,
51 mozilla::ErrorResult
& aRv
)
54 aRv
.Throw(NS_ERROR_NOT_INITIALIZED
);
58 // Unfortunately there's no API that lets us return the parameter value.
63 AsyncStatementParams::NamedSetter(JSContext
* aCx
,
64 const nsAString
& aName
,
65 JS::Handle
<JS::Value
> aValue
,
66 mozilla::ErrorResult
& aRv
)
69 aRv
.Throw(NS_ERROR_NOT_INITIALIZED
);
73 NS_ConvertUTF16toUTF8
name(aName
);
75 nsCOMPtr
<nsIVariant
> variant(convertJSValToVariant(aCx
, aValue
));
77 aRv
.Throw(NS_ERROR_UNEXPECTED
);
81 aRv
= mStatement
->BindByName(name
, variant
);
85 AsyncStatementParams::GetSupportedNames(nsTArray
<nsString
>& aNames
)
87 // We don't know how many params there are, so we can't implement this for
88 // AsyncStatementParams.
92 AsyncStatementParams::IndexedGetter(JSContext
* aCx
,
95 JS::MutableHandle
<JS::Value
> aResult
,
96 mozilla::ErrorResult
& aRv
)
99 aRv
.Throw(NS_ERROR_NOT_INITIALIZED
);
103 // Unfortunately there's no API that lets us return the parameter value.
108 AsyncStatementParams::IndexedSetter(JSContext
* aCx
,
110 JS::Handle
<JS::Value
> aValue
,
111 mozilla::ErrorResult
& aRv
)
114 aRv
.Throw(NS_ERROR_NOT_INITIALIZED
);
118 nsCOMPtr
<nsIVariant
> variant(convertJSValToVariant(aCx
, aValue
));
120 aRv
.Throw(NS_ERROR_UNEXPECTED
);
124 aRv
= mStatement
->BindByIndex(aIndex
, variant
);
127 } // namespace storage
128 } // namespace mozilla