Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM FakePluginTagInit.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "FakePluginTagInitBinding.h"
#include "MainThreadUtils.h"
#include "js/Array.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/ForOfIterator.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
FakePluginMimeEntry::FakePluginMimeEntry()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
FakePluginMimeEntry::InitIds(JSContext* cx, FakePluginMimeEntryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->type_id.init(cx, "type") ||
!atomsCache->extension_id.init(cx, "extension") ||
!atomsCache->description_id.init(cx, "description")) {
return false;
}
return true;
}
bool
FakePluginMimeEntry::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
FakePluginMimeEntryAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<FakePluginMimeEntryAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->description_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDescription)) {
return false;
}
} else {
mDescription.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->extension_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mExtension)) {
return false;
}
} else {
mExtension.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->type_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mType)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'type' member of FakePluginMimeEntry");
}
return true;
}
bool
FakePluginMimeEntry::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
void
FakePluginMimeEntry::TraceDictionary(JSTracer* trc)
{
}
FakePluginMimeEntry&
FakePluginMimeEntry::operator=(const FakePluginMimeEntry& aOther)
{
DictionaryBase::operator=(aOther);
mDescription = aOther.mDescription;
mExtension = aOther.mExtension;
mType = aOther.mType;
return *this;
}
bool
FakePluginMimeEntry::operator==(const FakePluginMimeEntry& aOther) const
{
if (mDescription != aOther.mDescription) {
return false;
}
if (mExtension != aOther.mExtension) {
return false;
}
if (mType != aOther.mType) {
return false;
}
return true;
}
FakePluginTagInit::FakePluginTagInit()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
FakePluginTagInit::InitIds(JSContext* cx, FakePluginTagInitAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->version_id.init(cx, "version") ||
!atomsCache->sandboxScript_id.init(cx, "sandboxScript") ||
!atomsCache->niceName_id.init(cx, "niceName") ||
!atomsCache->name_id.init(cx, "name") ||
!atomsCache->mimeEntries_id.init(cx, "mimeEntries") ||
!atomsCache->handlerURI_id.init(cx, "handlerURI") ||
!atomsCache->fullPath_id.init(cx, "fullPath") ||
!atomsCache->fileName_id.init(cx, "fileName") ||
!atomsCache->description_id.init(cx, "description")) {
return false;
}
return true;
}
bool
FakePluginTagInit::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
FakePluginTagInitAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<FakePluginTagInitAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->description_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDescription)) {
return false;
}
} else {
mDescription.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->fileName_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFileName)) {
return false;
}
} else {
mFileName.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->fullPath_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFullPath)) {
return false;
}
} else {
mFullPath.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->handlerURI_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mHandlerURI)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'handlerURI' member of FakePluginTagInit");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->mimeEntries_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (temp.ref().isObject()) {
JS::ForOfIterator iter(cx);
if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
return false;
}
if (!iter.valueIsIterable()) {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'mimeEntries' member of FakePluginTagInit", "sequence");
return false;
}
Sequence<FakePluginMimeEntry> &arr = mMimeEntries;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
FakePluginMimeEntry* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
FakePluginMimeEntry& slot = *slotPtr;
if (!slot.Init(cx, temp, "Element of 'mimeEntries' member of FakePluginTagInit", passedToJSImpl)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'mimeEntries' member of FakePluginTagInit", "sequence");
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'mimeEntries' member of FakePluginTagInit");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
return false;
}
} else {
mName.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->niceName_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mNiceName)) {
return false;
}
} else {
mNiceName.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->sandboxScript_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSandboxScript)) {
return false;
}
} else {
mSandboxScript.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->version_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVersion)) {
return false;
}
} else {
mVersion.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
return true;
}
bool
FakePluginTagInit::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
void
FakePluginTagInit::TraceDictionary(JSTracer* trc)
{
}
FakePluginTagInit&
FakePluginTagInit::operator=(const FakePluginTagInit& aOther)
{
DictionaryBase::operator=(aOther);
mDescription = aOther.mDescription;
mFileName = aOther.mFileName;
mFullPath = aOther.mFullPath;
mHandlerURI = aOther.mHandlerURI;
mMimeEntries = aOther.mMimeEntries;
mName = aOther.mName;
mNiceName = aOther.mNiceName;
mSandboxScript = aOther.mSandboxScript;
mVersion = aOther.mVersion;
return *this;
}
} // namespace mozilla::dom