2015-05-03 19:32:37 +00: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 04:04:59 +00: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/GuardObjects.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
template<typename T>
|
2016-05-12 18:14:29 +00:00
|
|
|
class MOZ_RAII RootedDictionary final : public T,
|
2013-09-26 04:04:59 +00:00
|
|
|
private JS::CustomAutoRooter
|
|
|
|
{
|
|
|
|
public:
|
2014-07-28 17:17:51 +00:00
|
|
|
explicit RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
2013-09-26 04:04:59 +00:00
|
|
|
T(),
|
|
|
|
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void trace(JSTracer *trc) override
|
2013-09-26 04:04:59 +00:00
|
|
|
{
|
|
|
|
this->TraceDictionary(trc);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
2016-05-12 18:14:29 +00:00
|
|
|
class MOZ_RAII NullableRootedDictionary final : public Nullable<T>,
|
2013-09-26 04:04:59 +00:00
|
|
|
private JS::CustomAutoRooter
|
|
|
|
{
|
|
|
|
public:
|
2014-07-28 17:17:51 +00:00
|
|
|
explicit NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
2013-09-26 04:04:59 +00:00
|
|
|
Nullable<T>(),
|
|
|
|
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void trace(JSTracer *trc) override
|
2013-09-26 04:04:59 +00:00
|
|
|
{
|
|
|
|
if (!this->IsNull()) {
|
|
|
|
this->Value().TraceDictionary(trc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_RootedDictionary_h__ */
|