| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file has been auto-generated by code_generator_v8.py. | 5 // This file has been auto-generated by code_generator_v8.py. |
| 6 // DO NOT MODIFY! | 6 // DO NOT MODIFY! |
| 7 | 7 |
| 8 // This file has been generated from the Jinja2 template in | 8 // This file has been generated from the Jinja2 template in |
| 9 // third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl | 9 // third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl |
| 10 | 10 |
| 11 // clang-format off | 11 // clang-format off |
| 12 #include "V8TestDictionaryDerived.h" | 12 #include "V8TestDictionaryDerived.h" |
| 13 | 13 |
| 14 #include "bindings/core/v8/ExceptionState.h" | 14 #include "bindings/core/v8/ExceptionState.h" |
| 15 #include "bindings/core/v8/IDLTypes.h" | 15 #include "bindings/core/v8/IDLTypes.h" |
| 16 #include "bindings/core/v8/NativeValueTraitsImpl.h" | 16 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
| 17 #include "bindings/core/v8/V8TestDictionary.h" | 17 #include "bindings/core/v8/V8TestDictionary.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 static const v8::Eternal<v8::Name>* eternalV8TestDictionaryDerivedImplementedAsK
eys(v8::Isolate* isolate) { |
| 22 static const char* const kKeys[] = { |
| 23 "derivedStringMember", |
| 24 "derivedStringMemberWithDefault", |
| 25 "requiredLongMember", |
| 26 "stringOrDoubleSequenceMember", |
| 27 }; |
| 28 return V8PerIsolateData::from(isolate)->findOrCreateKeys( |
| 29 kKeys, kKeys, WTF_ARRAY_LENGTH(kKeys)); |
| 30 } |
| 31 |
| 21 void V8TestDictionaryDerivedImplementedAs::toImpl(v8::Isolate* isolate, v8::Loca
l<v8::Value> v8Value, TestDictionaryDerivedImplementedAs& impl, ExceptionState&
exceptionState) { | 32 void V8TestDictionaryDerivedImplementedAs::toImpl(v8::Isolate* isolate, v8::Loca
l<v8::Value> v8Value, TestDictionaryDerivedImplementedAs& impl, ExceptionState&
exceptionState) { |
| 22 if (isUndefinedOrNull(v8Value)) { | 33 if (isUndefinedOrNull(v8Value)) { |
| 23 exceptionState.throwTypeError("Missing required member(s): requiredLongMembe
r."); | 34 exceptionState.throwTypeError("Missing required member(s): requiredLongMembe
r."); |
| 24 return; | 35 return; |
| 25 } | 36 } |
| 26 if (!v8Value->IsObject()) { | 37 if (!v8Value->IsObject()) { |
| 27 exceptionState.throwTypeError("cannot convert to dictionary."); | 38 exceptionState.throwTypeError("cannot convert to dictionary."); |
| 28 return; | 39 return; |
| 29 } | 40 } |
| 30 v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>(); | 41 v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>(); |
| 31 ALLOW_UNUSED_LOCAL(v8Object); | 42 ALLOW_UNUSED_LOCAL(v8Object); |
| 32 | 43 |
| 33 V8TestDictionary::toImpl(isolate, v8Value, impl, exceptionState); | 44 V8TestDictionary::toImpl(isolate, v8Value, impl, exceptionState); |
| 34 if (exceptionState.hadException()) | 45 if (exceptionState.hadException()) |
| 35 return; | 46 return; |
| 36 | 47 |
| 48 const v8::Eternal<v8::Name>* keys = eternalV8TestDictionaryDerivedImplementedA
sKeys(isolate); |
| 37 v8::TryCatch block(isolate); | 49 v8::TryCatch block(isolate); |
| 50 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 38 v8::Local<v8::Value> derivedStringMemberValue; | 51 v8::Local<v8::Value> derivedStringMemberValue; |
| 39 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "deri
vedStringMember")).ToLocal(&derivedStringMemberValue)) { | 52 if (!v8Object->Get(context, keys[0].Get(isolate)).ToLocal(&derivedStringMember
Value)) { |
| 40 exceptionState.rethrowV8Exception(block.Exception()); | 53 exceptionState.rethrowV8Exception(block.Exception()); |
| 41 return; | 54 return; |
| 42 } | 55 } |
| 43 if (derivedStringMemberValue.IsEmpty() || derivedStringMemberValue->IsUndefine
d()) { | 56 if (derivedStringMemberValue.IsEmpty() || derivedStringMemberValue->IsUndefine
d()) { |
| 44 // Do nothing. | 57 // Do nothing. |
| 45 } else { | 58 } else { |
| 46 V8StringResource<> derivedStringMember = derivedStringMemberValue; | 59 V8StringResource<> derivedStringMember = derivedStringMemberValue; |
| 47 if (!derivedStringMember.prepare(exceptionState)) | 60 if (!derivedStringMember.prepare(exceptionState)) |
| 48 return; | 61 return; |
| 49 impl.setDerivedStringMember(derivedStringMember); | 62 impl.setDerivedStringMember(derivedStringMember); |
| 50 } | 63 } |
| 51 | 64 |
| 52 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; | 65 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; |
| 53 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "deri
vedStringMemberWithDefault")).ToLocal(&derivedStringMemberWithDefaultValue)) { | 66 if (!v8Object->Get(context, keys[1].Get(isolate)).ToLocal(&derivedStringMember
WithDefaultValue)) { |
| 54 exceptionState.rethrowV8Exception(block.Exception()); | 67 exceptionState.rethrowV8Exception(block.Exception()); |
| 55 return; | 68 return; |
| 56 } | 69 } |
| 57 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWithDe
faultValue->IsUndefined()) { | 70 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWithDe
faultValue->IsUndefined()) { |
| 58 // Do nothing. | 71 // Do nothing. |
| 59 } else { | 72 } else { |
| 60 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberWithD
efaultValue; | 73 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberWithD
efaultValue; |
| 61 if (!derivedStringMemberWithDefault.prepare(exceptionState)) | 74 if (!derivedStringMemberWithDefault.prepare(exceptionState)) |
| 62 return; | 75 return; |
| 63 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault); | 76 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault); |
| 64 } | 77 } |
| 65 | 78 |
| 66 v8::Local<v8::Value> requiredLongMemberValue; | 79 v8::Local<v8::Value> requiredLongMemberValue; |
| 67 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "requ
iredLongMember")).ToLocal(&requiredLongMemberValue)) { | 80 if (!v8Object->Get(context, keys[2].Get(isolate)).ToLocal(&requiredLongMemberV
alue)) { |
| 68 exceptionState.rethrowV8Exception(block.Exception()); | 81 exceptionState.rethrowV8Exception(block.Exception()); |
| 69 return; | 82 return; |
| 70 } | 83 } |
| 71 if (requiredLongMemberValue.IsEmpty() || requiredLongMemberValue->IsUndefined(
)) { | 84 if (requiredLongMemberValue.IsEmpty() || requiredLongMemberValue->IsUndefined(
)) { |
| 72 exceptionState.throwTypeError("required member requiredLongMember is undefin
ed."); | 85 exceptionState.throwTypeError("required member requiredLongMember is undefin
ed."); |
| 73 return; | 86 return; |
| 74 } else { | 87 } else { |
| 75 int32_t requiredLongMember = NativeValueTraits<IDLLong>::nativeValue(isolate
, requiredLongMemberValue, exceptionState, NormalConversion); | 88 int32_t requiredLongMember = NativeValueTraits<IDLLong>::nativeValue(isolate
, requiredLongMemberValue, exceptionState, NormalConversion); |
| 76 if (exceptionState.hadException()) | 89 if (exceptionState.hadException()) |
| 77 return; | 90 return; |
| 78 impl.setRequiredLongMember(requiredLongMember); | 91 impl.setRequiredLongMember(requiredLongMember); |
| 79 } | 92 } |
| 80 | 93 |
| 81 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; | 94 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; |
| 82 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "stri
ngOrDoubleSequenceMember")).ToLocal(&stringOrDoubleSequenceMemberValue)) { | 95 if (!v8Object->Get(context, keys[3].Get(isolate)).ToLocal(&stringOrDoubleSeque
nceMemberValue)) { |
| 83 exceptionState.rethrowV8Exception(block.Exception()); | 96 exceptionState.rethrowV8Exception(block.Exception()); |
| 84 return; | 97 return; |
| 85 } | 98 } |
| 86 if (stringOrDoubleSequenceMemberValue.IsEmpty() || stringOrDoubleSequenceMembe
rValue->IsUndefined()) { | 99 if (stringOrDoubleSequenceMemberValue.IsEmpty() || stringOrDoubleSequenceMembe
rValue->IsUndefined()) { |
| 87 // Do nothing. | 100 // Do nothing. |
| 88 } else { | 101 } else { |
| 89 HeapVector<StringOrDouble> stringOrDoubleSequenceMember = toImplArray<HeapVe
ctor<StringOrDouble>>(stringOrDoubleSequenceMemberValue, 0, isolate, exceptionSt
ate); | 102 HeapVector<StringOrDouble> stringOrDoubleSequenceMember = toImplArray<HeapVe
ctor<StringOrDouble>>(stringOrDoubleSequenceMemberValue, 0, isolate, exceptionSt
ate); |
| 90 if (exceptionState.hadException()) | 103 if (exceptionState.hadException()) |
| 91 return; | 104 return; |
| 92 impl.setStringOrDoubleSequenceMember(stringOrDoubleSequenceMember); | 105 impl.setStringOrDoubleSequenceMember(stringOrDoubleSequenceMember); |
| 93 } | 106 } |
| 94 } | 107 } |
| 95 | 108 |
| 96 v8::Local<v8::Value> TestDictionaryDerivedImplementedAs::toV8Impl(v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) const { | 109 v8::Local<v8::Value> TestDictionaryDerivedImplementedAs::toV8Impl(v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) const { |
| 97 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); | 110 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); |
| 98 if (!toV8TestDictionaryDerivedImplementedAs(*this, v8Object, creationContext,
isolate)) | 111 if (!toV8TestDictionaryDerivedImplementedAs(*this, v8Object, creationContext,
isolate)) |
| 99 return v8::Undefined(isolate); | 112 return v8::Undefined(isolate); |
| 100 return v8Object; | 113 return v8Object; |
| 101 } | 114 } |
| 102 | 115 |
| 103 bool toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement
edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont
ext, v8::Isolate* isolate) { | 116 bool toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement
edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont
ext, v8::Isolate* isolate) { |
| 104 if (!toV8TestDictionary(impl, dictionary, creationContext, isolate)) | 117 if (!toV8TestDictionary(impl, dictionary, creationContext, isolate)) |
| 105 return false; | 118 return false; |
| 106 | 119 |
| 120 const v8::Eternal<v8::Name>* keys = eternalV8TestDictionaryDerivedImplementedA
sKeys(isolate); |
| 121 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 107 if (impl.hasDerivedStringMember()) { | 122 if (impl.hasDerivedStringMember()) { |
| 108 if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext
(), v8AtomicString(isolate, "derivedStringMember"), v8String(isolate, impl.deriv
edStringMember())))) | 123 if (!v8CallBoolean(dictionary->CreateDataProperty(context, keys[0].Get(isola
te), v8String(isolate, impl.derivedStringMember())))) |
| 109 return false; | 124 return false; |
| 110 } | 125 } |
| 111 | 126 |
| 112 if (impl.hasDerivedStringMemberWithDefault()) { | 127 if (impl.hasDerivedStringMemberWithDefault()) { |
| 113 if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext
(), v8AtomicString(isolate, "derivedStringMemberWithDefault"), v8String(isolate,
impl.derivedStringMemberWithDefault())))) | 128 if (!v8CallBoolean(dictionary->CreateDataProperty(context, keys[1].Get(isola
te), v8String(isolate, impl.derivedStringMemberWithDefault())))) |
| 114 return false; | 129 return false; |
| 115 } else { | 130 } else { |
| 116 if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext
(), v8AtomicString(isolate, "derivedStringMemberWithDefault"), v8String(isolate,
"default string value")))) | 131 if (!v8CallBoolean(dictionary->CreateDataProperty(context, keys[1].Get(isola
te), v8String(isolate, "default string value")))) |
| 117 return false; | 132 return false; |
| 118 } | 133 } |
| 119 | 134 |
| 120 if (impl.hasRequiredLongMember()) { | 135 if (impl.hasRequiredLongMember()) { |
| 121 if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext
(), v8AtomicString(isolate, "requiredLongMember"), v8::Integer::New(isolate, imp
l.requiredLongMember())))) | 136 if (!v8CallBoolean(dictionary->CreateDataProperty(context, keys[2].Get(isola
te), v8::Integer::New(isolate, impl.requiredLongMember())))) |
| 122 return false; | 137 return false; |
| 123 } else { | 138 } else { |
| 124 NOTREACHED(); | 139 NOTREACHED(); |
| 125 } | 140 } |
| 126 | 141 |
| 127 if (impl.hasStringOrDoubleSequenceMember()) { | 142 if (impl.hasStringOrDoubleSequenceMember()) { |
| 128 if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext
(), v8AtomicString(isolate, "stringOrDoubleSequenceMember"), ToV8(impl.stringOrD
oubleSequenceMember(), creationContext, isolate)))) | 143 if (!v8CallBoolean(dictionary->CreateDataProperty(context, keys[3].Get(isola
te), ToV8(impl.stringOrDoubleSequenceMember(), creationContext, isolate)))) |
| 129 return false; | 144 return false; |
| 130 } | 145 } |
| 131 | 146 |
| 132 return true; | 147 return true; |
| 133 } | 148 } |
| 134 | 149 |
| 135 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem
entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio
nState& exceptionState) { | 150 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem
entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio
nState& exceptionState) { |
| 136 TestDictionaryDerivedImplementedAs impl; | 151 TestDictionaryDerivedImplementedAs impl; |
| 137 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exceptionSt
ate); | 152 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exceptionSt
ate); |
| 138 return impl; | 153 return impl; |
| 139 } | 154 } |
| 140 | 155 |
| 141 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |