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/TestInterfaceMaplike.h"
6 : #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
7 : #include "nsPIDOMWindow.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 :
10 : namespace mozilla {
11 : namespace dom {
12 :
13 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplike, mParent)
14 :
15 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplike)
16 0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplike)
17 :
18 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplike)
19 0 : NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
20 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
21 0 : NS_INTERFACE_MAP_END
22 :
23 0 : TestInterfaceMaplike::TestInterfaceMaplike(nsPIDOMWindowInner* aParent)
24 0 : : mParent(aParent)
25 : {
26 0 : }
27 :
28 : //static
29 : already_AddRefed<TestInterfaceMaplike>
30 0 : TestInterfaceMaplike::Constructor(const GlobalObject& aGlobal,
31 : ErrorResult& aRv)
32 : {
33 0 : nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
34 0 : if (!window) {
35 0 : aRv.Throw(NS_ERROR_FAILURE);
36 0 : return nullptr;
37 : }
38 :
39 0 : RefPtr<TestInterfaceMaplike> r = new TestInterfaceMaplike(window);
40 0 : return r.forget();
41 : }
42 :
43 : JSObject*
44 0 : TestInterfaceMaplike::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
45 : {
46 0 : return TestInterfaceMaplikeBinding::Wrap(aCx, this, aGivenProto);
47 : }
48 :
49 : nsPIDOMWindowInner*
50 0 : TestInterfaceMaplike::GetParentObject() const
51 : {
52 0 : return mParent;
53 : }
54 :
55 : void
56 0 : TestInterfaceMaplike::SetInternal(const nsAString& aKey, int32_t aValue)
57 : {
58 0 : ErrorResult rv;
59 0 : TestInterfaceMaplikeBinding::MaplikeHelpers::Set(this, aKey, aValue, rv);
60 0 : }
61 :
62 : void
63 0 : TestInterfaceMaplike::ClearInternal()
64 : {
65 0 : ErrorResult rv;
66 0 : TestInterfaceMaplikeBinding::MaplikeHelpers::Clear(this, rv);
67 0 : }
68 :
69 : bool
70 0 : TestInterfaceMaplike::DeleteInternal(const nsAString& aKey)
71 : {
72 0 : ErrorResult rv;
73 0 : return TestInterfaceMaplikeBinding::MaplikeHelpers::Delete(this, aKey, rv);
74 : }
75 :
76 : bool
77 0 : TestInterfaceMaplike::HasInternal(const nsAString& aKey)
78 : {
79 0 : ErrorResult rv;
80 0 : return TestInterfaceMaplikeBinding::MaplikeHelpers::Has(this, aKey, rv);
81 : }
82 :
83 : } // namespace dom
84 : } // namespace mozilla
|