Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM SharedWorker.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_SHAREDWORKERBINDING_H_
#define DOM_SHAREDWORKERBINDING_H_
#include "WorkerBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class ProtoAndIfaceCache;
class SharedWorker;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class StringOrWorkerOptions : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eString,
eWorkerOptions
};
public:
enum class Type
{
eString = TypeOrUninit::eString,
eWorkerOptions = TypeOrUninit::eWorkerOptions
};
private:
union Value
{
UnionMember<binding_detail::FakeString<char16_t> > mString;
UnionMember<binding_detail::FastWorkerOptions > mWorkerOptions;
};
TypeOrUninit mType;
Value mValue;
StringOrWorkerOptions(const StringOrWorkerOptions&) = delete;
StringOrWorkerOptions& operator=(const StringOrWorkerOptions&) = delete;
public:
explicit inline StringOrWorkerOptions()
: mType(eUninitialized)
{
}
inline ~StringOrWorkerOptions()
{
Uninit();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline binding_detail::FakeString<char16_t>&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline const nsAString&
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
[[nodiscard]] inline binding_detail::FastWorkerOptions&
RawSetAsWorkerOptions()
{
if (mType == eWorkerOptions) {
return mValue.mWorkerOptions.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eWorkerOptions;
return mValue.mWorkerOptions.SetValue();
}
[[nodiscard]] inline binding_detail::FastWorkerOptions&
SetAsWorkerOptions()
{
if (mType == eWorkerOptions) {
return mValue.mWorkerOptions.Value();
}
Uninit();
mType = eWorkerOptions;
return mValue.mWorkerOptions.SetValue();
}
inline bool
IsWorkerOptions() const
{
return mType == eWorkerOptions;
}
inline binding_detail::FastWorkerOptions&
GetAsWorkerOptions()
{
MOZ_RELEASE_ASSERT(IsWorkerOptions(), "Wrong type!");
return mValue.mWorkerOptions.Value();
}
inline const WorkerOptions&
GetAsWorkerOptions() const
{
MOZ_RELEASE_ASSERT(IsWorkerOptions(), "Wrong type!");
return mValue.mWorkerOptions.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eString: {
DestroyString();
break;
}
case eWorkerOptions: {
DestroyWorkerOptions();
break;
}
}
}
private:
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
bool
TrySetToWorkerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToWorkerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyWorkerOptions()
{
MOZ_RELEASE_ASSERT(IsWorkerOptions(), "Wrong type!");
mValue.mWorkerOptions.Destroy();
mType = eUninitialized;
}
};
class OwningStringOrWorkerOptions : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eString,
eWorkerOptions
};
public:
enum class Type
{
eString = TypeOrUninit::eString,
eWorkerOptions = TypeOrUninit::eWorkerOptions
};
private:
union Value
{
UnionMember<nsString > mString;
UnionMember<WorkerOptions > mWorkerOptions;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningStringOrWorkerOptions()
: mType(eUninitialized)
{
}
OwningStringOrWorkerOptions(OwningStringOrWorkerOptions&& aOther);
explicit inline OwningStringOrWorkerOptions(const OwningStringOrWorkerOptions& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningStringOrWorkerOptions()
{
Uninit();
}
[[nodiscard]] nsString&
RawSetAsString();
[[nodiscard]] nsString&
SetAsString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline nsString const &
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
[[nodiscard]] WorkerOptions&
RawSetAsWorkerOptions();
[[nodiscard]] WorkerOptions&
SetAsWorkerOptions();
inline bool
IsWorkerOptions() const
{
return mType == eWorkerOptions;
}
inline WorkerOptions&
GetAsWorkerOptions()
{
MOZ_RELEASE_ASSERT(IsWorkerOptions(), "Wrong type!");
return mValue.mWorkerOptions.Value();
}
inline WorkerOptions const &
GetAsWorkerOptions() const
{
MOZ_RELEASE_ASSERT(IsWorkerOptions(), "Wrong type!");
return mValue.mWorkerOptions.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
OwningStringOrWorkerOptions&
operator=(OwningStringOrWorkerOptions&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningStringOrWorkerOptions&
operator=(const OwningStringOrWorkerOptions& aOther);
private:
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyString();
bool
TrySetToWorkerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToWorkerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyWorkerOptions();
};
namespace SharedWorker_Binding {
typedef mozilla::dom::SharedWorker NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::SharedWorker* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
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::SharedWorker,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace SharedWorker_Binding
} // namespace mozilla::dom
#endif // DOM_SHAREDWORKERBINDING_H_