Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM WindowsJumpListShortcutDescription.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "WindowsJumpListShortcutDescriptionBinding.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.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/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.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;
WindowsJumpListShortcutDescription::WindowsJumpListShortcutDescription()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
WindowsJumpListShortcutDescription::InitIds(JSContext* cx, WindowsJumpListShortcutDescriptionAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->title_id.init(cx, "title") ||
!atomsCache->path_id.init(cx, "path") ||
!atomsCache->iconPath_id.init(cx, "iconPath") ||
!atomsCache->fallbackIconIndex_id.init(cx, "fallbackIconIndex") ||
!atomsCache->description_id.init(cx, "description") ||
!atomsCache->arguments_id.init(cx, "arguments")) {
return false;
}
return true;
}
bool
WindowsJumpListShortcutDescription::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());
WindowsJumpListShortcutDescriptionAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<WindowsJumpListShortcutDescriptionAtoms>(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->arguments_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mArguments.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mArguments.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
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;
}
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>("'description' member of WindowsJumpListShortcutDescription");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->fallbackIconIndex_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'fallbackIconIndex' member of WindowsJumpListShortcutDescription", &mFallbackIconIndex)) {
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>("'fallbackIconIndex' member of WindowsJumpListShortcutDescription");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->iconPath_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mIconPath.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIconPath.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->path_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPath)) {
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>("'path' member of WindowsJumpListShortcutDescription");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->title_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTitle)) {
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>("'title' member of WindowsJumpListShortcutDescription");
}
return true;
}
bool
WindowsJumpListShortcutDescription::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);
}
bool
WindowsJumpListShortcutDescription::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
WindowsJumpListShortcutDescriptionAtoms* atomsCache = GetAtomCache<WindowsJumpListShortcutDescriptionAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mArguments.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mArguments.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->arguments_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mDescription;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->description_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
int32_t const & currentValue = mFallbackIconIndex;
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->fallbackIconIndex_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mIconPath.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mIconPath.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->iconPath_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mPath;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mTitle;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->title_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
WindowsJumpListShortcutDescription::TraceDictionary(JSTracer* trc)
{
}
WindowsJumpListShortcutDescription&
WindowsJumpListShortcutDescription::operator=(const WindowsJumpListShortcutDescription& aOther)
{
DictionaryBase::operator=(aOther);
mArguments.Reset();
if (aOther.mArguments.WasPassed()) {
mArguments.Construct(aOther.mArguments.Value());
}
mDescription = aOther.mDescription;
mFallbackIconIndex = aOther.mFallbackIconIndex;
mIconPath.Reset();
if (aOther.mIconPath.WasPassed()) {
mIconPath.Construct(aOther.mIconPath.Value());
}
mPath = aOther.mPath;
mTitle = aOther.mTitle;
return *this;
}
bool
WindowsJumpListShortcutDescription::operator==(const WindowsJumpListShortcutDescription& aOther) const
{
if (mArguments != aOther.mArguments) {
return false;
}
if (mDescription != aOther.mDescription) {
return false;
}
if (mFallbackIconIndex != aOther.mFallbackIconIndex) {
return false;
}
if (mIconPath != aOther.mIconPath) {
return false;
}
if (mPath != aOther.mPath) {
return false;
}
if (mTitle != aOther.mTitle) {
return false;
}
return true;
}
} // namespace mozilla::dom