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/TestInterfaceMaplikeObject.h"
8 #include "mozilla/dom/TestInterfaceMaplike.h"
9 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
10 #include "nsPIDOMWindow.h"
11 #include "mozilla/dom/BindingUtils.h"
13 namespace mozilla::dom
{
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplikeObject
, mParent
)
17 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplikeObject
)
18 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplikeObject
)
20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplikeObject
)
21 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
22 NS_INTERFACE_MAP_ENTRY(nsISupports
)
25 TestInterfaceMaplikeObject::TestInterfaceMaplikeObject(
26 nsPIDOMWindowInner
* aParent
)
30 already_AddRefed
<TestInterfaceMaplikeObject
>
31 TestInterfaceMaplikeObject::Constructor(const GlobalObject
& aGlobal
,
33 nsCOMPtr
<nsPIDOMWindowInner
> window
=
34 do_QueryInterface(aGlobal
.GetAsSupports());
36 aRv
.Throw(NS_ERROR_FAILURE
);
40 RefPtr
<TestInterfaceMaplikeObject
> r
= new TestInterfaceMaplikeObject(window
);
44 JSObject
* TestInterfaceMaplikeObject::WrapObject(
45 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
46 return TestInterfaceMaplikeObject_Binding::Wrap(aCx
, this, aGivenProto
);
49 nsPIDOMWindowInner
* TestInterfaceMaplikeObject::GetParentObject() const {
53 void TestInterfaceMaplikeObject::SetInternal(const nsAString
& aKey
) {
54 RefPtr
<TestInterfaceMaplike
> p(new TestInterfaceMaplike(mParent
));
56 TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Set(this, aKey
, *p
, rv
);
59 void TestInterfaceMaplikeObject::ClearInternal() {
61 TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Clear(this, rv
);
64 bool TestInterfaceMaplikeObject::DeleteInternal(const nsAString
& aKey
) {
66 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Delete(this, aKey
,
70 bool TestInterfaceMaplikeObject::HasInternal(const nsAString
& aKey
) {
72 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Has(this, aKey
,
76 already_AddRefed
<TestInterfaceMaplike
> TestInterfaceMaplikeObject::GetInternal(
77 const nsAString
& aKey
, ErrorResult
& aRv
) {
78 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Get(this, aKey
,
81 } // namespace mozilla::dom