JSApplePaySessionCustom.cpp [plain text]
#include "config.h"
#include "JSApplePaySession.h"
#if ENABLE(APPLE_PAY)
#include "ArrayValue.h"
#include "Dictionary.h"
#include "JSDOMBinding.h"
#include "JSDOMConvert.h"
#include <runtime/Error.h>
using namespace JSC;
namespace WebCore {
JSValue JSApplePaySession::completeShippingMethodSelection(ExecState& state)
{
JSValue thisValue = state.thisValue();
JSApplePaySession* castedThis = jsDynamicCast<JSApplePaySession*>(thisValue);
if (UNLIKELY(!castedThis))
return JSValue::decode(throwThisTypeError(state, "ApplePaySession", "completeShippingMethodSelection"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSApplePaySession::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state.argumentCount() < 3))
return JSValue::decode(throwVMError(&state, createNotEnoughArgumentsError(&state)));
ExceptionCode ec = 0;
uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion);
if (UNLIKELY(state.hadException()))
return jsUndefined();
Dictionary newTotal = { &state, state.argument(1) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
ArrayValue newLineItems { &state, state.argument(2) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
impl.completeShippingMethodSelection(status, newTotal, newLineItems, ec);
setDOMException(&state, ec);
return jsUndefined();
}
JSValue JSApplePaySession::completeShippingContactSelection(ExecState& state)
{
JSValue thisValue = state.thisValue();
JSApplePaySession* castedThis = jsDynamicCast<JSApplePaySession*>(thisValue);
if (UNLIKELY(!castedThis))
return JSValue::decode(throwThisTypeError(state, "ApplePaySession", "completeShippingContactSelection"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSApplePaySession::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state.argumentCount() < 4))
return JSValue::decode(throwVMError(&state, createNotEnoughArgumentsError(&state)));
ExceptionCode ec = 0;
uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion);
if (UNLIKELY(state.hadException()))
return jsUndefined();
ArrayValue newShippingMethods { &state, state.argument(1) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
Dictionary newTotal = { &state, state.argument(2) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
ArrayValue newLineItems { &state, state.argument(3) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
impl.completeShippingContactSelection(status, newShippingMethods, newTotal, newLineItems, ec);
setDOMException(&state, ec);
return jsUndefined();
}
JSValue JSApplePaySession::completePaymentMethodSelection(ExecState& state)
{
JSValue thisValue = state.thisValue();
JSApplePaySession* castedThis = jsDynamicCast<JSApplePaySession*>(thisValue);
if (UNLIKELY(!castedThis))
return JSValue::decode(throwThisTypeError(state, "ApplePaySession", "completePaymentMethodSelection"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSApplePaySession::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state.argumentCount() < 2))
return JSValue::decode(throwVMError(&state, createNotEnoughArgumentsError(&state)));
ExceptionCode ec = 0;
Dictionary newTotal = { &state, state.argument(0) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
ArrayValue newLineItems { &state, state.argument(1) };
if (UNLIKELY(state.hadException()))
return jsUndefined();
impl.completePaymentMethodSelection(newTotal, newLineItems, ec);
setDOMException(&state, ec);
return jsUndefined();
}
}
#endif