Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM BasicCardPayment.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "BasicCardPaymentBinding.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/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;
BasicCardChangeDetails::BasicCardChangeDetails()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
BasicCardChangeDetails::InitIds(JSContext* cx, BasicCardChangeDetailsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->billingAddress_id.init(cx, "billingAddress")) {
return false;
}
return true;
}
bool
BasicCardChangeDetails::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mBillingAddress = nullptr;
}
mIsAnyMemberPresent = true;
return true;
}
bool
BasicCardChangeDetails::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
BasicCardChangeDetailsAtoms* atomsCache = GetAtomCache<BasicCardChangeDetailsAtoms>(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));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
RefPtr<mozilla::dom::PaymentAddress> const & currentValue = mBillingAddress;
if (!currentValue) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->billingAddress_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->billingAddress_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
BasicCardChangeDetails::TraceDictionary(JSTracer* trc)
{
}
BasicCardChangeDetails&
BasicCardChangeDetails::operator=(const BasicCardChangeDetails& aOther)
{
DictionaryBase::operator=(aOther);
mBillingAddress = aOther.mBillingAddress;
return *this;
}
BasicCardErrors::BasicCardErrors()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
BasicCardErrors::InitIds(JSContext* cx, BasicCardErrorsAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->expiryYear_id.init(cx, "expiryYear") ||
!atomsCache->expiryMonth_id.init(cx, "expiryMonth") ||
!atomsCache->cardholderName_id.init(cx, "cardholderName") ||
!atomsCache->cardSecurityCode_id.init(cx, "cardSecurityCode") ||
!atomsCache->cardNumber_id.init(cx, "cardNumber") ||
!atomsCache->billingAddress_id.init(cx, "billingAddress")) {
return false;
}
return true;
}
bool
BasicCardErrors::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());
BasicCardErrorsAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<BasicCardErrorsAtoms>(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->billingAddress_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mBillingAddress.Construct();
if (!(mBillingAddress.Value()).Init(cx, temp.ref(), "'billingAddress' member of BasicCardErrors", passedToJSImpl)) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->cardNumber_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mCardNumber.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCardNumber.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->cardSecurityCode_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mCardSecurityCode.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCardSecurityCode.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->cardholderName_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mCardholderName.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCardholderName.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->expiryMonth_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mExpiryMonth.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mExpiryMonth.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->expiryYear_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mExpiryYear.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mExpiryYear.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
BasicCardErrors::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
BasicCardErrors::TraceDictionary(JSTracer* trc)
{
}
BasicCardErrors&
BasicCardErrors::operator=(const BasicCardErrors& aOther)
{
DictionaryBase::operator=(aOther);
mBillingAddress.Reset();
if (aOther.mBillingAddress.WasPassed()) {
mBillingAddress.Construct(aOther.mBillingAddress.Value());
}
mCardNumber.Reset();
if (aOther.mCardNumber.WasPassed()) {
mCardNumber.Construct(aOther.mCardNumber.Value());
}
mCardSecurityCode.Reset();
if (aOther.mCardSecurityCode.WasPassed()) {
mCardSecurityCode.Construct(aOther.mCardSecurityCode.Value());
}
mCardholderName.Reset();
if (aOther.mCardholderName.WasPassed()) {
mCardholderName.Construct(aOther.mCardholderName.Value());
}
mExpiryMonth.Reset();
if (aOther.mExpiryMonth.WasPassed()) {
mExpiryMonth.Construct(aOther.mExpiryMonth.Value());
}
mExpiryYear.Reset();
if (aOther.mExpiryYear.WasPassed()) {
mExpiryYear.Construct(aOther.mExpiryYear.Value());
}
return *this;
}
BasicCardRequest::BasicCardRequest()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
BasicCardRequest::InitIds(JSContext* cx, BasicCardRequestAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->supportedNetworks_id.init(cx, "supportedNetworks") ||
!atomsCache->requestSecurityCode_id.init(cx, "requestSecurityCode")) {
return false;
}
return true;
}
bool
BasicCardRequest::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());
BasicCardRequestAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<BasicCardRequestAtoms>(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->requestSecurityCode_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), "'requestSecurityCode' member of BasicCardRequest", &mRequestSecurityCode)) {
return false;
}
} else {
mRequestSecurityCode = true;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->supportedNetworks_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>("'supportedNetworks' member of BasicCardRequest", "sequence");
return false;
}
Sequence<nsString> &arr = mSupportedNetworks;
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
nsString* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
nsString& slot = *slotPtr;
if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'supportedNetworks' member of BasicCardRequest", "sequence");
return false;
}
} else {
/* mSupportedNetworks array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
return true;
}
bool
BasicCardRequest::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
BasicCardRequest::TraceDictionary(JSTracer* trc)
{
}
BasicCardRequest&
BasicCardRequest::operator=(const BasicCardRequest& aOther)
{
DictionaryBase::operator=(aOther);
mRequestSecurityCode = aOther.mRequestSecurityCode;
mSupportedNetworks = aOther.mSupportedNetworks;
return *this;
}
BasicCardResponse::BasicCardResponse()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
BasicCardResponse::InitIds(JSContext* cx, BasicCardResponseAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->expiryYear_id.init(cx, "expiryYear") ||
!atomsCache->expiryMonth_id.init(cx, "expiryMonth") ||
!atomsCache->cardholderName_id.init(cx, "cardholderName") ||
!atomsCache->cardSecurityCode_id.init(cx, "cardSecurityCode") ||
!atomsCache->cardNumber_id.init(cx, "cardNumber") ||
!atomsCache->billingAddress_id.init(cx, "billingAddress")) {
return false;
}
return true;
}
bool
BasicCardResponse::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mBillingAddress = nullptr;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCardSecurityCode.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mCardholderName.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mExpiryMonth.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mExpiryYear.AssignLiteral(u"");
}
mIsAnyMemberPresent = true;
return true;
}
bool
BasicCardResponse::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
BasicCardResponseAtoms* atomsCache = GetAtomCache<BasicCardResponseAtoms>(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));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
RefPtr<mozilla::dom::PaymentAddress> const & currentValue = mBillingAddress;
if (!currentValue) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->billingAddress_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->billingAddress_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 = mCardNumber;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->cardNumber_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 = mCardSecurityCode;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->cardSecurityCode_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 = mCardholderName;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->cardholderName_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 = mExpiryMonth;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->expiryMonth_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 = mExpiryYear;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->expiryYear_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
BasicCardResponse::TraceDictionary(JSTracer* trc)
{
}
BasicCardResponse&
BasicCardResponse::operator=(const BasicCardResponse& aOther)
{
DictionaryBase::operator=(aOther);
mBillingAddress = aOther.mBillingAddress;
mCardNumber = aOther.mCardNumber;
mCardSecurityCode = aOther.mCardSecurityCode;
mCardholderName = aOther.mCardholderName;
mExpiryMonth = aOther.mExpiryMonth;
mExpiryYear = aOther.mExpiryYear;
return *this;
}
} // namespace mozilla::dom