michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ michael@0: /* vim: set ts=2 sw=2 et tw=79: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_RootedDictionary_h__ michael@0: #define mozilla_dom_RootedDictionary_h__ michael@0: michael@0: #include "mozilla/GuardObjects.h" michael@0: #include "mozilla/dom/Nullable.h" michael@0: #include "jsapi.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: template michael@0: class MOZ_STACK_CLASS RootedDictionary : public T, michael@0: private JS::CustomAutoRooter michael@0: { michael@0: public: michael@0: RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : michael@0: T(), michael@0: JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) michael@0: { michael@0: } michael@0: michael@0: virtual void trace(JSTracer *trc) MOZ_OVERRIDE michael@0: { michael@0: this->TraceDictionary(trc); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable, michael@0: private JS::CustomAutoRooter michael@0: { michael@0: public: michael@0: NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : michael@0: Nullable(), michael@0: JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) michael@0: { michael@0: } michael@0: michael@0: virtual void trace(JSTracer *trc) MOZ_OVERRIDE michael@0: { michael@0: if (!this->IsNull()) { michael@0: this->Value().TraceDictionary(trc); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_RootedDictionary_h__ */