|
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/. */ |
|
6 |
|
7 #ifndef mozilla_dom_RootedDictionary_h__ |
|
8 #define mozilla_dom_RootedDictionary_h__ |
|
9 |
|
10 #include "mozilla/GuardObjects.h" |
|
11 #include "mozilla/dom/Nullable.h" |
|
12 #include "jsapi.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace dom { |
|
16 |
|
17 template<typename T> |
|
18 class MOZ_STACK_CLASS RootedDictionary : public T, |
|
19 private JS::CustomAutoRooter |
|
20 { |
|
21 public: |
|
22 RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : |
|
23 T(), |
|
24 JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) |
|
25 { |
|
26 } |
|
27 |
|
28 virtual void trace(JSTracer *trc) MOZ_OVERRIDE |
|
29 { |
|
30 this->TraceDictionary(trc); |
|
31 } |
|
32 }; |
|
33 |
|
34 template<typename T> |
|
35 class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable<T>, |
|
36 private JS::CustomAutoRooter |
|
37 { |
|
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) |
|
42 { |
|
43 } |
|
44 |
|
45 virtual void trace(JSTracer *trc) MOZ_OVERRIDE |
|
46 { |
|
47 if (!this->IsNull()) { |
|
48 this->Value().TraceDictionary(trc); |
|
49 } |
|
50 } |
|
51 }; |
|
52 |
|
53 } // namespace dom |
|
54 } // namespace mozilla |
|
55 |
|
56 #endif /* mozilla_dom_RootedDictionary_h__ */ |