TestInterfaceIterableDoubleUnion.h (1809B)
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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_TestInterfaceIterableDoubleUnion_h 8 #define mozilla_dom_TestInterfaceIterableDoubleUnion_h 9 10 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h" 11 #include "nsCOMPtr.h" 12 #include "nsWrapperCache.h" 13 14 class nsPIDOMWindowInner; 15 16 namespace mozilla { 17 18 class ErrorResult; 19 20 namespace dom { 21 22 class GlobalObject; 23 24 // Implementation of test binding for webidl iterable interfaces, using 25 // primitives for value type 26 class TestInterfaceIterableDoubleUnion final : public nsISupports, 27 public nsWrapperCache { 28 public: 29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 30 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TestInterfaceIterableDoubleUnion) 31 32 explicit TestInterfaceIterableDoubleUnion(nsPIDOMWindowInner* aParent); 33 nsPIDOMWindowInner* GetParentObject() const; 34 virtual JSObject* WrapObject(JSContext* aCx, 35 JS::Handle<JSObject*> aGivenProto) override; 36 static already_AddRefed<TestInterfaceIterableDoubleUnion> Constructor( 37 const GlobalObject& aGlobal, ErrorResult& rv); 38 39 size_t GetIterableLength(); 40 nsAString& GetKeyAtIndex(uint32_t aIndex); 41 OwningStringOrLong& GetValueAtIndex(uint32_t aIndex); 42 43 private: 44 virtual ~TestInterfaceIterableDoubleUnion() = default; 45 nsCOMPtr<nsPIDOMWindowInner> mParent; 46 nsTArray<std::pair<nsString, OwningStringOrLong>> mValues; 47 }; 48 49 } // namespace dom 50 } // namespace mozilla 51 52 #endif // mozilla_dom_TestInterfaceIterableDoubleUnion_h