Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "mozilla/dom/TestInterfaceMaplikeObject.h"
6 : #include "mozilla/dom/TestInterfaceMaplike.h"
7 : #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
8 : #include "nsPIDOMWindow.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplikeObject, mParent)
15 :
16 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplikeObject)
17 0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplikeObject)
18 :
19 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplikeObject)
20 0 : NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
22 0 : NS_INTERFACE_MAP_END
23 :
24 0 : TestInterfaceMaplikeObject::TestInterfaceMaplikeObject(nsPIDOMWindowInner* aParent)
25 0 : : mParent(aParent)
26 : {
27 0 : }
28 :
29 : //static
30 : already_AddRefed<TestInterfaceMaplikeObject>
31 0 : TestInterfaceMaplikeObject::Constructor(const GlobalObject& aGlobal,
32 : ErrorResult& aRv)
33 : {
34 0 : nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
35 0 : if (!window) {
36 0 : aRv.Throw(NS_ERROR_FAILURE);
37 0 : return nullptr;
38 : }
39 :
40 : RefPtr<TestInterfaceMaplikeObject> r =
41 0 : new TestInterfaceMaplikeObject(window);
42 0 : return r.forget();
43 : }
44 :
45 : JSObject*
46 0 : TestInterfaceMaplikeObject::WrapObject(JSContext* aCx,
47 : JS::Handle<JSObject*> aGivenProto)
48 : {
49 0 : return TestInterfaceMaplikeObjectBinding::Wrap(aCx, this, aGivenProto);
50 : }
51 :
52 : nsPIDOMWindowInner*
53 0 : TestInterfaceMaplikeObject::GetParentObject() const
54 : {
55 0 : return mParent;
56 : }
57 :
58 : void
59 0 : TestInterfaceMaplikeObject::SetInternal(const nsAString& aKey)
60 : {
61 0 : RefPtr<TestInterfaceMaplike> p(new TestInterfaceMaplike(mParent));
62 0 : ErrorResult rv;
63 0 : TestInterfaceMaplikeObjectBinding::MaplikeHelpers::Set(this, aKey, *p, rv);
64 0 : }
65 :
66 : void
67 0 : TestInterfaceMaplikeObject::ClearInternal()
68 : {
69 0 : ErrorResult rv;
70 0 : TestInterfaceMaplikeObjectBinding::MaplikeHelpers::Clear(this, rv);
71 0 : }
72 :
73 : bool
74 0 : TestInterfaceMaplikeObject::DeleteInternal(const nsAString& aKey)
75 : {
76 0 : ErrorResult rv;
77 0 : return TestInterfaceMaplikeObjectBinding::MaplikeHelpers::Delete(this, aKey, rv);
78 : }
79 :
80 : bool
81 0 : TestInterfaceMaplikeObject::HasInternal(const nsAString& aKey)
82 : {
83 0 : ErrorResult rv;
84 0 : return TestInterfaceMaplikeObjectBinding::MaplikeHelpers::Has(this, aKey, rv);
85 : }
86 :
87 : } // namespace dom
88 : } // namespace mozilla
|