2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-09-26 08:04:59 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_RootedDictionary_h__
|
|
|
|
#define mozilla_dom_RootedDictionary_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
template <typename T>
|
2016-05-12 21:14:29 +03:00
|
|
|
class MOZ_RAII RootedDictionary final : public T, private JS::CustomAutoRooter {
|
2013-09-26 08:04:59 +04:00
|
|
|
public:
|
2016-08-11 15:39:23 +03:00
|
|
|
template <typename CX>
|
2020-07-30 17:22:38 +03:00
|
|
|
explicit RootedDictionary(const CX& cx) : T(), JS::CustomAutoRooter(cx) {}
|
2013-09-26 08:04:59 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void trace(JSTracer* trc) override { this->TraceDictionary(trc); }
|
2013-09-26 08:04:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
2016-05-12 21:14:29 +03:00
|
|
|
class MOZ_RAII NullableRootedDictionary final : public Nullable<T>,
|
2013-09-26 08:04:59 +04:00
|
|
|
private JS::CustomAutoRooter {
|
|
|
|
public:
|
2016-08-11 15:39:23 +03:00
|
|
|
template <typename CX>
|
2020-07-30 17:22:38 +03:00
|
|
|
explicit NullableRootedDictionary(const CX& cx)
|
|
|
|
: Nullable<T>(), JS::CustomAutoRooter(cx) {}
|
2013-09-26 08:04:59 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void trace(JSTracer* trc) override {
|
2013-09-26 08:04:59 +04:00
|
|
|
if (!this->IsNull()) {
|
|
|
|
this->Value().TraceDictionary(trc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_RootedDictionary_h__ */
|