Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM BaseAudioContext.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_BASEAUDIOCONTEXTBINDING_H_
#define DOM_BASEAUDIOCONTEXTBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Span.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
class AudioBuffer;
class AudioContext;
class DOMException;
class DecodeErrorCallback;
class DecodeSuccessCallback;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class AudioContextState : uint8_t {
Suspended,
Running,
Closed,
};
namespace binding_detail {
template <> struct EnumStrings<AudioContextState> {
static constexpr nsLiteralCString Values[3] {
"suspended"_ns,
"running"_ns,
"closed"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, AudioContextState aArgument, JS::MutableHandle<JS::Value> aValue);
class DecodeErrorCallback : public CallbackFunction
{
public:
explicit inline DecodeErrorCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeErrorCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, DOMException& error, 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 = "DecodeErrorCallback";
}
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, error, aRv);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(DOMException& error, 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 = "DecodeErrorCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, error, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, DOMException& error, const char* aExecutionReason = nullptr)
{
return Call(thisVal, error, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(DOMException& error, const char* aExecutionReason = nullptr)
{
return Call(error, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const DecodeErrorCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, DOMException& error, ErrorResult& aRv);
};
namespace binding_detail {
class FastDecodeErrorCallback : public DecodeErrorCallback
{
public:
explicit inline FastDecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: DecodeErrorCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
DecodeErrorCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
DecodeErrorCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
class DecodeSuccessCallback : public CallbackFunction
{
public:
explicit inline DecodeSuccessCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline DecodeSuccessCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, AudioBuffer& decodedData, 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 = "DecodeSuccessCallback";
}
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, decodedData, aRv);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(AudioBuffer& decodedData, 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 = "DecodeSuccessCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, decodedData, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, AudioBuffer& decodedData, const char* aExecutionReason = nullptr)
{
return Call(thisVal, decodedData, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(AudioBuffer& decodedData, const char* aExecutionReason = nullptr)
{
return Call(decodedData, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const DecodeSuccessCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, AudioBuffer& decodedData, ErrorResult& aRv);
};
namespace binding_detail {
class FastDecodeSuccessCallback : public DecodeSuccessCallback
{
public:
explicit inline FastDecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: DecodeSuccessCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
DecodeSuccessCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
DecodeSuccessCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
namespace BaseAudioContext_Binding {
typedef mozilla::dom::AudioContext NativeType;
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::BaseAudioContext,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace BaseAudioContext_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::AudioContextState>
{
static constexpr dom::AudioContextState value = dom::AudioContextState::Closed;
static_assert(static_cast<uint8_t>(dom::AudioContextState::Suspended) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::AudioContextState>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_BASEAUDIOCONTEXTBINDING_H_