1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/TestInterfaceMaplike.h"
8 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
9 #include "nsPIDOMWindow.h"
10 #include "mozilla/dom/BindingUtils.h"
12 namespace mozilla::dom
{
14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplike
, mParent
)
16 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplike
)
17 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplike
)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplike
)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports
)
24 TestInterfaceMaplike::TestInterfaceMaplike(nsPIDOMWindowInner
* aParent
)
28 already_AddRefed
<TestInterfaceMaplike
> TestInterfaceMaplike::Constructor(
29 const GlobalObject
& aGlobal
, ErrorResult
& aRv
) {
30 nsCOMPtr
<nsPIDOMWindowInner
> window
=
31 do_QueryInterface(aGlobal
.GetAsSupports());
33 aRv
.Throw(NS_ERROR_FAILURE
);
37 RefPtr
<TestInterfaceMaplike
> r
= new TestInterfaceMaplike(window
);
41 JSObject
* TestInterfaceMaplike::WrapObject(JSContext
* aCx
,
42 JS::Handle
<JSObject
*> aGivenProto
) {
43 return TestInterfaceMaplike_Binding::Wrap(aCx
, this, aGivenProto
);
46 nsPIDOMWindowInner
* TestInterfaceMaplike::GetParentObject() const {
50 void TestInterfaceMaplike::SetInternal(const nsAString
& aKey
, int32_t aValue
) {
52 TestInterfaceMaplike_Binding::MaplikeHelpers::Set(this, aKey
, aValue
, rv
);
55 void TestInterfaceMaplike::ClearInternal() {
57 TestInterfaceMaplike_Binding::MaplikeHelpers::Clear(this, rv
);
60 bool TestInterfaceMaplike::DeleteInternal(const nsAString
& aKey
) {
62 return TestInterfaceMaplike_Binding::MaplikeHelpers::Delete(this, aKey
, rv
);
65 bool TestInterfaceMaplike::HasInternal(const nsAString
& aKey
) {
67 return TestInterfaceMaplike_Binding::MaplikeHelpers::Has(this, aKey
, rv
);
70 int32_t TestInterfaceMaplike::GetInternal(const nsAString
& aKey
,
72 return TestInterfaceMaplike_Binding::MaplikeHelpers::Get(this, aKey
, aRv
);
74 } // namespace mozilla::dom