Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM JSActor.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_JSACTORBINDING_H_
#define DOM_JSACTORBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/CallbackInterface.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/ToJSValue.h"
class nsISupports;
namespace mozilla {
namespace dom {
class MozJSActorCallback;
struct MozJSActorCallbacksAtoms;
class MozObserverCallback;
struct MozObserverCallbackAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class MozJSActorCallback : public CallbackFunction
{
public:
explicit inline MozJSActorCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MozJSActorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MozJSActorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline MozJSActorCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
inline void
Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "MozJSActorCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return Call(s.GetCallContext(), thisValJS, aRv);
}
inline void
Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "MozJSActorCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, aRv);
}
template <typename T>
inline void
Call(const T& thisVal, const char* aExecutionReason = nullptr)
{
return Call(thisVal, IgnoreErrors(), aExecutionReason);
}
inline void
Call(const char* aExecutionReason = nullptr)
{
return Call(IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const MozJSActorCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
};
namespace binding_detail {
class FastMozJSActorCallback : public MozJSActorCallback
{
public:
explicit inline FastMozJSActorCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: MozJSActorCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
MozJSActorCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
MozJSActorCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct MozJSActorCallbacks : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<MozJSActorCallback>> mActorCreated;
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<MozJSActorCallback>> mDidDestroy;
MozJSActorCallbacks();
explicit inline MozJSActorCallbacks(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MozJSActorCallbacks(MozJSActorCallbacks&& aOther) = default;
private:
MozJSActorCallbacks(const MozJSActorCallbacks&) = delete;
MozJSActorCallbacks& operator=(const MozJSActorCallbacks&) = delete;
static bool
InitIds(JSContext* cx, MozJSActorCallbacksAtoms* atomsCache);
public:
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mActorCreated, "mActorCreated", aFlags);
ImplCycleCollectionTraverse(aCallback, mDidDestroy, "mDidDestroy", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mActorCreated);
ImplCycleCollectionUnlink(mDidDestroy);
}
};
namespace binding_detail {
struct FastMozJSActorCallbacks : public MozJSActorCallbacks
{
inline FastMozJSActorCallbacks()
: MozJSActorCallbacks(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class MozObserverCallback : public CallbackInterface
{
public:
explicit inline MozObserverCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
}
explicit inline MozObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
explicit inline MozObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
}
template <typename T>
inline void
Observe(const T& thisVal, nsISupports* subject, const nsCString& topic, const nsAString& data, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "MozObserverCallback.observe";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return Observe(s.GetCallContext(), thisValJS, subject, topic, data, aRv);
}
inline void
Observe(nsISupports* subject, const nsCString& topic, const nsAString& data, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "MozObserverCallback.observe";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Observe(s.GetCallContext(), JS::UndefinedHandleValue, subject, topic, data, aRv);
}
template <typename T>
inline void
Observe(const T& thisVal, nsISupports* subject, const nsCString& topic, const nsAString& data, const char* aExecutionReason = nullptr)
{
return Observe(thisVal, subject, topic, data, IgnoreErrors(), aExecutionReason);
}
inline void
Observe(nsISupports* subject, const nsCString& topic, const nsAString& data, const char* aExecutionReason = nullptr)
{
return Observe(subject, topic, data, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const MozObserverCallback& aOther) const
{
return CallbackInterface::operator==(aOther);
}
private:
void Observe(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, nsISupports* subject, const nsCString& topic, const nsAString& data, ErrorResult& aRv);
static bool
InitIds(JSContext* cx, MozObserverCallbackAtoms* atomsCache);
};
namespace binding_detail {
class FastMozObserverCallback : public MozObserverCallback
{
public:
explicit inline FastMozObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: MozObserverCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
MozObserverCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
MozObserverCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
} // namespace mozilla::dom
#endif // DOM_JSACTORBINDING_H_