blob: 3dca8b06c4656f22045aa26b9a10a6aee887d263 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py.
// DO NOT MODIFY!
// This file has been generated from the Jinja2 template in
// third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl
// clang-format off
#include "V8PaymentDetailsInit.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/NativeValueTraitsImpl.h"
#include "bindings/modules/v8/V8PaymentDetailsBase.h"
#include "bindings/modules/v8/V8PaymentItem.h"
namespace blink {
static const v8::Eternal<v8::Name>* eternalV8PaymentDetailsInitKeys(v8::Isolate* isolate) {
static const char* const kKeys[] = {
"id",
"total",
};
return V8PerIsolateData::From(isolate)->FindOrCreateEternalNameCache(
kKeys, kKeys, WTF_ARRAY_LENGTH(kKeys));
}
void V8PaymentDetailsInit::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, PaymentDetailsInit& impl, ExceptionState& exceptionState) {
if (IsUndefinedOrNull(v8Value)) {
exceptionState.ThrowTypeError("Missing required member(s): total.");
return;
}
if (!v8Value->IsObject()) {
exceptionState.ThrowTypeError("cannot convert to dictionary.");
return;
}
v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>();
ALLOW_UNUSED_LOCAL(v8Object);
V8PaymentDetailsBase::toImpl(isolate, v8Value, impl, exceptionState);
if (exceptionState.HadException())
return;
const v8::Eternal<v8::Name>* keys = eternalV8PaymentDetailsInitKeys(isolate);
v8::TryCatch block(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Value> idValue;
if (!v8Object->Get(context, keys[0].Get(isolate)).ToLocal(&idValue)) {
exceptionState.RethrowV8Exception(block.Exception());
return;
}
if (idValue.IsEmpty() || idValue->IsUndefined()) {
// Do nothing.
} else {
V8StringResource<> id = idValue;
if (!id.Prepare(exceptionState))
return;
impl.setId(id);
}
v8::Local<v8::Value> totalValue;
if (!v8Object->Get(context, keys[1].Get(isolate)).ToLocal(&totalValue)) {
exceptionState.RethrowV8Exception(block.Exception());
return;
}
if (totalValue.IsEmpty() || totalValue->IsUndefined()) {
exceptionState.ThrowTypeError("required member total is undefined.");
return;
} else {
PaymentItem total;
V8PaymentItem::toImpl(isolate, totalValue, total, exceptionState);
if (exceptionState.HadException())
return;
impl.setTotal(total);
}
}
v8::Local<v8::Value> PaymentDetailsInit::ToV8Impl(v8::Local<v8::Object> creationContext, v8::Isolate* isolate) const {
v8::Local<v8::Object> v8Object = v8::Object::New(isolate);
if (!toV8PaymentDetailsInit(*this, v8Object, creationContext, isolate))
return v8::Undefined(isolate);
return v8Object;
}
bool toV8PaymentDetailsInit(const PaymentDetailsInit& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) {
if (!toV8PaymentDetailsBase(impl, dictionary, creationContext, isolate))
return false;
const v8::Eternal<v8::Name>* keys = eternalV8PaymentDetailsInitKeys(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Value> idValue;
bool idHasValueOrDefault = false;
if (impl.hasId()) {
idValue = V8String(isolate, impl.id());
idHasValueOrDefault = true;
}
if (idHasValueOrDefault &&
!V8CallBoolean(dictionary->CreateDataProperty(context, keys[0].Get(isolate), idValue))) {
return false;
}
v8::Local<v8::Value> totalValue;
bool totalHasValueOrDefault = false;
if (impl.hasTotal()) {
totalValue = ToV8(impl.total(), creationContext, isolate);
totalHasValueOrDefault = true;
} else {
NOTREACHED();
}
if (totalHasValueOrDefault &&
!V8CallBoolean(dictionary->CreateDataProperty(context, keys[1].Get(isolate), totalValue))) {
return false;
}
return true;
}
PaymentDetailsInit NativeValueTraits<PaymentDetailsInit>::NativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
PaymentDetailsInit impl;
V8PaymentDetailsInit::toImpl(isolate, value, impl, exceptionState);
return impl;
}
} // namespace blink