Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / dom / bindings / test / TestInterfaceIterableSingle.cpp
blob4da02e9093b1f2d5ba80fffc00bd40c2a1963d6c
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/TestInterfaceIterableSingle.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(TestInterfaceIterableSingle, mParent)
16 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceIterableSingle)
17 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceIterableSingle)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceIterableSingle)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports)
22 NS_INTERFACE_MAP_END
24 TestInterfaceIterableSingle::TestInterfaceIterableSingle(
25 nsPIDOMWindowInner* aParent)
26 : mParent(aParent) {
27 for (int i = 0; i < 3; ++i) {
28 mValues.AppendElement(i);
32 // static
33 already_AddRefed<TestInterfaceIterableSingle>
34 TestInterfaceIterableSingle::Constructor(const GlobalObject& aGlobal,
35 ErrorResult& aRv) {
36 nsCOMPtr<nsPIDOMWindowInner> window =
37 do_QueryInterface(aGlobal.GetAsSupports());
38 if (!window) {
39 aRv.Throw(NS_ERROR_FAILURE);
40 return nullptr;
43 RefPtr<TestInterfaceIterableSingle> r =
44 new TestInterfaceIterableSingle(window);
45 return r.forget();
48 JSObject* TestInterfaceIterableSingle::WrapObject(
49 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
50 return TestInterfaceIterableSingle_Binding::Wrap(aCx, this, aGivenProto);
53 nsPIDOMWindowInner* TestInterfaceIterableSingle::GetParentObject() const {
54 return mParent;
57 uint32_t TestInterfaceIterableSingle::Length() const {
58 return mValues.Length();
61 int32_t TestInterfaceIterableSingle::IndexedGetter(uint32_t aIndex,
62 bool& aFound) const {
63 if (aIndex >= mValues.Length()) {
64 aFound = false;
65 return 0;
68 aFound = true;
69 return mValues[aIndex];
72 } // namespace mozilla::dom