Merge m-c to fx-team.
[gecko.git] / dom / bindings / RootedDictionary.h
blobbee824f7f759492f4b2c542a21017c3d2702c2ff
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* vim: set ts=2 sw=2 et tw=79: */
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 #ifndef mozilla_dom_RootedDictionary_h__
8 #define mozilla_dom_RootedDictionary_h__
10 #include "mozilla/GuardObjects.h"
11 #include "mozilla/dom/Nullable.h"
12 #include "jsapi.h"
14 namespace mozilla {
15 namespace dom {
17 template<typename T>
18 class MOZ_STACK_CLASS RootedDictionary : public T,
19 private JS::CustomAutoRooter
21 public:
22 RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
23 T(),
24 JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
28 virtual void trace(JSTracer *trc) MOZ_OVERRIDE
30 this->TraceDictionary(trc);
34 template<typename T>
35 class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable<T>,
36 private JS::CustomAutoRooter
38 public:
39 NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
40 Nullable<T>(),
41 JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
45 virtual void trace(JSTracer *trc) MOZ_OVERRIDE
47 if (!this->IsNull()) {
48 this->Value().TraceDictionary(trc);
53 } // namespace dom
54 } // namespace mozilla
56 #endif /* mozilla_dom_RootedDictionary_h__ */